public void ShowComboDialog(IWorkspace workspace, bool fromLoadCarrier)
        {
            string workItemName;

            if (fromLoadCarrier)
            {
                workItemName = "FromLoadCarrierId";
            }
            else
            {
                workItemName = "ToLoadCarrierId";
            }

            if (WorkItem.WorkItems[workItemName] != null)
            {
                WorkItem.WorkItems[workItemName].Terminate();
            }
            FindLoadCarrierForPackStationFindViewParameters parameters = new FindLoadCarrierForPackStationFindViewParameters();

            if (viewParameters != null)
            {
                if (string.IsNullOrEmpty(viewParameters.DepartureId))
                {
                    parameters.DepartureId = "%";
                }
                else
                {
                    parameters.DepartureId = viewParameters.DepartureId;
                }
                if (string.IsNullOrEmpty(viewParameters.ShipToCustomerId))
                {
                    parameters.ShipToCustomerId = "%";
                }
                else
                {
                    parameters.ShipToCustomerId = viewParameters.ShipToCustomerId;
                }
                parameters.PackedBy = viewParameters.UserId;
                if (fromLoadCarrier)
                {
                    parameters.PickRowEmptyStatus = "NOTEMPTY";
                }
                else
                {
                    parameters.PickRowEmptyStatus = "EMPTY";
                }
            }
            else
            {
                parameters.DepartureId      = "%";
                parameters.ShipToCustomerId = "%";
                parameters.PackedBy         = WorkItem.Items.FindByType <PackStationSearchPanelView>().Last().CurrentItem.UserId;
                if (fromLoadCarrier)
                {
                    parameters.PickRowEmptyStatus = "NOTEMPTY";
                }
                else
                {
                    parameters.PickRowEmptyStatus = "EMPTY";
                }
            }

            parameters.WarehouseId = UserSessionService.WarehouseId;
            parameters.ClientId    = UserSessionService.ClientId;

            ShellInteractionService.ShowProgress();
            try
            {
                Assembly             assembly            = Assembly.Load("Imi.SupplyChain.Warehouse.UX.Modules.PackStation");
                IModuleLoaderService moduleLoaderService = WorkItem.Services.Get <IModuleLoaderService>();
                moduleLoaderService.Load(WorkItem.RootWorkItem.WorkItems["Warehouse"], assembly);
                Type   workItemType = typeof(ControlledWorkItem <>).MakeGenericType(assembly.GetType("Imi.SupplyChain.Warehouse.UX.Modules.PackStation.FindLoadCarrierForPackStationFind.FindLoadCarrierForPackStationFindController"));
                object workItem     = WorkItem.WorkItems.AddNew(workItemType, workItemName);
                object controller   = workItem.GetType().GetProperty("Controller").GetValue(workItem, null);
                controller.GetType().InvokeMember("Run", BindingFlags.InvokeMethod, null, controller, new object[] { workspace, parameters });
            }
            finally
            {
                ShellInteractionService.HideProgress();
            }
        }
Пример #2
0
        public void SelectAndClose(UserWarehouse selectedWarehouse)
        {
            if (selectedWarehouse != null)
            {
                try
                {
                    UserSettingsChangedEventArgs args = new UserSettingsChangedEventArgs();

                    EventTopic userSettingsTopic = WorkItem.EventTopics.Get(Imi.SupplyChain.UX.UXEventTopicNames.UserSettingsChangedTopic);

                    if (userSettingsTopic != null)
                    {
                        userSettingsTopic.Fire(this, args, WorkItem, PublicationScope.Descendants);

                        if (args.OpenDialogs.Count > 0)
                        {
                            if (ShellInteractionService.ShowMessageBox(this.View.Title, string.Format(LocalResources.ChangeUserSettings_CloseAll, string.Join("\n", args.OpenDialogs)), null, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                            {
                                Close();
                                return;
                            }
                        }
                    }

                    ShellInteractionService.ShowProgress();

                    // Get the application
                    ModuleController module = WorkItem.Items.FindByType <ModuleController>().First();

                    LogonParameters logonParameters = new LogonParameters();
                    logonParameters.UserIdentity        = UserSessionService.UserId;
                    logonParameters.WarehouseIdentity   = selectedWarehouse.WarehouseIdentity;
                    logonParameters.TerminalIdentity    = UserSessionService.TerminalId;
                    logonParameters.ApplicationIdentity = module.Id;

                    LogonRequest logonRequest = new LogonRequest();

                    logonRequest.LogonParameters = logonParameters;

                    Service.Logon(logonRequest);

                    UserSessionService.WarehouseId = selectedWarehouse.WarehouseIdentity;

                    if (userSettingsTopic != null)
                    {
                        UserSettingsChangedEventArgs userSettingsChangedEventArgs = new UserSettingsChangedEventArgs(true);
                        userSettingsTopic.Fire(this, userSettingsChangedEventArgs, WorkItem, PublicationScope.Descendants);
                    }

                    // Set the selected Warehouse and ClientId on statusrow in container
                    ShellInteractionService.ContextInfo = string.Format(LocalResources.STATUSBAR_WH,
                                                                        selectedWarehouse.WarehouseIdentity,
                                                                        selectedWarehouse.WarehouseName);

                    Close();
                }
                catch (Exception ex)
                {
                    ShellInteractionService.HideProgress();
                    ShellInteractionService.ShowMessageBox(StringResources.ActionException_Text, ex.Message, ex.ToString(), MessageBoxButton.Ok, MessageBoxImage.Error);
                }
                finally
                {
                    ShellInteractionService.HideProgress();
                }
            }
        }
        public void SelectAndClose(UserWarehouse selectedWarehouse)
        {
            if (selectedWarehouse != null)
            {
                try
                {
                    UserSettingsChangedEventArgs args = new UserSettingsChangedEventArgs();

                    EventTopic userSettingsTopic = WorkItem.EventTopics.Get(Imi.SupplyChain.UX.UXEventTopicNames.UserSettingsChangedTopic);

                    if (userSettingsTopic != null)
                    {
                        userSettingsTopic.Fire(this, args, WorkItem, PublicationScope.Descendants);

                        if (args.OpenDialogs.Count > 0)
                        {
                            if (ShellInteractionService.ShowMessageBox(this.View.Title, string.Format(LocalResources.ChangeUserSettings_CloseAll, string.Join("\n", args.OpenDialogs)), null, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                            {
                                Close();
                                return;
                            }
                        }
                    }

                    ShellInteractionService.ShowProgress();

                    UserSessionService.WarehouseId = selectedWarehouse.WarehouseIdentity;

                    ModifyUserDetailsParameters modifyUserDetailsParameters = new ModifyUserDetailsParameters();
                    modifyUserDetailsParameters.UserIdentity            = UserSessionService.UserId;
                    modifyUserDetailsParameters.LastLogonTime           = DateTime.Now;
                    modifyUserDetailsParameters.RecentWarehouseIdentity = selectedWarehouse.WarehouseIdentity;

                    ModifyUserDetailsRequest serviceRequest = new ModifyUserDetailsRequest();

                    serviceRequest.ModifyUserDetailsParameters = modifyUserDetailsParameters;

                    Service.ModifyUserDetails(serviceRequest);

                    if (userSettingsTopic != null)
                    {
                        UserSettingsChangedEventArgs userSettingsChangedEventArgs = new UserSettingsChangedEventArgs(true);
                        userSettingsTopic.Fire(this, userSettingsChangedEventArgs, WorkItem, PublicationScope.Descendants);
                    }

                    // Set the selected Warehouse and ClientId on statusrow in container
                    ShellInteractionService.ContextInfo = string.Format(LocalResources.STATUSBAR_WH,
                                                                        selectedWarehouse.WarehouseIdentity,
                                                                        selectedWarehouse.WarehouseName);
                    Close();
                }
                catch (Exception ex)
                {
                    ShellInteractionService.HideProgress();
                    ShellInteractionService.ShowMessageBox(StringResources.ActionException_Text, ex.Message, ex.ToString(), MessageBoxButton.Ok, MessageBoxImage.Error);
                }
                finally
                {
                    ShellInteractionService.HideProgress();
                }
            }
        }