Existing code

This commit is contained in:
Stoyan Zlatev
2023-04-04 11:12:07 +02:00
parent 994af6e7af
commit fdfb42da9e
55 changed files with 2239 additions and 39 deletions
@@ -2,11 +2,97 @@
{
using LaaProductionWeb.Data.Interfaces;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
public class DbContext : IDbContext
{
private readonly string connectionString;
public DbContext(string connectionString)
=> this.connectionString = connectionString;
public IEnumerable<T> AsEnumerable<T>(string query, Action<IParameterCollection> parameters, Func<ISqlReader, T> reader)
{
using (var sqlConnection = new SqlConnection(this.connectionString))
{
sqlConnection.OpenWithErrorHandling();
using (var sqlCommand = sqlConnection.CreateCommand())
{
sqlCommand.CommandText = query;
parameters(new ParameterCollection(sqlCommand.Parameters));
using (var sqlDataReader = sqlCommand.ExecuteReader())
{
while (sqlDataReader.Read())
{
yield return reader(new SqlReader(sqlDataReader));
}
}
}
}
}
public T FirstOrDefault<T>(string query, Action<IParameterCollection> parameters, Func<ISqlReader, T> reader)
{
var firstOrDefaultResult = default(T);
using (var sqlConnection = new SqlConnection(this.connectionString))
{
sqlConnection.OpenWithErrorHandling();
using (var sqlCommand = sqlConnection.CreateCommand())
{
sqlCommand.CommandText = query;
parameters(new ParameterCollection(sqlCommand.Parameters));
using (var sqlDataReader = sqlCommand.ExecuteReader())
{
if (sqlDataReader.Read())
{
firstOrDefaultResult = reader(new SqlReader(sqlDataReader));
}
}
}
}
return firstOrDefaultResult;
}
public T ScalarTransaction<T>(string query, Action<IParameterCollection> parameters)
{
var scalarResult = default(T);
using (var sqlConnection = new SqlConnection(this.connectionString))
{
sqlConnection.OpenWithErrorHandling();
using (var sqlTransaction = sqlConnection.BeginTransaction())
{
using (var sqlCommand = sqlConnection.CreateCommand())
{
sqlCommand.Transaction = sqlTransaction;
sqlCommand.CommandText = query;
parameters(new ParameterCollection(sqlCommand.Parameters));
var scalarObject = sqlCommand.ExecuteScalar();
if (scalarObject is T scalarValue)
{
scalarResult = scalarValue;
}
}
sqlTransaction.Commit();
}
}
return scalarResult;
}
}
}
@@ -4,6 +4,9 @@
using Microsoft.Extensions.DependencyInjection;
using System.Data.SqlClient;
using System.Diagnostics;
public static class DbContextExtensions
{
public static IServiceCollection AddDbContext(this IServiceCollection services, string connectionString)
@@ -12,5 +15,20 @@
return services;
}
internal static void OpenWithErrorHandling(this SqlConnection sqlConnection)
{
sqlConnection.FireInfoMessageEventOnUserErrors = true;
sqlConnection.InfoMessage += SqlConnectionInfoMessage;
sqlConnection.Open();
}
internal static void SqlConnectionInfoMessage(object sender, SqlInfoMessageEventArgs e)
{
Debug.WriteLine(e);
// TODO: Handle errors
}
}
}
@@ -1,6 +1,14 @@
namespace LaaProductionWeb.Data.Interfaces
{
using System;
using System.Collections.Generic;
public interface IDbContext
{
IEnumerable<T> AsEnumerable<T>(string query, Action<IParameterCollection> parameters, Func<ISqlReader, T> reader);
T FirstOrDefault<T>(string query, Action<IParameterCollection> parameters, Func<ISqlReader, T> reader);
T ScalarTransaction<T>(string query, Action<IParameterCollection> parameters);
}
}
@@ -0,0 +1,9 @@
namespace LaaProductionWeb.Data.Interfaces
{
public interface IParameterCollection
{
IParameterCollection Add(string name, object value);
IParameterCollection AddFile(string name, byte[] fileContent);
}
}
@@ -0,0 +1,11 @@
namespace LaaProductionWeb.Data.Interfaces
{
public interface ISqlReader
{
byte[] GetBytes(int index);
string GetString(int index);
T GetValue<T>(int index);
}
}
@@ -59,11 +59,14 @@
<Compile Include="DbContext.cs" />
<Compile Include="DbContextExtensions.cs" />
<Compile Include="Interfaces\IDbContext.cs" />
<Compile Include="Interfaces\IParameterCollection.cs" />
<Compile Include="Interfaces\ISqlReader.cs" />
<Compile Include="ParameterCollection.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlReader.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,34 @@
namespace LaaProductionWeb.Data
{
using LaaProductionWeb.Data.Interfaces;
using System.Data;
using System.Data.SqlClient;
public class ParameterCollection : IParameterCollection
{
private readonly SqlParameterCollection parameters;
public ParameterCollection(SqlParameterCollection parameters)
=> this.parameters = parameters;
public IParameterCollection Add(string name, object value)
{
this.parameters.Add(new SqlParameter(name, value));
return this;
}
public IParameterCollection AddFile(string name, byte[] fileContent)
{
var sqlParameter = new SqlParameter(name, SqlDbType.VarBinary)
{
Value = fileContent
};
this.parameters.Add(sqlParameter);
return this;
}
}
}
@@ -0,0 +1,50 @@
namespace LaaProductionWeb.Data
{
using LaaProductionWeb.Data.Interfaces;
using System;
using System.Data.SqlClient;
public class SqlReader : ISqlReader
{
private readonly SqlDataReader sqlDataReader;
public SqlReader(SqlDataReader sqlDataReader)
=> this.sqlDataReader = sqlDataReader;
public byte[] GetBytes(int index)
{
var bytes = default(byte[]);
if (!this.sqlDataReader.IsDBNull(index))
{
bytes = this.sqlDataReader.GetFieldValue<byte[]>(0);
}
return bytes ?? Array.Empty<byte>();
}
public string GetString(int index)
{
if (!this.sqlDataReader.IsDBNull(index))
{
return $"{this.sqlDataReader.GetValue(index)}";
}
return default(string);
}
public T GetValue<T>(int index)
{
if (!this.sqlDataReader.IsDBNull(index))
{
if (this.sqlDataReader.GetValue(index) is T value)
{
return value;
}
}
return default(T);
}
}
}
@@ -0,0 +1,11 @@
namespace LaaProductionWeb.Services.Interfaces
{
using LaaProductionWeb.Services.Models;
public interface IOrdersService : ITransient
{
OrdersFoundModel FindOrders(string search);
OrderPositions FindPositions(string id);
}
}
@@ -0,0 +1,22 @@
namespace LaaProductionWeb.Services.Interfaces
{
using LaaProductionWeb.Services.Models;
using System.Collections.Generic;
using System.IO;
public interface IProtocolService : ITransient
{
string FileContent(int? fileId);
OrderClientModel FindOrder(int orderId);
IEnumerable<KeyValuePair<int, string>> FindOrdersById(int orderno);
IEnumerable<KeyValuePair<int, string>> FindOrdersByClient(string clientName);
IEnumerable<TestStatus> LoadTestStatus(int orderId);
int SaveFile(Stream fileStream, int clientId, int orderId);
}
}
@@ -0,0 +1,17 @@
namespace LaaProductionWeb.Services.Interfaces
{
using LaaProductionWeb.Services.Models;
public interface IShipmentsService : ITransient
{
OrderScanModel DeletePalletEntry(int id);
int GetPalletsCount(OrderScanModel model);
byte[] LoadBatchBuffer(OrderScanModel model);
PalletsBatchModel LoadBatchModel(OrderScanModel model);
Result UpdateBatchModel(OrderScanModel model);
}
}
@@ -41,9 +41,10 @@
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.7.0.0\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
@@ -56,15 +57,36 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Interfaces\IOrdersService.cs" />
<Compile Include="Interfaces\IProtocolService.cs" />
<Compile Include="Interfaces\IShipmentsService.cs" />
<Compile Include="Interfaces\ITransient.cs" />
<Compile Include="Models\BatchPrintModel.cs" />
<Compile Include="Models\OrderClientModel.cs" />
<Compile Include="Models\OrderInfoModel.cs" />
<Compile Include="Models\OrderModel.cs" />
<Compile Include="Models\OrderPositions.cs" />
<Compile Include="Models\OrderScanModel.cs" />
<Compile Include="Models\OrdersFoundModel.cs" />
<Compile Include="Models\PalletsBatchModel.cs" />
<Compile Include="Models\Result.cs" />
<Compile Include="Models\SerialNr.cs" />
<Compile Include="Models\ShipmentModel.cs" />
<Compile Include="Models\TestStatus.cs" />
<Compile Include="OrdersService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProtocolService.cs" />
<Compile Include="ServicesExtensions.cs" />
<Compile Include="ShipmentsService.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
<ProjectReference Include="..\LaaProductionWeb.Data\LaaProductionWeb.Data.csproj">
<Project>{4B5BF112-D3BE-4E84-9A8E-74A0E314BBA7}</Project>
<Name>LaaProductionWeb.Data</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,37 @@
namespace LaaProductionWeb.Services.Models
{
using System.Collections.Generic;
using System.Linq;
public class BatchPrintModel
{
private readonly PalletsBatchModel batchModel;
public BatchPrintModel(PalletsBatchModel batchModel)
=> this.batchModel = batchModel;
public string ClientName
=> this.batchModel.ClientName;
public int OrderNr
=> this.batchModel.OrderNr;
public int ProductionOrderNr
=> this.batchModel.ProductionOrderNr;
public int PositionNr
=> this.batchModel.PositionNr;
public int TotlalItemsCount
=> this.batchModel.TotlalItemsCount;
public string ItemsType
=> this.batchModel.ItemsType;
public SerialNr[] Items
=> this.batchModel
.Items
.Where(x => x.IsScaned)
.ToArray();
}
}
@@ -0,0 +1,19 @@
using System.Web;
namespace LaaProductionWeb.Services.Models
{
public class OrderClientModel
{
public int? OrderId { get; set; }
public int? ClientId { get; set; }
public string ClientName { get; set; }
public string Positions { get; set; }
public int? FileId { get; set; }
public string FileContent { get; set; }
}
}
@@ -0,0 +1,32 @@
namespace LaaProductionWeb.Services.Models
{
using System.Collections.Generic;
public class OrderInfoModel
{
public int OrderNr { get; set; }
public int ProductionOrderNr { get; set; }
public string ClientName { get; set; }
public string Nr
=> this.OrderNr > 0
? $"{this.OrderNr}"
: this.ProductionOrderNr > 0
? $"{this.ProductionOrderNr}"
: default(string);
public static readonly OrderInfoComparer Comparer
= new OrderInfoComparer();
public class OrderInfoComparer : IEqualityComparer<OrderInfoModel>
{
public bool Equals(OrderInfoModel x, OrderInfoModel y)
=> x?.OrderNr == y?.OrderNr;
public int GetHashCode(OrderInfoModel obj)
=> obj?.OrderNr ?? default(int);
}
}
}
@@ -0,0 +1,20 @@
namespace LaaProductionWeb.Services.Models
{
using System.ComponentModel.DataAnnotations;
public class OrderModel
{
public readonly string ScanTitle = "Scanvorgang";
public readonly string BtnSerialNr = "Serien-Nr. hinzufügen";
[Required]
public int? OrderNr { get; set; }
[Required]
public int? PositionNr { get; set; }
[Required]
[Display(Name = "Serien-Nr. scanen oder eingeben")]
public string SerialNr { get; set; }
}
}
@@ -0,0 +1,19 @@
namespace LaaProductionWeb.Services.Models
{
using System.Collections;
using System.Collections.Generic;
public class OrderPositions : IEnumerable<int>
{
private readonly IEnumerable<int> positions;
public OrderPositions(IEnumerable<int> positions)
=> this.positions = positions;
public IEnumerator<int> GetEnumerator()
=> this.positions.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
=> this.GetEnumerator();
}
}
@@ -0,0 +1,36 @@
namespace LaaProductionWeb.Services.Models
{
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
public class OrderScanModel : OrderModel
{
public string Host { get; set; }
public string Place { get; set; }
public int PalletsCount { get; set; }
[Display(Name = "Paletten-Nr.")]
public int PalletNr { get; set; } = 1;
public IDictionary<int, bool> Pallets { get; set; }
= new Dictionary<int, bool> { { 1, false } };
public string PrintUrl
=> $"/Shipments/Print?ordernr={this.OrderNr}&positionnr={this.PositionNr}&palletnr={this.PalletNr}";
public string DownloadUrl
=> $"/Shipments/Download?ordernr={this.OrderNr}&positionnr={this.PositionNr}&palletnr={this.PalletNr}";
public void UpdatePalletsCount(int palletsCount)
{
this.PalletsCount = palletsCount;
this.Pallets = Enumerable
.Range(1, palletsCount)
.ToDictionary(x => x, x => false);
this.Pallets[this.PalletNr] = true;
}
}
}
@@ -0,0 +1,22 @@
namespace LaaProductionWeb.Services.Models
{
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class OrdersFoundModel : IEnumerable<OrderInfoModel>
{
private readonly IEnumerable<OrderInfoModel> orders;
public OrdersFoundModel(IEnumerable<OrderInfoModel> orders)
=> this.orders = orders;
public IEnumerator<OrderInfoModel> GetEnumerator()
=> this.orders
.Distinct(OrderInfoModel.Comparer)
.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
=> this.GetEnumerator();
}
}
@@ -0,0 +1,25 @@
namespace LaaProductionWeb.Services.Models
{
using System;
using System.Collections.Generic;
public class PalletsBatchModel
{
public string ClientName { get; set; }
public int OrderNr { get; set; }
public int ProductionOrderNr { get; set; }
public int PositionNr { get; set; }
public int TotlalItemsCount { get; set; }
public string ItemsType { get; set; }
public string AdditionalText { get; set; }
public IEnumerable<SerialNr> Items { get; set; }
= Array.Empty<SerialNr>();
}
}
@@ -0,0 +1,35 @@
namespace LaaProductionWeb.Services.Models
{
public struct Result
{
private readonly bool succeeded;
private readonly string message;
private Result(bool succeeded = true)
{
this.succeeded = succeeded;
this.message = string.Empty;
}
private Result(string message = default(string))
{
this.message = message;
this.succeeded = string.IsNullOrWhiteSpace(message);
}
public override string ToString()
=> this.message;
public static implicit operator Result(bool succeeded)
=> new Result(succeeded);
public static implicit operator Result(string message)
=> new Result(message);
public static implicit operator bool(Result result)
=> result.succeeded;
public static implicit operator string(Result result)
=> result.ToString();
}
}
@@ -0,0 +1,27 @@
namespace LaaProductionWeb.Services.Models
{
public class SerialNr
{
private int id;
public int Id
{
get => this.id;
set
{
this.id = value;
this.IsScaned = this.id > 0;
}
}
public int Nr { get; set; }
public int? PalletNr { get; set; }
public string ClientNr { get; set; }
public bool IsScaned { get; set; }
public string BarcodeNr => this.ClientNr ?? $"{this.Nr}";
}
}
@@ -0,0 +1,49 @@
namespace LaaProductionWeb.Services.Models
{
using System.ComponentModel.DataAnnotations;
public class ShipmentModel
{
public readonly string BtnSubmit = "Auftrag suchen";
private readonly OrderModel orderModel;
public ShipmentModel() { }
public ShipmentModel(OrderScanModel orderModel)
{
if (orderModel != null)
{
this.orderModel = orderModel;
this.OrderNr = orderModel.OrderNr;
this.PositionNr = orderModel.PositionNr;
}
}
[Required(ErrorMessage = "Auftrags-Nr. ist erforderlich!")]
[Display(Name = "Auftrags-Nr. scanen oder eingeben")]
public int? OrderNr { get; set; }
[Required(ErrorMessage = "Positions-Nr. ist erforderlich!")]
[Display(Name = "Positions-Nr. auswählen")]
public int? PositionNr { get; set; }
public bool HasOrder
=> this.orderModel != null;
public OrderModel OrderModel
=> this.orderModel
?? new OrderModel
{
OrderNr = this.OrderNr,
PositionNr = this.PositionNr
};
public OrderModel OrderScanModel
=> this.orderModel
?? new OrderScanModel
{
OrderNr = this.OrderNr,
PositionNr = this.PositionNr
};
}
}
@@ -0,0 +1,17 @@
namespace LaaProductionWeb.Services.Models
{
public class TestStatus
{
public string PosNr { get; set; }
public string SerialNr { get; set; }
public bool? HeliumTest { get; set; }
public bool? PressureTest { get; set; }
public bool? MetroTest { get; set; }
public bool? RadioTest { get; set; }
}
}
@@ -0,0 +1,57 @@
namespace LaaProductionWeb.Services
{
using LaaProductionWeb.Data.Interfaces;
using LaaProductionWeb.Services.Interfaces;
using LaaProductionWeb.Services.Models;
public class OrdersService : IOrdersService
{
private readonly IDbContext dbContext;
public OrdersService(IDbContext dbContext)
=> this.dbContext = dbContext;
public OrdersFoundModel FindOrders(string search)
{
var ordersFound = this.dbContext.AsEnumerable(
query: $@"
SELECT DISTINCT
[AlleAuftragPositionen].[AuftragNr] -- 0
, [AlleAuftragPositionen].[FertigungsauftragNr] -- 1
, [Kunde].[Name] -- 2
FROM [AlleAuftragPositionen]
LEFT JOIN [Kunde] ON [Kunde].[KundenNr] = [AlleAuftragPositionen].[KundenNr]
WHERE [AlleAuftragPositionen].[Versand_Ist_datum] IS NOT NULL
AND [AlleAuftragPositionen].[AuftragNr] LIKE @{nameof(search)}
ORDER BY [AlleAuftragPositionen].[AuftragNr]
, [AlleAuftragPositionen].[FertigungsauftragNr]
, [Kunde].[Name]",
parameters: parameters => parameters
.Add(nameof(search), $"%{search}%"),
reader: reader => new OrderInfoModel
{
OrderNr = reader.GetValue<int>(0),
ProductionOrderNr = reader.GetValue<int>(1),
ClientName = reader.GetValue<string>(2),
});
return new OrdersFoundModel(ordersFound);
}
public OrderPositions FindPositions(string orderNr)
{
var positionsFound = this.dbContext.AsEnumerable(
query: $@"
SELECT DISTINCT
[AlleAuftragPositionen].[PositionNr] -- 0
FROM [AlleAuftragPositionen]
WHERE [AlleAuftragPositionen].[AuftragNr] = @{nameof(orderNr)}
OR [AlleAuftragPositionen].[FertigungsauftragNr] = @{nameof(orderNr)}
ORDER BY [AlleAuftragPositionen].[PositionNr]",
parameters: parameters => parameters.Add(nameof(orderNr), orderNr),
reader: reader => (int)reader.GetValue<short>(0));
return new OrderPositions(positionsFound);
}
}
}
@@ -0,0 +1,191 @@
namespace LaaProductionWeb.Services
{
using LaaProductionWeb.Data.Interfaces;
using LaaProductionWeb.Services.Interfaces;
using LaaProductionWeb.Services.Models;
using System;
using System.Collections.Generic;
using System.IO;
public class ProtocolService : IProtocolService
{
private readonly IDbContext dbContext;
public ProtocolService(IDbContext dbContext)
=> this.dbContext = dbContext;
public string FileContent(int? fileId)
{
var fileContent = this.dbContext.FirstOrDefault(
query: $@"
SELECT [dbo].[File].[FileContent]
FROM [dbo].[File]
WHERE [dbo].[File].[FileId] = @{nameof(fileId)}",
parameters: parameters => parameters.Add(nameof(fileId), fileId),
reader: reader => reader.GetBytes(0));
return string.Format("data:application/pdf;base64,{0}", Convert.ToBase64String(fileContent));
}
public OrderClientModel FindOrder(int orderId)
=> this.dbContext.FirstOrDefault(
query: $@"
SELECT DISTINCT
[APG].[AuftragNr]
, [K].[KundenNr]
, [K].[Name]
, ISNULL((SELECT CAST([Positions].[PositionNr] AS VARCHAR) + ', '
FROM (SELECT DISTINCT TOP 1000 [PositionNr]
FROM [AuftragPositionSerienNr]
WHERE [AuftragNr] = [APG].[AuftragNr]
ORDER BY [PositionNr]) AS [Positions]
FOR XML PATH('')), '') AS [Positions]
FROM [AuftragPosition_Gesamt] AS [APG]
JOIN [Auftrag_Gesamt] AS [AG]
ON [AG].[AuftragNr] = [APG].[AuftragNr]
JOIN [IdentNr] AS [IN]
ON [IN].[IdentNr] = [APG].[Identnr]
AND [IN].[Typ] = 'GNS'
JOIN [Kunde] AS [K]
ON [K].[KundenNr] = [AG].[KundenNr]
WHERE [APG].[AuftragNr] = @{nameof(orderId)}",
parameters: parameters => parameters.Add(nameof(orderId), orderId),
reader: reader => new OrderClientModel
{
OrderId = reader.GetValue<int>(0),
ClientId = reader.GetValue<int>(1),
ClientName = reader.GetString(2),
Positions = reader.GetString(3).Trim().Trim(',')
}) ?? new OrderClientModel();
public IEnumerable<KeyValuePair<int, string>> FindOrdersById(int orderno)
=> this.dbContext.AsEnumerable($@"
SELECT DISTINCT
[APG].[AuftragNr]
, [K].[Name]
FROM [AuftragPosition_Gesamt] AS [APG]
JOIN [Auftrag_Gesamt] AS [AG]
ON [AG].[AuftragNr] = [APG].[AuftragNr]
JOIN [IdentNr] AS [IN]
ON [IN].[IdentNr] = [APG].[Identnr]
AND [IN].[Typ] = 'GNS'
JOIN [Kunde] AS [K]
ON [K].[KundenNr] = [AG].[KundenNr]
WHERE [APG].[AuftragNr] LIKE @{nameof(orderno)}",
parameters: parameters => parameters.Add(nameof(orderno), $"%{orderno}%"),
reader: reader => new KeyValuePair<int, string>(
key: reader.GetValue<int>(0),
value: reader.GetString(1)));
public IEnumerable<KeyValuePair<int, string>> FindOrdersByClient(string clientName)
=> this.dbContext.AsEnumerable(
query: $@"
SELECT DISTINCT
[APG].[AuftragNr]
, [K].[Name]
FROM [AuftragPosition_Gesamt] AS [APG]
JOIN [Auftrag_Gesamt] AS [AG]
ON [AG].[AuftragNr] = [APG].[AuftragNr]
JOIN [IdentNr] AS [IN]
ON [IN].[IdentNr] = [APG].[Identnr]
AND [IN].[Typ] = 'GNS'
JOIN [Kunde] AS [K]
ON [K].[KundenNr] = [AG].[KundenNr]
WHERE [K].[Name] LIKE @{nameof(clientName)}",
parameters: parameters => parameters.Add(nameof(clientName), $"%{clientName}%"),
reader: reader => new KeyValuePair<int, string>(
key: reader.GetValue<int>(0),
value: reader.GetString(1)));
public IEnumerable<TestStatus> LoadTestStatus(int orderId)
=> this.dbContext.AsEnumerable(
query: $@"
SELECT DISTINCT
[APS].[PositionNr] AS [PosNr] -- 0
, ISNULL([APS].[KundeneigeneSerienNr], [APS].[SerienNr]) AS [SerialNr] -- 1
, [CPT].[CordonelPressureTest_Valid] AS [3TightnessTest] -- 2
, [DP].[Dicht] AS [4PressureAndTightness] -- 3
, MAX([APS].[StatusFertigung]) AS [5Metrologicaltesting] -- 4
, [CRRH].[Result] AS [6ConfigComparisonAndRadiotest] -- 5
FROM [AuftragPositionSerienNr] AS [APS]
LEFT JOIN [Genesis_Meter] AS [GM]
ON [GM].[Seriennummer] = [APS].[SerienNr]
LEFT JOIN [MapPcbIdToSerialNumber] AS [PCB]
ON [PCB].[MapPcbIdToSerialNumber_SerialNumber] = [GM].[Seriennummer]
LEFT JOIN [Cordonel_Radio_RSSI_History] AS [CRRH]
ON [CRRH].[RadioAdress] = [GM].[Adresse] - 10000000000
AND [CRRH].[IsLast] = 1
AND [CRRH].[Result] = 1
LEFT JOIN [Druckpruefung] AS [DP]
ON [DP].[FabNr] = [PCB].[MapPcbIdToSerialNumber_PcbId]
AND [DP].[Dicht] = 1
LEFT JOIN [Cordonel_PressureTest] AS [CPT]
ON [CPT].[CordonelPressureTest_PcbId] = [PCB].[MapPcbIdToSerialNumber_PcbId]
AND [CPT].[CordonelPressureTest_Valid] = 1
WHERE [APS].[AuftragNr] = @{nameof(orderId)}
GROUP BY [APS].[PositionNr]
, [APS].[SerienNr]
, [APS].[KundeneigeneSerienNr]
, [CPT].[CordonelPressureTest_Valid]
, [DP].[Dicht]
, [CRRH].[Result]
ORDER BY [APS].[PositionNr]
, ISNULL([APS].[KundeneigeneSerienNr], [APS].[SerienNr])",
parameters: parameters => parameters.Add(nameof(orderId), orderId),
reader: reader => new TestStatus
{
PosNr = $"{reader.GetValue<short>(0)}",
SerialNr = reader.GetValue<string>(1),
HeliumTest = reader.GetValue<bool?>(2),
PressureTest = reader.GetValue<bool?>(3),
MetroTest = this.MetrologicalValue(reader.GetValue<byte?>(4)),
RadioTest = reader.GetValue<bool?>(5),
});
public int SaveFile(Stream fileStream, int clientId, int orderId)
{
var fileName = $"{clientId}_{orderId}.pdf";
var fileContent = this.GetBuffer(fileStream);
return this.dbContext.ScalarTransaction<int>(
query: $@"
INSERT INTO [dbo].[File] (
[FileName]
, [FileContent])
OUTPUT @{nameof(orderId)}, [Inserted].[FileId], 'PROTOCOL'
INTO [dbo].[FilesOrders]([OrderId], [FileId], [Usage])
OUTPUT [Inserted].[FileId]
VALUES (@{nameof(fileName)}
, @{nameof(fileContent)})",
parameters: parameters => parameters
.Add(nameof(orderId), orderId)
.Add(nameof(fileName), fileName)
.AddFile(nameof(fileContent), fileContent));
}
private byte[] GetBuffer(Stream fileStream)
{
var fileContent = new byte[fileStream.Length];
using (var memoryStream = new MemoryStream())
{
fileStream.CopyTo(memoryStream);
fileContent = memoryStream.ToArray();
}
return fileContent;
}
private bool? MetrologicalValue(byte? value)
{
if (value is null)
{
return null;
}
return value == 30;
}
}
}
@@ -0,0 +1,302 @@
namespace LaaProductionWeb.Services
{
using LaaProductionWeb.Data.Interfaces;
using LaaProductionWeb.Services.Interfaces;
using LaaProductionWeb.Services.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class ShipmentsService : IShipmentsService
{
private readonly IDbContext dbContext;
public ShipmentsService(IDbContext dbContext)
=> this.dbContext = dbContext;
public OrderScanModel DeletePalletEntry(int id)
{
var orderScanModel = this.DeletePalletEntryById(id);
if (orderScanModel != null)
{
var updated = this.UpdatePalletsNr(orderScanModel);
}
return orderScanModel;
}
public int GetPalletsCount(OrderScanModel model)
{
var palletsCount = this.dbContext.FirstOrDefault(
query: $@"
SELECT COUNT(1)
FROM (SELECT [PalettenNr] AS [PalletNr]
, COUNT([SerienNr]) AS [Count]
FROM [PalettenScan]
WHERE [AuftragNr] = @{nameof(model.OrderNr)}
AND [PositionNr] = @{nameof(model.PositionNr)}
GROUP BY [PalettenNr])
AS [Paletten]
WHERE [Count] > 0",
parameters: parameters => parameters
.Add(nameof(model.OrderNr), model.OrderNr)
.Add(nameof(model.PositionNr), model.PositionNr),
reader: reader => reader.GetValue<int>(0));
return Math.Max(palletsCount, 1);
}
public byte[] LoadBatchBuffer(OrderScanModel model)
{
var palletLoad = this.dbContext.AsEnumerable(
query: $@"
SELECT [PalettenNr]
, [SerienNr]
FROM [PalettenScan]
WHERE [AuftragNr] = @{nameof(model.OrderNr)}
AND [PositionNr] = @{nameof(model.PositionNr)}
AND [PalettenNr] = @{nameof(model.PalletNr)}
ORDER BY [SerienNr]",
parameters: parameters => parameters
.Add(nameof(model.OrderNr), model.OrderNr)
.Add(nameof(model.PositionNr), model.PositionNr)
.Add(nameof(model.PalletNr), model.PalletNr),
reader: reader => string.Join(",", new string[]
{
reader.GetString(0),
reader.GetString(1),
}));
var csvContent = string.Join(Environment.NewLine, palletLoad);
return Encoding.UTF8.GetBytes($"Pallet Nr.,Serial Nr.{Environment.NewLine}{csvContent}");
}
public IEnumerable<SerialNr> LoadBatchItems(OrderScanModel model)
=> this.dbContext.AsEnumerable(
query: $@"
SELECT DISTINCT
[PalettenScan].[ID] -- 0
, [AuftragPositionSerienNr].[SerienNr] -- 1
, REPLACE(RTRIM(LTRIM([AuftragPositionSerienNr].[KundeneigeneSerienNr])), ' ', '') -- 2
, [PalettenScan].[PalettenNr] -- 3
, CAST(CASE WHEN [PalettenScan].[ID] IS NULL THEN 0 ELSE 1 END AS BIT) -- 4
FROM [AuftragPositionSerienNr]
LEFT JOIN [PalettenScan]
ON [PalettenScan].[AuftragNr] = [AuftragPositionSerienNr].[AuftragNr]
AND [PalettenScan].[PositionNr] = [AuftragPositionSerienNr].[PositionNr]
AND [PalettenScan].[SerienNr] = REPLACE(RTRIM(LTRIM([AuftragPositionSerienNr].[KundeneigeneSerienNr])), ' ', '')
WHERE [AuftragPositionSerienNr].[AuftragNr] = @{nameof(model.OrderNr)}
AND [AuftragPositionSerienNr].[PositionNr] = @{nameof(model.PositionNr)}
AND ([PalettenScan].[PalettenNr] = @{nameof(model.PalletNr)}
OR [PalettenScan].[PalettenNr] IS NULL)",
parameters: parameters => parameters
.Add(nameof(model.OrderNr), model.OrderNr)
.Add(nameof(model.PositionNr), model.PositionNr)
.Add(nameof(model.PalletNr), model.PalletNr),
reader: reader => new SerialNr
{
Id = reader.GetValue<int>(0),
Nr = reader.GetValue<int>(1),
ClientNr = reader.GetString(2),
PalletNr = reader.GetValue<short>(3),
IsScaned = reader.GetValue<bool>(4)
})
.OrderByDescending(x => x.IsScaned)
.ThenBy(x => x.ClientNr);
public PalletsBatchModel LoadBatchModel(OrderScanModel model)
{
var batchModel = this.dbContext.FirstOrDefault(
query: $@"
SELECT TOP 1
[Auftrag].[AuftragNr] -- 0
, [Auftrag].[FertigungsauftragNr] -- 1
, [Auftrag].[PositionNr] -- 2
, [Auftrag].[Menge] -- 3
, [Kunde].[Name] -- 4
, [IdentNr].[Typ] -- 5
, [IdentNr].[Typzusatz] -- 6
, [IdentNr].[Nennweite] -- 7
, [Auftrag].[ZusatzText] -- 8
FROM [AlleAuftragPositionen] AS [Auftrag]
JOIN [Kunde] ON [Kunde].[KundenNr] = [Auftrag].[KundenNr]
JOIN [IdentNr] ON [IdentNr].[IdentNr] = [Auftrag].[IdentNr]
WHERE [Auftrag].[AuftragNr] = @{nameof(model.OrderNr)}
AND [Auftrag].[PositionNr] = @{nameof(model.PositionNr)}
ORDER BY [Auftrag].[FertigungsauftragNr] DESC",
parameters: parameters => parameters
.Add(nameof(model.OrderNr), model.OrderNr)
.Add(nameof(model.PositionNr), model.PositionNr),
reader: reader => new PalletsBatchModel
{
OrderNr = reader.GetValue<int>(0),
ProductionOrderNr = reader.GetValue<int>(1),
PositionNr = reader.GetValue<short>(2),
TotlalItemsCount = reader.GetValue<int>(3),
ClientName = reader.GetValue<string>(4),
ItemsType = string.Join(" ", new[]
{
reader.GetString(5),
reader.GetString(6),
reader.GetString(7),
}.Where(x => !string.IsNullOrWhiteSpace(x))),
AdditionalText = reader.GetValue<string>(8),
}) ?? new PalletsBatchModel();
if (batchModel.OrderNr > 0)
{
batchModel.Items = this.LoadBatchItems(model);
}
return batchModel;
}
public Result UpdateBatchModel(OrderScanModel model)
{
if (!string.IsNullOrWhiteSpace(model.SerialNr))
{
if (this.PalletsEntryExists(model.OrderNr, model.PositionNr, model.SerialNr))
{
return $"Der Packet mit Serien-Nr: {model.SerialNr} wurde bereits hinzugefügt.";
}
var orderKVP = this.GetOrderKVP(model.OrderNr, model.PositionNr, model.SerialNr);
if (orderKVP.Key <= 0)
{
return $"Der Packet mit Serien-Nr: {model.SerialNr} ist nicht dem Auftrag/Position: {model.OrderNr}/{model.PositionNr} zugewiesen.";
}
else
{
model.SerialNr = orderKVP.Value;
model.PalletNr = this.GetPalletNr(model);
}
var rowsAffected = this.InsertPalletEntry(model);
return rowsAffected == 1;
}
return false;
}
private int GetPalletNr(OrderScanModel model)
=> this.dbContext.FirstOrDefault(
query: $@"
SELECT MAX([PalettenNr]) + 1
FROM [PalettenScan]
WHERE [AuftragNr] = @{nameof(model.OrderNr)}
AND [PositionNr] = @{nameof(model.PositionNr)}",
parameters: parameters => parameters
.Add(nameof(model.OrderNr), model.OrderNr)
.Add(nameof(model.PositionNr), model.PositionNr),
reader: reader => Math.Min(reader.GetValue<int>(0), model.PalletNr));
private OrderScanModel DeletePalletEntryById(int id)
=> this.dbContext.FirstOrDefault(
query: $@"
DELETE
FROM [PalettenScan]
OUTPUT [deleted].[AuftragNr]
, [deleted].[PositionNr]
, [deleted].[PalettenNr]
WHERE [ID] = @{nameof(id)}",
parameters: parameters => parameters.Add(nameof(id), id),
reader: reader => new OrderScanModel
{
OrderNr = reader.GetValue<int>(0),
PositionNr = reader.GetValue<int>(1),
PalletNr = reader.GetValue<short>(2)
});
private KeyValuePair<int, string> GetOrderKVP(int? orderNr, int? positionNr, string serialNr)
=> this.dbContext.FirstOrDefault(
query: $@"
SELECT DISTINCT TOP 1
[AuftragPositionSerienNr].[SerienNr] -- 0
, REPLACE(RTRIM(LTRIM([AuftragPositionSerienNr].[KundeneigeneSerienNr])), ' ', '') -- 1
FROM [AuftragPositionSerienNr]
WHERE [AuftragPositionSerienNr].[AuftragNr] = @{nameof(orderNr)}
AND [AuftragPositionSerienNr].[PositionNr] = @{nameof(positionNr)}
AND @{nameof(serialNr)} LIKE '%' + (REPLACE(RTRIM(LTRIM([AuftragPositionSerienNr].[KundeneigeneSerienNr])), ' ', '')) + '%'",
parameters: parameters => parameters
.Add(nameof(orderNr), orderNr)
.Add(nameof(positionNr), positionNr)
.Add(nameof(serialNr), serialNr),
reader: reader => new KeyValuePair<int, string>(
key: reader.GetValue<int>(0),
value: reader.GetValue<string>(1)));
private int InsertPalletEntry(OrderScanModel model)
=> this.dbContext.ScalarTransaction<int>($@"
INSERT
INTO [PalettenScan] (
[PalettenNr]
, [AuftragNr]
, [PositionNr]
, [SerienNr]
, [Host]
, [Platz]
, [Datum])
VALUES (@{nameof(model.PalletNr)}
, @{nameof(model.OrderNr)}
, @{nameof(model.PositionNr)}
, @{nameof(model.SerialNr)}
, @{nameof(model.Host)}
, @{nameof(model.Place)}
, GETDATE())",
parameters => parameters
.Add(nameof(model.PalletNr), model.PalletNr)
.Add(nameof(model.OrderNr), model.OrderNr)
.Add(nameof(model.PositionNr), model.PositionNr)
.Add(nameof(model.SerialNr), model.SerialNr)
.Add(nameof(model.Host), model.Host)
.Add(nameof(model.Place), model.Place));
private bool PalletsEntryExists(int? orderNr, int? positionNr, string serialNr)
=> this.dbContext.FirstOrDefault($@"
SELECT CAST(CASE WHEN [PalettenScan].[ID] IS NULL THEN 0 ELSE 1 END AS BIT)
FROM [PalettenScan]
WHERE [PalettenScan].[AuftragNr] = @{nameof(orderNr)}
AND [PalettenScan].[PositionNr] = @{nameof(positionNr)}
AND [PalettenScan].[SerienNr] = @{nameof(serialNr)}",
parameters => parameters
.Add(nameof(orderNr), orderNr)
.Add(nameof(positionNr), positionNr)
.Add(nameof(serialNr), serialNr),
reader => reader.GetValue<bool>(0));
private bool UpdatePalletsNr(OrderScanModel model)
=> this.dbContext.FirstOrDefault($@"
BEGIN TRANSACTION
------------------------------------------------------------------------
DECLARE @rowsByAuftragPosition INT = (
SELECT COUNT(1)
FROM [PalettenScan]
WHERE [AuftragNr] = @{nameof(model.OrderNr)}
AND [PositionNr] = @{nameof(model.PositionNr)})
------------------------------------------------------------------------
UPDATE [PalettenScan]
SET [PalettenNr] = [OrderedPallets].[NewPalletNr]
FROM [PalettenScan]
JOIN (SELECT [ID]
, [PalettenNr]
, DENSE_RANK() OVER(ORDER BY [PalettenNr]) AS [NewPalletNr]
FROM [PalettenScan]
WHERE [AuftragNr] = @{nameof(model.OrderNr)}
AND [PositionNr] = @{nameof(model.PositionNr)})
AS [OrderedPallets]
ON [PalettenScan].[ID] = [OrderedPallets].[ID]
------------------------------------------------------------------------
IF @rowsByAuftragPosition = @@ROWCOUNT
BEGIN SELECT CAST(1 AS BIT); COMMIT; END
ELSE BEGIN SELECT CAST(0 AS BIT); ROLLBACK; END",
parameters => parameters
.Add(nameof(model.OrderNr), model.OrderNr)
.Add(nameof(model.PositionNr), model.PositionNr),
reader => reader.GetValue<bool>(0));
}
}
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@@ -3,6 +3,6 @@
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net462" />
<package id="Microsoft.Extensions.DependencyInjection" version="7.0.0" targetFramework="net462" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="7.0.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
</packages>
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
{
"CSD 770951": "Anglian Water",
"CSD 773102": "Yorkshire Water",
"38977_LP": "Stream/Leep"
}
@@ -18,16 +18,16 @@
public IController CreateController(RequestContext requestContext, string controllerName)
{
var controllerTypeName = requestContext.RouteData.DataTokens.TryGetValue("area", out object areaName)
var controllerTypeName = requestContext.RouteData.Values.TryGetValue("area", out object areaName)
? string.Format(AREAS_PATTERN, areaName, controllerName)
: string.Format(CONTROLLERS_PATTERN, controllerName);
var controllerType = Type.GetType(controllerTypeName, throwOnError: false, ignoreCase: true);
this.RedirectToDefaultIfNotFound(controllerType, requestContext.HttpContext.Response);
this.RedirectToDefault(controllerType, requestContext.HttpContext.Response);
var controller = this.serviceProvider.GetService(controllerType) as IController;
this.RedirectToDefaultIfNotFound(controller, requestContext.HttpContext.Response);
this.RedirectToDefault(controller, requestContext.HttpContext.Response);
return controller;
}
@@ -43,11 +43,11 @@
}
}
private void RedirectToDefaultIfNotFound(object resource, HttpResponseBase response)
private void RedirectToDefault(object resource, HttpResponseBase response)
{
if (response is null)
if (resource is null)
{
response.RedirectToRoute("MVC_Default");
response.Redirect("/");
response.End();
}
}
@@ -5,9 +5,6 @@
public class HomeController : Controller
{
[HttpGet]
public ActionResult Index()
{
return this.View();
}
public ActionResult Index() => this.View();
}
}
@@ -0,0 +1,98 @@
namespace LaaProductionWeb.Controllers
{
using LaaProductionWeb.Services.Interfaces;
using LaaProductionWeb.Services.Models;
using System.Web.Mvc;
[Authorize]
public class ProtocolController : Controller
{
public const string FilePDF = nameof(FilePDF);
private readonly IProtocolService protocolService;
public ProtocolController(IProtocolService protocolService)
=> this.protocolService = protocolService;
[HttpGet]
public ActionResult Index(int orderId = 0)
{
var orderClientModel = this.protocolService.FindOrder(orderId);
return this.View(orderClientModel);
}
[HttpPost]
public ActionResult Index(OrderClientModel model)
{
var files = this.Request.Files;
if (files.Count > 0)
{
var file = this.Request.Files.Get(0);
if (file.ContentType == "application/pdf" && model.ClientId > 0 && model.OrderId > 0)
{
model.FileId = this.protocolService.SaveFile(file.InputStream, model.ClientId.Value, model.OrderId.Value);
if (model.FileId > 0)
{
return this.RedirectToAction(nameof(this.Document), model);
}
else
{
this.TempData[FilePDF] = $"Der PDF Datei wurde nicht hochgeladen.";
}
}
else
{
this.TempData[FilePDF] = $"Bitte, PDF Datei hochladen.";
}
}
else
{
this.TempData[FilePDF] = "Kein PDF Datei wurde ausgewählt.";
}
return this.View(model);
}
[HttpGet]
public ActionResult Document(OrderClientModel model)
{
model.FileContent = this.protocolService.FileContent(model.FileId);
return this.View(model);
}
public ActionResult Clients(string search = null)
{
var clientsOrders = this.protocolService.FindOrdersByClient(search);
return this.PartialView(clientsOrders);
}
public ActionResult Orders(int search = 0)
{
var clientsOrders = this.protocolService.FindOrdersById(search);
return this.PartialView(clientsOrders);
}
public ActionResult Body(int orderId = 0)
{
var testStatus = this.protocolService.LoadTestStatus(orderId);
return this.PartialView(testStatus);
}
[HttpGet]
public ActionResult Print(int orderId = 0)
{
var orderClientModel = this.protocolService.FindOrder(orderId);
return this.View(orderClientModel);
}
}
}
@@ -0,0 +1,31 @@
namespace LaaProductionWeb.Controllers
{
using LaaProductionWeb.Services.Interfaces;
using System.Web.Mvc;
[Authorize]
public class SearchController : Controller
{
private readonly IOrdersService ordersService;
public SearchController(IOrdersService ordersService)
=> this.ordersService = ordersService;
[HttpGet]
public ActionResult Orders(string search)
{
var model = this.ordersService.FindOrders(search);
return this.PartialView(model);
}
[HttpGet]
public ActionResult Positions(string orderNr)
{
var model = this.ordersService.FindPositions(orderNr);
return this.PartialView(model);
}
}
}
@@ -0,0 +1,128 @@
namespace LaaProductionWeb.Controllers
{
using LaaProductionWeb.Services.Interfaces;
using LaaProductionWeb.Services.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Web.Mvc;
using SystemFile = System.IO.File;
[Authorize]
public class ShipmentsController : Controller
{
private readonly IShipmentsService shipmentsService;
public ShipmentsController(IShipmentsService shipmentsService)
=> this.shipmentsService = shipmentsService;
[HttpGet]
public ActionResult Index()
=> this.View(new ShipmentModel());
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Index(ShipmentModel model)
=> this.View(model);
public ActionResult Batch(OrderScanModel model)
{
var batchModel = this.shipmentsService
.LoadBatchModel(model ?? new OrderScanModel());
this.UpdateClientName(batchModel);
return this.PartialView(batchModel);
}
public ActionResult Scan(OrderScanModel model)
{
var palletsCount = this.shipmentsService.GetPalletsCount(model);
model.UpdatePalletsCount(palletsCount);
return this.PartialView(model);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ScanPost(OrderScanModel model)
{
if (this.ModelState.IsValid)
{
model.Host = this.HttpContext.Request.UserHostAddress;
model.Place = this.HttpContext.Request.UserHostName;
model.SerialNr = model.SerialNr?.Replace(" ", string.Empty);
var result = this.shipmentsService.UpdateBatchModel(model);
if (result)
{
model.SerialNr = default(string);
}
else
{
this.TempData[nameof(model.SerialNr)] = result;
}
}
return this.View(nameof(this.Index), new ShipmentModel(model));
}
[HttpGet]
public ActionResult Delete(int id)
{
var orderScanModel = this.shipmentsService.DeletePalletEntry(id);
return this.View(nameof(this.Index), new ShipmentModel(orderScanModel));
}
[HttpGet]
public ActionResult Print(OrderScanModel model)
{
var batchModel = this.shipmentsService.LoadBatchModel(model);
var batchPrintModel = new BatchPrintModel(batchModel);
return this.View(batchPrintModel);
}
[HttpGet]
public ActionResult Download(OrderScanModel model)
{
var batchBuffer = this.shipmentsService.LoadBatchBuffer(model);
var fileName = $"{model.OrderNr}_{model.PositionNr}_{model.PalletsCount}.csv";
this.Response.AddHeader("Content-Disposition", $"attachment;filename={fileName}");
return this.File(batchBuffer, "application/vnd.ms-excel");
}
private void UpdateClientName(PalletsBatchModel batchModel)
{
try
{
var path = this.Server.MapPath("~/App_Data/client_map.json");
var jsonContent = SystemFile.ReadAllText(path);
var clientMap = JsonConvert.DeserializeObject<IDictionary<string, string>>(jsonContent);
var additionalText = batchModel.AdditionalText ?? string.Empty;
foreach (var kvp in clientMap)
{
if (additionalText.Contains(kvp.Key))
{
batchModel.ClientName = kvp.Value;
break;
}
}
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}
}
}
@@ -69,8 +69,8 @@
<Reference Include="System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
@@ -93,6 +93,9 @@
<Reference Include="System.Web.Mvc, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.9\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.9\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
@@ -118,21 +121,12 @@
</Reference>
<Reference Include="System.Net.Http.WebRequest">
</Reference>
<Reference Include="System.Web.Optimization">
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
</Reference>
<Reference Include="WebGrease">
<Private>True</Private>
<HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
</Reference>
<Reference Include="Antlr3.Runtime">
<Private>True</Private>
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -145,6 +139,9 @@
<Compile Include="App_Start\ServicesConfig.cs" />
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\ProtocolController.cs" />
<Compile Include="Controllers\SearchController.cs" />
<Compile Include="Controllers\ShipmentsController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
@@ -160,19 +157,36 @@
<Content Include="App_Content\svg\sensus_xylem_logo.svg" />
<Content Include="favicon.ico" />
<Content Include="Global.asax" />
<Content Include="Web.config" />
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
<Content Include="Views\Web.config" />
<Content Include="Views\_ViewStart.cshtml" />
<Content Include="Views\Shared\_Layout.cshtml" />
<Content Include="Views\Home\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
<None Include="packages.config" />
<Content Include="Views\Shared\_PrintLayout.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Content\font\fonts\bootstrap-icons.woff" />
<Content Include="App_Content\font\fonts\bootstrap-icons.woff2" />
<None Include="packages.config" />
<Content Include="libman.json" />
<Content Include="App_Content\css\bootstrap.min.css.map" />
<Content Include="App_Data\client_map.json" />
<Content Include="Views\Protocol\Body.cshtml" />
<Content Include="Views\Protocol\Clients.cshtml" />
<Content Include="Views\Protocol\Document.cshtml" />
<Content Include="Views\Protocol\Index.cshtml" />
<Content Include="Views\Protocol\Orders.cshtml" />
<Content Include="Views\Protocol\Print.cshtml" />
<Content Include="Views\Search\Orders.cshtml" />
<Content Include="Views\Search\Positions.cshtml" />
<Content Include="Views\Shipments\Batch.cshtml" />
<Content Include="Views\Shipments\Index.cshtml" />
<Content Include="Views\Shipments\Print.cshtml" />
<Content Include="Views\Shipments\Scan.cshtml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LaaProductionWeb.Data\LaaProductionWeb.Data.csproj">
@@ -1,8 +1,4 @@
@{
ViewBag.Title = "Home Page";
}
<div class="container my-5 py-5">
<div class="container my-5 py-5">
<div class="row">
<div class="col-12">
<div class="jumbotron">
@@ -0,0 +1,74 @@
@model IEnumerable<LaaProductionWeb.Services.Models.TestStatus>
@{
Func<bool?, string> testPassed = testStatus =>
{
if (testStatus is null)
{
return "bi bi-check2 text-secondary opacity-25 fs-3";
}
else if (testStatus == false)
{
return "bi bi-x text-danger fs-3";
}
else
{
return "bi bi-check2 text-teal fs-3";
}
};
}
<tbody>
<tr>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th class="white-space-nowrap">Pos. No.</th>
<th class="white-space-nowrap">Serial No.</th>
<th>Tightness Test</th>
<th>Pressure and burst test composit transducer</th>
<th>Metrological testing</th>
<th>Config comparison and radio test</th>
</tr>
<tr>
<th colspan="2">Acceptance Norms</th>
<td>Rejected in case of leakage</td>
<td>Rejected in case of leakage or breakage</td>
<td>
Maximum Permissible Error at
<br>Q1 < ± 5%
<br>Q2 < ± 2%
<br>Q3 < ± 2%
</td>
<td>
Main functions,
<br>LCD display,
<br>LED,
<br>Radio functions according to specs
<br>
<br>Parameter readable and according to customer specification
</td>
</tr>
@foreach (var item in this.Model)
{
<tr>
<td class="va-middle">@item.PosNr</td>
<td class="va-middle white-space-nowrap px-5">@item.SerialNr</td>
<td class="text-center">
<bi class="@testPassed(item.HeliumTest)"></bi>
</td>
<td class="text-center">
<bi class="@testPassed(item.PressureTest)"></bi>
</td>
<td class="text-center">
<bi class="@testPassed(item.MetroTest)"></bi>
</td>
<td class="text-center">
<bi class="@testPassed(item.RadioTest)"></bi>
</td>
</tr>
}
</table>
</td>
</tr>
</tbody>
@@ -0,0 +1,16 @@
@model IEnumerable<KeyValuePair<int, string>>
@if (this.Model != null && this.Model.Any())
{
foreach (var kvp in this.Model)
{
<li><a class="dropdown-item" href="#@kvp.Key">@kvp.Key - @kvp.Value</a></li>
}
}
else
{
<li>
<a class="dropdown-item text-secondary bg-light text-normal" href="#"><i class="bi bi-search"></i> Search by client name</a>
</li>
}
@@ -0,0 +1,19 @@
@model OrderClientModel
@using LaaProductionWeb.Services.Models
<form>
@this.Html.HiddenFor(x => x.FileId)
@this.Html.HiddenFor(x => x.OrderId)
@this.Html.HiddenFor(x => x.ClientId)
@this.Html.HiddenFor(x => x.ClientName)
@this.Html.HiddenFor(x => x.Positions)
</form>
<div class="container-fluid h-100 p-0">
<div class="row h-100">
<div class="position-relative h-100">
<iframe class="position-absolute align-top align-left w-100 h-100" src="@this.Model.FileContent" frameborder="0" allowfullscreen />
</div>
</div>
</div>
@@ -0,0 +1,133 @@
@model OrderClientModel
@using LaaProductionWeb.Controllers
@using LaaProductionWeb.Services.Models
<table class="table table-bordered">
<thead>
<tr>
<th class="align-top p-0 w-100">
<table class="table table-bordered">
<tr>
<td colspan="2" class="py-1 fs-5 white-space-nowrap text-center text-smallcaps">Test Protocol</td>
</tr>
<tr>
<td class="py-1 white-space-nowrap va-middle"><label for="client_name">Client</label></td>
<td class="p-1 dropdown">
<input id="client_name" class="form-control border-0 rounded-0" value="@this.Model.ClientName" />
<ul class="dropdown-menu mt-2 w-100" id="client_name_options">
<li class="text-secondary bg-light text-normal">Search by client name</li>
</ul>
</td>
</tr>
<tr>
<td class="py-1 white-space-nowrap va-middle"><label for="order_no">Order No.</label></td>
<td class="p-1">
<input id="order_no" class="form-control border-0 rounded-0" value="@this.Model.OrderId" />
<ul class="dropdown-menu mt-2 w-100" id="order_no_options">
<li class="text-secondary bg-light text-normal">Search by order no.</li>
</ul>
</td>
</tr>
<tr class="border-bottom-0">
<td class="py-1 white-space-nowrap va-middle">Positions</td>
<td class="p-1">
<div class="form-control border-0 rounded-0">
@if (string.IsNullOrWhiteSpace(this.Model.Positions))
{
<span class="text-white">...</span>
}
else
{
<span>@this.Model.Positions</span>
}
</div>
</td>
</tr>
</table>
</th>
<th class="text-center va-middle w-auto">
<img src="~/App_Content/svg/sensus_xylem_logo.svg" width="210" class="mx-5"/>
<form action="/Protocol/Index" method="post" enctype="multipart/form-data">
@this.Html.HiddenFor(x => x.OrderId)
@this.Html.HiddenFor(x => x.ClientId)
@this.Html.HiddenFor(x => x.ClientName)
@this.Html.HiddenFor(x => x.Positions)
<input name="FilePDF" id="FilePDF" type="file" class="d-none" accept="application/pdf" />
<div class="input-group flex-nowrap mt-3">
<a class="btn btn-light white-space-nowrap" href="/Protocol/Print?orderId=@this.Model.OrderId" target="_blank"><i class="bi bi-printer me-2"></i> Vorschau</a>
<label for="FilePDF" class="btn btn-outline-light border text-dark white-space-nowrap"><i class="bi bi-filetype-pdf"></i> Auswählen</label>
<button type="submit" class="btn btn-success white-space-nowrap"><i class="bi bi-upload"></i> Hochladen</button>
</div>
@if (this.TempData.TryGetValue(ProtocolController.FilePDF, out object errorMessage))
{
<div class="text-danger small">
@($"{errorMessage}")
</div>
}
</form>
</th>
</tr>
</thead>
@if (this.Model.OrderId > 0)
{
this.Html.RenderAction(nameof(ProtocolController.Body), new { orderId = this.Model.OrderId });
}
</table>
@section scripts {
<script>
document.addEventListener("DOMContentLoaded", () => {
const show = 'show';
let clientNrInput = document.getElementById('client_name');
let clientMenu = document.getElementById('client_name_options');
if (clientNrInput && clientMenu) {
clientNrInput.oninput = function loadOrdersByOrderNr() {
setTimeout(function handler() {
let search = clientNrInput.value;
if (search && search.length > 3) {
fetch(`/Protocol/Clients?search=${search}`)
.then(response => response.text())
.then(orderItems => {
clientMenu.innerHTML = orderItems;
clientMenu.classList.add(show);
})
} else {
clientMenu.classList.remove(show);
}
}, 50);
};
}
let orderNrInput = document.getElementById('order_no');
let orderMenu = document.getElementById('order_no_options');
if (orderNrInput && orderMenu) {
orderNrInput.oninput = function loadOrdersByOrderNr() {
setTimeout(function handler() {
let search = orderNrInput.value;
if (search && search.length > 3) {
fetch(`/Protocol/Orders?search=${search}`)
.then(response => response.text())
.then(orderItems => {
orderMenu.innerHTML = orderItems;
orderMenu.classList.add(show);
})
} else {
orderMenu.classList.remove(show);
}
}, 50);
};
}
window.addEventListener('hashchange', function () {
clientMenu.classList.remove(show);
orderMenu.classList.remove(show);
location.href = `/Protocol?orderId=${location.hash.substring(1)}`
});
});
</script>
}
@@ -0,0 +1,15 @@
@model IEnumerable<KeyValuePair<int, string>>
@if (this.Model != null && this.Model.Any())
{
foreach (var kvp in this.Model)
{
<li><a class="dropdown-item" href="#@kvp.Key">@kvp.Key - @kvp.Value</a></li>
}
}
else
{
<li>
<a class="dropdown-item text-secondary bg-light text-normal" href="#"><i class="bi bi-search"></i> Search by order no.</a>
</li>
}
@@ -0,0 +1,74 @@
@model OrderClientModel
@using LaaProductionWeb.Controllers
@using LaaProductionWeb.Services.Models
@{
this.Layout = "~/Views/Shared/_PrintLayout.cshtml";
}
<table class="table table-bordered">
<thead>
<tr>
<th class="align-top p-0 w-100">
<table class="table table-bordered">
<tr>
<td colspan="2" class="py-1 fs-5 white-space-nowrap text-center text-smallcaps">Test Protocol</td>
</tr>
<tr>
<td class="py-1 white-space-nowrap va-middle"><label for="client_name">Client</label></td>
<td class="p-1 dropdown">
<div class="form-control border-0 rounded-0">
@if (string.IsNullOrWhiteSpace(this.Model.ClientName))
{
<span class="text-white">...</span>
}
else
{
<span>@this.Model.ClientName</span>
}
</div>
</td>
</tr>
<tr>
<td class="py-1 white-space-nowrap va-middle"><label for="order_no">Order No.</label></td>
<td class="p-1">
<div class="form-control border-0 rounded-0">
@if (this.Model.OrderId is null)
{
<span class="text-white">...</span>
}
else
{
<span>@this.Model.OrderId</span>
}
</div>
</td>
</tr>
<tr class="border-bottom-0">
<td class="py-1 white-space-nowrap va-middle">Positions</td>
<td class="p-1">
<div class="form-control border-0 rounded-0">
@if (string.IsNullOrWhiteSpace(this.Model.Positions))
{
<span class="text-white">...</span>
}
else
{
<span>@this.Model.Positions</span>
}
</div>
</td>
</tr>
</table>
</th>
<th class="text-center va-middle w-auto p-3">
<img src="~/App_Content/svg/sensus_xylem_logo.svg" width="210" class="mx-5" />
</th>
</tr>
</thead>
@if (this.Model.OrderId > 0)
{
this.Html.RenderAction(nameof(ProtocolController.Body), new { orderId = this.Model.OrderId });
}
</table>
@@ -0,0 +1,6 @@
@model LaaProductionWeb.Services.Models.OrdersFoundModel
@foreach (var order in this.Model)
{
<li><a class="dropdown-item" href="#@order.Nr,@order.ProductionOrderNr">@($"{order.OrderNr, 10} / {order.ProductionOrderNr, 10}") - @order.ClientName</a></li>
}
@@ -0,0 +1,6 @@
@model LaaProductionWeb.Services.Models.OrderPositions
@foreach (var position in this.Model)
{
<li><span class="dropdown-item">@position</span></li>
}
@@ -8,7 +8,7 @@
}
<!DOCTYPE html>
<html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
@Styles.Render("~/bootstrap_css")
@Styles.Render("~/bootstrap_icons")
@Styles.Render("~/styles_css")
</head>
<body>
@this.RenderBody()
@Scripts.Render("~/bootstrap_js")
@Scripts.Render("~/barcodes_js")
@Scripts.Render("~/scripts_js")
@this.RenderSection("scripts", required: false)
</body>
</html>
@@ -0,0 +1,72 @@
@using LaaProductionWeb.Services.Models
@model PalletsBatchModel
<div class="d-flex justify-content-center">
<div id="batch" class="print-page border rounded shadow-sm mt-5 p-5">
<div class="table-responsive">
<table>
<tr>
<th colspan="2" class="fs-5">Paletten Begleitschein</th>
<th colspan="2" class="fs-5">@this.Model.ClientName</th>
</tr>
<tr>
<td class="py-0 pe-3 white-space-nowrap">Kunden-Auftrag/Pos.Nr.</td>
<td class="py-0 pe-3">@this.Model.OrderNr/@this.Model.PositionNr</td>
<td class="py-0 pe-3 white-space-nowrap">Fertigungsauftrags-Nr.</td>
<td class="py-0 pe-3">@this.Model.ProductionOrderNr</td>
</tr>
<tr>
<td class="py-0 pe-3 white-space-nowrap">Auftragsmenge</td>
<td class="py-0 pe-3">@this.Model.TotlalItemsCount</td>
<td class="py-0 pe-3 white-space-nowrap">Typ</td>
<td class="py-0 pe-3">@this.Model.ItemsType</td>
</tr>
</table>
<table class="table table-borderless table-striped">
<thead>
<tr>
<th>Nr.</th>
<th class="w-100">Serial Nr.</th>
<th class="w-100">Barcode</th>
<th class="white-space-nowrap">Paletten Nr.</th>
<th class="w-100"></th>
</tr>
</thead>
<tbody>
@{
var count = 1;
foreach (var item in this.Model.Items)
{
<tr class="is_scaned_@(item.IsScaned ? 1 : 0)">
<td class="va-middle @(item.IsScaned ? null : "text-secondary")">@(count++).</td>
<td class="va-middle w-100 @(item.IsScaned ? null : "text-secondary")">@item.BarcodeNr</td>
<td class="va-middle w-100 text-center">
<svg class="barcode"
jsbarcode-format="auto"
jsbarcode-value="@item.BarcodeNr"
jsbarcode-displayValue="false"
jsbarcode-background="transparent"
jsbarcode-lineColor="@(item.IsScaned ? "black" : "#ced4da")"
jsbarcode-height="50"
jsbarcode-margin="0"
jsbarcode-textmargin="0"
jsbarcode-fontoptions="bold">
</svg>
</td>
<td class="va-middle text-end">@(item.IsScaned ? item.PalletNr : null)</td>
<td class="va-middle text-center">
<a class="btn btn-sm btn-danger" href="/Shipments/Delete/@item.Id">
<i class="bi bi-x"></i>
</a>
</td>
</tr>
}
}
</tbody>
</table>
</div>
</div>
</div>
@@ -0,0 +1,150 @@
@using LaaProductionWeb.Controllers
@using LaaProductionWeb.Services.Models
@model ShipmentModel
<div class="container-fluid h-100">
<div class="row h-100 overflow-hidden">
<div class="col-md-3 py-3 h-100 scrollable-sm bg-light border-end shadow-sm">
<h5 class="text-smallcaps">Palettenbegleiter</h5>
<hr />
<form id="order_form" action="/Shipments" method="post" autocomplete="off">
@this.Html.AntiForgeryToken()
<div class="form-floating mb-3 dropdown">
@this.Html.TextBoxFor(x => x.OrderNr, new { id = "order_nr", @class = "form-control", placeholder = "0000000000" })
@this.Html.LabelFor(x => x.OrderNr, new { @for = "order_nr", @class = "text-smallcaps" })
@this.Html.ValidationMessageFor(x => x.OrderNr, string.Empty, new { @class = "small text-danger m-0 p-0" })
<ul id="order_nr_menu" class="dropdown-menu w-100 mt-1"></ul>
</div>
<div class="form-floating mb-3 dropdown">
@this.Html.TextBoxFor(x => x.PositionNr, new { id = "pos_nr", @class = "form-control", placeholder = "0000000000" })
@this.Html.LabelFor(x => x.PositionNr, new { @for = "pos_nr", @class = "text-smallcaps" })
@this.Html.ValidationMessageFor(x => x.PositionNr, string.Empty, new { @class = "small text-danger m-0 p-0" })
<i class="bi bi-chevron-down" style="position: absolute;right: 3.5%;top: 35%;"></i>
<ul id="pos_nr_menu" class="dropdown-menu w-100 mt-1">
<li class="dropdown-item disabled white-space-break">Keine Positionen vorhanden.</li>
</ul>
</div>
<div class="form-floating mb-3">
<button type="submit" class="btn btn-primary py-3 w-100 text-smallcaps">
@this.Model.BtnSubmit <i class="bi bi-chevron-right ms-2"></i>
</button>
</div>
</form>
@if (this.IsPost || this.Model.HasOrder)
{
this.Html.RenderAction(nameof(ShipmentsController.Scan), this.Model.OrderScanModel);
}
</div>
<div class="col-md-9 h-100 scrollable-sm pb-5">
@if (this.IsPost || this.Model.HasOrder)
{
this.Html.RenderAction(nameof(ShipmentsController.Batch), this.Model.OrderScanModel);
}
</div>
</div>
</div>
@section scripts {
<script>
(function autocompleteHandler() {
const show = 'show';
let orderNrInput = document.getElementById('order_nr');
let orderNrMenu = document.getElementById('order_nr_menu');
let positionNrInput = document.getElementById('pos_nr');
let positionNrMenu = document.getElementById('pos_nr_menu');
let orderChanged = false;
function ordersAutocomplete(orders) {
if (orders) {
orderNrMenu.innerHTML = orders;
if (orderNrMenu.children.length == 1) {
let firstOrder = orderNrMenu.querySelector('a.dropdown-item');
if (firstOrder) {
firstOrder.click();
} else {
orderNrMenu.classList.add(show);
}
} else {
orderNrMenu.classList.add(show);
}
}
}
function onOrderNrInput() {
orderNrMenu.classList.remove(show);
orderNrMenu.innerHTML = null;
let orderNr = orderNrInput.value;
if (orderNr && orderNr.length > 3) {
fetch(`/Search/Orders?search=${orderNr}`)
.then(response => response.text())
.then(data => ordersAutocomplete(data))
.catch(error => console.log(error));
}
}
function positionsHandler(data) {
const dropdownItemSelector = '#pos_nr_menu span.dropdown-item';
positionNrMenu.innerHTML = data;
positionNrMenu
.querySelectorAll(dropdownItemSelector)
.forEach(x => x.onclick = function (e) {
positionNrInput.value = e.target.innerText;
document
.getElementById('order_form')
.submit();
});
orderNrMenu.classList.remove(show);
if (orderChanged) {
orderChanged = false;
positionNrInput.value = positionNrMenu
.querySelector(dropdownItemSelector)
.innerHTML;
document
.getElementById('order_form')
.submit();
}
}
function getPositions(orderNr) {
if (orderNr && orderNr.length > 3) {
fetch(`/Search/Positions?ordernr=${orderNr}`)
.then(response => response.text())
.then(data => positionsHandler(data))
.catch(error => console.log(error));
}
}
window.addEventListener('hashchange', function () {
if (location.hash) {
orderChanged = true;
let orderNr = location
.hash
.substring(1)
.split(',')[0];
orderNrInput.value = orderNr;
getPositions(orderNr);
}
});
orderNrInput.oninput = function () {
setTimeout(onOrderNrInput, 50);
};
positionNrInput.setAttribute('data-bs-toggle', 'dropdown');
positionNrInput.setAttribute('aria-expanded', 'false');
positionNrMenu.innerHTML = '<li class="dropdown-item disabled white-space-break">Keine Positionen vorhanden.</li>';
getPositions('@this.Model.OrderNr');
JsBarcode(".barcode").init();
let serialNrInput = document.getElementById('serial_nr');
if (serialNrInput) {
serialNrInput.focus({ focusVisible: true });
}
})();
</script>
}
@@ -0,0 +1,91 @@
@model LaaProductionWeb.Services.Models.BatchPrintModel
@{
this.Layout = "~/Views/Shared/_PrintLayout.cshtml";
var items = this.Model.Items;
var itemsLength = items.Length;
}
<table class="table table-borderless table-striped">
<thead>
<tr>
<th colspan="6" class="px-0">
<table class="table table-borderless">
<thead>
<tr>
<th colspan="2" class="fs-4">Paletten Begleitschein</th>
<th colspan="2" class="fs-4">@this.Model.ClientName</th>
</tr>
<tr>
<td class="py-0 white-space-nowrap">Kunden-Auftrag/Pos.Nr.</td>
<td class="py-0 fw-normal">@this.Model.OrderNr/@this.Model.PositionNr</td>
<td class="py-0 white-space-nowrap">Fertigungsauftrags-Nr.</td>
<td class="py-0 fw-normal">@this.Model.ProductionOrderNr</td>
</tr>
<tr>
<td class="py-0 white-space-nowrap">Auftragsmenge</td>
<td class="py-0 fw-normal">@this.Model.TotlalItemsCount</td>
<td class="py-0 white-space-nowrap">Typ</td>
<td class="py-0 fw-normal">@this.Model.ItemsType</td>
</tr>
</thead>
</table>
</th>
</tr>
<tr>
<th class="small">No.</th>
<th class="small">Serial No.</th>
<th class="small"></th>
<th class="small">No.</th>
<th class="small">Serial No.</th>
<th class="small"></th>
</tr>
</thead>
<tbody>
@for (var i = 0; i < itemsLength; i += 2)
{
var ni = i + 1;
var item = items[i];
<tr>
<td class="va-middle">@(i + 1)</td>
<td class="va-middle">@item.BarcodeNr</td>
<td class="va-middle">
<svg class="barcode"
jsbarcode-height="50"
jsbarcode-format="auto"
jsbarcode-displayValue="false"
jsbarcode-background="transparent"
jsbarcode-value="@item.BarcodeNr" />
</td>
@if (ni < itemsLength)
{
var nitem = items[ni];
<td class="va-middle">@(ni + 1)</td>
<td class="va-middle">@nitem.BarcodeNr</td>
<td class="va-middle">
<svg class="barcode"
jsbarcode-height="50"
jsbarcode-format="auto"
jsbarcode-displayValue="false"
jsbarcode-background="transparent"
jsbarcode-value="@nitem.BarcodeNr" />
</td>
}
else
{
<td></td>
<td></td>
<td></td>
}
</tr>
}
</tbody>
</table>
@section scripts {
<script>
JsBarcode(".barcode").init();
</script>
}
@@ -0,0 +1,51 @@
@model LaaProductionWeb.Services.Models.OrderScanModel
<div>
<h5 class="text-smallcaps">@this.Model.ScanTitle</h5>
<hr />
</div>
<form id="scan_form" action="/Shipments/ScanPost" method="post" autocomplete="off">
@this.Html.AntiForgeryToken()
@this.Html.HiddenFor(x => x.OrderNr)
@this.Html.HiddenFor(x => x.PositionNr)
@this.Html.HiddenFor(x => x.PalletsCount)
<div class="d-flex flex-wrap">
@foreach (var pallet in this.Model.Pallets)
{
var css = pallet.Key != this.Model.PalletNr
? "btn btn-outline-success"
: "btn btn-success";
var id = $"pallet_{pallet.Key}";
<label for="@id" class="@css mb-3 me-3">@pallet.Key</label>
<input id="@id" name="@nameof(this.Model.PalletNr)" value="@pallet.Key" class="d-none" type="submit" />
}
<a class="btn btn-outline-secondary mb-3 me-3" href="@this.Model.PrintUrl" target="_blank">
<i class="bi bi-printer"></i> Druckvorschau
</a>
<a class="btn btn-outline-secondary mb-3 me-3" href="@this.Model.DownloadUrl">
<i class="bi bi-filetype-csv"></i> Herunterladen
</a>
</div>
<div class="input-group">
<div class="form-floating w-auto">
@this.Html.TextBoxFor(x => x.SerialNr, new { id = "serial_nr", @class = "form-control form-control-success text-center", placeholder = "0000000000" })
@this.Html.LabelFor(x => x.SerialNr, new { @for = "serial_nr", @class = "text-smallcaps" })
</div>
<div class="form-floating">
@this.Html.TextBoxFor(x => x.PalletNr, new { id = "pallet_nr", @class = "form-control form-control-success text-center", placeholder = "0" })
@this.Html.LabelFor(x => x.PalletNr, new { @for = "pallet_nr", @class = "text-smallcaps" })
</div>
</div>
@if (this.TempData.TryGetValue(nameof(this.Model.SerialNr), out object errorMessage))
{
<div class="text-danger small">
@($"{errorMessage}")
</div>
}
<div class="my-3">
<button class="btn btn-success py-3 w-100 text-smallcaps">
@this.Model.BtnSerialNr <i class="bi bi-chevron-right ms-2"></i>
</button>
</div>
</form>
@@ -9,6 +9,7 @@
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="ConnectionString" value="Data Source=SLASQL01.emea.sensus.net;Initial Catalog=Auftrag;Password=ServiceParingfile;Persist Security Info=True;User ID=ServiceParingfile;"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.2" />
@@ -53,6 +54,10 @@
<assemblyIdentity name="Microsoft.Web.Infrastructure" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
@@ -0,0 +1,13 @@
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": [
{
"library": "bootstrap@5.2.3",
"destination": "App_Content/",
"files": [
"css/bootstrap.min.css.map"
]
}
]
}
@@ -15,7 +15,7 @@
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="7.0.0" targetFramework="net462" />
<package id="Microsoft.Web.Infrastructure" version="2.0.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
<package id="WebGrease" version="1.6.0" targetFramework="net462" />
</packages>