Пример #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 override bool PackStationFromLcEditRunPackRowForPackStationCondition_CanExecute(string action, WorkItem context, object caller, object target)
        {
            // Multi select is not supported
            if (context.Items.FindByType <IList <PackStationFromLcEditViewResult> >().Count > 0)
            {
                if (context.Items.FindByType <IList <PackStationFromLcEditViewResult> >().Last().Count > 1)
                {
                    return(false);
                }
            }

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

            PackStationFromLcEditViewResult          viewResult       = null;
            RunPackRowForPackStationActionParameters actionParameters = null;
            bool isItemSelected = false;

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

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

            PackStationFromLcEditViewToRunPackRowForPackStationActionTranslator translator = null;

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

            actionParameters = translator.Translate(viewResult);
            if (context.Items.FindByType <PackStationOverviewPresenter>().Count > 0)
            {
                if (!string.IsNullOrEmpty(context.Items.FindByType <PackStationOverviewPresenter>().Last().ToLoadCarrierId))
                {
                    actionParameters.ToLoadCarrierId = context.Items.FindByType <PackStationOverviewPresenter>().Last().ToLoadCarrierId;
                }
                else
                {
                    actionParameters.ToLoadCarrierId = string.Empty;
                }
            }
            actionParameters.IsItemSelected          = isItemSelected;
            actionParameters.IsMultipleItemsSelected = false;
            return(actionCatalog.CanExecute(ActionNames.RunPackRowForPackStation, context, caller, actionParameters));
        }
Пример #3
0
        private void RemoveActionImplementation(IBuilderContext context, IActionCatalogService catalog, object existing, MethodInfo methodInfo)
        {
            foreach (ActionAttribute attr in methodInfo.GetCustomAttributes(typeof(ActionAttribute), true)) {
                catalog.RemoveActionImplementation(attr.ActionName);

                TraceTearDown(context, existing, "Action implementation removed for action {0}, for the method {1} on the type {2}.", attr.ActionName, methodInfo.Name, existing.GetType().Name);
            }
        }
Пример #4
0
        private void RemoveActionImplementation(IBuilderContext context, IActionCatalogService catalog, object existing, MethodInfo methodInfo)
        {
            foreach (ActionAttribute attr in methodInfo.GetCustomAttributes(typeof(ActionAttribute), true))
            {
                catalog.RemoveActionImplementation(attr.ActionName);

                TraceTearDown(context, existing, "Action implementation removed for action {0}, for the method {1} on the type {2}.", attr.ActionName, methodInfo.Name, existing.GetType().Name);
            }
        }
Пример #5
0
        public void OnCustomerWorkItemCreated(object sender, EventArgs <WorkItem> args)
        {
            WorkItem customerWorkItem = args.Data;

            customerWorkItem.Items.AddNew <ModuleActions>();
            IActionCatalogService catalog = customerWorkItem.Services.Get <IActionCatalogService>();

            catalog.Execute(ActionNames.ShowPurchaseCDCommand, customerWorkItem, this, null);
        }
        public override void AddServices()
        {
            base.AddServices();
            _rootWorkItem.Services.AddNew <GenericPrincipalImpersonationService, IImpersonationService>();
            _rootWorkItem.Services.AddNew <EnterpriseLibraryCacheService, ICacheService>();
            IActionCatalogService catalog = _rootWorkItem.Services.Get <IActionCatalogService>();

            catalog.RegisterGeneralCondition(new EnterpriseLibraryAuthorizationActionCondition());
        }
Пример #7
0
        private void RegisterActionImplementation(IBuilderContext context, IActionCatalogService catalog, object existing, string idToBuild, MethodInfo methodInfo)
        {
            foreach (ActionAttribute attr in methodInfo.GetCustomAttributes(typeof(ActionAttribute), true)) {
                ActionDelegate actionDelegate = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), existing, methodInfo);
                catalog.RegisterActionImplementation(attr.ActionName, actionDelegate);

                // TODO: Add to resources
                TraceBuildUp(context, existing.GetType(), idToBuild, "Action implementation built for action {0}, for the method {1} on the type {2}.", attr.ActionName, methodInfo.Name, existing.GetType().Name);
            }
        }
Пример #8
0
        private void RegisterActionImplementation(IBuilderContext context, IActionCatalogService catalog, object existing, string idToBuild, MethodInfo methodInfo)
        {
            foreach (ActionAttribute attr in methodInfo.GetCustomAttributes(typeof(ActionAttribute), true))
            {
                ActionDelegate actionDelegate = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), existing, methodInfo);
                catalog.RegisterActionImplementation(attr.ActionName, actionDelegate);

                // TODO: Add to resources
                TraceBuildUp(context, existing.GetType(), idToBuild, "Action implementation built for action {0}, for the method {1} on the type {2}.", attr.ActionName, methodInfo.Name, existing.GetType().Name);
            }
        }
 public ModuleActions
 (
     [ServiceDependency] WorkItem workItem,
     [ServiceDependency] IActionCatalogService actionCatalog,
     [ComponentDependency("QueueEntry")] QueueEntry queueEntry
 )
 {
     _workItem      = workItem;
     _queueEntry    = queueEntry;
     _actionCatalog = actionCatalog;
 }
Пример #10
0
        public override bool PackStationOverviewRunStopPackingCondition_CanExecute(string action, WorkItem context, object caller, object target)
        {
            PackStationOverviewViewParameters viewParameters = null;

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


            if (string.IsNullOrEmpty(viewParameters.PickZoneId) && !string.IsNullOrEmpty(viewParameters.DepartureId) && !string.IsNullOrEmpty(viewParameters.ShipToCustomerId) && !string.IsNullOrEmpty(viewParameters.UserId))
            {
                IActionCatalogService actionCatalog = context.Services.Get <IActionCatalogService>(true);

                RunStopPackingActionParameters actionParameters = null;
                bool isItemSelected = false;

                if (context.Items.FindByType <PackStationOverviewViewResult>().Count > 0)
                {
                    isItemSelected = true;
                }

                PackStationOverviewViewToRunStopPackingActionTranslator translator = null;

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

                actionParameters = translator.Translate(new PackStationOverviewViewParameters());
                actionParameters.IsItemSelected          = isItemSelected;
                actionParameters.IsMultipleItemsSelected = false;

                return(actionCatalog.CanExecute(ActionNames.RunStopPacking, context, caller, actionParameters));
            }

            return(false);
        }
        public void Run(QueueEntry queueEntry, IWorkspace workspace)
        {
            IActionCatalogService catalog = WorkItem.Services.AddNew <ActionCatalogService, IActionCatalogService>();

            catalog.RegisterGeneralCondition(new EnterpriseLibraryAuthorizationActionCondition());

            WorkItem.Items.Add(queueEntry, "QueueEntry");
            WorkItem.Activated += new EventHandler(WorkItem_Activated);

            _queueEntry  = queueEntry;
            _workspace   = workspace;
            _officerView = WorkItem.SmartParts.AddNew <OfficerView>();

            // Show the summary as default
            CustomerSummaryView summary = WorkItem.SmartParts.AddNew <CustomerSummaryView>();

            WorkItem.Workspaces[WorkspaceNames.OfficerWorkspace].Show(summary);
        }
Пример #12
0
        public override object TearDown(IBuilderContext context, object item)
        {
            WorkItem workItem = GetWorkItem(context, item);

            if (workItem != null)
            {
                IActionCatalogService actionCatalog = workItem.Services.Get <IActionCatalogService>();
                if (actionCatalog != null)
                {
                    Type targetType = item.GetType();

                    foreach (MethodInfo methodInfo in targetType.GetMethods())
                    {
                        RemoveActionImplementation(context, actionCatalog, item, methodInfo);
                    }
                }
            }
            return(base.TearDown(context, item));
        }
Пример #13
0
        public override object BuildUp(IBuilderContext context, Type typeToBuild, object existing, string idToBuild)
        {
            WorkItem workItem = GetWorkItem(context, existing);

            if (workItem != null)
            {
                IActionCatalogService actionCatalog = workItem.Services.Get <IActionCatalogService>();
                if (actionCatalog != null)
                {
                    Type targetType = existing.GetType();

                    foreach (MethodInfo methodInfo in targetType.GetMethods())
                    {
                        RegisterActionImplementation(context, actionCatalog, existing, idToBuild, methodInfo);
                    }
                }
            }

            return(base.BuildUp(context, typeToBuild, existing, idToBuild));
        }
Пример #14
0
        public void ActionExecutedEventHandler(object sender, DataEventArgs <ShellDrillDownMenuItem> e)
        {
            ShellDrillDownMenuItem action = e.Data;

            if (!action.IsAuthorized)
            {
                IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();
                messageBoxView.Show(StringResources.Authorization_NotAuhtorized
                                    , StringResources.Authorization_Message
                                    , null
                                    , Infrastructure.MessageBoxButton.Ok
                                    , Infrastructure.MessageBoxImage.Warning);

                return;
            }
            else if (!action.IsEnabled)
            {
                return;
            }

            try
            {
                _shellView.ShowProgress();

                try
                {
                    IActionCatalogService actionCatalog = action.WorkItem.Services.Get <IActionCatalogService>();
                    actionCatalog.Execute(action.Id, action.WorkItem, this, action.Parameters);
                }
                finally
                {
                    _shellView.HideProgress();
                }
            }
            catch (Exception ex)
            {
                IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();
                messageBoxView.Show(StringResources.ActionException_Text, ex.Message, ex.ToString(), Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error);
            }
        }
Пример #15
0
        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 void OnCreditCardAccountOpen(object sender, EventArgs <CreditCard> args)
        {
            IActionCatalogService catalog = _customerWorkItem.Services.Get <IActionCatalogService>();

            catalog.Execute(ActionNames.ShowCreditCardAccountViewAction, _customerWorkItem, this, args.Data);
        }