VSFM omni - reprint labels

This commit is contained in:
Stoyan Zlatev 2024-07-05 10:58:03 +02:00
parent 926676931e
commit c5ecb784bb
7 changed files with 346 additions and 147 deletions

View File

@ -25,6 +25,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<NoWarn>IDE0003;IDE0049;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -59,6 +60,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Converters\BooleanInverterConverter.cs" />
<Compile Include="Converters\BooleanToVisibilityConverter.cs" />
<Compile Include="Converters\ProcessstateToColorConverter.cs" />
<Compile Include="Converters\ProcessStateToImageConverter.cs" />
<Compile Include="Converters\ProcessStateToImageSourceConverter.cs" />

View File

@ -0,0 +1,25 @@
namespace Common.UI.VFM.Converters
{
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
public class BooleanToVisibilityConverter : IValueConverter
{
public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
{
if (value is Boolean visible && visible)
{
return Visibility.Visible;
}
return Visibility.Collapsed;
}
public Object ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -9,6 +9,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
@ -20,7 +21,7 @@
private readonly IHttpClient http;
private readonly SQLConnection sql;
private readonly OmniConnection omni;
private OmniValuesModel defaults;
private OmniValuesModel values;
public OmniShipmentModel(String portName, String sqlConnectionString, String labelsURL)
{
@ -44,9 +45,20 @@
?? key.Name
, val => (Func<ProcessResult>)val.CreateDelegate(typeof(Func<ProcessResult>), this));
internal Boolean WasPrinted()
=> this.sql
.CreateCommand($@"
SELECT COUNT(*)
FROM [OmniExport]
WHERE [CustomerSN] = @{nameof(this.CustId)}
AND [PCBAID] = @{nameof(this.MeterPcb)}")
.SetParameter(nameof(this.MeterPcb), this.MeterPcb)
.SetParameter(nameof(this.CustId), this.CustId)
.FirstOrDefault(x => x.GetValue<Int32>(0)) == 1;
internal void Initialize()
{
this.defaults = new OmniValuesModel();
this.values = new OmniValuesModel();
this.omni.UseUniPro(this.portName);
this.omni.StartRecording();
@ -75,7 +87,7 @@
}
[Display(Name = "Produktionsauftragsdaten laden")]
private ProcessResult LoadProductionOrderData()
internal ProcessResult LoadProductionOrderData()
{
var any = this.sql
.CreateCommand($@"
@ -84,11 +96,13 @@
, [ap].[FertigungsauftragNr]
, [ap].[IdentNr]
, [ap].[Menge]
, (SELECT COUNT([apsn].[KundeneigeneSerienNr])
FROM [AuftragPositionSerienNr] AS [apsn]
WHERE [apsn].[AuftragNr] = [ap].[AuftragNr]
AND [apsn].[PositionNr] = [ap].[PositionNr]
AND [apsn].[StatusFertigung] = 30) + 1
, (SELECT TOP 1 [x].[Nr]
FROM (SELECT [apsn].[SerienNr]
, ROW_NUMBER() OVER (PARTITION BY [apsn].[PositionNr] ORDER BY [apsn].[SerienNr]) AS [Nr]
FROM [AuftragPositionSerienNr] AS [apsn]
WHERE [apsn].[AuftragNr] = [ap].[AuftragNr]
AND [apsn].[PositionNr] = [ap].[PositionNr]) AS [x]
WHERE [x].[SerienNr] = [aps].[SerienNr])
AS [BoxNr]
, [aps].[SerienNr]
, [aps].[KundeneigeneSerienNr]
@ -108,20 +122,20 @@
.SetParameter(nameof(this.CustId), this.CustId)
.FirstOrDefault(reader =>
{
this.defaults.Orderno = reader.GetValue<Int32>(0);
this.defaults.Positionno = reader.GetValue<Int16>(1);
this.defaults.ProductionOrderno = reader.GetValue<Int32>(2);
this.defaults.OrderIdentno = reader.GetValue<Int32>(3);
this.defaults.Count = reader.GetValue<Int32>(4);
this.defaults.Boxno = reader.GetValue<Int32>(5);
this.defaults.Serialno = reader.GetValue<Int32>(6);
this.defaults.DbCustId = reader.GetValue<String>(7);
this.defaults.FactId = reader.GetValue<Int32>(8);
this.defaults.ProductionStatus = reader.GetValue<Byte>(9);
this.defaults.Partno = reader.GetValue<String>(10);
this.defaults.DescriptionL1 = reader.GetValue<String>(11);
this.defaults.DescriptionL2 = reader.GetValue<String>(12);
this.defaults.Variant = reader.GetValue<String>(13);
this.values.Orderno = reader.GetValue<Int32>(0);
this.values.Positionno = reader.GetValue<Int16>(1);
this.values.ProductionOrderno = reader.GetValue<Int32>(2);
this.values.OrderIdentno = reader.GetValue<Int32>(3);
this.values.Count = reader.GetValue<Int32>(4);
this.values.Boxno = reader.GetValue<Int32>(5);
this.values.Serialno = reader.GetValue<Int32>(6);
this.values.DbCustId = reader.GetValue<String>(7);
this.values.FactId = reader.GetValue<Int32>(8);
this.values.ProductionStatus = reader.GetValue<Byte>(9);
this.values.Partno = reader.GetValue<String>(10);
this.values.DescriptionL1 = reader.GetValue<String>(11);
this.values.DescriptionL2 = reader.GetValue<String>(12);
this.values.Variant = reader.GetValue<String>(13);
return true;
});
@ -131,7 +145,7 @@
return new ProcessResult
{
State = ProcessState.Warning,
Message = $"{this.defaults.DescriptionL1} - {(this.defaults.Variant.StartsWith("R", StringComparison.InvariantCultureIgnoreCase) ? "SCHWARZE" : "GRAUE")} AUSFÜHRUNG!!!",
Message = $"{this.values.DescriptionL1} - {(this.values.Variant.StartsWith("R", StringComparison.InvariantCultureIgnoreCase) ? "SCHWARZE" : "GRAUE")} AUSFÜHRUNG!!!",
};
}
else
@ -145,7 +159,7 @@
}
[Display(Name = "Prüfungsgebnisse laden")]
private ProcessResult LoadProductionTestData()
internal ProcessResult LoadProductionTestData()
{
var testIdentNr = default(Int32);
var descriptionL1 = default(String);
@ -162,6 +176,7 @@
, [TR].[Succeeded]
, [TR].[CrrfAfter]
, [TR].[Id]
, [TR].[ManifacturingTime]
, [OD].[IdentNr]
, [OD].[DescriptionL1]
FROM [OmniTestRuns] AS [TR]
@ -178,26 +193,31 @@
.SetParameter(nameof(this.MeterPcb), this.MeterPcb)
.FirstOrDefault(reader =>
{
this.defaults.MaxGPM = reader.GetValue<Double>(0);
this.defaults.MaxACC = reader.GetValue<Double>(1);
this.defaults.MidGPM = reader.GetValue<Double>(2);
this.defaults.MidACC = reader.GetValue<Double>(3);
this.defaults.MinGPM = reader.GetValue<Double>(4);
this.defaults.MinACC = reader.GetValue<Double>(5);
this.defaults.TestDate = reader.GetValue<DateTime>(6);
this.defaults.Succeeded = reader.GetValue<Boolean>(7);
this.defaults.CalibrationFactor = reader.GetValue<Single>(8);
this.defaults.TestRunId = reader.GetValue<Int32>(9);
this.values.MaxGPM = reader.GetValue<Double>(0);
this.values.MaxACC = reader.GetValue<Double>(1);
this.values.MidGPM = reader.GetValue<Double>(2);
this.values.MidACC = reader.GetValue<Double>(3);
this.values.MinGPM = reader.GetValue<Double>(4);
this.values.MinACC = reader.GetValue<Double>(5);
this.values.TestDate = reader.GetValue<DateTime>(6);
this.values.Succeeded = reader.GetValue<Boolean>(7);
this.values.CalibrationFactor = reader.GetValue<Single>(8);
this.values.TestRunId = reader.GetValue<Int32>(9);
this.values.ManifacturingTime = new SystemTime
{
DateTime = reader.GetValue<DateTime>(10)
}
.SecondsSince;
testIdentNr = reader.GetValue<Int32>(10);
descriptionL1 = reader.GetValue<String>(11);
testIdentNr = reader.GetValue<Int32>(11);
descriptionL1 = reader.GetValue<String>(12);
return true;
});
if (any)
{
if (!this.defaults.Succeeded)
if (!this.values.Succeeded)
{
return new ProcessResult
{
@ -205,7 +225,7 @@
Message = $"{this.MeterPcb} - wurde nicht erfolgreich geprüft!",
};
}
else if (this.defaults.OrderIdentno != testIdentNr)
else if (this.values.OrderIdentno != testIdentNr)
{
return new ProcessResult
{
@ -230,9 +250,9 @@
}
[Display(Name = "Standardwerte laden")]
private ProcessResult LoadDefaults()
internal ProcessResult LoadDefaultValues()
{
var identno = this.defaults.OrderIdentno;
var identno = this.values.OrderIdentno;
var any = this.sql
.CreateCommand($@"
SELECT [d].[Size]
@ -265,31 +285,31 @@
.SetParameter(nameof(identno), identno)
.FirstOrDefault(reader =>
{
this.defaults.Size = reader.GetValue<Byte>(0);
this.defaults.Range = reader.GetValue<Byte>(1);
this.defaults.Direction = reader.GetValue<Byte>(2);
this.defaults.IntPart = reader.GetValue<Byte>(3);
this.defaults.Fraction = reader.GetValue<UInt16>(4);
this.defaults.Crf = reader.GetValue<Int16>(5);
this.defaults.Ppr = reader.GetValue<Byte>(6);
this.defaults.MeterUnits = reader.GetValue<Byte>(7);
this.defaults.FlowUnits = reader.GetValue<Byte>(8);
this.defaults.FlowRate = reader.GetValue<Byte>(9);
this.defaults.PulseWeight = reader.GetValue<Byte>(10);
this.defaults.PulseWidth = reader.GetValue<Byte>(11);
this.defaults.PulseUpdate = reader.GetValue<Byte>(12);
this.defaults.AlarmPercistancePeriodDays = reader.GetValue<Byte>(13);
this.defaults.DataLogIntervalMinutes = reader.GetValue<Int32>(14);
this.defaults.NumberOfReadingDigits = reader.GetValue<Int16>(15);
this.defaults.OptionalUniDirFields = reader.GetValue<Int32>(16);
this.defaults.ReadingPreset = reader.GetValue<String>(17);
this.defaults.DeviceID = reader.GetValue<String>(18);
this.defaults.LeakAlarmGPM = reader.GetValue<Single>(19);
this.defaults.LeakAlarmTime = reader.GetValue<Int64>(20);
this.defaults.HighFlowAlarmGPM = reader.GetValue<Single>(21);
this.defaults.HighFlowAlarmTime = reader.GetValue<Int64>(22);
this.defaults.ReverseFlowAlarmGPM = reader.GetValue<Single>(23);
this.defaults.ReverseFlowAlarmTime = reader.GetValue<Int64>(24);
this.values.Size = reader.GetValue<Byte>(0);
this.values.Range = reader.GetValue<Byte>(1);
this.values.Direction = reader.GetValue<Byte>(2);
this.values.IntPart = reader.GetValue<Byte>(3);
this.values.Fraction = reader.GetValue<UInt16>(4);
this.values.Crf = reader.GetValue<Int16>(5);
this.values.Ppr = reader.GetValue<Byte>(6);
this.values.MeterUnits = reader.GetValue<Byte>(7);
this.values.FlowUnits = reader.GetValue<Byte>(8);
this.values.FlowRate = reader.GetValue<Byte>(9);
this.values.PulseWeight = reader.GetValue<Byte>(10);
this.values.PulseWidth = reader.GetValue<Byte>(11);
this.values.PulseUpdate = reader.GetValue<Byte>(12);
this.values.AlarmPercistancePeriodDays = reader.GetValue<Byte>(13);
this.values.DataLogIntervalMinutes = reader.GetValue<Int32>(14);
this.values.NumberOfReadingDigits = reader.GetValue<Int16>(15);
this.values.OptionalUniDirFields = reader.GetValue<Int32>(16);
this.values.ReadingPreset = reader.GetValue<String>(17);
this.values.DeviceID = reader.GetValue<String>(18);
this.values.LeakAlarmGPM = reader.GetValue<Single>(19);
this.values.LeakAlarmTime = reader.GetValue<Int64>(20);
this.values.HighFlowAlarmGPM = reader.GetValue<Single>(21);
this.values.HighFlowAlarmTime = reader.GetValue<Int64>(22);
this.values.ReverseFlowAlarmGPM = reader.GetValue<Single>(23);
this.values.ReverseFlowAlarmTime = reader.GetValue<Int64>(24);
return true;
});
@ -312,7 +332,7 @@
}
[Display(Name = "Zählerzustand ablesen")]
private ProcessResult LoadMeterState()
internal ProcessResult LoadMeterState()
{
var systemParameters = this.omni.ViewSystemParameters();
@ -351,15 +371,9 @@
if (manifacturingTime == 0)
{
manifacturingTime = new SystemTime
{
DateTime = new DateTime(2023, 12, 1, 0, 0, 0)
}
.SecondsSince;
manifacturingTime = this.values.ManifacturingTime;
}
this.defaults.ManifacturingTime = manifacturingTime;
var registerSettings = this.omni.ViewRegisterSettings();
if (!registerSettings.Completed)
@ -393,18 +407,18 @@
};
}
this.defaults.EheadPcb = eheadPcb.Value;
this.values.EheadPcb = eheadPcb.Value;
return new ProcessResult
{
State = ProcessState.Success,
Message = $"E-Head-PCB: {this.defaults.EheadPcb}"
Message = $"E-Head-PCB: {this.values.EheadPcb}"
};
}
[Display(Name = "System Reboot")]
private ProcessResult RebootMeter()
internal ProcessResult RebootMeter()
{
var systemReset = this.omni.Set(new SystemTime());
@ -426,25 +440,25 @@
}
[Display(Name = "Registereinstellungen Schreiben")]
private ProcessResult WriteRegisterSettings()
internal ProcessResult WriteRegisterSettings()
{
Thread.Sleep(5000);
var response = this.omni.Set(new RegisterSettings
{
IntPart = this.defaults.IntPart,
Fraction = (ushort)this.defaults.Fraction,
Size = this.defaults.Size,
Range = this.defaults.Range,
IntPart = this.values.IntPart,
Fraction = (ushort)this.values.Fraction,
Size = this.values.Size,
Range = this.values.Range,
VolumePerPulseUnit = 0x00,
MeterUnits = this.defaults.MeterUnits,
FlowUnits = this.defaults.FlowUnits,
FlowRate = this.defaults.FlowRate,
FactoryCorrection = (sbyte)(this.defaults.CalibrationFactor * 10),
MeterUnits = this.values.MeterUnits,
FlowUnits = this.values.FlowUnits,
FlowRate = this.values.FlowRate,
FactoryCorrection = (sbyte)(this.values.CalibrationFactor * 10),
FieldCorrection = 0x00,
PulseWeight = this.defaults.PulseWeight,
PulseWidth = this.defaults.PulseWidth,
PulseUpdate = this.defaults.PulseUpdate,
PulseWeight = this.values.PulseWeight,
PulseWidth = this.values.PulseWidth,
PulseUpdate = this.values.PulseUpdate,
});
if (!response.Completed)
@ -463,22 +477,22 @@
}
[Display(Name = "Konfigurationseinstellungen Schreiben")]
private ProcessResult WriteConfigurationParameters()
internal ProcessResult WriteConfigurationParameters()
{
var response = this.omni.Set(new ConfigurationParametersSet
{
BuildInfo = this.MeterPcb.Trim(),
ProgrammableID = this.CustId.Trim(),
FactoryID = this.defaults.FactId.ToString(),
AlarmPercistancePeriodDays = this.defaults.AlarmPercistancePeriodDays,
DataLogIntervalMinutes = (ushort)this.defaults.DataLogIntervalMinutes,
ManifacturingTime = this.defaults.ManifacturingTime,
NumberOfReadingDigits = (sbyte)this.defaults.NumberOfReadingDigits,
OptionalUniDirFields = (ushort)this.defaults.OptionalUniDirFields,
ReadingPreset = this.defaults.ReadingPreset,
FactoryID = this.values.FactId.ToString(),
AlarmPercistancePeriodDays = this.values.AlarmPercistancePeriodDays,
DataLogIntervalMinutes = (ushort)this.values.DataLogIntervalMinutes,
ManifacturingTime = this.values.ManifacturingTime,
NumberOfReadingDigits = (sbyte)this.values.NumberOfReadingDigits,
OptionalUniDirFields = (ushort)this.values.OptionalUniDirFields,
ReadingPreset = this.values.ReadingPreset,
RebootCount = 0,
SystemTime = Epoch20000101.UTCNow,
DeviceID = this.defaults.DeviceID
DeviceID = this.values.DeviceID
});
if (!response.Completed)
@ -497,7 +511,7 @@
}
[Display(Name = "Alarme einrichten")]
private ProcessResult SettingAlarms()
internal ProcessResult SettingAlarms()
{
var response = this.omni.ClearDisplay();
@ -512,8 +526,8 @@
response = this.omni.Set(new LeakAlarm
{
FlowRateGPM = this.defaults.LeakAlarmGPM,
TimeLimit = (uint)this.defaults.LeakAlarmTime
FlowRateGPM = this.values.LeakAlarmGPM,
TimeLimit = (uint)this.values.LeakAlarmTime
});
if (!response.Completed)
@ -527,8 +541,8 @@
response = this.omni.Set(new HighFlowAlarm
{
FlowRateGPM = this.defaults.HighFlowAlarmGPM,
TimeLimit = (uint)this.defaults.HighFlowAlarmTime
FlowRateGPM = this.values.HighFlowAlarmGPM,
TimeLimit = (uint)this.values.HighFlowAlarmTime
});
if (!response.Completed)
@ -542,8 +556,8 @@
response = this.omni.Set(new ReverseFlowAlarm
{
FlowRateGPM = this.defaults.ReverseFlowAlarmGPM,
TimeLimit = (uint)this.defaults.ReverseFlowAlarmTime
FlowRateGPM = this.values.ReverseFlowAlarmGPM,
TimeLimit = (uint)this.values.ReverseFlowAlarmTime
});
if (!response.Completed)
@ -605,7 +619,7 @@
}
[Display(Name = "OMNI versiegeln")]
private ProcessResult SealMeter()
internal ProcessResult SealMeter()
{
var response = this.omni.FactorySeal(true);
@ -687,7 +701,7 @@
};
}
if (configuration.FactoryID.Value != this.defaults.FactId.ToString())
if (configuration.FactoryID.Value != this.values.FactId.ToString())
{
return new ProcessResult
{
@ -704,25 +718,26 @@
}
[Display(Name = "Prüflabel drucken")]
private ProcessResult PrintTestLabel()
internal ProcessResult PrintTestLabel()
{
var body = new StringBuilder();
var culture = new CultureInfo("en-US");
body.AppendLine($"PcbId = {this.MeterPcb};");
body.AppendLine($"Orderno = {this.defaults.Orderno};");
body.AppendLine($"Posno = {this.defaults.Positionno};");
body.AppendLine($"TestDate = {this.defaults.TestDate:dd-MM-yyyy};");
body.AppendLine($"Partno = {this.defaults.Partno};");
body.AppendLine($"DescriptionL1 = {this.defaults.DescriptionL1};");
body.AppendLine($"DescriptionL2 = {this.defaults.DescriptionL2};");
body.AppendLine($"CustId = {this.defaults.DbCustId};");
body.AppendLine($"FactId = {this.defaults.FactId};");
body.AppendLine($"QmaxGPM = {this.defaults.MaxGPM:0.0};");
body.AppendLine($"QmidGPM = {this.defaults.MidGPM:0.0};");
body.AppendLine($"QminGPM = {this.defaults.MinGPM:0.0};");
body.AppendLine($"QmaxACC = {this.defaults.MaxACC:0.0};");
body.AppendLine($"QmidACC = {this.defaults.MidACC:0.0};");
body.AppendLine($"QminACC = {this.defaults.MinACC:0.0};");
body.AppendLine($"Orderno = {this.values.Orderno};");
body.AppendLine($"Posno = {this.values.Positionno};");
body.AppendLine($"TestDate = {this.values.TestDate:dd-MM-yyyy};");
body.AppendLine($"Partno = {this.values.Partno};");
body.AppendLine($"DescriptionL1 = {this.values.DescriptionL1};");
body.AppendLine($"DescriptionL2 = {this.values.DescriptionL2};");
body.AppendLine($"CustId = {this.values.DbCustId};");
body.AppendLine($"FactId = {this.values.FactId};");
body.AppendLine($"QmaxGPM = {this.values.MaxGPM.ToString("0.0", culture)};");
body.AppendLine($"QmidGPM = {this.values.MidGPM.ToString("0.00", culture)};");
body.AppendLine($"QminGPM = {this.values.MinGPM.ToString("0.00", culture)};");
body.AppendLine($"QmaxACC = {this.values.MaxACC.ToString("0.0", culture)};");
body.AppendLine($"QmidACC = {this.values.MidACC.ToString("0.0", culture)};");
body.AppendLine($"QminACC = {this.values.MinACC.ToString("0.0", culture)};");
var response = this.http
.PostRequest("/aspx/api.aspx")
@ -738,19 +753,19 @@
}
[Display(Name = "Kartonlabel drucken")]
private ProcessResult PrintBoxLabel()
internal ProcessResult PrintBoxLabel()
{
var body = new StringBuilder();
body.AppendLine($"CustId = {this.defaults.DbCustId};");
body.AppendLine($"Title = OMNI+™ ({this.defaults.Variant}) Chamber");
body.AppendLine($"DescriptionL1 = {this.defaults.DescriptionL1};");
body.AppendLine($"DescriptionL2 = {this.defaults.DescriptionL2};");
body.AppendLine($"Partno = {this.defaults.Partno};");
body.AppendLine($"Orderno = {this.defaults.Orderno};");
body.AppendLine($"CustId = {this.values.DbCustId};");
body.AppendLine($"Title = OMNI+™ ({this.values.Variant}) Chamber");
body.AppendLine($"DescriptionL1 = {this.values.DescriptionL1};");
body.AppendLine($"DescriptionL2 = {this.values.DescriptionL2};");
body.AppendLine($"Partno = {this.values.Partno};");
body.AppendLine($"Orderno = {this.values.Orderno};");
body.AppendLine($"BoxDate = {DateTime.Now:dd-MM-yyyy};");
body.AppendLine($"Boxno = {this.defaults.Boxno};");
body.AppendLine($"Quantity = {this.defaults.Count};");
body.AppendLine($"Boxno = {this.values.Boxno};");
body.AppendLine($"Quantity = {this.values.Count};");
var response = this.http
.PostRequest("/aspx/api.aspx")
@ -766,10 +781,10 @@
}
[Display(Name = "Daten Export")]
private ProcessResult ExportData()
internal ProcessResult ExportData()
{
var testRun = this.defaults.TestRunId;
var serialno = this.defaults.Serialno;
var testRun = this.values.TestRunId;
var serialno = this.values.Serialno;
var prueffehlerInfo = $"{DateTime.Now:dd-MM-yyyy HH:mm:ss}";
var created = this.sql
@ -805,14 +820,14 @@
, [tr].[Q10_Acc] - 100.0
, @{nameof(prueffehlerInfo)}
FROM [OmniTestRuns] AS [tr]
WHERE [Id] = @{nameof(testRun)}")
WHERE [tr].[Id] = @{nameof(testRun)}")
.SetParameter(nameof(testRun), testRun)
.SetParameter(nameof(serialno), serialno)
.SetParameter(nameof(prueffehlerInfo), prueffehlerInfo)
.ExecuteNonQuery() == 1;
var meterPcb = this.defaults.MeterPcb;
var eheadPcb = this.defaults.EheadPcb;
var meterPcb = this.values.MeterPcb;
var eheadPcb = this.values.EheadPcb;
var exported = this.sql
.CreateCommand($@"
@ -874,6 +889,39 @@
.SetParameter(nameof(eheadPcb), eheadPcb)
.ExecuteNonQuery() == 1;
var updated = this.sql
.CreateCommand($@"
UPDATE [AuftragPositionSerienNr]
SET [Pruefgangnr] = [y].[Pruefgang]
, [PruefgangDatum] = [y].[EndDate]
, [Wiederholungen] = [y].[Wiederholungen]
, [Einbauplatz] = [y].[SlotNr]
, [Bemerkung] = 'Inserted after omni export'
, [StatusFertigung] = 30
FROM [AuftragPositionSerienNr] AS [aps]
JOIN [OmniExport] AS [oe]
ON [oe].[ManufacturingSN] = [aps].[SerienNr]
JOIN (SELECT TOP 1
[Pruefgang]
, [EndDate]
, [Wiederholungen]
, [SlotNr]
, [BuildInfo]
FROM (SELECT ROW_NUMBER() OVER (PARTITION BY [BuildInfo] ORDER BY [Id]) AS [Wiederholungen]
, [BuildInfo]
, [Pruefgang]
, [EndDate]
, [SlotNr]
FROM [OmniTestRuns]
WHERE [BuildInfo] = @{nameof(this.MeterPcb)}
AND [Q1_TpId] IS NOT NULL)
AS [x]
ORDER BY [x].[Wiederholungen] DESC)
AS [y]
ON [oe].[PCBAID] = [y].[BuildInfo]")
.SetParameter(nameof(this.MeterPcb), this.MeterPcb)
.ExecuteNonQuery() == 1;
var state = ProcessState.Success;
var message = default(String);
@ -889,6 +937,12 @@
message = "Prueffehler wurde nicht Exportiert.\n";
}
if (!updated)
{
state = ProcessState.Warning;
message = "APS wurde nicht Aktualisiert.\n";
}
return new ProcessResult
{
State = state,

View File

@ -108,6 +108,6 @@
public Int64 ReverseFlowAlarmTime { get; set; }
public UInt32 ManifacturingTime { get; internal set; }
public UInt32 ManifacturingTime { get; set; }
}
}

View File

@ -19,19 +19,36 @@
this.model = new OmniShipmentModel(this.PortName, this.SqlConnectionString, this.LabelServer);
this.ResetProcessState = new Command(this.ResetProcessStateHandler);
this.StartProcessing = new Command(this.StartProcessingHandler);
this.ReprintBoxLable = new Command(this.ReprintBoxLableHandler);
this.ReprintTestLable = new Command(this.ReprintTestLableHandler);
this.Processes = new ObservableCollection<ProcessStepViewModel>(this.LoadProcesses());
}
public String CustId
{
get => this.model.CustId;
set => this.Set(() => this.model.CustId = value);
set => this.Set(() =>
{
this.model.CustId = value;
this.ReprintEnabled = !this.Proccessing && this.model.WasPrinted();
});
}
public String MeterPcb
{
get => this.model.MeterPcb;
set => this.Set(() => this.model.MeterPcb = value);
set => this.Set(() =>
{
this.model.MeterPcb = value;
this.ReprintEnabled = !this.Proccessing && this.model.WasPrinted();
});
}
private Boolean reprintEnabled;
public Boolean ReprintEnabled
{
get => this.reprintEnabled;
set => this.Set(() => this.reprintEnabled = value);
}
private String message;
@ -53,6 +70,10 @@
public ICommand StartProcessing { get; }
public ICommand ReprintBoxLable { get; }
public ICommand ReprintTestLable { get; }
public ObservableCollection<ProcessStepViewModel> Processes { get; }
private IEnumerable<ProcessStepViewModel> LoadProcesses()
@ -63,6 +84,68 @@
}
}
private void ReprintBoxLableHandler()
{
if (!this.Proccessing)
{
Task.Factory
.StartNew(state =>
{
if (state is ShipmnetViewModel viewModel)
{
viewModel.model.LoadProductionOrderData();
viewModel.model.LoadProductionTestData();
viewModel.model.LoadDefaultValues();
viewModel.model.PrintBoxLabel();
}
}, this, CancellationToken.None)
.ContinueWith(task =>
{
if (task.AsyncState is ShipmnetViewModel viewModel)
{
if (task.Exception != null)
{
viewModel.Message = task.Exception.Message;
}
viewModel.Proccessing = false;
}
});
}
}
private void ReprintTestLableHandler()
{
if (!this.Proccessing)
{
Task.Factory
.StartNew(state =>
{
if (state is ShipmnetViewModel viewModel)
{
viewModel.model.LoadProductionOrderData();
viewModel.model.LoadProductionTestData();
viewModel.model.LoadDefaultValues();
viewModel.model.PrintTestLabel();
}
}, this, CancellationToken.None)
.ContinueWith(task =>
{
if (task.AsyncState is ShipmnetViewModel viewModel)
{
if (task.Exception != null)
{
viewModel.Message = task.Exception.Message;
}
viewModel.Proccessing = false;
}
});
}
}
private void ResetProcessStateHandler()
{
if (!this.resetted)

View File

@ -6,6 +6,7 @@
<Application.Resources>
<C:BooleanInverterConverter x:Key="BooleanInverter" />
<C:BooleanToVisibilityConverter x:Key="BooleanToVisibility" />
<C:ProcessstateToColorConverter x:Key="ProcessstateToColor" />
<C:ProcessStateToImageConverter x:Key="ProcessStateToImage" />
<C:ProcessStateToImageSourceConverter x:Key="ProcessStateToImageSource" />

View File

@ -120,22 +120,56 @@
Grid.ColumnSpan="2"
Grid.Row="8"
Margin="0, 6, 0, 0" >
<StackPanel HorizontalAlignment="Stretch">
<TextBlock HorizontalAlignment="Right"
FontSize="13"
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock FontSize="13"
Foreground="DimGray"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="0"
HorizontalAlignment="Right"
Padding="0, 5"
Text="{Binding Message}"
TextWrapping="Wrap"
Visibility="{Binding Message, Converter={StaticResource StringToVisibility}}"/>
<Button Content="Start Processing"
Command="{Binding StartProcessing}"
<Button Command="{Binding ReprintBoxLable}"
Content="Kartonlabel drucken"
Cursor="Hand"
FontFamily="Verdana"
FontSize="13"
HorizontalAlignment="Right"
Grid.Column="0"
Grid.Row="1"
Visibility="{Binding ReprintEnabled, Converter={StaticResource BooleanToVisibility}}"
Margin="0, 0, 5, 0"
Padding="10, 4" />
<Button Command="{Binding ReprintTestLable}"
Content="Prüflabel drucken"
Cursor="Hand"
FontFamily="Verdana"
FontSize="13"
Grid.Column="1"
Grid.Row="1"
Visibility="{Binding ReprintEnabled, Converter={StaticResource BooleanToVisibility}}"
Margin="0, 0, 5, 0"
Padding="10, 4" />
<Button Command="{Binding StartProcessing}"
Content="VSFM Starten"
Cursor="Hand"
FontFamily="Verdana"
FontSize="13"
Grid.Column="3"
Grid.Row="1"
IsEnabled="{Binding Proccessing, Converter={StaticResource BooleanInverter}}"
Padding="10, 4" />
</StackPanel>
</Grid>
</Border>
</Grid>