Beispiel #1
0
        private Carton createCarton(string labelScan)
        {
            //Create a new carton
            Carton carton = null;

            try {
                //Create a scanned carton; check for a valid scan, then check if carton exists in db
                carton = new Carton(labelScan);
                tripValidToSortCheck();
                if (!carton.isValid)
                {
                    throw new WorkflowException("Invalid scan " + carton.ScanData + ".");
                }

                if (FreightService.CartonExists(carton))
                {
                    //Log a duplicate carton that was not the previous carton
                    if ((carton.ScanData != this.mPreviousCarton.ScanData) && (this.mPreviousCarton.ScanData != ""))
                    {
                        throw new WorkflowException("Duplicate carton.");
                    }
                    else
                    {
                        throw new WorkflowException("Carton exists.");
                    }
                }

                //Set carton objects for label creation
                carton.Workstation    = this.mStation;
                carton.InboundFreight = this.mAssignment;
                carton.Client         = EnterpriseService.GetClient(carton.ClientNumber);
                switch (carton.FreightType)
                {
                case "44":
                    //Regular freight- get a label configuration based upon client and store
                    carton.Store = EnterpriseService.GetStore(carton.ClientNumber, carton.StoreNumber);
                    carton.Zone  = EnterpriseService.GetZone(carton.Store.Zone, carton.Store.ZoneType);
                    break;

                case "88":
                    //Return freight- get a label configuration based upon client and vendor
                    carton.ClientVendor = EnterpriseService.GetClientVendor(carton.ClientNumber, carton.VendorNumber);
                    carton.Zone         = EnterpriseService.GetZone(carton.ClientVendor.ZONE_CODE, carton.ClientVendor.ZONE_TYPE);
                    break;
                }

                //Validate the lanes (if applicable)
                if (StationOperator.ValidateLane)
                {
                    if (carton.Zone.Lane.Length == 0)
                    {
                        throw new ApplicationException("The lane for zone " + carton.Zone.Code + " is missing");
                    }
                    if (carton.Zone.Lane.CompareTo("00") <= 0)
                    {
                        throw new ApplicationException("The lane for zone " + carton.Zone.Code + " is invalid (" + carton.Zone.Lane.Trim() + ")");
                    }
                }
                if (StationOperator.ValidateSmallLane)
                {
                    if (carton.Zone.SmallSortLane.Length == 0)
                    {
                        throw new ApplicationException("The small lane for zone " + carton.Zone.Code + " is missing");
                    }
                    if (carton.Zone.SmallSortLane.CompareTo("00") <= 0)
                    {
                        throw new ApplicationException("The small lane for zone " + carton.Zone.Code + " is invalid (" + carton.Zone.Lane.Trim() + ")");
                    }
                }
                //carton.TrailerLoad = CreateTrailerLoad(carton.Zone.TRAILER_LOAD_NUM);
            }
            catch (WorkflowException ex) { throw ex; }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new carton instance.", ex); }

            return(carton);
        }