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

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

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

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

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

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

                PackStationFromLCViewToRunPackAllRowsForPackStationActionTranslator translator = null;

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

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

            return(false);
        }
        private void PackPickOrderLine(PackStationFromLCViewResult lineToPackFrom, decimal quantityToPack)
        {
            PackStationOverviewPackRowEventArgs args = new PackStationOverviewPackRowEventArgs();

            args.FromLoadCarrier     = lineToPackFrom.LoadCarrierId;
            args.ToLoadCarrier       = ToLoadCarrierId;
            args.PickOrderLineNumber = lineToPackFrom.PickOrderLineNumber;
            args.QuantityToPack      = quantityToPack;

            if (PackRow != null)
            {
                PackRow(this, args);
            }
        }
        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);
                }
            }
        }