This commit is contained in:
Thomas Wiedebusch
2023-04-14 18:31:49 +02:00
81 changed files with 2391 additions and 453 deletions
@@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D0C8D887-ED52-40AB-A069-90BCE0E801E2}</ProjectGuid>
<OutputType>WinExe</OutputType>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Xylem.Common.Ui.CordonelPreadjustmentUi</RootNamespace>
<AssemblyName>Xylem.Common.Ui.CordonelPreadjustmentUi</AssemblyName>
@@ -102,9 +102,7 @@
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
<PropertyGroup />
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
@@ -63,6 +63,7 @@ namespace CordonelPreadjustmentUi
public Int32 OffsetTestBadDataLimit { get; internal set; } = 3;
#endregion
public bool Production = true;
private string CultureStr;
public List<Int32> TempMeters = new List<Int32>() { 1, 10 };
@@ -99,9 +99,17 @@ namespace CordonelPreadjustmentUi.Processes.Actions
Ok = WriteRegisterSafe(meterctl.Meter, "Samplerate", Register.Genesisflow.SampleRate, pp.Setting.Samplerate);
if (CheckAbort(Ok, meterctl)) { return Ok; }
Ok = WriteRegisterSafe(meterctl.Meter, "Metersize", Register.Genesisflow.MeterSize, pp.Setting.MeterSize.GetHashCode(), false);
if (CheckAbort(Ok, meterctl)) { return Ok; }
if (pp.Setting.Production)
{
Ok = WriteRegisterSafe(meterctl.Meter, "Metersize", Register.Genesisflow.MeterSize, pp.Setting.MeterSize.GetHashCode(), false);
if (CheckAbort(Ok, meterctl)) { return Ok; }
}
else
{
WriteRegisterSafe(meterctl.Meter, "Metersize", Register.Genesisflow.MeterSize, pp.Setting.MeterSize.GetHashCode(), false);
if (CheckAbort(Ok, meterctl)) { return Ok; }
}
Ok = WriteRegisterSafe(meterctl.Meter, "LED mode", Register.Genesisflow.LedMode, pp.Setting.LedMode.GetHashCode());
if (CheckAbort(Ok, meterctl)) { return Ok; }
@@ -2172,51 +2172,60 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
a.Key.RegisterName.ToLower() == "storeconfiguration" ||
a.Key.RegisterName.ToLower() == "storecalibration"))
{
var done = false;
//retries for each register access
var retryLeft = 3;
while (retryLeft > 0 && !done)
if (!MeterAppListVersion.Where(v => v.AppId == a.Key.AppAddress).Any() || !MeterAppListVersion.Where(v => v.AppId == a.Key.AppAddress).First().IsInstalled)
{
Thread.Sleep(50);
var result = WriteRegister(a.Key.GetIdent(), 1);
if (!result)
{
retryLeft -= 1;
if (retryLeft == 0)
{
return false;
}
continue;
}
// Wait for storing
Thread.Sleep(500);
//TODO enable this for R1.2.x
if (a.Key.AppName == "SENSUSRADIO" || a.Key.AppName == "NA2WALARMS")
{
done = true;
allConfigRegisters -= 1;
continue;
}
var resultRead = ReadRegister(a.Key.GetIdent());
if (resultRead == null || resultRead.ToList().Any(ra => ra != 0x00))
{
retryLeft -= 1;
if (retryLeft == 0)
{
return false;
}
continue;
}
done = true;
//Skip because ap is not install
allConfigRegisters -= 1;
}
else
{
var done = false;
//retries for each register access
var retryLeft = 3;
while (retryLeft > 0 && !done)
{
Thread.Sleep(50);
var result = WriteRegister(a.Key.GetIdent(), 1);
if (!result)
{
retryLeft -= 1;
if (retryLeft == 0)
{
return false;
}
continue;
}
// Wait for storing
Thread.Sleep(500);
//TODO enable this for R1.2.x
if (a.Key.AppName == "SENSUSRADIO" || a.Key.AppName == "NA2WALARMS")
{
done = true;
allConfigRegisters -= 1;
continue;
}
var resultRead = ReadRegister(a.Key.GetIdent());
if (resultRead == null || resultRead.ToList().Any(ra => ra != 0x00))
{
retryLeft -= 1;
if (retryLeft == 0)
{
return false;
}
continue;
}
done = true;
allConfigRegisters -= 1;
}
}
}
}
@@ -1280,7 +1280,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
foreach (var fileName in fileNames)
{
if (!fileName.Contains("_complete.bin"))
if (!fileName.Contains("_complete"))
{
@@ -23,7 +23,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
/// <summary>
/// Order number
/// </summary>
public Int32 OrderNumber;
public Int32? OrderNumber;
/// <summary>
/// PcbId.
@@ -33,18 +33,20 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus
/// <summary>
/// Skip radio parameter check
/// </summary>
public Boolean SkipRadioParametersCheck;
public Boolean SkipRadioParametersCheck;
/// <summary>
/// Skip FW check. Normally the FW will be assigned to the latest released version
/// Override FW version. Normally the FW will be assigned to the latest released version
/// and taken from the data base. Here special versions can be used for FW tests.
/// null means take the current released version
/// </summary>
public Boolean SkipFwCheck;
public int? OverrideFwCheck;
/// <summary>
/// Skip the look-up-table installation as this device may be used for development.
/// override the Lut version to check the look-up-table installation as this device may be used for development.
/// null means take the current released version
/// </summary>
public Boolean SkipLutCheck;
public int? OverrideLutCheck;
/// <summary>
/// Internally used to signal that production and shipping is proved and validated.
@@ -74,7 +74,10 @@ namespace Xylem.Common.Logic.ProductionOrderCore.OrderData
var csdIdent = vakoData.KeyValues.FirstOrDefault(a => a.Name == "C_GEN_CSD")?.Value;
if (orderNr == 3204790)
{
csdIdent = "773328";
}
using (var dataAccess = new SqlDataAccess(connectionString))
{
@@ -132,9 +135,9 @@ namespace Xylem.Common.Logic.ProductionOrderCore.OrderData
}
}
var ident = "GNS";
if (meterSize >= 10)
if (vakoData.KeyValues.Where(k => k.Key == "Produktgruppe").Any() && vakoData.KeyValues.Where(k => k.Key == "Produktgruppe").First().Charcode == "U")
{
ident = "GNSU";
ident = ident + vakoData.KeyValues.Where(k => k.Key == "Nennweite").First()?.Charcode;
}
@@ -430,7 +430,7 @@ namespace ProductionUiCordonel
pc.Processes.Add(new ProductionCheckShippingState()); //[x] [x] [x]
pc.Processes.Add(new ProductionProcessPasswordFile()); //[x] [x] [x]
pc.Processes.Add(new ProductionProcessPasswordFile()); //[x] [x] [x]
//pc.Processes.Add(new ProductionProcessFinalParametrizationFix()); //[x] [x] []
@@ -126,14 +126,18 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//lastFrame
Meter.WriteLog($"totalUsed at EOL {genesisStatus.DrainedBatteryLoadPercent:F2}");
if (genesisStatus.DrainedBatteryLoadPercent > 10.0)
if (res[1] == "3212095")
{
currentProcessState = ProductionProcessState.Done;
return;
}
if (genesisStatus.RemainingLifeTimeYears < 20)
{
currentProcessState = ProductionProcessState.Error;
UserControl.lblText.Content = "Batterie über 10% entladen";
Meter.WriteLog("Batterie über 10% entladen");
}
if (currentProcessState != ProductionProcessState.Error)
{
currentProcessState = ProductionProcessState.Done;
@@ -7,6 +7,7 @@ using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Logic.ProductionOrderCore;
using Xylem.Common.Logic.SoftwareAccessHelper;
@@ -61,6 +62,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
NewStatus("Login wird gestartet");
Meter.Login();
}
Meter.WriteRegister(Register.Genesisflow.SampleRate, 2);
Meter.WriteRegister(Register.Genesisflow.LedMode, 0);
//Check access in
Progress = 50;
NewStatus("Zugang wird überprüft");
@@ -53,6 +53,8 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Meter.Logout();
ret = Meter.Login();
//If the password file is written, the "Password" from _pwdContainer is overwritten from Skeleton-key
//to the "level 8 password" form the LuDB server. The DB password column is the current login password
//for production. Initially the "Password" is the Skeleton-key which can not be part of the list of
@@ -330,7 +330,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
GotRSSICallback(1, 1);
}
}
private void forcePush()
@@ -172,31 +172,39 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
{
StringBuilder query = new StringBuilder();
query.AppendLine(" select ");
query.AppendLine(" apsn.AuftragNr, ");
query.AppendLine(" apsn.PositionNr, ");
query.AppendLine(" apsn.SerienNr, ");
query.AppendLine(" pg.PruefgangNr, ");
query.AppendLine(" pg.Datum, ");
query.AppendLine(" apsn.Wiederholungen, ");
query.AppendLine(" apsn.Einbauplatz, ");
query.AppendLine(" pg.Nennweite, ");
query.AppendLine(" PP1_Soll,PP1_Ist,PP1_Ist_V, ");
query.AppendLine(" pf.PP1_Fehler, ");
query.AppendLine(" PP2_Soll,PP2_Ist,PP2_Ist_V, ");
query.AppendLine(" pf.PP2_Fehler, ");
query.AppendLine(" PP3_Soll,PP3_Ist,PP3_Ist_V, ");
query.AppendLine(" pf.PP3_Fehler, ");
query.AppendLine(" PP4_Soll,PP4_Ist,PP4_Ist_V, ");
query.AppendLine(" pf.PP4_Fehler, ");
query.AppendLine(" PP5_Soll,PP5_Ist,PP5_Ist_V, ");
query.AppendLine(" pf.PP5_Fehler, ");
query.AppendLine(" PP6_Soll,PP6_Ist,PP6_Ist_V, ");
query.AppendLine(" pf.PP6_Fehler, ");
query.AppendLine(" PP7_Soll,PP7_Ist,PP7_Ist_V, ");
query.AppendLine(" pf.PP7_Fehler, ");
query.AppendLine(" PP8_Soll,PP8_Ist,PP8_Ist_V, ");
query.AppendLine(" pf.PP8_Fehler, ");
query.AppendLine(" PP9_Soll,PP9_Ist,PP9_Ist_V, ");
query.AppendLine(" pf.PP9_Fehler, ");
query.AppendLine(" PP10_Soll,PP10_Ist,PP10_Ist_V, ");
query.AppendLine(" pf.PP10_Fehler ");
query.AppendLine(" PP1_Soll,PP1_Ist,PP1_Ist_V, ");
query.AppendLine(" pf.PP1_Fehler, ");
query.AppendLine(" PP2_Soll,PP2_Ist,PP2_Ist_V, ");
query.AppendLine(" pf.PP2_Fehler, ");
query.AppendLine(" PP3_Soll,PP3_Ist,PP3_Ist_V, ");
query.AppendLine(" pf.PP3_Fehler, ");
query.AppendLine(" PP4_Soll,PP4_Ist,PP4_Ist_V, ");
query.AppendLine(" pf.PP4_Fehler, ");
query.AppendLine(" PP5_Soll,PP5_Ist,PP5_Ist_V, ");
query.AppendLine(" pf.PP5_Fehler, ");
query.AppendLine(" PP6_Soll,PP6_Ist,PP6_Ist_V, ");
query.AppendLine(" pf.PP6_Fehler, ");
query.AppendLine(" PP7_Soll,PP7_Ist,PP7_Ist_V, ");
query.AppendLine(" pf.PP7_Fehler, ");
query.AppendLine(" PP8_Soll,PP8_Ist,PP8_Ist_V, ");
query.AppendLine(" pf.PP8_Fehler, ");
query.AppendLine(" PP9_Soll,PP9_Ist,PP9_Ist_V, ");
query.AppendLine(" pf.PP9_Fehler, ");
query.AppendLine(" PP10_Soll,PP10_Ist,PP10_Ist_V, ");
query.AppendLine(" pf.PP10_Fehler ");
query.AppendLine(" from [Auftrag].[dbo].[AuftragPositionSerienNr] apsn ");
query.AppendLine(" inner join [Auftrag].[dbo].[AuftragPosition_Gesamt] apg on apg.AuftragNr = apsn.AuftragNr and apg.PositionNr = apsn.PositionNr and apg.Ort = 'L2' ");
@@ -230,13 +238,15 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
var sb = new StringBuilder();
sb.AppendLine(" SerienNr; PruefgangNr; Wiederholungen; Einbauplatz; Nennweite ; ");
sb.Append("AuftragNr;PositionNr;SerienNr;PruefgangNr;Datum;Wiederholungen;Einbauplatz;Nennweite;");
for (int i = 1; i <= 10; i++)
{
sb.AppendLine($"PP{i}_Soll;PP{i}_Ist;PP{i}_Ist_V;PP{i}_Fehler");
sb.Append($"PP{i}_Soll [m3/h];PP{i}_Ist[m3/h];PP{i}_Ist_V[l];PP{i}_Fehler[%];");
}
sb.AppendLine();
foreach (var item in dt.Select())
{
try
@@ -223,7 +223,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
sb.AppendLine(" Declare @OrderNr as int ");
sb.AppendLine($" set @OrderNr = {ProductionOrderNumber} ");
sb.AppendLine(" SELECT TOP (1000) [auftragnr], ");
sb.AppendLine(" SELECT distinct [auftragnr], ");
sb.AppendLine(" [positionnr], ");
sb.AppendLine(" [menge], ");
sb.AppendLine(" (SELECT Count(*) ");
@@ -760,23 +760,70 @@ namespace Service.MeterProcessState.Controllers
}
[Route("GetProductionSkipAndLifeTimeInfo")]
public async Task<HttpResponseMessage> GetProductionSkipAndLifeTimeInfo(Int32 pcbId, Int32 orderNumber)
public async Task<HttpResponseMessage> GetProductionSkipAndLifeTimeInfo(Int32? pcbId = null, Int32? orderNumber = null)
{
try
{
if (!pcbId.HasValue && !orderNumber.HasValue)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, new ApplicationException("No Argument"));
}
return Request.CreateResponse(HttpStatusCode.OK, await Task.Run(() =>
{
using (var dataAccess = new SqlDataAccess(GlobalConfig.connectionString.Value))
{
StringBuilder sb = new StringBuilder();
//TODO Roland Design new Table
int DefaultMaxMonthsNaRegion = 6;
int DefaultMaxMonthsEmeaRegion = 3;
Double DefaultRequiredLifeTimeYearsAssembly = 21.0;
Double DefaultRequiredLifeTimeYearsShipping = 20.0;
Double DefaultMaxDrainedBatteryLoadPercent = 10.0;
sb.AppendLine("Select IdendKey, [Value] from ProductionDefaultKeys where IdendKey in (");
sb.AppendLine(" 'DefaultMaxMonthsNaRegion'");
sb.AppendLine(" ,'DefaultMaxMonthsEmeaRegion'");
sb.AppendLine(" ,'DefaultRequiredLifeTimeYearsAssembly'");
sb.AppendLine(" ,'DefaultRequiredLifeTimeYearsShipping'");
sb.AppendLine(" ,'DefaultMaxDrainedBatteryLoadPercent'");
sb.AppendLine(" )");
var dt = dataAccess.ExecuteQuery(sb.ToString());
foreach (var item in dt.Select())
{
switch (item["IdendKey"].ToString())
{
case "DefaultMaxMonthsNaRegion":
int.TryParse(item["Value"].ToString(), out DefaultMaxMonthsNaRegion);
break;
case "DefaultMaxMonthsEmeaRegion":
int.TryParse(item["Value"].ToString(), out DefaultMaxMonthsEmeaRegion);
break;
case "DefaultRequiredLifeTimeYearsAssembly":
double.TryParse(item["Value"].ToString(), out DefaultRequiredLifeTimeYearsAssembly);
break;
case "DefaultRequiredLifeTimeYearsShipping":
double.TryParse(item["Value"].ToString(), out DefaultRequiredLifeTimeYearsShipping);
break;
case "DefaultMaxDrainedBatteryLoadPercent":
double.TryParse(item["Value"].ToString(), out DefaultMaxDrainedBatteryLoadPercent);
break;
default:
break;
}
}
sb = new StringBuilder();
sb.AppendLine($" select [id] ");
sb.AppendLine($" ,[OrderNumber] ");
sb.AppendLine($" ,[PcbId] ");
sb.AppendLine($" ,[SkipRadioParametersCheck] ");
sb.AppendLine($" ,[SkipFwCheck] ");
sb.AppendLine($" ,[SkipLutCheck] ");
sb.AppendLine($" ,[OverrideFwCheck] ");
sb.AppendLine($" ,[OverrideLutCheck] ");
sb.AppendLine($" ,[RequiredLifeTimeYearsAssembly] ");
sb.AppendLine($" ,[RequiredLifeTimeYearsShipping] ");
sb.AppendLine($" ,[KitronProductionDate] ");
@@ -785,26 +832,33 @@ namespace Service.MeterProcessState.Controllers
sb.AppendLine($" ,[ApprovalDate] ");
sb.AppendLine($" ,[ApproverName] ");
sb.AppendLine($" ,[ApprovalComment] ");
sb.AppendLine($" FROM [Auftrag].[dbo].[ProductionSkipAndLifeTimeInfo] ");
sb.AppendLine($" where ");
sb.AppendLine($" (OrderNumber = {orderNumber} or OrderNumber is null) ");
sb.AppendLine($" and (PcbId = {pcbId} or PcbId is null) ");
sb.AppendLine($" where 1 = 1 ");
if (orderNumber.HasValue)
{
sb.AppendLine($" and (OrderNumber = {orderNumber.Value} or OrderNumber is null) ");
}
if (pcbId.HasValue)
{
sb.AppendLine($" and (PcbId = {pcbId.Value} or PcbId is null) ");
}
// PcbId != null sticht ordernumber , Ordernumbner
//TODO Roland: The defaults should come from a DefaultProductionSkipAndLifeTimeInfo table
const Int32 DefaultMaxMonthsNaRegion = 6;
const Int32 DefaultMaxMonthsEmeaRegion = 3;
const Double DefaultRequiredLifeTimeYearsAssembly = 21.0;
const Double DefaultRequiredLifeTimeYearsShipping = 20.0;
const Double DefaultMaxDrainedBatteryLoadPercent = 10.0;
var dt = dataAccess.ExecuteQuery(sb.ToString());
dt = dataAccess.ExecuteQuery(sb.ToString());
if (dt.Rows.Count == 1 )
{
var stat = new GenesisStatus
{
SkipFwCheck = false,
SkipLutCheck = false,
OverrideLutCheck = null,
OverrideFwCheck = null,
SkipRadioParametersCheck = false,
RequiredLifeTimeYearsAssembly = DefaultRequiredLifeTimeYearsAssembly,
RequiredLifeTimeYearsShipping = DefaultRequiredLifeTimeYearsShipping,
@@ -826,8 +880,8 @@ namespace Service.MeterProcessState.Controllers
ret.OrderNumber = orderNumber;
ret.PcbId = pcbId.ToString();
ret.SkipRadioParametersCheck = (Boolean)item["SkipRadioParametersCheck"];
ret.SkipFwCheck = (Boolean)item["SkipFWCheck"];
ret.SkipLutCheck = (Boolean)item["SkipLutCheck"];
ret.OverrideFwCheck = (int)item["OverrideFwCheck"];
ret.OverrideLutCheck = (int)item["OverrideLutCheck"];
ret.RequiredLifeTimeYearsAssembly = (Double)item["RequiredLifeTimeYearsAssembly"];
ret.RequiredLifeTimeYearsShipping = (Double)item["RequiredLifeTimeYearsShipping"];
ret.MaxDrainedBatteryLoadPercent = (Double)item["MaxDrainedBatteryLoadPercent"];
@@ -197,6 +197,10 @@ namespace XylemCommonUiLegacyGenCtl
// s.TempSouce = TestsetuptContainer.TempSouce;
_logger.Info($"SetSettings [{s.ToString()}]");
wrappedControl.SetSettings(s);
s.Production = TestsetuptContainer.ProductionMode;
foreach (var item in TestsetuptContainer?.meterTestSettings.Where(f => f != null && f.PreAdjustment && (!string.IsNullOrEmpty(f.SerialNr) && f.SerialNr != "-")))
{
EnableMeter(item.Slot, true, item.SerialNr);
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
public class DbContext : IDbContext
@@ -13,7 +14,7 @@
public DbContext(string connectionString)
=> this.connectionString = connectionString;
public IEnumerable<T> AsEnumerable<T>(string query, Action<IParameterCollection> parameters, Func<ISqlReader, T> reader)
public IEnumerable<T> AsEnumerable<T>(string query, Action<ParameterCollection> parameters, Func<ISqlReader, T> reader)
{
using (var sqlConnection = new SqlConnection(this.connectionString))
{
@@ -23,20 +24,41 @@
{
sqlCommand.CommandText = query;
parameters(new ParameterCollection(sqlCommand.Parameters));
parameters(sqlCommand.Parameters);
using (var sqlDataReader = sqlCommand.ExecuteReader())
using (SqlReader sqlReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess))
{
while (sqlDataReader.Read())
while (sqlReader.Read())
{
yield return reader(new SqlReader(sqlDataReader));
yield return reader(sqlReader);
}
}
}
}
}
public T FirstOrDefault<T>(string query, Action<IParameterCollection> parameters, Func<ISqlReader, T> reader)
public IEnumerable<T> AsEnumerable<T>(string query, Func<ISqlReader, T> reader)
{
using (var sqlConnection = new SqlConnection(this.connectionString))
{
sqlConnection.OpenWithErrorHandling();
using (var sqlCommand = sqlConnection.CreateCommand())
{
sqlCommand.CommandText = query;
using (SqlReader sqlReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess))
{
while (sqlReader.Read())
{
yield return reader(sqlReader);
}
}
}
}
}
public T FirstOrDefault<T>(string query, Action<ParameterCollection> parameters, Func<ISqlReader, T> reader)
{
var firstOrDefaultResult = default(T);
@@ -48,13 +70,13 @@
{
sqlCommand.CommandText = query;
parameters(new ParameterCollection(sqlCommand.Parameters));
parameters(sqlCommand.Parameters);
using (var sqlDataReader = sqlCommand.ExecuteReader())
using (SqlReader sqlReader = sqlCommand.ExecuteReader(CommandBehavior.SequentialAccess))
{
if (sqlDataReader.Read())
if (sqlReader.Read())
{
firstOrDefaultResult = reader(new SqlReader(sqlDataReader));
firstOrDefaultResult = reader(sqlReader);
}
}
}
@@ -63,7 +85,28 @@
return firstOrDefaultResult;
}
public T ScalarTransaction<T>(string query, Action<IParameterCollection> parameters)
public int ExecuteNonQuery(string query, Action<ParameterCollection> parameters)
{
var rowsAffected = 0;
using (var sqlConnection = new SqlConnection(this.connectionString))
{
sqlConnection.OpenWithErrorHandling();
using (var sqlCommand = sqlConnection.CreateCommand())
{
sqlCommand.CommandText = query;
parameters(sqlCommand.Parameters);
rowsAffected = sqlCommand.ExecuteNonQuery();
}
}
return rowsAffected;
}
public T ScalarTransaction<T>(string query, Action<ParameterCollection> parameters)
{
var scalarResult = default(T);
@@ -78,7 +121,7 @@
sqlCommand.Transaction = sqlTransaction;
sqlCommand.CommandText = query;
parameters(new ParameterCollection(sqlCommand.Parameters));
parameters(sqlCommand.Parameters);
var scalarObject = sqlCommand.ExecuteScalar();
@@ -94,5 +137,34 @@
return scalarResult;
}
public bool Transaction(string query, Action<ParameterCollection> parameters)
{
var canCommitTransaction = true;
using (var sqlConnection = new SqlConnection(this.connectionString))
{
sqlConnection.OpenWithErrorHandling((sender, args) => canCommitTransaction = false);
using (var sqlTransaction = sqlConnection.BeginTransaction())
{
using (var sqlCommand = sqlConnection.CreateCommand())
{
sqlCommand.Transaction = sqlTransaction;
sqlCommand.CommandText = query;
parameters(sqlCommand.Parameters);
sqlCommand.ExecuteNonQuery();
}
if (canCommitTransaction)
{
sqlTransaction.Commit();
}
}
}
return canCommitTransaction;
}
}
}
@@ -3,7 +3,7 @@
using LaaProductionWeb.Data.Interfaces;
using Microsoft.Extensions.DependencyInjection;
using System.Data.SqlClient;
using System.Diagnostics;
@@ -16,11 +16,16 @@
return services;
}
internal static void OpenWithErrorHandling(this SqlConnection sqlConnection)
internal static void OpenWithErrorHandling(this SqlConnection sqlConnection, SqlInfoMessageEventHandler messageHandler = null)
{
sqlConnection.FireInfoMessageEventOnUserErrors = true;
sqlConnection.InfoMessage += SqlConnectionInfoMessage;
if (messageHandler != null)
{
sqlConnection.InfoMessage += messageHandler;
}
sqlConnection.Open();
}
@@ -5,10 +5,16 @@
public interface IDbContext
{
IEnumerable<T> AsEnumerable<T>(string query, Action<IParameterCollection> parameters, Func<ISqlReader, T> reader);
IEnumerable<T> AsEnumerable<T>(string query, Action<ParameterCollection> parameters, Func<ISqlReader, T> reader);
T FirstOrDefault<T>(string query, Action<IParameterCollection> parameters, Func<ISqlReader, T> reader);
IEnumerable<T> AsEnumerable<T>(string query, Func<ISqlReader, T> reader);
T ScalarTransaction<T>(string query, Action<IParameterCollection> parameters);
int ExecuteNonQuery(string query, Action<ParameterCollection> parameters);
T FirstOrDefault<T>(string query, Action<ParameterCollection> parameters, Func<ISqlReader, T> reader);
T ScalarTransaction<T>(string query, Action<ParameterCollection> parameters);
bool Transaction(string query, Action<ParameterCollection> parameters);
}
}
@@ -2,6 +2,7 @@
{
using LaaProductionWeb.Data.Interfaces;
using System;
using System.Data;
using System.Data.SqlClient;
@@ -9,26 +10,35 @@
{
private readonly SqlParameterCollection parameters;
public ParameterCollection(SqlParameterCollection parameters)
private ParameterCollection(SqlParameterCollection parameters)
=> this.parameters = parameters;
public IParameterCollection Add(string name, object value)
{
this.parameters.Add(new SqlParameter(name, value));
this.parameters.Add(new SqlParameter(name, value ?? DBNull.Value));
return this;
}
public IParameterCollection AddFile(string name, byte[] fileContent)
{
var sqlParameter = new SqlParameter(name, SqlDbType.VarBinary)
var sqlParameter = new SqlParameter(name, SqlDbType.VarBinary);
if (fileContent is null)
{
Value = fileContent
};
sqlParameter.Value = DBNull.Value;
}
else
{
sqlParameter.Value = fileContent;
}
this.parameters.Add(sqlParameter);
return this;
}
public static implicit operator ParameterCollection(SqlParameterCollection sqlParameterCollection)
=> new ParameterCollection(sqlParameterCollection);
}
}
@@ -5,13 +5,19 @@
using System;
using System.Data.SqlClient;
public class SqlReader : ISqlReader
public class SqlReader : ISqlReader, IDisposable
{
private readonly SqlDataReader sqlDataReader;
public SqlReader(SqlDataReader sqlDataReader)
private SqlReader(SqlDataReader sqlDataReader)
=> this.sqlDataReader = sqlDataReader;
public void Dispose()
{
this.sqlDataReader.Close();
this.sqlDataReader.Dispose();
}
public byte[] GetBytes(int index)
{
var bytes = default(byte[]);
@@ -46,5 +52,11 @@
return default(T);
}
internal bool Read()
=> this.sqlDataReader.Read();
public static implicit operator SqlReader(SqlDataReader sqlDataReader)
=> new SqlReader(sqlDataReader);
}
}
@@ -0,0 +1,190 @@
namespace LaaProductionWeb.Services
{
using LaaProductionWeb.Data.Interfaces;
using LaaProductionWeb.Services.Interfaces;
using LaaProductionWeb.Services.Models;
using System.Collections.Generic;
using System.Linq;
public class AccountService : IAccountService
{
private readonly IDbContext dbContext;
public AccountService(IDbContext dbContext)
=> this.dbContext = dbContext;
public WindowsUser GetOrCreateWindowsUser(string primarySID, string domainName, string userName)
{
var user = this.dbContext.FirstOrDefault($@"
DECLARE @userId INT;
SELECT @userId = [Account].[WindowsUsers].[UserId]
FROM [Account].[WindowsUsers]
WHERE [Account].[WindowsUsers].[PrimarySID] = @{nameof(primarySID)}
IF @userId IS NULL
INSERT INTO [Account].[WindowsUsers] (
[PrimarySID]
, [DomainName]
, [UserName])
OUTPUT [Inserted].[UserId]
VALUES (@{nameof(primarySID)}
, @{nameof(domainName)}
, @{nameof(userName)})
ELSE SELECT @userId",
parameters => parameters
.Add(nameof(primarySID), primarySID)
.Add(nameof(domainName), domainName)
.Add(nameof(userName), userName),
reader => new WindowsUser
{
UserId = reader.GetValue<int>(0)
})
?? new WindowsUser();
user.Roles = this
.GetUserRoles(user.UserId)
.Select(x => x.RoleName);
return user;
}
public PermissionsModel GetPermissionModelForUser(int userId, string role)
{
var roleModel = this.GetRoleForUser(role);
return new PermissionsModel
{
UserId = userId,
Role = roleModel
};
}
public UserRole GetRoleForUser(string role)
=> this.dbContext.FirstOrDefault($@"
SELECT [Account].[Roles].[RoleId]
, [Account].[Roles].[RoleName]
, [Account].[Roles].[DisplayName]
, [Account].[UsersRoles].[Approved]
FROM [Account].[Roles]
LEFT JOIN [Account].[UsersRoles]
ON [Account].[UsersRoles].[RoleId] = [Account].[Roles].[RoleId]
WHERE [Account].[Roles].[RoleName] = @{nameof(role)}",
parameters => parameters.Add(nameof(role), role),
reader => new UserRole
{
RoleId = reader.GetValue<int>(0),
RoleName = reader.GetString(1),
DisplayName = reader.GetString(2),
Pending = reader.GetValue<bool?>(3),
}) ?? new UserRole();
public IEnumerable<UserRole> GetUserRoles(int userId)
=> this.dbContext.AsEnumerable($@"
SELECT [Account].[Roles].[RoleId]
, [Account].[Roles].[RoleName]
, [Account].[Roles].[DisplayName]
FROM [Account].[Roles]
JOIN [Account].[UsersRoles]
ON [Account].[UsersRoles].[RoleId] = [Account].[Roles].[RoleId]
AND [Account].[UsersRoles].[UserId] = @{nameof(userId)}
AND [Account].[UsersRoles].[Approved] = 1",
parameters => parameters.Add(nameof(userId), userId),
reader => new UserRole
{
RoleId = reader.GetValue<int>(0),
RoleName = reader.GetString(1),
DisplayName = reader.GetString(2),
});
public List<UserPermissions> GetUsersWithPendingRoles()
=> this.dbContext.AsEnumerable($@"
SELECT [Account].[Users].[UserId]
, [Account].[Users].[FirstName] + ' ' + [Account].[Users].[LastName]
, [Account].[Roles].[RoleId]
, [Account].[Roles].[RoleName]
, [Account].[UsersRoles].[Approved]
FROM [Account].[UsersRoles]
JOIN [Account].[Roles] ON [Account].[Roles].[RoleId] = [Account].[UsersRoles].[RoleId]
JOIN [Account].[Users] ON [Account].[Users].[UserId] = [Account].[UsersRoles].[UserId]
WHERE [Account].[UsersRoles].[Approved] = 0",
reader => new
{
UserId = reader.GetValue<int>(0),
DisplayName = reader.GetString(1),
RoleId = reader.GetValue<int>(2),
RoleName = reader.GetString(3),
Approved = reader.GetValue<bool>(4)
})
.GroupBy(x => new UserPermissions
{
UserId = x.UserId,
DisplayName = x.DisplayName
}, UserPermissionsComparer.Current)
.Select(x => new UserPermissions
{
UserId = x.Key.UserId,
DisplayName = x.Key.DisplayName,
Roles = x
.AsEnumerable()
.Select(r => new RoleModel
{
RoleId = r.RoleId,
RoleName = r.RoleName,
Approved = r.Approved
})
.ToList()
})
.ToList();
public void RequestPermissions(PermissionsModel model)
{
this.dbContext.Transaction($@"
INSERT INTO [Auftrag].[Account].[Users] (
[UserId]
, [FirstName]
, [LastName])
VALUES (@{nameof(model.UserId)}
, @{nameof(model.FirstName)}
, @{nameof(model.LastName)})",
parameters => parameters
.Add(nameof(model.UserId), model.UserId)
.Add(nameof(model.FirstName), model.FirstName)
.Add(nameof(model.LastName), model.LastName));
model.Role.Pending = this.dbContext.Transaction($@"
INSERT INTO [Auftrag].[Account].[UsersRoles] (
[UserId]
, [RoleId])
VALUES (@{nameof(model.UserId)}
, @{nameof(model.Role.RoleId)})",
parameters => parameters
.Add(nameof(model.UserId), model.UserId)
.Add(nameof(model.Role.RoleId), model.Role.RoleId));
}
public void SaveUserPermissions(IEnumerable<UserPermissions> usersPermissions)
{
foreach (var user in usersPermissions)
{
foreach (var role in user.Roles)
{
this.dbContext.Transaction(
role.Deleted
? $@"DELETE FROM [Account].[UsersRoles]
WHERE [Account].[UsersRoles].[UserId] = @{nameof(user.UserId)}
AND [Account].[UsersRoles].[RoleId] = @{nameof(role.RoleId)}"
: $@"UPDATE [Account].[UsersRoles]
SET [Approved] = @{nameof(role.Approved)}
WHERE [Account].[UsersRoles].[UserId] = @{nameof(user.UserId)}
AND [Account].[UsersRoles].[RoleId] = @{nameof(role.RoleId)}",
parameters => parameters
.Add(nameof(user.UserId), user.UserId)
.Add(nameof(role.RoleId), role.RoleId)
.Add(nameof(role.Approved), role.Approved));
}
}
}
}
}
@@ -0,0 +1,23 @@
namespace LaaProductionWeb.Services.Interfaces
{
using LaaProductionWeb.Services.Models;
using System.Collections.Generic;
public interface IAccountService : ITransient
{
WindowsUser GetOrCreateWindowsUser(string primarySID, string domainName, string userName);
PermissionsModel GetPermissionModelForUser(int userId, string role);
IEnumerable<UserRole> GetUserRoles(int userId);
List<UserPermissions> GetUsersWithPendingRoles();
UserRole GetRoleForUser(string role);
void RequestPermissions(PermissionsModel model);
void SaveUserPermissions(IEnumerable<UserPermissions> usersPermissions);
}
}
@@ -7,6 +7,8 @@
public interface IProtocolService : ITransient
{
bool DeleteFile(int fileId);
string FileContent(int? fileId);
OrderClientModel FindOrder(int orderId);
@@ -17,6 +19,8 @@
IEnumerable<TestStatus> LoadTestStatus(int orderId);
bool OrderCompleted(int orderNr);
int SaveFile(Stream fileStream, int clientId, int orderId);
}
}
@@ -0,0 +1,13 @@
namespace LaaProductionWeb.Services.Interfaces
{
using LaaProductionWeb.Services.Models;
using System.Collections.Generic;
public interface IReportService : ITransient
{
HeliumReportModel LoadHeliumPressureReport(HeliumReportModel model = null);
IEnumerable<HeliumPressurePoint> LoadHeliumPressureResults(int testId);
}
}
@@ -57,10 +57,25 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AccountService.cs" />
<Compile Include="Interfaces\IAccountService.cs" />
<Compile Include="Interfaces\IOrdersService.cs" />
<Compile Include="Interfaces\IProtocolService.cs" />
<Compile Include="Interfaces\IReportService.cs" />
<Compile Include="Interfaces\IShipmentsService.cs" />
<Compile Include="Interfaces\ITransient.cs" />
<Compile Include="Models\HeliumPressurePoint.cs" />
<Compile Include="Models\HeliumReportFilter.cs" />
<Compile Include="Models\HeliumReportFilterProperty.cs" />
<Compile Include="Models\HeliumReportItem.cs" />
<Compile Include="Models\HeliumReportModel.cs" />
<Compile Include="Models\HeliumReportModelExtensions.cs" />
<Compile Include="Models\OrderIdentity.cs" />
<Compile Include="Models\PalletPosition.cs" />
<Compile Include="Models\RoleModel.cs" />
<Compile Include="Models\UserRole.cs" />
<Compile Include="Models\UserPermissions.cs" />
<Compile Include="Models\WindowsUser.cs" />
<Compile Include="Models\BatchPrintModel.cs" />
<Compile Include="Models\OrderClientModel.cs" />
<Compile Include="Models\OrderInfoModel.cs" />
@@ -69,6 +84,7 @@
<Compile Include="Models\OrderScanModel.cs" />
<Compile Include="Models\OrdersFoundModel.cs" />
<Compile Include="Models\PalletsBatchModel.cs" />
<Compile Include="Models\PermissionsModel.cs" />
<Compile Include="Models\Result.cs" />
<Compile Include="Models\SerialNr.cs" />
<Compile Include="Models\ShipmentModel.cs" />
@@ -76,6 +92,7 @@
<Compile Include="OrdersService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProtocolService.cs" />
<Compile Include="ReportService.cs" />
<Compile Include="ServicesExtensions.cs" />
<Compile Include="ShipmentsService.cs" />
</ItemGroup>
@@ -19,14 +19,14 @@
public int ProductionOrderNr
=> this.batchModel.ProductionOrderNr;
public int PositionNr
=> this.batchModel.PositionNr;
public IEnumerable<PalletPosition> Positions
=> this.batchModel.Positions;
public int TotlalItemsCount
=> this.batchModel.TotlalItemsCount;
public string ItemsType
=> this.batchModel.ItemsType;
public int ItemsCount
=> this.batchModel.ItemsCount;
public SerialNr[] Items
=> this.batchModel
@@ -0,0 +1,11 @@
namespace LaaProductionWeb.Services.Models
{
public class HeliumPressurePoint
{
public int TestId { get; set; }
public int PointNr { get; set; }
public decimal Result { get; set; }
}
}
@@ -0,0 +1,162 @@
namespace LaaProductionWeb.Services.Models
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
public class HeliumReportFilter : List<HeliumReportFilterProperty>
{
public HeliumReportFilter()
{
var model = default(HeliumReportItem);
this.Add(model.Text(x => x.FertigungNr, this.Count));
this.Add(model.Text(x => x.AuftragNr, this.Count));
this.Add(model.Text(x => x.PositionNr, this.Count));
this.Add(model.Text(x => x.SerialNr, this.Count));
this.Add(model.Text(x => x.IdentNr, this.Count));
this.Add(model.Text(x => x.HeId, this.Count));
this.Add(model.Text(x => x.HeTestId, this.Count));
this.Add(model.Text(x => x.PcbId, this.Count));
this.Add(model.Text(x => x.Nennweite, this.Count));
this.Add(model.Text(x => x.Baulaenge, this.Count));
this.Add(model.Text(x => x.Typ, this.Count));
this.Add(model.Text(x => x.Druck, this.Count));
this.Add(model.Text(x => x.Temperatur, this.Count));
this.Add(model.Text(x => x.HeLakeRate, this.Count));
this.Add(model.Text(x => x.HeTestPressure, this.Count));
this.Add(model.Boolean(x => x.IsValid, this.Count));
this.Add(model.Text(x => x.Text, this.Count));
this.Add(model.DateTime(x => x.TestDate, this.Count, -1));
this.Add(model.Text(x => x.Tester, this.Count));
}
internal SqlExpression OrderBy()
{
var sqlExpression = new SqlExpression();
foreach (var property in this)
{
if (property.OrderBy == 1)
{
sqlExpression.Add($"{property.Column}");
}
else if (property.OrderBy == -1)
{
sqlExpression.Add($"{property.Column} DESC");
}
}
return sqlExpression.BuildOrderBy(", ");
}
internal SqlExpression Where()
{
var sqlExpression = new SqlExpression();
foreach (var property in this)
{
if (string.IsNullOrWhiteSpace(property.Like))
{
continue;
}
if (property.Type == PropertyType.Date)
{
if (!string.IsNullOrWhiteSpace(property.Like))
{
var dateTokens = property
.Like
.Split(new[] { '-' })
.Select(x => DateTimeOffset.TryParse($"{x}".Trim(), new CultureInfo("de"), DateTimeStyles.None, out DateTimeOffset date)
? (DateTimeOffset?)date
: null)
.ToArray();
if (dateTokens.Length >= 1)
{
var date1 = dateTokens.FirstOrDefault();
if (date1 != null)
{
var date = date1.Value;
var propertyName = $"{property.Property}_{property.Index}_From";
var propertyValue = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
sqlExpression.Add($"{property.Column} >= @{propertyName}", propertyName, propertyValue);
}
}
if (dateTokens.Length >= 2)
{
var date2 = dateTokens.LastOrDefault();
if (date2 != null)
{
var date = date2.Value.AddDays(1);
var propertyName = $"{property.Property}_{property.Index}_To";
var propertyValue = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
sqlExpression.Add($"{property.Column} <= @{propertyName}", propertyName, propertyValue);
}
}
}
}
else if (property.Type == PropertyType.Bool)
{
var propertyName = $"{property.Property}_{property.Index}";
var propertyValue = int.TryParse(property.Like, out int bit) ? bit : 0;
sqlExpression.Add($"{property.Column} = @{propertyName}", propertyName, property.Like);
}
else
{
var propertyName = $"{property.Property}_{property.Index}";
var propertyValue = $"%{property.Like}%";
sqlExpression.Add($"{property.Column} LIKE @{propertyName}", propertyName, propertyValue);
}
}
return sqlExpression.BuildWhere(" AND ");
}
public class SqlExpression
{
private readonly ICollection<string> expressions
= new List<string>();
public string Query { get; set; }
public IDictionary<string, object> Parameters { get; set; }
= new Dictionary<string, object>();
internal void Add(string expression)
=> this.expressions.Add(expression);
internal void Add(string expression, string propertyName, object propertyValue)
{
this.Parameters[propertyName] = propertyValue;
this.expressions.Add(expression);
}
internal SqlExpression BuildOrderBy(string delimiter)
{
this.Query = string.Join(delimiter, this.expressions);
return this;
}
internal SqlExpression BuildWhere(string delimiter)
{
this.Query = this.expressions.Any()
? string.Join(delimiter, this.expressions)
: "1 = 1";
return this;
}
}
}
}
@@ -0,0 +1,39 @@
namespace LaaProductionWeb.Services.Models
{
public class HeliumReportFilterProperty
{
public int Index { get; set; }
public PropertyType Type { get; set; }
public string Property { get; set; }
public string Column { get; set; }
public string Like { get; set; }
public int OrderBy { get; set; }
public string TypeName
=> $"Filter[{this.Index}].{nameof(this.Type)}";
public string IndexName
=> $"Filter[{this.Index}].{nameof(this.Index)}";
public string PropertyName
=> $"Filter[{this.Index}].{nameof(this.Property)}";
public string ColumnName
=> $"Filter[{this.Index}].{nameof(this.Column)}";
public string LikeName
=> $"Filter[{this.Index}].{nameof(this.Like)}";
public string OrderByName
=> $"Filter[{this.Index}].{nameof(this.OrderBy)}";
public string OrderById
=> $"Filter_{this.Index}_{nameof(this.OrderBy)}";
}
}
@@ -0,0 +1,85 @@
namespace LaaProductionWeb.Services.Models
{
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
public class HeliumReportItem
{
[Display(Name = "Auftrag Nr.")]
[Column("[POS].[AuftragNr]")]
public int AuftragNr { get; set; }
[Display(Name = "Fertigung Nr.")]
[Column("[PT].[CordonelPressureTest_FertigungsAuftragsNr]")]
public int FertigungNr { get; set; }
[Display(Name = "Pos.")]
[Column("[POS].[PositionNr]")]
public short PositionNr { get; set; }
[Display(Name = "Serial Nr.")]
[Column("[PCB2SN].[MapPcbIdToSerialNumber_SerialNumber]")]
public int SerialNr { get; set; }
[Display(Name = "Ident Nr.")]
[Column("[ID].[IdentNr]")]
public int IdentNr { get; set; }
[Display(Name = "He Id")]
[Column("[PT_HE].[CordonelPressureTestHe_Id]")]
public int HeId { get; set; }
[Display(Name = "He TestId")]
[Column("[PT_HE].[CordonelPressureTestHe_TestID]")]
public int HeTestId { get; set; }
[Display(Name = "Pcb Id")]
[Column("[PT].[CordonelPressureTest_PcbId]")]
public int PcbId { get; set; }
[Display(Name = "Nennweite")]
[Column("[ID].[Nennweite]")]
public int? Nennweite { get; set; }
[Display(Name = "Baulänge")]
[Column("[ID].[Baulaenge]")]
public int? Baulaenge { get; set; }
[Display(Name = "Typ")]
[Column("[ID].[Typ]")]
public string Typ { get; set; }
[Display(Name = "Druck")]
[Column("[ID].[Druck]")]
public int? Druck { get; set; }
[Display(Name = "°C")]
[Column("[ID].[Temperatur]")]
public int? Temperatur { get; set; }
[Display(Name = "Lake Rate")]
[Column("[PT_HE].[CordonelPressureTestHe_LeakRate]")]
public string HeLakeRate { get; set; }
[Display(Name = "He Druck")]
[Column("[PT_HE].[CordonelPressureTestHe_TestPressure]")]
public string HeTestPressure { get; set; }
[Display(Name = "Valid")]
[Column("[PT].[CordonelPressureTest_Valid]")]
public bool IsValid { get; set; }
[Display(Name = "Text")]
[Column("[PT].[CordonelPressureTest_Text]")]
public string Text { get; set; }
[Display(Name = "Datum")]
[Column("[PT].[CordonelPressureTest_Date]")]
public DateTimeOffset TestDate { get; set; }
[Display(Name = "Tester")]
[Column("[PT_HE].[CordonelPressureTestHe_TesterName]")]
public string Tester { get; set; }
}
}
@@ -0,0 +1,38 @@
namespace LaaProductionWeb.Services.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq.Expressions;
using System.Reflection;
public class HeliumReportModel
{
public HeliumReportFilter Filter { get; set; }
= new HeliumReportFilter();
public IEnumerable<HeliumReportItem> Items { get; set; }
= Array.Empty<HeliumReportItem>();
public static implicit operator HeliumReportModel(HeliumReportFilter filter)
=> new HeliumReportModel { Filter = filter };
public string Display(Expression<Func<HeliumReportItem, object>> expression)
{
var memberInfo = default(MemberInfo);
if (expression.Body is MemberExpression memberExpression)
{
memberInfo = memberExpression.Member;
}
else if (expression.Body is UnaryExpression unaryExpression && unaryExpression.Operand is MemberExpression operandExpression)
{
memberInfo = operandExpression.Member;
}
return memberInfo
?.GetCustomAttribute<DisplayAttribute>()
?.Name;
}
}
}
@@ -0,0 +1,55 @@
namespace LaaProductionWeb.Services.Models
{
using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq.Expressions;
using System.Reflection;
public enum PropertyType
{
Text,
Date,
Bool
}
public static class HeliumReportModelExtensions
{
public static HeliumReportFilterProperty Text(this HeliumReportItem model, Expression<Func<HeliumReportItem, object>> expression, int index, int orderBy = 0)
=> model.Property(expression, index, PropertyType.Text, orderBy);
public static HeliumReportFilterProperty DateTime(this HeliumReportItem model, Expression<Func<HeliumReportItem, object>> expression, int index, int orderBy = 0)
=> model.Property(expression, index, PropertyType.Date, orderBy);
public static HeliumReportFilterProperty Boolean(this HeliumReportItem model, Expression<Func<HeliumReportItem, object>> expression, int index, int orderBy = 0)
=> model.Property(expression, index, PropertyType.Bool, orderBy);
public static HeliumReportFilterProperty Property(
this HeliumReportItem model
, Expression<Func<HeliumReportItem, object>> expression
, int index
, PropertyType propertyType
, int orderBy)
{
var memberInfo = default(MemberInfo);
if (expression.Body is MemberExpression memberExpression)
{
memberInfo = memberExpression.Member;
}
else if (expression.Body is UnaryExpression unaryExpression && unaryExpression.Operand is MemberExpression operandExpression)
{
memberInfo = operandExpression.Member;
}
return new HeliumReportFilterProperty
{
Column = memberInfo?.GetCustomAttribute<ColumnAttribute>()?.Name,
Property = memberInfo?.Name,
OrderBy = orderBy,
Index = index,
Type = propertyType
};
}
}
}
@@ -15,5 +15,7 @@ namespace LaaProductionWeb.Services.Models
public int? FileId { get; set; }
public string FileContent { get; set; }
public string Responsible { get; set; }
}
}
@@ -0,0 +1,13 @@
namespace LaaProductionWeb.Services.Models
{
public class OrderIdentity
{
public int OrderNr { get; set; }
public int PositionNr { get; set; }
public int SerialNr { get; set; }
public string ClientSerialNr { get; set; }
}
}
@@ -9,8 +9,7 @@
[Required]
public int? OrderNr { get; set; }
[Required]
public int? PositionNr { get; set; }
[Required]
@@ -0,0 +1,11 @@
namespace LaaProductionWeb.Services.Models
{
public class PalletPosition
{
public int PositionNr { get; set; }
public string Description { get; set; }
public int ItemsCount { get; set; }
}
}
@@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
using System.Linq;
public class PalletsBatchModel
{
@@ -11,15 +12,17 @@
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 int ItemsCount
=> this.Positions.Sum(x => x.ItemsCount);
public IEnumerable<SerialNr> Items { get; set; }
= Array.Empty<SerialNr>();
public IEnumerable<PalletPosition> Positions { get; set; }
= Array.Empty<PalletPosition>();
}
}
@@ -0,0 +1,19 @@
namespace LaaProductionWeb.Services.Models
{
using System.ComponentModel.DataAnnotations;
public class PermissionsModel
{
public int UserId { get; set; }
[Display(Name = "Vorname")]
[Required(ErrorMessage = "Die Vorname ist erforderlich.")]
public string FirstName { get; set; }
[Display(Name = "Name")]
[Required(ErrorMessage = "Die Name ist erforderlich.")]
public string LastName { get; set; }
public UserRole Role { get; set; }
}
}
@@ -0,0 +1,13 @@
namespace LaaProductionWeb.Services.Models
{
public class RoleModel
{
public int RoleId { get; set; }
public string RoleName { get; set; }
public bool Approved { get; set; }
public bool Deleted { get; set; }
}
}
@@ -16,6 +16,8 @@
public int Nr { get; set; }
public int PositionNr { get; set; }
public int? PalletNr { get; set; }
public string ClientNr { get; set; }
@@ -22,13 +22,12 @@
[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;
=> this.orderModel != null && this.orderModel.OrderNr > 0;
public OrderModel OrderModel
=> this.orderModel
@@ -0,0 +1,25 @@
namespace LaaProductionWeb.Services.Models
{
using System.Collections.Generic;
public class UserPermissions
{
public int UserId { get; set; }
public string DisplayName { get; set; }
public List<RoleModel> Roles { get; set; }
}
public class UserPermissionsComparer : IEqualityComparer<UserPermissions>
{
public bool Equals(UserPermissions x, UserPermissions y)
=> x?.UserId == y?.UserId;
public int GetHashCode(UserPermissions obj)
=> obj?.UserId ?? default(int);
public static UserPermissionsComparer Current
= new UserPermissionsComparer();
}
}
@@ -0,0 +1,13 @@
namespace LaaProductionWeb.Services.Models
{
public class UserRole
{
public int RoleId { get; set; }
public string RoleName { get; set; }
public string DisplayName { get; set; }
public bool? Pending { get; set; }
}
}
@@ -0,0 +1,12 @@
namespace LaaProductionWeb.Services.Models
{
using System;
using System.Collections.Generic;
public class WindowsUser
{
public int UserId { get; set; } = -1;
public IEnumerable<string> Roles { get; set; } = Array.Empty<string>();
}
}
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
public class ProtocolService : IProtocolService
{
@@ -15,6 +16,15 @@
public ProtocolService(IDbContext dbContext)
=> this.dbContext = dbContext;
public bool DeleteFile(int fileId)
=> this.dbContext.ScalarTransaction<int>($@"
DELETE FROM [File]
WHERE [FileId] = @{nameof(fileId)};
DELETE FROM [FilesOrders]
OUTPUT [Deleted].[FileId]
WHERE [FileId] = @{nameof(fileId)};",
parameters: parameters => parameters.Add(nameof(fileId), fileId)) > 0;
public string FileContent(int? fileId)
{
var fileContent = this.dbContext.FirstOrDefault(
@@ -23,13 +33,14 @@
FROM [dbo].[File]
WHERE [dbo].[File].[FileId] = @{nameof(fileId)}",
parameters: parameters => parameters.Add(nameof(fileId), fileId),
reader: reader => reader.GetBytes(0));
reader: reader => reader.GetBytes(0)) ?? Array.Empty<byte>();
return string.Format("data:application/pdf;base64,{0}", Convert.ToBase64String(fileContent));
}
public OrderClientModel FindOrder(int orderId)
=> this.dbContext.FirstOrDefault(
{
var orderClientModel = this.dbContext.FirstOrDefault(
query: $@"
SELECT DISTINCT
[APG].[AuftragNr]
@@ -57,7 +68,21 @@
ClientId = reader.GetValue<int>(1),
ClientName = reader.GetString(2),
Positions = reader.GetString(3).Trim().Trim(',')
}) ?? new OrderClientModel();
});
if (orderClientModel != null && orderId > 0)
{
orderClientModel.FileId = this.dbContext.FirstOrDefault($@"
SELECT [FileId]
FROM [FilesOrders]
WHERE [OrderId] = @{nameof(orderId)}
AND [Usage] = 'PROTOCOL'",
parameters: parameters => parameters.Add(nameof(orderId), orderId),
reader: reader => reader.GetValue<int>(0));
}
return orderClientModel ?? new OrderClientModel();
}
public IEnumerable<KeyValuePair<int, string>> FindOrdersById(int orderno)
=> this.dbContext.AsEnumerable($@"
@@ -109,20 +134,15 @@
, 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
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]
@@ -143,6 +163,37 @@
RadioTest = reader.GetValue<bool?>(5),
});
public bool OrderCompleted(int orderId)
{
var sumResults = this.dbContext.AsEnumerable($@"
SELECT CAST(CASE WHEN ISNULL([CPT].[CordonelPressureTest_Valid], 1) = 1 THEN 0 ELSE 1 END AS INT)
+ CAST(CASE WHEN ISNULL([DP].[Dicht], 1) = 1 THEN 0 ELSE 1 END AS INT)
+ ISNULL(MAX([APS].[StatusFertigung]) - 30, 0)
+ CAST(CASE WHEN ISNULL([CRRH].[Result], 1) = 1 THEN 0 ELSE 1 END AS INT)
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]",
parameters => parameters.Add(nameof(orderId), orderId),
reader => reader.GetValue<int>(0))
.Sum(x => x);
return sumResults == 0;
}
public int SaveFile(Stream fileStream, int clientId, int orderId)
{
var fileName = $"{clientId}_{orderId}.pdf";
@@ -0,0 +1,111 @@
namespace LaaProductionWeb.Services
{
using LaaProductionWeb.Data.Interfaces;
using LaaProductionWeb.Services.Interfaces;
using LaaProductionWeb.Services.Models;
using System;
using System.Collections.Generic;
using System.Linq;
public class ReportService : IReportService
{
private readonly IDbContext dbContext;
public ReportService(IDbContext dbContext)
=> this.dbContext = dbContext;
public HeliumReportModel LoadHeliumPressureReport(HeliumReportModel model = null)
{
if (model is null)
{
model = new HeliumReportModel();
}
var where = model.Filter.Where();
var orderBy = model.Filter.OrderBy();
model.Items = this.dbContext.AsEnumerable($@"
SELECT [PT].[CordonelPressureTest_FertigungsAuftragsNr] AS [FertigungNr] -- 0 Filter
, [POS].[AuftragNr] AS [AuftragNr] -- 1 Filter
, [POS].[PositionNr] AS [PositionNr] -- 2 Filter
, [PCB2SN].[MapPcbIdToSerialNumber_SerialNumber] AS [SerialNr] -- 3
, [ID].[IdentNr] AS [IdentNr] -- 4 Filter
, [PT_HE].[CordonelPressureTestHe_Id] AS [HeId] -- 5
, [PT_HE].[CordonelPressureTestHe_TestID] AS [HeTestId] -- 6
, [PT].[CordonelPressureTest_PcbId] AS [PcbId] -- 7 Filter
, [ID].[Nennweite] AS [Nennweite] -- 8 Filter
, [ID].[Baulaenge] AS [Baulaenge] -- 9 Filter
, [ID].[Typ] AS [Typ] -- 10 Filter
, [ID].[Druck] AS [Druck] -- 11 Filter
, [ID].[Temperatur] AS [Temperatur] -- 12 Filter
, [PT_HE].[CordonelPressureTestHe_LeakRate] AS [HeLakeRate] -- 13
, [PT_HE].[CordonelPressureTestHe_TestPressure] AS [HeTestPressure] -- 14
, [PT].[CordonelPressureTest_Valid] AS [IsValid] -- 15 Filter
, [PT].[CordonelPressureTest_Date] AS [TestDate] -- 16 Filter
, [PT].[CordonelPressureTest_Text] AS [Text] -- 17 Filter
, [PT_HE].[CordonelPressureTestHe_TesterName] AS [Tester] -- 18
FROM [Cordonel_PressureTest] AS [PT]
JOIN [Cordonel_PressureTest_He] AS [PT_HE] ON [PT_HE].[CordonelPressureTestHe_TestID] = [PT].[CordonelPressureTest_Id]
LEFT JOIN [Druckpruefung] AS [DP] ON [DP].[FabNr] = [PT].[CordonelPressureTest_PcbId]
JOIN [MapPcbIdToSerialNumber] AS [PCB2SN] ON [PCB2SN].[MapPcbIdToSerialNumber_PcbId] = [PT].[CordonelPressureTest_PcbId]
JOIN [AuftragPosition_Gesamt] AS [POS] ON [POS].[FertigungsauftragNr] = [PT].[CordonelPressureTest_FertigungsAuftragsNr]
JOIN [Identnr] AS [ID] ON [ID].[IdentNr] = [POS].[Identnr]
WHERE [CordonelPressureTest_IsDeleted] = 0
AND {where.Query}
ORDER BY {orderBy.Query}",
parameters =>
{
foreach (var kvp in where.Parameters)
{
parameters.Add(kvp.Key, kvp.Value);
}
foreach (var kvp in orderBy.Parameters)
{
parameters.Add(kvp.Key, kvp.Value);
}
},
reader => new HeliumReportItem
{
FertigungNr = reader.GetValue<int>(0),
AuftragNr = reader.GetValue<int>(1),
PositionNr = reader.GetValue<short>(2),
SerialNr = reader.GetValue<int>(3),
IdentNr = reader.GetValue<int>(4),
HeId = reader.GetValue<int>(5),
HeTestId = reader.GetValue<int>(6),
PcbId = reader.GetValue<int>(7),
Nennweite = reader.GetValue<int?>(8),
Baulaenge = reader.GetValue<int?>(9),
Typ = reader.GetString(10),
Druck = reader.GetValue<int?>(11),
Temperatur = reader.GetValue<int?>(12),
HeLakeRate = reader.GetString(13),
HeTestPressure = reader.GetString(14),
IsValid = reader.GetValue<bool>(15),
TestDate = reader.GetValue<DateTimeOffset>(16),
Text = reader.GetString(17),
Tester = reader.GetString(18)
})
.ToList();
return model;
}
public IEnumerable<HeliumPressurePoint> LoadHeliumPressureResults(int testId)
=> this.dbContext.AsEnumerable($@"
SELECT [CordonelPressureTestTestPoints_Id]
, [CordonelPressureTest_TestPointNr]
, CAST([CordonelPressureTest_TestPointResult] AS NUMERIC(9, 8))
FROM [Auftrag].[dbo].[Cordonel_PressureTest_TestPoints]
WHERE [CordonelPressureTest_Id] = @{nameof(testId)}",
parameters => parameters.Add(nameof(testId), testId),
reader => new HeliumPressurePoint
{
TestId = reader.GetValue<int>(0),
PointNr = reader.GetValue<int>(1),
Result = reader.GetValue<decimal>(2),
});
}
}
@@ -33,11 +33,12 @@
var palletsCount = this.dbContext.FirstOrDefault(
query: $@"
SELECT COUNT(1)
FROM (SELECT [PalettenNr] AS [PalletNr]
, COUNT([SerienNr]) AS [Count]
FROM (SELECT [PalettenNr] AS [PalletNr]
, COUNT([SerienNr]) AS [Count]
FROM [PalettenScan]
WHERE [AuftragNr] = @{nameof(model.OrderNr)}
AND [PositionNr] = @{nameof(model.PositionNr)}
WHERE [AuftragNr] = @{nameof(model.OrderNr)}
AND (@{nameof(model.PositionNr)} IS NULL
OR [PositionNr] = @{nameof(model.PositionNr)})
GROUP BY [PalettenNr])
AS [Paletten]
WHERE [Count] > 0",
@@ -83,13 +84,15 @@
, REPLACE(RTRIM(LTRIM([AuftragPositionSerienNr].[KundeneigeneSerienNr])), ' ', '') -- 2
, [PalettenScan].[PalettenNr] -- 3
, CAST(CASE WHEN [PalettenScan].[ID] IS NULL THEN 0 ELSE 1 END AS BIT) -- 4
, ISNULL([PalettenScan].[PositionNr], [AuftragPositionSerienNr].[PositionNr]) -- 5
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 (@{nameof(model.PositionNr)} IS NULL
OR [AuftragPositionSerienNr].[PositionNr] = @{nameof(model.PositionNr)})
AND ([PalettenScan].[PalettenNr] = @{nameof(model.PalletNr)}
OR [PalettenScan].[PalettenNr] IS NULL)",
parameters: parameters => parameters
@@ -102,31 +105,34 @@
Nr = reader.GetValue<int>(1),
ClientNr = reader.GetString(2),
PalletNr = reader.GetValue<short>(3),
IsScaned = reader.GetValue<bool>(4)
IsScaned = reader.GetValue<bool>(4),
PositionNr = reader.GetValue<int>(5),
})
.OrderByDescending(x => x.IsScaned)
.ThenBy(x => x.PositionNr)
.ThenBy(x => x.ClientNr);
public PalletsBatchModel LoadBatchModel(OrderScanModel model)
{
const string orderNr = nameof(model.OrderNr);
const string palNr = nameof(model.PalletNr);
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
[Auftrag].[AuftragNr] -- 0
, [Auftrag].[FertigungsauftragNr] -- 1
, (SELECT SUM([AAP].[Menge])
FROM [AlleAuftragPositionen] AS [AAP]
WHERE [AAP].[AuftragNr] = [Auftrag].[AuftragNr]) -- 2
, [Kunde].[Name] -- 3
, [Auftrag].[ZusatzText] -- 4
FROM [AlleAuftragPositionen] AS [Auftrag]
JOIN [Kunde] ON [Kunde].[KundenNr] = [Auftrag].[KundenNr]
JOIN [IdentNr] ON [IdentNr].[IdentNr] = [Auftrag].[IdentNr]
JOIN [Kunde] ON [Kunde].[KundenNr] = [Auftrag].[KundenNr]
WHERE [Auftrag].[AuftragNr] = @{nameof(model.OrderNr)}
AND [Auftrag].[PositionNr] = @{nameof(model.PositionNr)}
ORDER BY [Auftrag].[FertigungsauftragNr] DESC",
AND (@{nameof(model.PositionNr)} IS NULL
OR [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),
@@ -134,26 +140,59 @@
{
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();
TotlalItemsCount = reader.GetValue<int>(2),
ClientName = reader.GetValue<string>(3),
AdditionalText = reader.GetValue<string>(4),
})
?? new PalletsBatchModel();
if (batchModel.OrderNr > 0)
{
batchModel.Items = this.LoadBatchItems(model);
batchModel.Positions = this.LoadBatchPositions(model, orderNr, palNr);
}
return batchModel;
}
private IEnumerable<PalletPosition> LoadBatchPositions(OrderScanModel model, string orderNr, string palNr)
=> this.dbContext.AsEnumerable($@"
SELECT DISTINCT
[Auftrag].[PositionNr]
, COUNT(1)
, [Identnr].[Typ]
, [Identnr].[Typzusatz]
, [Identnr].[Nennweite]
FROM [Identnr]
JOIN [AlleAuftragPositionen] AS [Auftrag]
ON [Auftrag].[IdentNr] = [Identnr].[IdentNr]
JOIN [PalettenScan]
ON [PalettenScan].[AuftragNr] = [Auftrag].[AuftragNr]
AND [PalettenScan].[PositionNr] = [Auftrag].[PositionNr]
AND [PalettenScan].[PalettenNr] = @{palNr}
WHERE [Auftrag].[AuftragNr] = @{orderNr}
GROUP BY [Auftrag].[PositionNr]
, [Identnr].[Typ]
, [Identnr].[Typzusatz]
, [Identnr].[Nennweite]
ORDER BY [Auftrag].[PositionNr] ",
parameters => parameters
.Add(orderNr, model.OrderNr)
.Add(palNr, model.PalletNr),
positionReader => new PalletPosition
{
PositionNr = positionReader.GetValue<short>(0),
ItemsCount = positionReader.GetValue<int>(1),
Description = string
.Join(" ", new[]
{
positionReader.GetString(2),
positionReader.GetString(3),
positionReader.GetString(4),
}
.Where(x => !string.IsNullOrWhiteSpace(x)))
});
public Result UpdateBatchModel(OrderScanModel model)
{
if (!string.IsNullOrWhiteSpace(model.SerialNr))
@@ -163,16 +202,16 @@
return $"Der Packet mit Serien-Nr: {model.SerialNr} wurde bereits hinzugefügt.";
}
var orderKVP = this.GetOrderKVP(model.OrderNr, model.PositionNr, model.SerialNr);
var orderIdentity = this.UpdateOrderIdentifiers(model.OrderNr, model.PositionNr, model.SerialNr);
if (orderKVP.Key <= 0)
if (orderIdentity is null)
{
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);
model.SerialNr = orderIdentity.ClientSerialNr;
model.PositionNr = orderIdentity.PositionNr;
}
var rowsAffected = this.InsertPalletEntry(model);
@@ -183,18 +222,6 @@
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: $@"
@@ -212,26 +239,31 @@
PalletNr = reader.GetValue<short>(2)
});
private KeyValuePair<int, string> GetOrderKVP(int? orderNr, int? positionNr, string serialNr)
private OrderIdentity UpdateOrderIdentifiers(int? orderNr, int? positionNr, string serialNr)
=> this.dbContext.FirstOrDefault(
query: $@"
SELECT DISTINCT TOP 1
[AuftragPositionSerienNr].[SerienNr] -- 0
, REPLACE(RTRIM(LTRIM([AuftragPositionSerienNr].[KundeneigeneSerienNr])), ' ', '') -- 1
[AuftragPositionSerienNr].[PositionNr] -- 0
, [AuftragPositionSerienNr].[SerienNr] -- 1
, REPLACE(RTRIM(LTRIM([AuftragPositionSerienNr].[KundeneigeneSerienNr])), ' ', '') -- 2
FROM [AuftragPositionSerienNr]
WHERE [AuftragPositionSerienNr].[AuftragNr] = @{nameof(orderNr)}
AND [AuftragPositionSerienNr].[PositionNr] = @{nameof(positionNr)}
AND @{nameof(serialNr)} LIKE '%' + (REPLACE(RTRIM(LTRIM([AuftragPositionSerienNr].[KundeneigeneSerienNr])), ' ', '')) + '%'",
WHERE [AuftragPositionSerienNr].[AuftragNr] = @{nameof(orderNr)}
AND ([AuftragPositionSerienNr].[PositionNr] = @{nameof(positionNr)} OR @{nameof(positionNr)} IS NULL)
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)));
reader: reader => new OrderIdentity
{
OrderNr = orderNr ?? -1,
PositionNr = reader.GetValue<short>(0),
SerialNr = reader.GetValue<int>(1),
ClientSerialNr = reader.GetValue<string>(2),
});
private int InsertPalletEntry(OrderScanModel model)
=> this.dbContext.ScalarTransaction<int>($@"
=> this.dbContext.ExecuteNonQuery($@"
INSERT
INTO [PalettenScan] (
[PalettenNr]
@@ -261,11 +293,9 @@
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));
@@ -117,4 +117,28 @@ table.table table.table {
.text-teal {
color: var(--bs-teal);
}
}
.btn.btn-link:hover {
text-decoration: underline !important;
}
.bg-whitesmoke {
background-color: whitesmoke !important
}
.bi-bold:before {
font-weight: bolder !important;
}
.table-responsive::-webkit-scrollbar:horizontal {
position: fixed;
bottom: 0;
}
.cursor-pointer:hover {
cursor: pointer !important;
text-decoration: underline !important;
}
@@ -0,0 +1,23 @@
namespace LaaProductionWeb.App_Infrastructure
{
using System.Security.Claims;
using System.Web.Mvc;
public class AllowedRolesAttribute : AuthorizeAttribute
{
public AllowedRolesAttribute(params string[] roles)
=> this.Roles = string.Join(",", roles);
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
if (filterContext.HttpContext.User is ClaimsPrincipal claimsPrincipal)
{
filterContext.Result = new RedirectResult($"/Account/Authorize?role={this.Roles}");
}
else
{
base.HandleUnauthorizedRequest(filterContext);
}
}
}
}
@@ -0,0 +1,48 @@
namespace LaaProductionWeb.App_Infrastructure
{
using LaaProductionWeb.Services.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Web.Mvc;
public class AuthorizationFilter : IAuthorizationFilter
{
public void OnAuthorization(AuthorizationContext filterContext)
{
if (filterContext.HttpContext.User is ClaimsPrincipal claimsPrincipal)
{
this.GetWindowsUser(claimsPrincipal, out string primarySID, out string domainName, out string userName);
var accountService = ServiceProvider.Current.GetService<IAccountService>();
var windowsUser = accountService.GetOrCreateWindowsUser(primarySID, domainName, userName);
var claims = new List<Claim> { new Claim(ClaimTypes.NameIdentifier, $"{windowsUser.UserId}") };
foreach (var role in windowsUser.Roles)
{
claims.Add(new Claim(ClaimTypes.Role, role));
}
var claimsIdentity = new ClaimsIdentity(claims, nameof(ClaimsPrincipal), ClaimTypes.Name, ClaimTypes.Role);
claimsPrincipal.AddIdentity(claimsIdentity);
}
}
private void GetWindowsUser(ClaimsPrincipal claimsPrincipal, out string primarySID, out string domainName, out string userName)
{
var nameTokens = claimsPrincipal
.FindFirst(ClaimTypes.Name)
?.Value
?.ToLower()
?.Split(new[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries)
?? Array.Empty<string>();
primarySID = claimsPrincipal.FindFirst(ClaimTypes.PrimarySid)?.Value;
domainName = nameTokens.FirstOrDefault();
userName = nameTokens.LastOrDefault();
}
}
}
@@ -3,7 +3,12 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Security.Claims;
using System.Security.Principal;
using System.Web.Mvc;
public static class ControllersExtensions
@@ -32,5 +37,45 @@
return serviceProvider;
}
public static int NameIdentifier(this IPrincipal principal)
{
if (principal is ClaimsPrincipal claimsPrincipal)
{
var nameIdentifier = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier)?.Value;
if (int.TryParse($"{nameIdentifier}", out int userId))
{
return userId;
}
}
return -1;
}
public static T NameIdentifier<T>(this ViewContext viewContext)
{
return default(T);
}
public static string Display<T>(this T model, Expression<Func<T, object>> expression)
{
if (expression.Body is MemberExpression memberExpression)
{
return memberExpression
.Member
.GetCustomAttribute<DisplayAttribute>()
.GetName();
}
else if (expression.Body is UnaryExpression unaryExpression && unaryExpression.Operand is MemberExpression operandExpression)
{
return operandExpression
.Member
.GetCustomAttribute<DisplayAttribute>()
.GetName();
}
return default(string);
}
}
}
@@ -0,0 +1,12 @@
namespace LaaProductionWeb.App_Infrastructure
{
using System.Web.Mvc;
public class ExceptionFilter : IExceptionFilter
{
public void OnException(ExceptionContext filterContext)
{
filterContext.Result = new RedirectResult("/");
}
}
}
@@ -0,0 +1,39 @@
namespace LaaProductionWeb.App_Infrastructure
{
using Microsoft.Extensions.DependencyInjection;
using System;
public class ServiceProvider
{
private readonly IServiceProvider services;
private ServiceProvider(IServiceProvider services)
=> this.services = services;
public T GetService<T>() where T : class
{
if (this.services.GetService<T>() is T service)
{
return service;
}
return default(T);
}
public static ServiceProvider Current { get; private set; }
internal static void SetServiceProvider(IServiceProvider serviceProvider)
=> Current = new ServiceProvider(serviceProvider);
}
public static class ServiceProviderExtensions
{
public static IServiceProvider RegisterServiceProvider(this IServiceProvider serviceProvider)
{
ServiceProvider.SetServiceProvider(serviceProvider);
return serviceProvider;
}
}
}
@@ -1,12 +1,15 @@
namespace LaaProductionWeb
{
using LaaProductionWeb.App_Infrastructure;
using System.Web.Mvc;
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new ExceptionFilter());
filters.Add(new AuthorizationFilter());
}
}
}
@@ -12,7 +12,8 @@
=> new ServiceCollection()
.ConfigureServices()
.BuildServiceProvider()
.BuildControllerFactory();
.BuildControllerFactory()
.RegisterServiceProvider();
static IServiceCollection ConfigureServices(this IServiceCollection services)
{
@@ -0,0 +1,61 @@
namespace LaaProductionWeb.Controllers
{
using LaaProductionWeb.App_Infrastructure;
using LaaProductionWeb.Services.Interfaces;
using LaaProductionWeb.Services.Models;
using System.Collections.Generic;
using System.Web.Mvc;
[Authorize]
public class AccountController : Controller
{
private readonly IAccountService accountService;
public AccountController(IAccountService accountService)
=> this.accountService = accountService;
[HttpGet]
public ActionResult Authorize(string role)
{
var userId = this.User.NameIdentifier();
var permissionsModel = this.accountService
.GetPermissionModelForUser(userId, role);
return this.View(model: permissionsModel);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Authorize(PermissionsModel model)
{
if (this.ModelState.IsValid)
{
this.accountService.RequestPermissions(model);
}
return this.View(model);
}
[HttpGet]
[AllowedRoles("Admin")]
public ActionResult Permissions()
{
var model = this.accountService.GetUsersWithPendingRoles();
return this.View(model);
}
[HttpPost]
[AllowedRoles("Admin")]
[ValidateAntiForgeryToken]
public ActionResult Permissions(List<UserPermissions> model)
{
this.accountService.SaveUserPermissions(model);
model = this.accountService.GetUsersWithPendingRoles();
return this.View(model);
}
}
}
@@ -6,6 +6,7 @@
using System.Web.Mvc;
[Authorize]
// [AllowedRoles("Protocol")]
public class ProtocolController : Controller
{
public const string FilePDF = nameof(FilePDF);
@@ -20,39 +21,58 @@
{
var orderClientModel = this.protocolService.FindOrder(orderId);
if (orderClientModel.FileId > 0)
{
return this.RedirectToAction(nameof(Document), orderClientModel);
}
return this.View(orderClientModel);
}
[HttpPost]
public ActionResult Index(OrderClientModel model)
{
var files = this.Request.Files;
if (files.Count > 0)
if (model.OrderId > 0 && model.ClientId > 0)
{
var file = this.Request.Files.Get(0);
var files = this.Request.Files;
if (file.ContentType == "application/pdf" && model.ClientId > 0 && model.OrderId > 0)
if (files.Count > 0)
{
model.FileId = this.protocolService.SaveFile(file.InputStream, model.ClientId.Value, model.OrderId.Value);
var file = files.Get(0);
if (model.FileId > 0)
if (file.ContentType == "application/pdf")
{
return this.RedirectToAction(nameof(this.Document), model);
if (this.protocolService.OrderCompleted(model.OrderId.Value))
{
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] = $"Auftrag enthält nicht bestandene Prüfungen.";
}
}
else
{
this.TempData[FilePDF] = $"Der PDF Datei wurde nicht hochgeladen.";
this.TempData[FilePDF] = $"Bitte, PDF Datei hochladen.";
}
}
else
{
this.TempData[FilePDF] = $"Bitte, PDF Datei hochladen.";
this.TempData[FilePDF] = "Kein PDF Datei wurde ausgewählt.";
}
}
else
{
this.TempData[FilePDF] = "Kein PDF Datei wurde ausgewählt.";
this.TempData[FilePDF] = $"Bitte Auftrag auswählen.";
}
return this.View(model);
@@ -66,6 +86,15 @@
return this.View(model);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult DeleteFile(int fileId, int orderId)
{
this.protocolService.DeleteFile(fileId);
return this.RedirectToAction(nameof(this.Index), new { orderId });
}
public ActionResult Clients(string search = null)
{
var clientsOrders = this.protocolService.FindOrdersByClient(search);
@@ -0,0 +1,40 @@
namespace LaaProductionWeb.Controllers
{
using LaaProductionWeb.Services.Interfaces;
using LaaProductionWeb.Services.Models;
using System.Web.Mvc;
[Authorize]
// [AllowedRoles("HeReport")]
public class ReportController : Controller
{
private readonly IReportService reportService;
public ReportController(IReportService reportService)
=> this.reportService = reportService;
[HttpGet]
public ActionResult Index()
{
var model = this.reportService.LoadHeliumPressureReport();
return this.View(model);
}
[HttpPost]
public ActionResult Index(HeliumReportModel model)
{
model = this.reportService.LoadHeliumPressureReport(model);
return this.View(model);
}
public ActionResult Results(int testId = 0)
{
var results = this.reportService.LoadHeliumPressureResults(testId);
return this.PartialView(results);
}
}
}
@@ -13,6 +13,7 @@
using SystemFile = System.IO.File;
[Authorize]
// [AllowedRoles("Shipment")]
public class ShipmentsController : Controller
{
private readonly IShipmentsService shipmentsService;
@@ -62,6 +63,7 @@
if (result)
{
model.PositionNr = null;
model.SerialNr = default(string);
}
else
@@ -77,6 +79,7 @@
public ActionResult Delete(int id)
{
var orderScanModel = this.shipmentsService.DeletePalletEntry(id);
orderScanModel.PositionNr = null;
return this.View(nameof(this.Index), new ShipmentModel(orderScanModel));
}
@@ -131,15 +131,21 @@
</ItemGroup>
<ItemGroup>
<Compile Include="App_Infrastructure\ApplicationSettings.cs" />
<Compile Include="App_Infrastructure\AuthorizationFilter.cs" />
<Compile Include="App_Infrastructure\ControllerFactory.cs" />
<Compile Include="App_Infrastructure\ControllersExtensions.cs" />
<Compile Include="App_Infrastructure\ExceptionFilter.cs" />
<Compile Include="App_Infrastructure\AllowedRolesAttribute.cs" />
<Compile Include="App_Infrastructure\ServiceProvider.cs" />
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="App_Start\ServicesConfig.cs" />
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Controllers\AccountController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\ProtocolController.cs" />
<Compile Include="Controllers\ReportController.cs" />
<Compile Include="Controllers\SearchController.cs" />
<Compile Include="Controllers\ShipmentsController.cs" />
<Compile Include="Global.asax.cs">
@@ -156,6 +162,7 @@
<Content Include="App_Content\js\scripts.js" />
<Content Include="App_Content\svg\sensus_xylem_logo.svg" />
<Content Include="favicon.ico" />
<Content Include="favicon.svg" />
<Content Include="Global.asax" />
<Content Include="Web.config">
<SubType>Designer</SubType>
@@ -168,11 +175,18 @@
<ItemGroup>
<None Include="packages.config" />
<Content Include="Views\Shared\_PrintLayout.cshtml" />
<Content Include="Views\Account\Authorize.cshtml" />
<Content Include="Views\Account\UserRole.cshtml" />
<Content Include="Views\Account\Permissions.cshtml" />
<Content Include="Views\Report\Index.cshtml" />
<Content Include="Views\Report\Filter.cshtml" />
<Content Include="Views\Report\Results.cshtml" />
<Content Include="Views\Report\DateFilter.cshtml" />
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Content\font\fonts\bootstrap-icons.woff" />
<Content Include="App_Content\font\fonts\bootstrap-icons.woff2" />
<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" />
@@ -198,6 +212,7 @@
<Name>LaaProductionWeb.Services</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
@@ -0,0 +1,35 @@
@model PermissionsModel
@using LaaProductionWeb.Services.Models
<div class="d-flex justify-content-center align-items-center h-100">
@if (this.Model.Role.Pending is null)
{
<div class="col-md-3 card p-5">
<form action="/Account/Authorize" method="post" autocomplete="off">
@this.Html.AntiForgeryToken()
@this.Html.HiddenFor(x => x.UserId)
@this.Html.Partial(nameof(UserRole), this.Model.Role, new ViewDataDictionary { { "namePattern", $"{nameof(this.Model.Role)}.{{0}}" } })
<h5 class="mb-3">Ihnen fehlt die Berechtigung – '@this.Model.Role.DisplayName'.</h5>
<div class="form-floating mb-3">
@this.Html.TextBoxFor(x => x.FirstName, new { @class = "form-control", placeholder = "Vorname" })
@this.Html.LabelFor(x => x.FirstName, new { @class = "text-secondary" })
@this.Html.ValidationMessageFor(x => x.FirstName, string.Empty, new { @class = "small text-danger" })
</div>
<div class="form-floating mb-3">
@this.Html.TextBoxFor(x => x.LastName, new { @class = "form-control", placeholder = "Vorname" })
@this.Html.LabelFor(x => x.LastName, new { @class = "text-secondary" })
@this.Html.ValidationMessageFor(x => x.LastName, string.Empty, new { @class = "small text-danger" })
</div>
<button type="submit" class="btn btn-primary py-3 w-100">Berechtigung anfordern</button>
</form>
</div>
}
else
{
<div class="col-md-3 card p-5 border-success">
<h1 class="text-center text-success"><i class="bi bi-shield-exclamation"></i></h1>
<h6 class="text-center text-success">Ihre anfrage für die berechtigung – '@this.Model.Role.DisplayName' ist in bearbeitung ...</h6>
</div>
}
</div>
@@ -0,0 +1,60 @@
@model List<LaaProductionWeb.Services.Models.UserPermissions>
@if (this.Model.Any())
{
<form action="/Account/Permissions" method="post" autocomplete="off">
@this.Html.AntiForgeryToken()
<ul class="list-group list-group-flush mb-3">
@{
var usersCount = this.Model.Count;
for (int userIndex = 0; userIndex < usersCount; userIndex++)
{
var user = this.Model[userIndex];
var hiddenUserId = $"[{userIndex}].{nameof(user.UserId)}";
var hiddenUserName = $"[{userIndex}].{nameof(user.DisplayName)}";
<li class="list-group-item">
<input type="hidden" name="@hiddenUserId" value="@user.UserId" />
<input type="hidden" name="@hiddenUserName" value="@user.DisplayName" />
<h5>@user.DisplayName</h5>
</li>
<li class="list-group-item">
<table>
<thead>
<tr>
<th class="text-secondary white-space-nowrap small px-3">Role Id</th>
<th class="text-secondary white-space-nowrap small px-3">Role Name</th>
<th class="text-secondary white-space-nowrap small px-3">Is Approved</th>
<th class="text-secondary white-space-nowrap small px-3">Is Deleted</th>
</tr>
</thead>
<tbody>
@{
var rolesCount = user.Roles.Count;
for (int roleIndex = 0; roleIndex < rolesCount; roleIndex++)
{
var role = user.Roles[roleIndex];
var hiddenRoleId = $"[{userIndex}].{nameof(user.Roles)}[{roleIndex}].{nameof(role.RoleId)}";
var hiddenRoleName = $"[{userIndex}].{nameof(user.Roles)}[{roleIndex}].{nameof(role.RoleName)}";
var roleApproved = $"[{userIndex}].{nameof(user.Roles)}[{roleIndex}].{nameof(role.Approved)}";
var roleDeleted = $"[{userIndex}].{nameof(user.Roles)}[{roleIndex}].{nameof(role.Deleted)}";
<tr>
<td class="px-3">@role.RoleId <input type="hidden" name="@hiddenRoleId" value="@role.RoleId" /></td>
<td class="px-3">@role.RoleName <input type="hidden" name="@hiddenRoleName" value="@role.RoleName" /></td>
<td class="px-3">@this.Html.CheckBox(roleApproved, role.Approved, new { @class = "form-check-input" })</td>
<td class="px-3">@this.Html.CheckBox(roleDeleted, role.Deleted, new { @class = "form-check-input" })</td>
</tr>
}
}
</tbody>
</table>
</li>
}
}
</ul>
<button type="submit" class="btn btn-primary py-2 px-5 ms-3">Änderungen speichern</button>
</form>
}
@@ -0,0 +1,14 @@
@model LaaProductionWeb.Services.Models.UserRole
@{
var namePattern = "{0}";
if (this.ViewData.TryGetValue(nameof(namePattern), out object value))
{
namePattern = $"{value}";
}
}
@this.Html.Hidden(string.Format(namePattern, nameof(this.Model.RoleId)), this.Model.RoleId)
@this.Html.Hidden(string.Format(namePattern, nameof(this.Model.RoleName)), this.Model.RoleName)
@this.Html.Hidden(string.Format(namePattern, nameof(this.Model.DisplayName)), this.Model.DisplayName)
@@ -15,17 +15,17 @@
enables a clean separation of concerns and gives you full control over markup
for enjoyable, agile development.
</p>
<p><a class="btn btn-default" >Learn more &raquo;</a></p>
<p><a class="btn btn-default">Learn more &raquo;</a></p>
</div>
<div class="col-md-4">
<h2>Get more libraries</h2>
<p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
<p><a class="btn btn-default" >Learn more &raquo;</a></p>
<p><a class="btn btn-default">Learn more &raquo;</a></p>
</div>
<div class="col-md-4">
<h2>Web Hosting</h2>
<p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p>
<p><a class="btn btn-default" >Learn more &raquo;</a></p>
<p><a class="btn btn-default">Learn more &raquo;</a></p>
</div>
</div>
</div>
@@ -1,19 +1,23 @@
@model IEnumerable<LaaProductionWeb.Services.Models.TestStatus>
@{
Func<bool?, string> testPassed = testStatus =>
Func<bool?, bool, MvcHtmlString> testPassed = (testStatus, nullable) =>
{
if (testStatus is null)
if (testStatus is null && nullable)
{
return "bi bi-check2 text-secondary opacity-25 fs-3";
return new MvcHtmlString("<td class=\"text-center text-success\">OK*</td>");
}
else if (testStatus is null)
{
return new MvcHtmlString("<td class=\"text-center text-secondary small\">n/a</td>");
}
else if (testStatus == false)
{
return "bi bi-x text-danger fs-3";
return new MvcHtmlString("<td class=\"text-center text-danger\">X</td>");
}
else
{
return "bi bi-check2 text-teal fs-3";
return new MvcHtmlString("<td class=\"text-center text-success\">OK</td>");
}
};
}
@@ -23,52 +27,119 @@
<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">Pos.</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>
<th class="text-center">T1</th>
<th class="text-center">T2</th>
<th class="text-center">T3</th>
<th class="text-center">T4</th>
<th class="text-center">T5</th>
<th class="text-center">T6</th>
<th class="text-center">T7</th>
</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>
<td class="va-middle white-space-nowrap">@item.SerialNr</td>
@testPassed(null, true)
@testPassed(item.PressureTest, false)
@testPassed(item.HeliumTest, false)
@testPassed(null, true)
@testPassed(item.MetroTest, false)
@testPassed(item.RadioTest, false)
@testPassed(null, true)
</tr>
}
</table>
</td>
</tr>
<tr>
<td colspan="2" class="pt-5 pb-0 px-0 small">
<table class="table table-sm table-bordered border-top">
<tr>
<th>Legend:</th>
<th>Component & Operation</th>
<th>Quantum of Check</th>
<th>Acceptance Norms</th>
</tr>
<tr>
<th class="va-middle py-0">T1</th>
<th class="va-middle py-0">Powder coating</th>
<td class="py-0">
1 piece per quarter<br />
1 piece per h
</td>
<td class="va-middle py-0">
Adhesion according to DIN 53151,coating faultless & corrosion free<br />
According drawing
</td>
</tr>
<tr>
<th class="va-middle py-0">T2</th>
<th class="va-middle py-0">Pressure and burst test composit transducer</th>
<td class="py-0">
First part / batch<br />
500 th part / batch<br />
Last part / batch
</td>
<td class="va-middle">Rejected in case of leakage or breakage</td>
</tr>
<tr>
<th class="va-middle py-0">T3</th>
<th class="va-middle py-0">Tightness Test</th>
<td class="py-0">100%</td>
<td class="va-middle">Rejected in case of leakage</td>
</tr>
<tr>
<th class="va-middle py-0">T4</th>
<th class="va-middle py-0">Pressure and tightness test</th>
<td class="py-0">100% at start of production</td>
<td class="va-middle py-0">Rejected in case of leakage or breakage</td>
</tr>
<tr>
<th class="va-middle py-0">T5</th>
<th class="va-middle py-0">Metrological testing</th>
<td class="py-0">100%</td>
<td class="va-middle py-0">
Maximum Permissible Error at<br />
Q1 < ± 5%<br />
Q2 < ± 2%<br />
Q3 < ± 2%
</td>
</tr>
<tr>
<th class="va-middle py-0">T6</th>
<th class="va-middle py-0">Config comparison and radio test</th>
<td class="py-0">100%</td>
<td class="va-middle py-0">
Main functions, LCD display, LED, Radio functions according to specs<br />
Parameter readable and according to customer specification
</td>
</tr>
<tr>
<th class="va-middle py-0">T7</th>
<th class="py-0">100%</th>
<td class="va-middle py-0">Packaging of meter</td>
<td class="va-middle py-0">SENSUS-1-924</td>
</tr>
<tr>
<th class="va-middle py-0">n/a</th>
<td class="va-middle py-0" colspan="3">Not applicable</td>
</tr>
<tr>
<th class="va-middle py-0">Ok</th>
<td class="va-middle py-0" colspan="3">Test passed</td>
</tr>
<tr>
<th class="va-middle py-0">Ok*</th>
<td class="va-middle py-0" colspan="3">Test passed according to the Quantum of Check</td>
</tr>
<tr>
<th class="va-middle py-0">X</th>
<td class="va-middle py-0" colspan="3">Test not passed</td>
</tr>
</table>
</td>
</tr>
</tbody>
@@ -2,18 +2,21 @@
@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="d-flex flex-column h-100">
<form action="/Protocol/DeleteFile" method="post" class="nav justify-content-end bg-whitesmoke">
@this.Html.AntiForgeryToken()
@this.Html.HiddenFor(x => x.FileId)
@this.Html.HiddenFor(x => x.OrderId)
<button class="btn btn-link text-danger nav-link">
<i class="bi bi-trash"></i> Delete
</button>
</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 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>
</div>
@@ -3,7 +3,7 @@
@using LaaProductionWeb.Controllers
@using LaaProductionWeb.Services.Models
<table class="table table-bordered">
<table class="table table-bordered mb-5">
<thead>
<tr>
<th class="align-top p-0 w-100">
@@ -13,7 +13,7 @@
</tr>
<tr>
<td class="py-1 white-space-nowrap va-middle"><label for="client_name">Client</label></td>
<td class="p-1 dropdown">
<td class="p-1 dropdown w-75">
<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>
@@ -22,7 +22,7 @@
</tr>
<tr>
<td class="py-1 white-space-nowrap va-middle"><label for="order_no">Order No.</label></td>
<td class="p-1">
<td class="p-1 w-75">
<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>
@@ -31,7 +31,7 @@
</tr>
<tr class="border-bottom-0">
<td class="py-1 white-space-nowrap va-middle">Positions</td>
<td class="p-1">
<td class="p-1 w-75">
<div class="form-control border-0 rounded-0">
@if (string.IsNullOrWhiteSpace(this.Model.Positions))
{
@@ -53,15 +53,18 @@
@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" />
<input name="FilePDF" id="FilePDF" type="file" class="d-none" accept="application/pdf" onchange="javascript: this.form.submit();" />
<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>
<a class="btn btn-light border white-space-nowrap w-100" 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 w-100">
<i class="bi bi-filetype-pdf"></i> Auswählen
</label>
</div>
@if (this.TempData.TryGetValue(ProtocolController.FilePDF, out object errorMessage))
{
<div class="text-danger small">
<div class="text-danger small fw-normal">
@($"{errorMessage}")
</div>
}
@@ -95,7 +98,7 @@
clientMenu.classList.add(show);
})
} else {
clientMenu.classList.remove(show);
orderMenu.classList.remove(show);
}
}, 50);
};
@@ -17,7 +17,7 @@
</tr>
<tr>
<td class="py-1 white-space-nowrap va-middle"><label for="client_name">Client</label></td>
<td class="p-1 dropdown">
<td class="p-1 w-75">
<div class="form-control border-0 rounded-0">
@if (string.IsNullOrWhiteSpace(this.Model.ClientName))
{
@@ -32,7 +32,7 @@
</tr>
<tr>
<td class="py-1 white-space-nowrap va-middle"><label for="order_no">Order No.</label></td>
<td class="p-1">
<td class="p-1 w-75">
<div class="form-control border-0 rounded-0">
@if (this.Model.OrderId is null)
{
@@ -47,7 +47,7 @@
</tr>
<tr class="border-bottom-0">
<td class="py-1 white-space-nowrap va-middle">Positions</td>
<td class="p-1">
<td class="p-1 w-75">
<div class="form-control border-0 rounded-0">
@if (string.IsNullOrWhiteSpace(this.Model.Positions))
{
@@ -63,7 +63,7 @@
</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" />
<img src="~/App_Content/svg/sensus_xylem_logo.svg" width="130" class="mx-5" />
</th>
</tr>
</thead>
@@ -71,4 +71,24 @@
{
this.Html.RenderAction(nameof(ProtocolController.Body), new { orderId = this.Model.OrderId });
}
</table>
</table>
<div class="container-fluid">
<div class="row py-5">
<div class="col-4 d-flex flex-column justify-content-end">
<label class="small">Date: @($"{DateTime.Now:dd.MM.yyyy}")</label>
<hr class="mt-2" />
</div>
<div class="col-4 d-flex flex-column justify-content-end">
<div class="input-group align-items-end">
<label class="small">Name: </label>
<input class="form-control border-0 rounded-0" />
</div>
<hr class="mt-2" />
</div>
<div class="col-4 d-flex flex-column justify-content-end">
<label class="small">Sign: </label>
<hr class="mt-2" />
</div>
</div>
</div>
@@ -0,0 +1,33 @@
@model LaaProductionWeb.Services.Models.HeliumReportFilterProperty
@{
Func<bool, string> isChecked = x => x ? "checked" : string.Empty;
Func<bool, string> bgColor = x => !x ? "bg-light" : string.Empty;
}
<input type="hidden" name="@this.Model.TypeName" value="@this.Model.Type" />
<input type="hidden" name="@this.Model.IndexName" value="@this.Model.Index" />
<input type="hidden" name="@this.Model.ColumnName" value="@this.Model.Column" />
<input type="hidden" name="@this.Model.PropertyName" value="@this.Model.Property" />
<input autocomplete="off"
style="min-width: 200px"
class="form-control form-control-sm mb-1"
name="@this.Model.LikeName"
value="@this.Model.Like"
placeholder="dd.MM.yyyy-dd.MM.yyyy"/>
<div class="input-group flex-nowrap justify-content-center">
<input id="@(this.Model.OrderById)_1" name="@this.Model.OrderByName" type="radio" value="1" @isChecked(this.Model.OrderBy == 1) class="d-none" />
<label for="@(this.Model.OrderById)_1" class="form-control form-control-sm text-center text-secondary border-light @bgColor(this.Model.OrderBy == 1) cursor-pointer">
<i class="bi bi-chevron-up"></i>
</label>
<input id="@(this.Model.OrderById)_0" name="@this.Model.OrderByName" type="radio" value="0" @isChecked(this.Model.OrderBy == 0) class="d-none" />
<label for="@(this.Model.OrderById)_0" class="form-control form-control-sm text-center text-secondary border-light @bgColor(this.Model.OrderBy == 0) cursor-pointer">
<i class="bi bi-dash"></i>
</label>
<input id="@(this.Model.OrderById)__1" name="@this.Model.OrderByName" type="radio" value="-1" @isChecked(this.Model.OrderBy == -1) class="d-none" />
<label for="@(this.Model.OrderById)__1" class="form-control form-control-sm text-center text-secondary border-light @bgColor(this.Model.OrderBy == -1) cursor-pointer">
<i class="bi bi-chevron-down"></i>
</label>
</div>
@@ -0,0 +1,27 @@
@model LaaProductionWeb.Services.Models.HeliumReportFilterProperty
@{
Func<bool, string> isChecked = x => x ? "checked" : string.Empty;
Func<bool, string> bgColor = x => !x ? "bg-light" : string.Empty;
}
<input type="hidden" name="@this.Model.TypeName" value="@this.Model.Type" />
<input type="hidden" name="@this.Model.IndexName" value="@this.Model.Index" />
<input type="hidden" name="@this.Model.ColumnName" value="@this.Model.Column" />
<input type="hidden" name="@this.Model.PropertyName" value="@this.Model.Property" />
<input name="@this.Model.LikeName" class="form-control form-control-sm mb-1" autocomplete="off" value="@this.Model.Like" />
<div class="input-group flex-nowrap justify-content-center">
<input id="@(this.Model.OrderById)_1" name="@this.Model.OrderByName" type="radio" value="1" @isChecked(this.Model.OrderBy == 1) class="d-none" />
<label for="@(this.Model.OrderById)_1" class="form-control form-control-sm text-center text-secondary border-light @bgColor(this.Model.OrderBy == 1) cursor-pointer">
<i class="bi bi-chevron-up"></i>
</label>
<input id="@(this.Model.OrderById)_0" name="@this.Model.OrderByName" type="radio" value="0" @isChecked(this.Model.OrderBy == 0) class="d-none" />
<label for="@(this.Model.OrderById)_0" class="form-control form-control-sm text-center text-secondary border-light @bgColor(this.Model.OrderBy == 0) cursor-pointer">
<i class="bi bi-dash"></i>
</label>
<input id="@(this.Model.OrderById)__1" name="@this.Model.OrderByName" type="radio" value="-1" @isChecked(this.Model.OrderBy == -1) class="d-none" />
<label for="@(this.Model.OrderById)__1" class="form-control form-control-sm text-center text-secondary border-light @bgColor(this.Model.OrderBy == -1) cursor-pointer">
<i class="bi bi-chevron-down"></i>
</label>
</div>
@@ -0,0 +1,131 @@
@model LaaProductionWeb.Services.Models.HeliumReportModel
<form action="/Report" method="post" autocomplete="off" class="h-100" id="he_report">
<div class="table-responsive h-100 mh-100">
<table class="table table-sm table-bordered mb-0">
<thead class="bg-light">
<tr>
<th class="text-nowrap p-2">@this.Model.Display(x => x.FertigungNr)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.AuftragNr)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.PositionNr)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.SerialNr)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.IdentNr)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.HeId)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.HeTestId)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.PcbId)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Nennweite)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Baulaenge)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Typ)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Druck)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Temperatur)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.HeLakeRate)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.HeTestPressure)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.IsValid)</th>
<th class="p-2" style="min-width: 200px">@this.Model.Display(x => x.Text)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.TestDate)</th>
<th class="text-nowrap p-2">@this.Model.Display(x => x.Tester)</th>
</tr>
<tr>
@foreach (var filter in this.Model.Filter)
{
if (filter.Type == LaaProductionWeb.Services.Models.PropertyType.Date)
{
<td>@this.Html.Partial("DateFilter", filter)</td>
}
else
{
<td>@this.Html.Partial("Filter", filter)</td>
}
}
</tr>
</thead>
<tbody>
@foreach (var item in this.Model.Items)
{
<tr>
<td class="text-nowrap p-2">@item.FertigungNr</td>
<td class="text-nowrap p-2">@item.AuftragNr</td>
<td class="text-nowrap p-2">@item.PositionNr</td>
<td class="text-nowrap p-2">@item.SerialNr</td>
<td class="text-nowrap p-2">@item.IdentNr</td>
<td class="text-nowrap p-2">@item.HeId</td>
<td class="text-nowrap p-2">
<a class="text-decoration-none cursor-pointer" href="#@item.HeTestId">
@item.HeTestId
</a>
</td>
<td class="text-nowrap p-2">@item.PcbId</td>
<td class="text-nowrap p-2">@item.Nennweite</td>
<td class="text-nowrap p-2">@item.Baulaenge</td>
<td class="text-nowrap p-2">@item.Typ</td>
<td class="text-nowrap p-2">@item.Druck</td>
<td class="text-nowrap p-2">@item.Temperatur</td>
<td class="text-nowrap p-2">@item.HeLakeRate</td>
<td class="text-nowrap p-2">@item.HeTestPressure</td>
<td class="text-nowrap p-2"><i class="bi bi-bold @(item.IsValid ? "bi-check text-success" : "bi-x text-danger")"></i></td>
<td class="p-2">@item.Text</td>
<td class="text-nowrap p-2">@($"{item.TestDate:dd.MM.yyyy}")</td>
<td class="text-nowrap p-2">@item.Tester</td>
</tr>
}
</tbody>
</table>
</div>
</form>
<button id="modal_btn" class="d-none" data-bs-toggle="modal" data-bs-target="#modal"></button>
<!-- Modal -->
<div class="modal fade" id="modal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Testergebnisse</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table table-sm table-bordered">
<thead>
<tr>
<th>Test Id</th>
<th>Punkt Nr</th>
<th>Ergebniss</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
</div>
</div>
</div>
</div>
@section scripts {
<script>
let form = document.getElementById('he_report');
let inputFields = form
.querySelectorAll('input')
.forEach(x => x.onchange = () => form.submit());
let tbody = this.document.getElementById('tbody');
let modal = this.document.getElementById('modal');
let modalBtn = this.document.getElementById('modal_btn');
modal.addEventListener('hide.bs.modal', x => this.location.hash = '');
window.addEventListener('hashchange', function () {
tbody.innerHTML = null;
if (location.hash) {
let testId = location.hash.substring(1);
if (testId) {
fetch(`/Report/Results?testId=${testId}`)
.then(response => response.text())
.then(function (html) {
tbody.innerHTML = html;
modalBtn.click();
})
.catch(x => console.log(x));
}
}
});
</script>
}
@@ -0,0 +1,10 @@
@model IEnumerable<LaaProductionWeb.Services.Models.HeliumPressurePoint>
@foreach (var item in this.Model)
{
<tr>
<td>@item.TestId</td>
<td>@item.PointNr</td>
<td>@item.Result</td>
</tr>
}
@@ -1,5 +1,7 @@
@model LaaProductionWeb.Services.Models.OrderPositions
<li><span class="dropdown-item">Alle</span></li>
@foreach (var position in this.Model)
{
<li><span class="dropdown-item">@position</span></li>
@@ -13,6 +13,8 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg" href="~/favicon.svg">
@Styles.Render("~/bootstrap_css")
@Styles.Render("~/bootstrap_icons")
@Styles.Render("~/styles_css")
@@ -33,6 +35,9 @@
<li class="nav-item">
<a class="nav-link text-smallcaps" href="/Protocol">Prüfprotokoll</a>
</li>
<li class="nav-item">
<a class="nav-link text-smallcaps" href="/Report">[He] Report</a>
</li>
</ul>
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item">
@@ -2,71 +2,88 @@
@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>
@if (!string.IsNullOrWhiteSpace(this.Model.ClientName))
{
<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 class="table table-borderless">
<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>
<th colspan="2" class="fs-5">Paletten Begleitschein</th>
<th colspan="2" class="fs-5">@this.Model.ClientName</th>
</tr>
<tr>
<th class="py-1 white-space-nowrap">Kunden-Auftrag</th>
<td class="py-1">@this.Model.OrderNr</td>
<th class="py-1 white-space-nowrap">Fertigungsauftrags-Nr.</th>
<td class="py-1">@this.Model.ProductionOrderNr</td>
</tr>
</thead>
<tbody>
@{
var count = 1;
var isFirst = true;
foreach (var item in this.Model.Items)
foreach (var position in this.Model.Positions)
{
<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>
<th class="py-1">@(isFirst ? "Position Nr" : string.Empty)</th>
<td class="py-1">@position.PositionNr</td>
<th class="py-1">@(isFirst ? "Bezeichnung" : string.Empty)</th>
<td class="py-1">@position.Description</td>
</tr>
isFirst = false;
}
}
</tbody>
</table>
<tr>
<th class="py-1 white-space-nowrap">Palettemenge</th>
<td class="py-1">@this.Model.ItemsCount</td>
<th class="py-1 white-space-nowrap">Auftragsmenge</th>
<td class="py-1">@this.Model.TotlalItemsCount</td>
</tr>
</table>
<table class="table table-borderless table-striped">
<thead>
<tr>
<th>Nr.</th>
<th class="w-100">(Pos) 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.PositionNr) @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>
</div>
}
@@ -17,10 +17,9 @@
<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.TextBoxFor(x => x.PositionNr, new { id = "pos_nr", @class = "form-control bg-white cursor-pointer", placeholder = "0000000000", @readonly = "readonly" })
@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>
<i class="bi bi-chevron-down" style="position: absolute;right: 3.5%;top: 35%;" data-bs-toggle="dropdown"></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>
@@ -31,14 +30,12 @@
</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>
@@ -97,15 +94,6 @@
.submit();
});
orderNrMenu.classList.remove(show);
if (orderChanged) {
orderChanged = false;
positionNrInput.value = positionNrMenu
.querySelector(dropdownItemSelector)
.innerHTML;
document
.getElementById('order_form')
.submit();
}
}
function getPositions(orderNr) {
@@ -18,16 +18,31 @@
<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">Kunden-Auftrag</td>
<td class="py-0 fw-normal">@this.Model.OrderNr</td>
<td class="py-0 white-space-nowrap">Fertigungsauftrags-Nr.</td>
<td class="py-0 fw-normal">@this.Model.ProductionOrderNr</td>
</tr>
@{
var isFirst = true;
foreach (var position in this.Model.Positions)
{
<tr>
<td class="py-0">@(isFirst ? "Position Nr" : string.Empty)</td>
<td class="py-0 fw-normal">@position.PositionNr</td>
<td class="py-0">@(isFirst ? "Bezeichnung" : string.Empty)</td>
<td class="py-0 fw-normal">@position.Description</td>
</tr>
isFirst = false;
}
}
<tr>
<td class="py-0 white-space-nowrap">Palettenmenge</td>
<td class="py-0 fw-normal">@this.Model.ItemsCount</td>
<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>
@@ -35,10 +50,10 @@
</tr>
<tr>
<th class="small">No.</th>
<th class="small">Serial No.</th>
<th class="small">Pos.</th>
<th class="small"></th>
<th class="small">No.</th>
<th class="small">Serial No.</th>
<th class="small">Pos.</th>
<th class="small"></th>
</tr>
</thead>
@@ -49,26 +64,28 @@
var item = items[i];
<tr>
<td class="va-middle">@(i + 1)</td>
<td class="va-middle">@item.BarcodeNr</td>
<td class="va-middle">
<td class="fs-5">@(i + 1).</td>
<td class="fs-5">@item.PositionNr</td>
<td class="py-0">
<svg class="barcode"
jsbarcode-height="50"
jsbarcode-height="70"
jsbarcode-format="auto"
jsbarcode-displayValue="false"
jsbarcode-displayValue="true"
jsbarcode-textMargin="0"
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">
<td class="fs-5" >@(ni + 1).</td>
<td class="fs-5">@nitem.PositionNr</td>
<td class="py-0">
<svg class="barcode"
jsbarcode-height="50"
jsbarcode-height="70"
jsbarcode-format="auto"
jsbarcode-displayValue="false"
jsbarcode-displayValue="true"
jsbarcode-textMargin="0"
jsbarcode-background="transparent"
jsbarcode-value="@nitem.BarcodeNr" />
</td>
@@ -1,51 +1,53 @@
@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)
@if (this.Model.OrderNr > 0)
{
<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))
{
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" />
<div class="text-danger small">
@($"{errorMessage}")
</div>
}
<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 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>
<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>
</form>
}
@@ -0,0 +1,26 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 275.27 123.65">
<defs>
<style>.cls-1{fill:#71d54c;}.cls-2{fill:#003895;}.cls-3{fill:#078ab1;}</style>
</defs>
<title>sensus_xylem_logo</title>
<g id="Layer_2" data-name="Layer 2">
<g id="Layer_1-2" data-name="Layer 1">
<rect class="cls-1" x="47.04" width="37.99" height="7.14"/>
<rect class="cls-1" x="47.04" y="11.65" width="37.99" height="7.14"/>
<rect class="cls-1" x="47.04" y="23.29" width="37.99" height="7.14"/>
<path class="cls-2" d="M124.94,35h-22.3c-7.14,0-9.31,2.08-9.31,8.9v27.5h9.14V42.71h22.64V71.36h9.14V43.86c0-6.82-2.18-8.9-9.31-8.9"/>
<path class="cls-2" d="M219.87,35V63.61H197.23V35h-9.14v27.5c0,6.82,2.18,8.9,9.31,8.9h22.3c7.14,0,9.31-2.08,9.31-8.9V35Z"/>
<path class="cls-2" d="M55.38,35c-6.82,0-8.91,2.18-8.91,9.31V62.05c0,7.14,2.08,9.31,8.91,9.31H85V63.61H55v-7H85V49.2H55v-7H85V35Z"/>
<path class="cls-2" d="M38.4,42.23V35H9.31C2.18,35,0,37,0,43.86v3.89c0,6.82,2.18,8.9,9.31,8.9H30.78v7H0v7.75H29.76c7.1,0,9.38-2.16,9.38-8.9V57.61c0-6.74-2.28-8.9-9.38-8.9H8.3V42.23Z"/>
<path class="cls-2" d="M179.92,42.23V35H150.83c-7.14,0-9.32,2.08-9.32,8.9v3.89c0,6.82,2.18,8.9,9.32,8.9h21.46v7H141.52v7.75h29.76c7.1,0,9.38-2.16,9.38-8.9V57.61c0-6.74-2.28-8.9-9.38-8.9H149.82V42.23Z"/>
<path class="cls-2" d="M274.53,42.23V35H245.44c-7.14,0-9.31,2.08-9.31,8.9v3.89c0,6.82,2.17,8.9,9.31,8.9H266.9v7H236.13v7.75h29.75c7.1,0,9.39-2.16,9.39-8.9V57.61c0-6.74-2.28-8.9-9.39-8.9H244.43V42.23Z"/>
<path class="cls-3" d="M68.21,103.11c0-3-1.66-4.54-4.69-4.54a7.49,7.49,0,0,0-5.23,2.07l-1.42-1.7a9.79,9.79,0,0,1,6.9-2.51c3.8,0,6.84,2.1,6.84,6.38v7.7a23.25,23.25,0,0,0,.3,4h-2.3a19,19,0,0,1-.26-2.86h-.06a7,7,0,0,1-6.38,3.31c-2.67,0-6.1-1.43-6.1-5.33,0-5.42,6-5.9,12.4-5.9Zm-.75,2.55c-4.16,0-9,.46-9,3.8,0,2.51,2.13,3.33,4.13,3.33A5.48,5.48,0,0,0,68.21,107v-1.31Z"/>
<path class="cls-3" d="M190.39,111.47v3h-2.55V86.07h2.55V99.92h.07a8,8,0,0,1,6.65-3.49c5.49,0,9.09,4.05,9.09,9.23s-3.6,9.24-9.09,9.24a8.08,8.08,0,0,1-6.65-3.43Zm6.47-12.91a7.09,7.09,0,0,0,0,14.16c4.22,0,6.64-3.15,6.64-7.06s-2.41-7.09-6.64-7.09"/>
<path class="cls-3" d="M209.09,96.87h2.46c.06.95.15,2.25.15,3h.07a6.25,6.25,0,0,1,5.64-3.45,6.58,6.58,0,0,1,1.68.18l-.34,2.4a6.89,6.89,0,0,0-1.8-.22c-2.7,0-5.15,2-5.15,6.65v9h-2.55V100.74c0-.94,0-2.66-.16-3.87"/>
<path class="cls-3" d="M232.09,103.11c0-3-1.66-4.54-4.69-4.54a7.46,7.46,0,0,0-5.23,2.07l-1.41-1.7a9.74,9.74,0,0,1,6.89-2.51c3.8,0,6.84,2.1,6.84,6.38v7.7a24.22,24.22,0,0,0,.31,4h-2.3a18.26,18.26,0,0,1-.26-2.86h-.07a7.05,7.05,0,0,1-6.39,3.31c-2.66,0-6.07-1.43-6.07-5.33,0-5.42,6-5.9,12.39-5.9Zm-.75,2.55c-4.18,0-9,.46-9,3.8,0,2.51,2.14,3.33,4.13,3.33a5.48,5.48,0,0,0,5.64-5.82v-1.31Z"/>
<path class="cls-3" d="M241.1,96.87c.06.95.16,2.25.16,3h.07a6.85,6.85,0,0,1,6-3.45c4.47,0,6.68,2.89,6.68,7.25v10.78h-2.55v-9.73c0-3.67-1.08-6.16-4.77-6.16-2.69,0-5.33,2.18-5.33,6.87v9h-2.55V100.74c0-.94,0-2.66-.14-3.87Z"/>
<path class="cls-3" d="M266,114.9c-5.49,0-9.09-4.06-9.09-9.24s3.59-9.23,9.09-9.23a8,8,0,0,1,6.65,3.49h.07V86.07h2.55v28.39h-2.55v-3h-.07A8.1,8.1,0,0,1,266,114.9m.27-2.18a6.71,6.71,0,0,0,6.75-7.06c0-4-2.81-7.09-6.75-7.09-4.24,0-6.64,3.19-6.64,7.09s2.4,7.06,6.64,7.06"/>
<path class="cls-3" d="M176.07,111.18v3.28h-1.85c-3.13,0-4.65-1.63-4.65-5.28v-5.72c0-1.79-.56-3.63-2.82-3.63s-3,1.84-3,3.63v11h-4v-11c0-1.79-.78-3.63-3.09-3.63s-3.06,1.84-3.06,3.63v11h-3.92V103.32c0-4.35,2.8-7,7-7a6.78,6.78,0,0,1,5.09,2.06,6.77,6.77,0,0,1,5.08-2.06c3.85,0,6.59,2.48,6.59,7v5.91c0,1.35.62,1.95,1.76,1.95Zm-30.61.47a11.42,11.42,0,0,1-7.74,3.07c-5.88,0-9.35-3.82-9.35-9.22s3.73-9.23,9-9.23c5.48,0,8.82,4.25,8.82,9.53,0,.66-.05,1.33-.05,1.33h-13.7c.51,2.59,2.1,4.22,5.28,4.22a7.37,7.37,0,0,0,5.21-2.17Zm-13-7.63h9.73c-.45-2.66-2.2-4.39-4.78-4.39s-4.39,1.79-5,4.39M120,109c0,3.83,1.58,5.42,4.83,5.42h1.78v-3.37h-.84c-1.2,0-1.87-.59-1.87-2.05V86.95H120Zm-10.95,2H109c-1,0-1.55-1.49-2.54-4.18l-1.64-4.52c-1.54-4.21-3.1-6.11-6.66-6.11-3,0-4.52,1.81-6.38,4.32L90.4,102.4,86,96.56H81.39l6.69,8.77-2.61,3.51c-1.34,1.8-2.16,2.34-3.31,2.34h-.78v3.28h1.67a4.91,4.91,0,0,0,4.41-2.27l2.86-4,4.6,6.29h4.69l-7-9.21,1.74-2.3c1.58-2.11,2.33-3.12,3.67-3.12s2.12,1.31,3.32,4.36l2,5.09c1.15,3,2.26,5.17,4.29,5.17h.26l-1,2.58c-.8,2-1.56,3.28-3.67,3.28h-.92v3.33h1.34c3.13,0,5.36-1.54,6.81-5.59l7.73-21.51H114Z"/>
</g>
</g>
</svg>
@@ -1,13 +0,0 @@
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": [
{
"library": "bootstrap@5.2.3",
"destination": "App_Content/",
"files": [
"css/bootstrap.min.css.map"
]
}
]
}