144 lines
3.9 KiB
C#
144 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Controls;
|
|
using ProductionUiCordonelLegacy.ProductionProcesses.Enum;
|
|
using ProductionUiCordonelLegacy.UserControls.FinalTest;
|
|
|
|
namespace ProductionUiCordonelLegacy.ProductionProcesses.Actions
|
|
{
|
|
public class ProductionProcessDone : BaseProductionProcess
|
|
{
|
|
public event EventHandler<Tuple<Boolean,Boolean, Boolean>> isDone;
|
|
private UcDialog UserControl;
|
|
public DialogResult Result = DialogResult.None;
|
|
public enum DialogResult
|
|
{
|
|
None,
|
|
Retry,
|
|
Print,
|
|
Abort
|
|
}
|
|
public Boolean DialogIsDone { get; }
|
|
private Boolean Error;
|
|
public ProductionProcessDone(Boolean error = false)
|
|
{
|
|
Error = error;
|
|
DialogIsDone = false;
|
|
name = "Fertig";
|
|
currentProcessState = ProductionProcessState.Waiting;
|
|
}
|
|
public override void InitUserControl()
|
|
{
|
|
UserControl = new UcDialog();
|
|
}
|
|
|
|
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;
|
|
var retry = false;
|
|
var abort = false;
|
|
var print = false;
|
|
if (Error)
|
|
{
|
|
switch (Result)
|
|
{
|
|
|
|
case DialogResult.Retry:
|
|
retry = true;
|
|
break;
|
|
case DialogResult.Print:
|
|
abort = true;
|
|
print = true;
|
|
break;
|
|
case DialogResult.Abort:
|
|
abort = true;
|
|
break;
|
|
}
|
|
}
|
|
isDone?.Invoke(null, new Tuple<Boolean, Boolean,Boolean>(retry, abort, print));
|
|
}
|
|
|
|
private void StepError(String ErrorText = "Ein Fehler ist aufgetreten")
|
|
{
|
|
|
|
UserControl.SetDesc(ErrorText);
|
|
var errorOptionList = new List<UcDialog.DialogOption>();
|
|
var retry = new UcDialog.DialogOption("Wiederholen", "Alle Schritte werden wiederholt", () =>
|
|
{
|
|
Result = DialogResult.Retry;
|
|
StepDone();
|
|
|
|
});
|
|
|
|
var Abort = new UcDialog.DialogOption("Abbruch", "Diesen Zähler NICHT verpacken", () =>
|
|
{
|
|
Result = DialogResult.Abort;
|
|
StepDone();
|
|
|
|
});
|
|
var print = new UcDialog.DialogOption("Rückläuferschein drucken", "Rückläuferschein beim Zähler lassen und auf Klärung durch QS warten", () =>
|
|
{
|
|
Result = DialogResult.Print;
|
|
StepDone();
|
|
|
|
});
|
|
|
|
|
|
errorOptionList.Add(retry);
|
|
errorOptionList.Add(Abort);
|
|
errorOptionList.Add(print);
|
|
|
|
UserControl.SetDialogOptions(errorOptionList);
|
|
}
|
|
|
|
private void StepSuccsess()
|
|
{
|
|
|
|
UserControl.SetDesc("Zähler verpacken");
|
|
var OptionList = new List<UcDialog.DialogOption>();
|
|
var retry = new UcDialog.DialogOption("Ok", "", () =>
|
|
{
|
|
Result = DialogResult.None;
|
|
StepDone();
|
|
|
|
});
|
|
|
|
|
|
OptionList.Add(retry);
|
|
|
|
UserControl.SetDialogOptions(OptionList);
|
|
}
|
|
|
|
public override void StartProcess()
|
|
{
|
|
if (Error)
|
|
{
|
|
StepError();
|
|
}
|
|
else
|
|
{
|
|
StepSuccsess();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|