Esempio n. 1
0
        private void HyperlinkExecutedEventHandler(object sender, HyperlinkExecutedEventArgs e)
        {
            if (e.Hyperlink.Data.ContainsKey("DialogId")) //Support for links with only moduleid
            {
                var node = (from n in GetMenu().SelectNodes("descendant::item").Cast <XmlNode>()
                            where n.Attributes["operation"].Value == e.Hyperlink.Data["DialogId"]
                            select n).LastOrDefault();

                if (node != null)
                {
                    ShellMenuItem temp = new ShellMenuItem();
                    temp.Operation = node.Attributes["operation"].Value;

                    AuthorizationService.CheckAuthorization(Id, new IAuthOperation[] { temp });

                    if (temp.IsAuthorized)
                    {
                        if (!string.IsNullOrEmpty(node.Attributes["assemblyFile"].Value))
                        {
                            ModuleInfo info = new ModuleInfo(node.Attributes["assemblyFile"].Value);
                            ModuleLoaderService.Load(WorkItem, info);
                        }

                        EventTopic    itemTopic = WorkItem.RootWorkItem.EventTopics.Get(node.Attributes["parameters"].Value);
                        MenuEventArgs args      = new MenuEventArgs("", HyperlinkHelper.BuildQueryString(e.Hyperlink.Data), true, null);
                        itemTopic.Fire(this, args, WorkItem, PublicationScope.Global);
                    }
                    else
                    {
                        ShellInteractionService.ShowMessageBox(StringResources.Authorization_NotAuhtorized, StringResources.Authorization_Message, null, MessageBoxButton.Ok, MessageBoxImage.Warning);
                    }
                }
            }
        }
        public void SelectAndClose(UserNode selectedNode)
        {
            if (selectedNode != 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.NodeId = selectedNode.NodeIdentity;

                    ModifyUserDetailsParameters modifyUserDetailsParameters = new ModifyUserDetailsParameters();
                    modifyUserDetailsParameters.UserIdentity       = UserSessionService.UserId;
                    modifyUserDetailsParameters.LastLogonTime      = DateTime.Now;
                    modifyUserDetailsParameters.RecentNodeIdentity = selectedNode.NodeIdentity;

                    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_GATEWAYTMS_NODE,
                                                                        selectedNode.NodeIdentity,
                                                                        selectedNode.NodeName);
                    Close();
                }
                catch (Exception ex)
                {
                    ShellInteractionService.HideProgress();
                    ShellInteractionService.ShowMessageBox(StringResources.ActionException_Text, ex.Message, ex.ToString(), MessageBoxButton.Ok, MessageBoxImage.Error);
                }
                finally
                {
                    ShellInteractionService.HideProgress();
                }
            }
        }
Esempio n. 3
0
        public void OnChooseDefaultWarehouseDialog(object sender, EventArgs args)
        {
            try
            {
                IChooseDefaultWarehouseView chooseWarehouse = WorkItem.SmartParts.AddNew <ChooseDefaultWarehouseView>();

                chooseWarehouse.hideClientId = true;

                if (chooseWarehouse.ShowDialog() == true)
                {
                    _activityMonitorUserSessionService.ClientId    = chooseWarehouse.SelectedClientId;
                    _activityMonitorUserSessionService.WarehouseId = chooseWarehouse.SelectedWarehouseId;

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

                    if (userSettingsTopic != null)
                    {
                        UserSettingsChangedEventArgs userSettingsChangedEventArgs = new UserSettingsChangedEventArgs(true);
                        userSettingsTopic.Fire(this, userSettingsChangedEventArgs, WorkItem, PublicationScope.Descendants);
                    }
                }
            }
            finally
            {
                if ((_activityMonitorUserSessionService.ClientId == null) || (_activityMonitorUserSessionService.WarehouseId == null))
                {
                    ShellInteractionService.ShowMessageBox(LocalResources.ChangeUserSettings_Caption, LocalResources.ChangeUserSettings_Message, null, MessageBoxButton.Ok, MessageBoxImage.Warning);
                }
            }
        }
        public XmlDocument GetMenu()
        {
            XmlDocument menu = new XmlDocument();;

            // let user choose logical OMS user
            try
            {
                if (omsSessionContext.ClientProgram == null)  // dashboard compliance
                {
                    EventTopic userSettingsTopic = WorkItem.EventTopics.Get(Imi.SupplyChain.UX.Modules.OrderManagement.Views.Constants.EventTopicNames.ShowChooseUserDialog);
                    userSettingsTopic.Fire(this, new EventArgs(), WorkItem, PublicationScope.Global);
                }
            }
            catch (EventTopicException ex)
            {
                string message = "";
                if (ex.Exceptions.Count > 0)
                {
                    message = ex.Exceptions[0].Message;
                }

                ShellInteractionService.ShowMessageBox(Resources.ChooseOMSUserException_text,
                                                       message, null, Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error);
                XmlElement root = menu.CreateElement("folder");
                root.SetAttribute("caption", "");
                menu.AppendChild(root);
                return(menu);
            }
            catch (Exception ex)
            {
                ShellInteractionService.ShowMessageBox(Resources.ChooseOMSUserException_text,
                                                       ex.Message, null, Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error);
                XmlElement root = menu.CreateElement("folder");
                root.SetAttribute("caption", "");
                menu.AppendChild(root);
                return(menu);
            }

            try
            {
                menu = omsWebServiceWrapper.GetMenu();
            }
            catch (Exception ex)
            {
                menu = new XmlDocument();
                XmlElement root = menu.CreateElement("folder");
                root.SetAttribute("caption", "");
                menu.AppendChild(root);

                ShellInteractionService.ShowMessageBox(Resources.LoadMenuException_text,
                                                       ex.Message, null, Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error);
            }

            //Debug.WriteLine(menu.OuterXml);
            return(menu);
        }
Esempio n. 5
0
        public void SearchCompletedCallback(object data, Exception error)
        {
            try
            {
                OnProgressUpdated(null, 100);
            }
            finally
            {
                try
                {
                    if (error == null)
                    {
                        PresentData(data);
                    }
                    else
                    {
                        if (!isCancelled)
                        {
                            bool showLocalError = false;

                            if (View is IErrorHandler)
                            {
                                if (View is IDataView)
                                {
                                    showLocalError = ((IDataView)View).IsDetailView;
                                }
                                else
                                {
                                    showLocalError = true;
                                }
                            }

                            bool showError = true;

                            if (showLocalError)
                            {
                                showError = !(View as IErrorHandler).HandleError(error);
                            }

                            if (showError)
                            {
                                ShellInteractionService.ShowMessageBox(StringResources.Search_Error, error.Message, error.ToString(), Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error);
                            }
                        }
                    }
                }
                finally
                {
                    searchWaitEvent.Set();
                }
            }
        }
        public void SelectAndClose(Imi.SupplyChain.OutputManager.Services.Initialization.DataContracts.OutputManager selectedOutputManager)
        {
            if (selectedOutputManager != 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(false);
                                return;
                            }
                        }
                    }



                    ShellInteractionService.ShowProgress();

                    // Get the application
                    IShellModule module = WorkItem.Items.FindByType <IShellModule>().First();
                    OutputManagerSessionService.OutputManagerId = selectedOutputManager.OutputManagerIdentity;

                    // Set the selected Output Manager
                    ShellInteractionService.ContextInfo = string.Format(LocalResources.STATUSBAR_OM_CLIENT,
                                                                        selectedOutputManager.OutputManagerIdentity,
                                                                        selectedOutputManager.OutputManagerName);
                    Close(true);
                }
                catch (Exception ex)
                {
                    ShellInteractionService.HideProgress();
                    ShellInteractionService.ShowMessageBox(StringResources.ActionException_Text, ex.Message, ex.ToString(), MessageBoxButton.Ok, MessageBoxImage.Error);
                }
                finally
                {
                    ShellInteractionService.HideProgress();
                }
            }
        }
Esempio n. 7
0
 public void OnChooseDefaultNodeDialog(object sender, EventArgs args)
 {
     try
     {
         IChooseDefaultNodeView chooseNode = WorkItem.SmartParts.AddNew <ChooseDefaultNodeView>();
         chooseNode.ShowDialog();
     }
     finally
     {
         if (_gatewayUserSessionService.NodeId == null)
         {
             ShellInteractionService.ShowMessageBox(LocalResources.ChangeUserSettings_Caption, LocalResources.ChangeUserSettings_Message, null, UX.Infrastructure.MessageBoxButton.Ok, UX.Infrastructure.MessageBoxImage.Warning);
         }
     }
 }
Esempio n. 8
0
 public void OnChooseDefaultWarehouseDialog(object sender, EventArgs args)
 {
     try
     {
         IChooseDefaultWarehouseView chooseWarehouse = WorkItem.SmartParts.AddNew <ChooseDefaultWarehouseView>();
         chooseWarehouse.ShowDialog();
     }
     finally
     {
         if (_dockUserSessionService.WarehouseId == null)
         {
             ShellInteractionService.ShowMessageBox(LocalResources.ChangeUserSettings_Caption, LocalResources.ChangeUserSettings_Message, null, MessageBoxButton.Ok, MessageBoxImage.Warning);
         }
     }
 }
 public void ShowCreateLoadCarrierDialog()
 {
     if (viewParameters != null && currentItem != null)
     {
         CreateLoadCarrierForPackStationViewParameters loadCarrierParameters = new CreateLoadCarrierForPackStationViewParameters();
         loadCarrierParameters.ClientId           = UserSessionService.ClientId;
         loadCarrierParameters.DepartureId        = viewParameters.DepartureId;
         loadCarrierParameters.UserId             = viewParameters.UserId;
         loadCarrierParameters.ShipToCustomerId   = viewParameters.ShipToCustomerId;
         loadCarrierParameters.ShipToCustomerType = currentItem.ShipToCustomerType;
         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.CreateLoadCarrierForPackStation.CreateLoadCarrierForPackStationController"));
             WorkItem workItem     = WorkItem.WorkItems.AddNew(workItemType, "CreateLoadCarrier");
             workItem.Terminated += (s, e) =>
             {
                 DialogResult dialogResult = DialogResult.None;
                 if (workItem.Items.Get("DialogResult") != null)
                 {
                     dialogResult = (DialogResult)workItem.Items.Get("DialogResult");
                 }
                 if ((dialogResult == DialogResult.Ok) &&
                     (workItem.Items.FindByType <CreateLoadCarrierForPackStationViewResult>().Count > 0))
                 {
                     CreateLoadCarrierForPackStationViewResult result = workItem.Items.FindByType <CreateLoadCarrierForPackStationViewResult>().Last();
                     try
                     {
                         SelectToLoadCarrier(result.LoadCarrierId);
                     }
                     catch (Exception ex)
                     {
                         ShellInteractionService.ShowMessageBox(ex);
                     }
                 }
             };
             object controller = workItem.GetType().GetProperty("Controller").GetValue(workItem, null);
             controller.GetType().InvokeMember("Run", BindingFlags.InvokeMethod, null, controller, new object[] { loadCarrierParameters });
         }
         finally
         {
             ShellInteractionService.HideProgress();
         }
     }
 }
        public void OnChooseDefaultOutputManagerDialog(object sender, EventArgs args)
        {
            try
            {
                IChooseDefaultOutputManagerView chooseOutputManager = WorkItem.SmartParts.AddNew <ChooseDefaultOutputManagerView>();

                UXSettingsService settingsServiceLoad = WorkItem.Items.AddNew <UXSettingsService>("IChooseDefaultOutputManagerView");
                settingsServiceLoad.ContainerName = "IChooseDefaultOutputManagerView";
                settingsServiceLoad.AddProvider(chooseOutputManager, new ChooseDefaultOutputManagerSettingsProvider());
                settingsServiceLoad.LoadSettings();
                WorkItem.Items.Remove(settingsServiceLoad);

                if (chooseOutputManager.ShowDialog() == true)
                {
                    _OutputManagerUserSessionService.OutputManagerId = chooseOutputManager.SelectedOutputManagerId;

                    UXSettingsService settingsService = WorkItem.Items.AddNew <UXSettingsService>("IChooseDefaultOutputManagerView");
                    settingsService.ContainerName = "IChooseDefaultOutputManagerView";
                    settingsService.AddProvider(chooseOutputManager, new ChooseDefaultOutputManagerSettingsProvider());
                    settingsService.SaveSettings();
                    WorkItem.Items.Remove(settingsService);


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

                    if (userSettingsTopic != null)
                    {
                        UserSettingsChangedEventArgs userSettingsChangedEventArgs = new UserSettingsChangedEventArgs(true);
                        userSettingsTopic.Fire(this, userSettingsChangedEventArgs, WorkItem, PublicationScope.Descendants);
                    }
                }
            }
            finally
            {
                if (_OutputManagerUserSessionService.OutputManagerId == null)
                {
                    ShellInteractionService.ShowMessageBox(LocalResources.ChangeUserSettings_Caption, LocalResources.ChangeUserSettings_Message, null, Imi.SupplyChain.UX.Infrastructure.MessageBoxButton.Ok, Imi.SupplyChain.UX.Infrastructure.MessageBoxImage.Warning);
                }
            }
        }
        public void SelectAndClose(UserWarehouse selectedWarehouse, UserCompany selectedCompany)
        {
            if ((selectedWarehouse != null) && (selectedCompany != 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(false);
                                return;
                            }
                        }
                    }

                    ShellInteractionService.ShowProgress();

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

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

                    LogonRequest logonRequest = new LogonRequest();

                    logonRequest.LogonParameters = logonParameters;

                    LogonResponse response = Service.Logon(logonRequest);

                    // Set the selected Warehouse and ClientId on statusrow in container
                    ShellInteractionService.ContextInfo = string.Format(LocalResources.STATUSBAR_WH_CLIENT,
                                                                        selectedWarehouse.WarehouseIdentity,
                                                                        selectedWarehouse.WarehouseName,
                                                                        selectedCompany.CompanyIdentity,
                                                                        selectedCompany.CompanyName);
                    Close(true);
                }
                catch (Exception ex)
                {
                    ShellInteractionService.HideProgress();
                    ShellInteractionService.ShowMessageBox(StringResources.ActionException_Text, ex.Message, ex.ToString(), MessageBoxButton.Ok, MessageBoxImage.Error);
                }
                finally
                {
                    ShellInteractionService.HideProgress();
                }
            }
        }
        private void ErrorInfoButtonClickEventHanlder(object sender, RoutedEventArgs e)
        {
            e.Handled = true;

            ShellInteractionService.ShowMessageBox(StringResources.View_UpdateError, error.Message, error.ToString(), Imi.SupplyChain.UX.Infrastructure.MessageBoxButton.Ok, Imi.SupplyChain.UX.Infrastructure.MessageBoxImage.Error);
        }
        public void PackWithEAN(string eanCode)
        {
            if (!string.IsNullOrEmpty(ToLoadCarrierId))
            {
                if (WorkItem.Items.FindByType <IPackStationFromLCView>().Count > 0)
                {
                    IPackStationFromLCView detailView            = WorkItem.Items.FindByType <IPackStationFromLCView>().LastOrDefault();
                    List <string>          productNumbersFromEAN = UpdateDataSourceFindArtIdFromEAN(eanCode);

                    string productNumber = string.Empty;

                    if (productNumbersFromEAN.Count == 1)
                    {
                        productNumber = productNumbersFromEAN[0];
                    }
                    else
                    {
                        productNumber = eanCode;
                    }

                    //else
                    //{
                    //    Console.Beep(350, 1000);
                    //    if (productNumbersFromEAN.Count == 0)
                    //    {
                    //        ShellInteractionService.ShowMessageBox(ResourceManager.str_EANPack_Error_Title, GetAlarmText("PACK006"), string.Empty, MessageBoxButton.Ok, MessageBoxImage.Warning);
                    //    }
                    //    else
                    //    {
                    //        ShellInteractionService.ShowMessageBox(ResourceManager.str_EANPack_Error_Title, GetAlarmText("PACK005"), string.Empty, MessageBoxButton.Ok, MessageBoxImage.Warning);
                    //    }
                    //}

                    if (productNumber != string.Empty)
                    {
                        List <PackStationFromLCViewResult> pickOrderLines = detailView.GetData;

                        List <PackStationFromLCViewResult> foundProductLines = FindPickOrderLineWithProductNumber(pickOrderLines, productNumber);

                        if (foundProductLines.Count > 0)
                        {
                            if (foundProductLines.Count == 1)
                            {
                                PackStationFromLCViewResult foundProductLine = foundProductLines[0];

                                if (ScanEachPickPackage)
                                {
                                    if (foundProductLine.PickedQuantity <= MaxNoOfScans || !string.IsNullOrEmpty(viewParameters.PickZoneId)) //Override MaxNoOfScans if Pack & Sort
                                    {
                                        detailView.CurrentItem = foundProductLine;
                                        PackPickOrderLine(foundProductLine, 1);
                                    }
                                    else
                                    {
                                        Console.Beep(350, 1000);
                                        ShellInteractionService.ShowMessageBox(ResourceManager.str_EANPack_Error_Title, GetAlarmText("PACK002"), string.Empty, MessageBoxButton.Ok, MessageBoxImage.Warning);
                                        //Error message "The pick quantity is greater the max number of scans. Please pack the line manualy"

                                        detailView.CurrentItem = foundProductLine;
                                        detailView.Refresh();
                                        detailView.SetFocus();
                                    }
                                }
                                else
                                {
                                    PackPickOrderLine(foundProductLine, foundProductLine.PickedQuantity.Value);
                                }
                            }
                            else
                            {
                                Console.Beep(350, 1000);
                                ShellInteractionService.ShowMessageBox(ResourceManager.str_EANPack_Error_Title, GetAlarmText("PACK003"), string.Empty, MessageBoxButton.Ok, MessageBoxImage.Warning);
                                //Error message "The product can´t be packed with EAN since there are several pick order lines for this product"
                            }
                        }
                        else
                        {
                            Console.Beep(350, 1000);
                            ShellInteractionService.ShowMessageBox(ResourceManager.str_EANPack_Error_Title, GetAlarmText("PACK004"), string.Empty, MessageBoxButton.Ok, MessageBoxImage.Warning);
                            //Error messaga "No product corresponds to this EAN code"
                        }
                    }
                }
            }
            else //Start Pack & Sort
            {
                PackStationSearchPanelView searchPanel = null;
                if (WorkItem.Items.FindByType <PackStationSearchPanelView>().Count > 0)
                {
                    searchPanel = WorkItem.Items.FindByType <PackStationSearchPanelView>().Last();
                }

                string empId      = string.Empty;
                string pickZoneId = string.Empty;

                if (viewParameters != null)
                {
                    if (!string.IsNullOrEmpty(viewParameters.PickZoneId))
                    {
                        pickZoneId = viewParameters.PickZoneId;
                    }

                    if (!string.IsNullOrEmpty(viewParameters.UserId))
                    {
                        empId = viewParameters.UserId;
                    }
                }

                if (searchPanel != null)
                {
                    if (string.IsNullOrEmpty(empId))
                    {
                        empId = searchPanel.CurrentItem.UserId;
                    }

                    if (string.IsNullOrEmpty(pickZoneId))
                    {
                        pickZoneId = searchPanel.CurrentItem.PickZoneId;
                    }
                }

                if (!string.IsNullOrEmpty(pickZoneId))
                {
                    if (!string.IsNullOrEmpty(empId))
                    {
                        ScanEachPickPackage = true;

                        StartPackAndSortArtResponse serviceResponse = null;
                        //try
                        //{
                        StartPackAndSortArtRequest serviceRequest = new StartPackAndSortArtRequest();
                        serviceRequest.StartPackAndSortArtParameters               = new StartPackAndSortArtParameters();
                        serviceRequest.StartPackAndSortArtParameters.UserId        = empId;
                        serviceRequest.StartPackAndSortArtParameters.PickZoneId    = pickZoneId;
                        serviceRequest.StartPackAndSortArtParameters.BarCodeNumber = eanCode;
                        serviceRequest.StartPackAndSortArtParameters.WarehouseId   = UserSessionService.WarehouseId;
                        serviceRequest.StartPackAndSortArtParameters.ClientId      = UserSessionService.ClientId;
                        serviceResponse = Service.StartPackAndSortArt(serviceRequest);
                        if ((serviceResponse != null) && (serviceResponse.StartPackAndSortArtResult != null))
                        {
                            ToLoadCarrierId = serviceResponse.StartPackAndSortArtResult.LoadCarrierId;
                            View.EnableComponent("ToLoadCarrier", false);
                            View.EnableComponent("FromLoadCarrier", false);

                            if (searchPanel != null)
                            {
                                searchPanel.DepartureId.Text      = serviceResponse.StartPackAndSortArtResult.DepartureId;
                                searchPanel.ShipToCustomerId.Text = serviceResponse.StartPackAndSortArtResult.ShipToCustomerId;
                                searchPanel.UserId.Text           = empId;
                                PackStationSearchPanelViewResult searchPanelResult = new PackStationSearchPanelViewResult();
                                searchPanelResult.DepartureId      = serviceResponse.StartPackAndSortArtResult.DepartureId;
                                searchPanelResult.ShipToCustomerId = serviceResponse.StartPackAndSortArtResult.ShipToCustomerId;
                                searchPanelResult.PickZoneId       = pickZoneId;
                                searchPanelResult.UserId           = empId;
                                searchPanel.PresentData(searchPanelResult);
                                PackStationOverviewViewParameters parameters = new PackStationOverviewViewParameters();
                                parameters.DepartureId      = serviceResponse.StartPackAndSortArtResult.DepartureId;
                                parameters.ClientId         = UserSessionService.ClientId;
                                parameters.PickZoneId       = pickZoneId;
                                parameters.UserId           = empId;
                                parameters.ShipToCustomerId = serviceResponse.StartPackAndSortArtResult.ShipToCustomerId;
                                View.Update(parameters);
                            }
                        }
                        //}
                        //catch (FaultException<ApplicationFault> ex)
                        //{
                        //    if (ShellInteractionService.ShowMessageBox(ResourceManager.str_ResetPackStatio_Title, GetAlarmText(ex.Detail.ErrorCode), null, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Ok)
                        //    {
                        //    }
                        //}
                    }
                }
                else
                {
                    Console.Beep(350, 1000);
                    ShellInteractionService.ShowMessageBox(ResourceManager.str_EANPack_Error_Title, GetAlarmText("PACK007"), string.Empty, MessageBoxButton.Ok, MessageBoxImage.Warning);
                }
            }
        }
        public bool SelectToLoadCarrier(string loadCarrierId)
        {
            PackStationSearchPanelView searchPanel = null;

            if (WorkItem.Items.FindByType <PackStationSearchPanelView>().Count > 0)
            {
                searchPanel = WorkItem.Items.FindByType <PackStationSearchPanelView>().Last();
            }
            string customerId  = string.Empty;
            string departureId = string.Empty;
            string empId       = string.Empty;
            bool   firstCarId  = false;

            if (viewParameters != null)
            {
                if (!string.IsNullOrEmpty(viewParameters.DepartureId))
                {
                    departureId = viewParameters.DepartureId;
                }
                if (!string.IsNullOrEmpty(viewParameters.ShipToCustomerId))
                {
                    customerId = viewParameters.ShipToCustomerId;
                }
                if (!string.IsNullOrEmpty(viewParameters.UserId))
                {
                    empId = viewParameters.UserId;
                }
            }
            if (string.IsNullOrEmpty(empId))
            {
                if (searchPanel != null)
                {
                    empId = searchPanel.CurrentItem.UserId;
                }
            }
            if (string.IsNullOrEmpty(departureId) || string.IsNullOrEmpty(customerId))
            {
                firstCarId = true;
            }
            SelectToLoadCarrierForPackStationResponse serviceResponse = null;

            try
            {
                SelectToLoadCarrierForPackStationRequest serviceRequest = new SelectToLoadCarrierForPackStationRequest();
                serviceRequest.SelectToLoadCarrierForPackStationParameters                  = new SelectToLoadCarrierForPackStationParameters();
                serviceRequest.SelectToLoadCarrierForPackStationParameters.ClientId         = UserSessionService.ClientId;
                serviceRequest.SelectToLoadCarrierForPackStationParameters.DepartureId      = departureId;
                serviceRequest.SelectToLoadCarrierForPackStationParameters.LoadCarrierId    = loadCarrierId;
                serviceRequest.SelectToLoadCarrierForPackStationParameters.ShipToCustomerId = customerId;
                serviceRequest.SelectToLoadCarrierForPackStationParameters.UserId           = empId;
                serviceRequest.SelectToLoadCarrierForPackStationParameters.WarehouseId      = UserSessionService.WarehouseId;
                serviceResponse = Service.SelectToLoadCarrierForPackStation(serviceRequest);
                if ((serviceResponse == null) || (serviceResponse.SelectToLoadCarrierForPackStationResult == null))
                {
                    return(false);
                }
            }
            catch (FaultException <ApplicationFault> ex)
            {
                if (ex.Detail.ErrorCode == "PBCAR078" || ex.Detail.ErrorCode == "PBCAR048")
                {
                    if (ShellInteractionService.ShowMessageBox(ResourceManager.str_ResetPackStatio_Title, GetAlarmText("PACK001"), null, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        if (StopPacking != null)
                        {
                            StopPacking(this, null);
                        }
                        viewParameters.DepartureId      = string.Empty;
                        viewParameters.ShipToCustomerId = string.Empty;
                        SelectToLoadCarrier(loadCarrierId);
                        return(true);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(ToLoadCarrierId))
                        {
                            ToLoadCarrierId = ToLoadCarrierId;
                        }
                        else
                        {
                            ToLoadCarrierId = string.Empty;
                        }
                        return(false);
                    }
                }
                else
                {
                    if (firstCarId)
                    {
                        if (viewParameters != null)
                        {
                            viewParameters.UserId = string.Empty;
                        }
                    }
                    ToLoadCarrierId = string.Empty;
                    throw;
                }
            }
            if (firstCarId)
            {
                if (searchPanel != null)
                {
                    searchPanel.DepartureId.Text      = serviceResponse.SelectToLoadCarrierForPackStationResult.DepartureId;
                    searchPanel.ShipToCustomerId.Text = serviceResponse.SelectToLoadCarrierForPackStationResult.ShipToCustomerId;
                    searchPanel.UserId.Text           = empId;
                    PackStationSearchPanelViewResult searchPanelResult = new PackStationSearchPanelViewResult();
                    searchPanelResult.DepartureId      = serviceResponse.SelectToLoadCarrierForPackStationResult.DepartureId;
                    searchPanelResult.ShipToCustomerId = serviceResponse.SelectToLoadCarrierForPackStationResult.ShipToCustomerId;
                    searchPanelResult.UserId           = empId;
                    searchPanel.PresentData(searchPanelResult);
                    PackStationOverviewViewParameters parameters = new PackStationOverviewViewParameters();
                    parameters.DepartureId      = serviceResponse.SelectToLoadCarrierForPackStationResult.DepartureId;
                    parameters.ClientId         = UserSessionService.ClientId;
                    parameters.UserId           = empId;
                    parameters.ShipToCustomerId = serviceResponse.SelectToLoadCarrierForPackStationResult.ShipToCustomerId;
                    viewParameters = parameters;
                }
            }

            ScanEachPickPackage = serviceResponse.SelectToLoadCarrierForPackStationResult.ScanEachPickPackage.Value;
            MaxNoOfScans        = serviceResponse.SelectToLoadCarrierForPackStationResult.MaxNoOfScans.GetValueOrDefault(0);

            ToLoadCarrierId = loadCarrierId;
            return(true);
        }
        public bool SelectFromLoadCarrier(string loadCarrierId)
        {
            PackStationSearchPanelView searchPanel = null;

            if (WorkItem.Items.FindByType <PackStationSearchPanelView>().Count > 0)
            {
                searchPanel = WorkItem.Items.FindByType <PackStationSearchPanelView>().Last();
            }
            string customerId  = string.Empty;
            string departureId = string.Empty;
            string empId       = string.Empty;
            bool   firstCarId  = false;

            string shipToCustomerId = string.Empty;
            string pickZoneId       = string.Empty;

            if (viewParameters != null)
            {
                if (!string.IsNullOrEmpty(viewParameters.DepartureId))
                {
                    departureId = viewParameters.DepartureId;
                }
                if (!string.IsNullOrEmpty(viewParameters.ShipToCustomerId))
                {
                    customerId = viewParameters.ShipToCustomerId;
                }
                if (!string.IsNullOrEmpty(viewParameters.UserId))
                {
                    empId = viewParameters.UserId;
                }
                if (!string.IsNullOrEmpty(viewParameters.PickZoneId))
                {
                    pickZoneId = viewParameters.PickZoneId;
                }
            }

            if (searchPanel != null)
            {
                if (string.IsNullOrEmpty(empId))
                {
                    empId = searchPanel.CurrentItem.UserId;
                    if (viewParameters != null)
                    {
                        viewParameters.UserId = empId;
                    }
                }

                if (string.IsNullOrEmpty(pickZoneId))
                {
                    pickZoneId = searchPanel.CurrentItem.PickZoneId;
                }
            }

            if (string.IsNullOrEmpty(departureId) || string.IsNullOrEmpty(customerId))
            {
                firstCarId = true;
            }


            if (firstCarId && !string.IsNullOrEmpty(pickZoneId) && string.IsNullOrEmpty(toLoadCarrierId)) //Start Pack & Sort
            {
                StartPackAndSortCarResponse serviceResponse = null;
                StartPackAndSortCarRequest  serviceRequest  = new StartPackAndSortCarRequest();
                serviceRequest.StartPackAndSortCarParameters               = new StartPackAndSortCarParameters();
                serviceRequest.StartPackAndSortCarParameters.UserId        = empId;
                serviceRequest.StartPackAndSortCarParameters.LoadCarrierId = loadCarrierId;
                serviceResponse = Service.StartPackAndSortCar(serviceRequest);
                if ((serviceResponse == null) || (serviceResponse.StartPackAndSortCarResult == null))
                {
                    return(false);
                }
                else
                {
                    departureId      = serviceResponse.StartPackAndSortCarResult.DepartureId;
                    shipToCustomerId = serviceResponse.StartPackAndSortCarResult.ShipToCustomerId;

                    ToLoadCarrierId = loadCarrierId;
                    View.EnableComponent("ToLoadCarrier", false);
                    View.EnableComponent("FromLoadCarrier", false);
                }
            }
            else
            {
                SelectFromLoadCarrierForPackStationResponse serviceResponse = null;
                try
                {
                    SelectFromLoadCarrierForPackStationRequest serviceRequest = new SelectFromLoadCarrierForPackStationRequest();
                    serviceRequest.SelectFromLoadCarrierForPackStationParameters                  = new SelectFromLoadCarrierForPackStationParameters();
                    serviceRequest.SelectFromLoadCarrierForPackStationParameters.ClientId         = UserSessionService.ClientId;
                    serviceRequest.SelectFromLoadCarrierForPackStationParameters.DepartureId      = departureId;
                    serviceRequest.SelectFromLoadCarrierForPackStationParameters.LoadCarrierId    = loadCarrierId;
                    serviceRequest.SelectFromLoadCarrierForPackStationParameters.ShipToCustomerId = customerId;
                    serviceRequest.SelectFromLoadCarrierForPackStationParameters.UserId           = empId;
                    serviceRequest.SelectFromLoadCarrierForPackStationParameters.WarehouseId      = UserSessionService.WarehouseId;
                    serviceResponse = Service.SelectFromLoadCarrierForPackStation(serviceRequest);
                    if ((serviceResponse == null) || (serviceResponse.SelectFromLoadCarrierForPackStationResult == null))
                    {
                        return(false);
                    }
                    else
                    {
                        departureId      = serviceResponse.SelectFromLoadCarrierForPackStationResult.DepartureId;
                        shipToCustomerId = serviceResponse.SelectFromLoadCarrierForPackStationResult.ShipToCustomerId;
                    }
                }
                catch (FaultException <ApplicationFault> ex)
                {
                    if (ex.Detail.ErrorCode == "PBCAR078" || ex.Detail.ErrorCode == "PBCAR048")
                    {
                        if (ShellInteractionService.ShowMessageBox(ResourceManager.str_ResetPackStatio_Title, GetAlarmText("PACK001"), null, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            if (StopPacking != null)
                            {
                                StopPacking(this, null);
                            }
                            viewParameters.DepartureId      = string.Empty;
                            viewParameters.ShipToCustomerId = string.Empty;
                            ToLoadCarrierId = string.Empty;
                            SelectFromLoadCarrier(loadCarrierId);
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else if (ex.Detail.ErrorCode == "PBCAR083")
                    {
                        if (ShellInteractionService.ShowMessageBox(StringResources.ActionException_Text, ex.Message, null, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            ForceSelectFromLoadCarrierForPackStationRequest forceSelectServiceRequest = new ForceSelectFromLoadCarrierForPackStationRequest();
                            forceSelectServiceRequest.ForceSelectFromLoadCarrierForPackStationParameters = new ForceSelectFromLoadCarrierForPackStationParameters();
                            forceSelectServiceRequest.ForceSelectFromLoadCarrierForPackStationParameters.LoadCarrierId = loadCarrierId;
                            forceSelectServiceRequest.ForceSelectFromLoadCarrierForPackStationParameters.UserId        = empId;
                            ForceSelectFromLoadCarrierForPackStationResponse forceResponce = Service.ForceSelectFromLoadCarrierForPackStation(forceSelectServiceRequest);
                            if ((forceResponce == null) || (forceResponce.ForceSelectFromLoadCarrierForPackStationResult == null))
                            {
                                return(false);
                            }
                            else
                            {
                                departureId      = forceResponce.ForceSelectFromLoadCarrierForPackStationResult.DepartureId;
                                shipToCustomerId = forceResponce.ForceSelectFromLoadCarrierForPackStationResult.ShipToCustomerId;
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (firstCarId)
                        {
                            if (viewParameters != null)
                            {
                                viewParameters.UserId = string.Empty;
                            }
                        }
                        ShellInteractionService.ShowMessageBox(StringResources.ActionException_Text, ex.Message, null, MessageBoxButton.Ok, MessageBoxImage.Error);
                        return(false);
                    }
                }
            }

            if (firstCarId)
            {
                if (searchPanel != null)
                {
                    searchPanel.DepartureId.Text      = departureId;
                    searchPanel.ShipToCustomerId.Text = shipToCustomerId;
                    searchPanel.UserId.Text           = empId;
                    PackStationSearchPanelViewResult searchPanelResult = new PackStationSearchPanelViewResult();
                    searchPanelResult.DepartureId      = departureId;
                    searchPanelResult.ShipToCustomerId = shipToCustomerId;
                    searchPanelResult.UserId           = empId;
                    searchPanelResult.PickZoneId       = pickZoneId;
                    searchPanel.PresentData(searchPanelResult);
                    PackStationOverviewViewParameters parameters = new PackStationOverviewViewParameters();
                    parameters.DepartureId      = departureId;
                    parameters.ClientId         = UserSessionService.ClientId;
                    parameters.UserId           = empId;
                    parameters.ShipToCustomerId = shipToCustomerId;
                    parameters.PickZoneId       = pickZoneId;
                    View.Update(parameters);
                }
            }
            else
            {
                View.Update(viewParameters); // View.OnViewUpdated();
            }
            return(true);
        }