Пример #1
0
        public override bool PackStationOverviewRunUndoPackingCondition_CanExecute(string action, WorkItem context, object caller, object target)
        {
            PackStationOverviewPresenter overviewPresenter = context.Items.FindByType <PackStationOverviewPresenter>().LastOrDefault();

            if (!string.IsNullOrEmpty(overviewPresenter.ToLoadCarrierId))
            {
                IActionCatalogService          actionCatalog    = context.Services.Get <IActionCatalogService>(true);
                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>();
                }

                actionParameters = translator.Translate(overviewPresenter.ToLoadCarrierId);
                actionParameters.IsItemSelected          = true;
                actionParameters.IsMultipleItemsSelected = false;
                return(actionCatalog.CanExecute(ActionNames.RunUndoPacking, context, caller, actionParameters));
            }

            return(false);
        }
Пример #2
0
        public RunUndoPackingActionParameters Translate(string toLoadCarrierId)
        {
            RunUndoPackingActionParameters runUndoPackingActionParameters = new RunUndoPackingActionParameters();

            runUndoPackingActionParameters.LoadCarrierId = toLoadCarrierId;

            return(runUndoPackingActionParameters);
        }
        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));
            }
        }