예제 #1
0
        public override bool PackStationFromLCRunPackAllRowsForPackStationCondition_CanExecute(string action, WorkItem context, object caller, object target)
        {
            PackStationOverviewPresenter overviewPresenter = context.Items.FindByType <PackStationOverviewPresenter>().LastOrDefault();

            if (!string.IsNullOrEmpty(overviewPresenter.ToLoadCarrierId))
            {
                // Multi select is not supported
                if (context.Items.FindByType <IList <PackStationFromLCViewResult> >().Count > 0)
                {
                    if (context.Items.FindByType <IList <PackStationFromLCViewResult> >().Last().Count > 1)
                    {
                        return(false);
                    }
                }

                IActionCatalogService actionCatalog = context.Services.Get <IActionCatalogService>(true);

                PackStationFromLCViewResult viewResult = null;
                RunPackAllRowsForPackStationActionParameters actionParameters = null;
                bool isItemSelected = false;

                if (context.Items.FindByType <PackStationFromLCViewResult>().Count > 0)
                {
                    viewResult     = context.Items.FindByType <PackStationFromLCViewResult>().Last();
                    isItemSelected = true;
                }
                else
                {
                    PackStationFromLCViewResult vr = new PackStationFromLCViewResult();

                    if (context.Items.FindByType <PackStationFromLCViewParameters>().Count() > 0)
                    {
                        PackStationFromLCViewParameters viewParameters = context.Items.FindByType <PackStationFromLCViewParameters>().Last();
                    }
                    viewResult = vr;
                }

                PackStationFromLCViewToRunPackAllRowsForPackStationActionTranslator translator = null;

                if (context.Items.FindByType <PackStationFromLCViewToRunPackAllRowsForPackStationActionTranslator>().Count > 0)
                {
                    translator = context.Items.FindByType <PackStationFromLCViewToRunPackAllRowsForPackStationActionTranslator>().Last();
                }
                else
                {
                    translator = context.Items.AddNew <PackStationFromLCViewToRunPackAllRowsForPackStationActionTranslator>();
                }

                actionParameters = translator.Translate(new PackStationOverviewViewParameters(), "");
                actionParameters.IsItemSelected          = isItemSelected;
                actionParameters.IsMultipleItemsSelected = false;
                return(actionCatalog.CanExecute(ActionNames.RunPackAllRowsForPackStation, context, caller, actionParameters));
            }

            return(false);
        }
예제 #2
0
        public RunPackAllRowsForPackStationActionParameters Translate(PackStationOverviewViewParameters packStationOverviewParameters, string toLoadCarrierId)
        {
            RunPackAllRowsForPackStationActionParameters runPackAllRowsForPackStationActionParameters = new RunPackAllRowsForPackStationActionParameters();

            runPackAllRowsForPackStationActionParameters.ClientId         = UserSessionService.ClientId;
            runPackAllRowsForPackStationActionParameters.DepartureId      = packStationOverviewParameters.DepartureId;
            runPackAllRowsForPackStationActionParameters.ShipToCustomerId = packStationOverviewParameters.ShipToCustomerId;
            runPackAllRowsForPackStationActionParameters.LoadCarrierId    = toLoadCarrierId;
            runPackAllRowsForPackStationActionParameters.UserId           = packStationOverviewParameters.UserId;

            return(runPackAllRowsForPackStationActionParameters);
        }
        public override void OnPackStationFromLCRunPackAllRowsForPackStation(WorkItem context, object caller, object target)
        {
            WorkItem wi = GetModuleWorkItem(context);

            if (wi.Items.FindByType <RunPackAllRowsForPackStationAction>().Count == 0)
            {
                wi.Items.AddNew <RunPackAllRowsForPackStationAction>();
            }

            RunPackAllRowsForPackStationActionParameters actionParameters = null;
            PackStationFromLCViewToRunPackAllRowsForPackStationActionTranslator translator = null;

            if (context.Items.FindByType <PackStationFromLCViewToRunPackAllRowsForPackStationActionTranslator>().Count > 0)
            {
                translator = context.Items.FindByType <PackStationFromLCViewToRunPackAllRowsForPackStationActionTranslator>().Last();
            }
            else
            {
                translator = context.Items.AddNew <PackStationFromLCViewToRunPackAllRowsForPackStationActionTranslator>();
            }

            PackStationOverviewViewParameters viewParameters = null;

            if (context.Items.FindByType <PackStationOverviewViewParameters>().Count() > 0)
            {
                viewParameters = context.Items.FindByType <PackStationOverviewViewParameters>().Last();
            }

            PackStationOverviewPresenter overviewPresenter = null;

            if (context.Items.FindByType <PackStationOverviewPresenter>().Count > 0)
            {
                overviewPresenter = context.Items.FindByType <PackStationOverviewPresenter>().Last();
            }
            if (viewParameters == null || overviewPresenter == null)
            {
                return;
            }

            actionParameters = translator.Translate(viewParameters, overviewPresenter.ToLoadCarrierId);
            actionParameters.IsItemSelected          = true;
            actionParameters.IsMultipleItemsSelected = false;

            IPackStationFromLCView   view = context.SmartParts.FindByType <PackStationFromLCView>().Last();
            IPackStationOverviewView packStationOverviewView = context.SmartParts.FindByType <IPackStationOverviewView>().LastOrDefault();

            try
            {
                if (!view.Validate())
                {
                    return;
                }

                ActionCatalog.Execute(ActionNames.RunPackAllRowsForPackStation, context, caller, actionParameters);

                // Check if view should be closed.
                bool ignoreClosing = ((context.Items.Get("IgnoreClose") != null) &&
                                      ((bool)(context.Items.Get("IgnoreClose"))));

                packStationOverviewView.Refresh();
            }
            catch (Imi.SupplyChain.UX.ValidationException ex)
            {
                view.HandleValidationResult(ValidationHelper.ConvertToResult((Imi.SupplyChain.UX.ValidationException)ex));
            }
        }