Exemplo n.º 1
0
        public virtual ActionResult LocatePallet(LocationViewModel model)
        {
            //TC18: Location must be empty.When after merging pallets, we are trying to put the pallet on some location.
            if (string.IsNullOrEmpty(model.ScanText))
            {
                return(View(Views.ScanToPallet, new ScanToPalletViewModel()));
            }

            try
            {
                _service.EnsureLocationIsValid(model.ScanText);
            }
            catch (BoxManagerServiceException ex)
            {
                switch (ex.ErrorCode)
                {
                case BoxManagerServiceErrorCode.InvalidLocation:
                    ModelState.AddModelError("", string.Format("Location {0} is invalid, Please scan a valid location.", model.ScanText));
                    break;
                }
                return(Location(model.PalletId));
            }
            _service.UpdatePalletLocation(model.PalletId, model.ScanText);
            this.AddStatusMessage(string.Format("Pallet {0} placed on location {1}.", model.PalletId, model.ScanText));
            return(CreatingPalletIndex());
        }
Exemplo n.º 2
0
        public virtual ActionResult HandleDestinationScan(DestinationViewModel model)
        {
            //TC22: Location must be empty.
            if (!ModelState.IsValid || string.IsNullOrEmpty(model.ScanText))
            {
                // Invalid source pallet
                return(Index());
            }
            try
            {
                ////Compatibility Code to handle location scan
                ////#####################################################################################
                //int nLength = model.ScanText.Length;
                //if (nLength <= 4 && nLength > 0)
                //{
                //    int nDiffChars = 5 - nLength;
                //    char padChar = '0';
                //    model.ScanText = "911" + model.ScanText.PadLeft(nLength + nDiffChars, padChar);
                //}
                ////######################################################################################
                //if (__regLocation.IsMatch(model.ScanText))
                //{
                //As per our discussion we will assume default scan as a location scan. MB,DB and SHIVA(June 19th 2012)

                _service.EnsureLocationIsValid(model.ScanText);
                // Location scan
                _service.UpdatePalletLocation(model.SourcePalletId, model.ScanText);
                this.AddStatusMessage(string.Format("Pallet {0} placed on Location {1}.", model.SourcePalletId, model.ScanText));
                return(Index());
            }
            catch (BoxManagerServiceException ex)
            {
                switch (ex.ErrorCode)
                {
                case BoxManagerServiceErrorCode.MergingPalletWithSelf:
                    ModelState.AddModelError("", string.Format("Pallet {0} and {1} could not be merged because they are same.", model.ScanText, model.SourcePalletId));
                    break;

                case BoxManagerServiceErrorCode.MultipleAreaPallet:
                    ModelState.AddModelError("", string.Format("Pallet {0} contains boxes of multiple areas {1}.", model.ScanText, ex.Data["Data"]));
                    break;

                case BoxManagerServiceErrorCode.MultipleLocationPallet:
                    ModelState.AddModelError("", string.Format("Pallet {0} contain boxes of multiple locations {1}.", model.ScanText, ex.Data["Data"]));
                    break;

                case BoxManagerServiceErrorCode.MultipleBucketPallet:
                    ModelState.AddModelError("", string.Format("Merging denied because merged pallet {0} and {1} would contain boxes of multiple buckets {2}.",
                                                               model.ScanText, model.SourcePalletId, ex.Data["Data"]));
                    break;

                case BoxManagerServiceErrorCode.MultipleCustomerPallet:
                    ModelState.AddModelError("", string.Format("Merging denied because merged pallet {0} and {1} would contain boxes of multiple customers {2}.",
                                                               model.ScanText, model.SourcePalletId, ex.Data["Data"]));
                    break;

                case BoxManagerServiceErrorCode.MultipleDcPallet:
                    ModelState.AddModelError("", string.Format("Merging denied because merged pallet {0} and {1} would contain boxes of multiple DCs {2}.",
                                                               model.ScanText, model.SourcePalletId, ex.Data["Data"]));
                    break;

                case BoxManagerServiceErrorCode.MultiplePoPallet:
                    ModelState.AddModelError("", string.Format("Merging denied because merged pallet {0} and {1} would contain boxes of multiple POs {2}.",
                                                               model.ScanText, model.SourcePalletId, ex.Data["Data"]));
                    break;

                case BoxManagerServiceErrorCode.InvalidLocation:
                    ModelState.AddModelError("", string.Format("Location {0} is invalid.", model.ScanText));
                    break;
                }
                // The service generates this exception. The pallets cannot be merged.
                return(RedirectToAction(this.Actions.Destination(model.SourcePalletId, Sound.Error)));
            }
        }