public override bool PackStationToLCRunFinishPackingWorkflowCondition_CanExecute(string action, WorkItem context, object caller, object target) { // Multi select is not supported if (context.Items.FindByType <IList <PackStationToLCViewResult> >().Count > 0) { if (context.Items.FindByType <IList <PackStationToLCViewResult> >().Last().Count > 1) { return(false); } } IActionCatalogService actionCatalog = context.Services.Get <IActionCatalogService>(true); PackStationToLCViewResult viewResult = null; RunFinishPackingWorkflowActionParameters actionParameters = null; bool isItemSelected = false; if (context.Items.FindByType <PackStationToLCViewResult>().Count > 0) { viewResult = context.Items.FindByType <PackStationToLCViewResult>().Last(); isItemSelected = true; } //Check for Pack & Sort dissable finish pack if (context.Items.FindByType <PackStationOverviewViewParameters>().Count() > 0) { PackStationOverviewViewParameters overviewViewParameters = context.Items.FindByType <PackStationOverviewViewParameters>().Last(); if (!string.IsNullOrEmpty(overviewViewParameters.PickZoneId)) { if (context.Items.FindByType <IList <PackStationFromLCViewResult> >().Count > 0) { IList <PackStationFromLCViewResult> fromLCViewResults = context.Items.FindByType <IList <PackStationFromLCViewResult> >().Last(); if (fromLCViewResults.Count == 0) { isItemSelected = isItemSelected & true; } else { isItemSelected = isItemSelected & false; } } else { isItemSelected = isItemSelected & true; } } } PackStationToLCViewToRunFinishPackingWorkflowActionTranslator translator = null; if (context.Items.FindByType <PackStationToLCViewToRunFinishPackingWorkflowActionTranslator>().Count > 0) { translator = context.Items.FindByType <PackStationToLCViewToRunFinishPackingWorkflowActionTranslator>().Last(); } else { translator = context.Items.AddNew <PackStationToLCViewToRunFinishPackingWorkflowActionTranslator>(); } actionParameters = translator.Translate(viewResult); actionParameters.IsItemSelected = isItemSelected; actionParameters.IsMultipleItemsSelected = false; return(actionCatalog.CanExecute(ActionNames.RunFinishPackingWorkflow, context, caller, actionParameters)); }
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)); } } }