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 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));
            }
        }
        public virtual void OnPackStationOverviewRunPackRowForPackStation(WorkItem context, object caller, object target)
        {
            if (target is Imi.SupplyChain.Warehouse.UX.Views.PickLoadCarrier.PackStationOverviewPackRowEventArgs)
            {
                WorkItem wi = GetModuleWorkItem(context);

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

                Imi.SupplyChain.Warehouse.UX.Views.PickLoadCarrier.PackStationOverviewPackRowEventArgs args = target as Imi.SupplyChain.Warehouse.UX.Views.PickLoadCarrier.PackStationOverviewPackRowEventArgs;

                RunPackRowForPackStationActionParameters actionParameters = new RunPackRowForPackStationActionParameters();
                actionParameters.FromLoadCarrierId   = args.FromLoadCarrier;
                actionParameters.ToLoadCarrierId     = args.ToLoadCarrier;
                actionParameters.PickOrderLineNumber = args.PickOrderLineNumber;
                actionParameters.PickedQuantity      = args.QuantityToPack;
                actionParameters.IsItemSelected      = true;

                IPackStationOverviewView packStationOverviewView = context.SmartParts.FindByType <IPackStationOverviewView>().LastOrDefault();
                IPackStationFromLCView   packStationFromLcView   = context.SmartParts.FindByType <IPackStationFromLCView>().LastOrDefault();
                IPackStationToLCView     packStationToLcView     = context.SmartParts.FindByType <IPackStationToLCView>().LastOrDefault();

                try
                {
                    ActionCatalog.Execute(ActionNames.RunPackRowForPackStation, context, caller, actionParameters);

                    if (context.Items.Contains("RefreshPackStationOverview"))
                    {
                        if (((bool)context.Items["RefreshPackStationOverview"]))
                        {
                            packStationOverviewView.Refresh();
                        }
                        else
                        {
                            if (packStationFromLcView != null)
                            {
                                packStationFromLcView.Refresh();
                            }

                            if (packStationToLcView != null)
                            {
                                packStationToLcView.Refresh();
                            }
                        }
                    }
                    else
                    {
                        if (packStationFromLcView != null)
                        {
                            packStationFromLcView.Refresh();
                        }

                        if (packStationToLcView != null)
                        {
                            packStationToLcView.Refresh();
                        }
                    }
                }
                catch
                {
                    throw;
                }
            }
        }
        public override void OnPackStationFromLcEditRunPackRowForPackStation(WorkItem context, object caller, object target)
        {
            WorkItem wi = GetModuleWorkItem(context);

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

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

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

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

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

            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;

            IPackStationFromLcEditView view = context.SmartParts.FindByType <PackStationFromLcEditView>().Last();

            IPackStationOverviewView packStationOverviewView = context.SmartParts.FindByType <IPackStationOverviewView>().LastOrDefault();
            IPackStationFromLCView   packStationFromLcView   = context.SmartParts.FindByType <IPackStationFromLCView>().LastOrDefault();
            IPackStationToLCView     packStationToLcView     = context.SmartParts.FindByType <IPackStationToLCView>().LastOrDefault();

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

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

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

                if (context.Items.Contains("RefreshPackStationOverview"))
                {
                    if (((bool)context.Items["RefreshPackStationOverview"]))
                    {
                        packStationOverviewView.Refresh();
                    }
                    else
                    {
                        if (packStationFromLcView != null)
                        {
                            packStationFromLcView.Refresh();
                        }

                        if (packStationToLcView != null)
                        {
                            packStationToLcView.Refresh();
                        }
                    }
                }
                else
                {
                    if (packStationFromLcView != null)
                    {
                        packStationFromLcView.Refresh();
                    }

                    if (packStationToLcView != null)
                    {
                        packStationToLcView.Refresh();
                    }
                }
            }
            catch (Imi.SupplyChain.UX.ValidationException ex)
            {
                view.HandleValidationResult(ValidationHelper.ConvertToResult((Imi.SupplyChain.UX.ValidationException)ex));
            }
        }