using System; using System.Collections.Generic; using System.Windows.Controls; using Newtonsoft.Json; using ProductionUiCordonelLegacy.ProductionProcesses.Enum; using ProductionUiCordonelLegacy.UserControls.FinalTest; using Xylem.Common.CommonCore.Configuration; using Xylem.Common.Logic.ProductionOrderCore.Vako; using Xylem.Common.Logic.SoftwareAccessHelper; namespace ProductionUiCordonelLegacy.ProductionProcesses.Actions { public class ProductionProcessCheckAttachment : BaseProductionProcess { public event EventHandler isDone; private UcDialog UserControl; public DialogResult Result = DialogResult.Error; public enum DialogResult { Error, Acknowledge } public Boolean DialogIsDone { get; } public Int32 OrderNumber { get; set; } public ProductionProcessCheckAttachment(Int32 orderNumber) { OrderNumber = orderNumber; DialogIsDone = false; name = "Zubehör/Beigaben überprüfen"; 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; isDone?.Invoke(null, EventArgs.Empty); } private void StepError() { currentProcessState = ProductionProcessState.Error; isDone?.Invoke(null, EventArgs.Empty); } public override void StartProcess() { try { var a = LocalWebRequest.GetRequest($"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetSingleVakoKey?ProductionOrderNumber={OrderNumber}&KeyName=C_GEN_PULS"); var myJsonResponse = JsonConvert.DeserializeObject(a); if (myJsonResponse.Value.ToLower() == "q" || myJsonResponse.Value.ToLower() == "k") { UserControl.SetDesc("Pulse Module anbauen!"); } else { StepDone(); } } catch (Exception) { UserControl.SetDesc("Bitte den Auftrag prüfen ob ein Pulse Module verbaut werden soll"); } var OptionList = new List(); var retry = new UcDialog.DialogOption("Nicht möglich", "", () => { Result = DialogResult.Error; StepError(); }); OptionList.Add(retry); var Acknowledge = new UcDialog.DialogOption("Erledigt", "", () => { Result = DialogResult.Acknowledge; StepDone(); }); OptionList.Add(Acknowledge); UserControl.SetDialogOptions(OptionList); } } }