122 lines
3.4 KiB
C#
122 lines
3.4 KiB
C#
using System;
|
|
using System.Windows.Controls;
|
|
using ProductionUiCordonelLegacy.ProductionProcesses.Enum;
|
|
using ProductionUiCordonelLegacy.UserControls.FinalTest;
|
|
|
|
namespace ProductionUiCordonelLegacy.ProductionProcesses.Actions
|
|
{
|
|
public class ProductionProcessCheckSerialNumber : BaseProductionProcess
|
|
{
|
|
public event EventHandler isDone;
|
|
private UcBarcodeInput UserControl;
|
|
public DialogResult Result = DialogResult.None;
|
|
public enum DialogResult
|
|
{
|
|
None,
|
|
Retry,
|
|
Print,
|
|
Abort
|
|
}
|
|
public Boolean DialogIsDone { get; }
|
|
public String PcbSerialNumber {
|
|
get;
|
|
private set; }
|
|
|
|
public String AltRadio { get; }
|
|
|
|
public ProductionProcessCheckSerialNumber(String pcbSerialNumber, String altRadio = null)
|
|
|
|
{
|
|
PcbSerialNumber = pcbSerialNumber;
|
|
AltRadio = altRadio;
|
|
DialogIsDone = false;
|
|
name = "Überprüfe Seriennummer/Deckel";
|
|
currentProcessState = ProductionProcessState.Waiting;
|
|
}
|
|
public override void InitUserControl()
|
|
{
|
|
UserControl = new UcBarcodeInput();
|
|
}
|
|
|
|
public override UserControl GetControl()
|
|
{
|
|
if (UserControl == null)
|
|
{
|
|
throw new Exception($"UserControl {GetType()} not Ready");
|
|
}
|
|
return UserControl;
|
|
}
|
|
|
|
|
|
public override void ProcessDone()
|
|
{
|
|
//clear
|
|
}
|
|
|
|
private void StepDone()
|
|
{
|
|
currentProcessState = ProductionProcessState.Done;
|
|
isDone?.Invoke(this, EventArgs.Empty);
|
|
}
|
|
|
|
private void StepMismatch(String msg)
|
|
{
|
|
currentProcessState = ProductionProcessState.Error;
|
|
NewStatus(msg);
|
|
isDone?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
|
|
|
}
|
|
|
|
private void UserControl_KeyDown(Object sender, String input)
|
|
{
|
|
var a = input;
|
|
//PcbSerialNumber = Meter.SerialNumber;
|
|
UserControl.txtHiddenInput.Text = "";
|
|
if (a.Trim().Contains(PcbSerialNumber.Trim()))
|
|
{
|
|
StepDone();
|
|
}
|
|
else
|
|
{
|
|
if (PcbSerialNumber.Contains("/") && (a.Trim().Replace(" ", "").Contains(PcbSerialNumber.Split('/')[0].Trim().Replace(" ", "")) || a.Trim().Replace(" ", "").Contains(PcbSerialNumber.Split('/')[1].Trim().Replace(" ", ""))))
|
|
{
|
|
StepDone();
|
|
}
|
|
else
|
|
{
|
|
|
|
if (AltRadio != null && a.Trim().Contains(AltRadio.Trim()))
|
|
{
|
|
StepDone();
|
|
}
|
|
else
|
|
{
|
|
|
|
StepMismatch($"Falsche oder fehlerhafter Scan! {Environment.NewLine} Dieser Zähler müsste die ({PcbSerialNumber}) haben. gescannt wurde {a}");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//StepDone();
|
|
}
|
|
|
|
public override void StartProcess()
|
|
{
|
|
//PcbSerialNumber = Meter.SerialNumber;
|
|
UserControl.SetDesc($"Bitte den Deckel des Zählers Scannern{Environment.NewLine} Die Seriennummer muss abgeglichen werden.");
|
|
UserControl.SetFocusMe();
|
|
UserControl.BarcodeInput += UserControl_KeyDown;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|