public override void OnPackStationOverviewRunUndoPacking(WorkItem context, object caller, object target) { WorkItem wi = GetModuleWorkItem(context); if (wi.Items.FindByType <RunUndoPackingAction>().Count == 0) { wi.Items.AddNew <RunUndoPackingAction>(); } RunUndoPackingActionParameters actionParameters = null; PackStationOverviewViewToRunUndoPackingActionTranslator translator = null; if (context.Items.FindByType <PackStationOverviewViewToRunUndoPackingActionTranslator>().Count > 0) { translator = context.Items.FindByType <PackStationOverviewViewToRunUndoPackingActionTranslator>().Last(); } else { translator = context.Items.AddNew <PackStationOverviewViewToRunUndoPackingActionTranslator>(); } PackStationOverviewPresenter overviewPresenter = null; if (context.Items.FindByType <PackStationOverviewPresenter>().Count > 0) { overviewPresenter = context.Items.FindByType <PackStationOverviewPresenter>().Last(); } if (overviewPresenter == null) { return; } actionParameters = translator.Translate(overviewPresenter.ToLoadCarrierId); actionParameters.IsItemSelected = true; actionParameters.IsMultipleItemsSelected = false; IPackStationOverviewView view = context.SmartParts.FindByType <PackStationOverviewView>().Last(); try { ActionCatalog.Execute(ActionNames.RunUndoPacking, context, caller, actionParameters); // Check if view should be closed. bool ignoreClosing = ((context.Items.Get("IgnoreClose") != null) && ((bool)(context.Items.Get("IgnoreClose")))); overviewPresenter.ClearAllButPackedBy(); } catch (Imi.SupplyChain.UX.ValidationException ex) { view.HandleValidationResult(ValidationHelper.ConvertToResult((Imi.SupplyChain.UX.ValidationException)ex)); } }
public override void OnPackStationToLCRunFinishPackingWorkflow(WorkItem context, object caller, object target) { WorkItem wi = GetModuleWorkItem(context); if (wi.Items.FindByType <RunFinishPackingWorkflowAction>().Count == 0) { wi.Items.AddNew <RunFinishPackingWorkflowAction>(); } PackStationToLCViewResult viewResult = null; RunFinishPackingWorkflowActionParameters actionParameters = null; PackStationToLCViewToRunFinishPackingWorkflowActionTranslator translator = null; bool isItemSelected = false; if (context.Items.FindByType <PackStationToLCViewToRunFinishPackingWorkflowActionTranslator>().Count > 0) { translator = context.Items.FindByType <PackStationToLCViewToRunFinishPackingWorkflowActionTranslator>().Last(); } else { translator = context.Items.AddNew <PackStationToLCViewToRunFinishPackingWorkflowActionTranslator>(); } if (context.Items.FindByType <PackStationToLCViewResult>().Count > 0) { viewResult = context.Items.FindByType <PackStationToLCViewResult>().Last(); isItemSelected = true; } else { viewResult = new PackStationToLCViewResult(); if (context.Items.FindByType <PackStationToLCViewParameters>().Count() > 0) { PackStationToLCViewParameters viewParameters = context.Items.FindByType <PackStationToLCViewParameters>().Last(); } } actionParameters = translator.Translate(viewResult); actionParameters.IsItemSelected = isItemSelected; actionParameters.IsMultipleItemsSelected = false; if (context.Items.FindByType <PackStationOverviewViewParameters>().Count > 0) { PackStationOverviewViewParameters overviewParameters = context.Items.FindByType <PackStationOverviewViewParameters>().Last(); IPackStationToLCView view = context.SmartParts.FindByType <PackStationToLCView>().Last(); PackStationOverviewPresenter overviewPresenter = context.Items.FindByType <PackStationOverviewPresenter>().Last(); actionParameters.UserId = overviewParameters.UserId; try { if (!view.Validate()) { return; } ActionCatalog.Execute(ActionNames.RunFinishPackingWorkflow, context, caller, actionParameters); // Check if view should be closed. bool ignoreClosing = ((context.Items.Get("IgnoreClose") != null) && ((bool)(context.Items.Get("IgnoreClose")))); overviewPresenter.ToLoadCarrierId = string.Empty; overviewPresenter.ClearAllButPackedBy(); } catch (Imi.SupplyChain.UX.ValidationException ex) { view.HandleValidationResult(ValidationHelper.ConvertToResult((Imi.SupplyChain.UX.ValidationException)ex)); } } }