Пример #1
0
        public void ProcessCarton(string labelScan)
        {
            //Check for valid assignment
            if (!isTripAssigned)
            {
                throw new WorkflowException("There is no Trip assignment on this station.");
            }

            //Create a new carton object and attach associated objects
            Carton carton = null;

            try {
                carton = createCarton(labelScan);
            }
            catch (LabelException ex) { throw new WorkflowException("Label did not format correctly. PLEASE RESCAN CARTON.", ex); }
            catch (WorkflowException ex) { throw ex; }
            catch (Exception ex) { throw new WorkflowException("Unexpected error. PLEASE RESCAN CARTON.", ex); }

            //Print an outbound label for this carton
            try {
                string labelTypeOverride = "", labelType = "";
                switch (carton.FreightType)
                {
                case "44":
                    labelTypeOverride = (StationOperator.LabelTypeOverrideRegular.Length > 0) ? StationOperator.LabelTypeOverrideRegular : "";
                    labelType         = (carton.Store.LabelType.Trim().Length > 0) ? carton.Store.LabelType.Trim() : carton.Zone.LabelType.Trim();
                    break;

                case "88":
                    labelTypeOverride = (StationOperator.LabelTypeOverrideReturns.Trim().Length > 0) ? StationOperator.LabelTypeOverrideReturns.Trim() : "";
                    labelType         = carton.Zone.LabelType.Trim();
                    break;
                }
                if (labelTypeOverride.Length > 0)
                {
                    labelType = labelTypeOverride;
                }
                OutboundLabel label = FreightService.GetOutboundLabel(labelType, this.mStation.PrinterType);
                string        zpl   = carton.FormatLabelTemplate(label.Template);
                this.mStation.Printer.Print(zpl);
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new WorkflowException("Label Error", ex); }

            //Save carton to database (generates label seq number)
            try {
                if (FreightService.CreateCarton(carton, this.mAssignment.Number, this.mStation.Number))
                {
                    this.mPreviousCarton = carton;
                    this.mCartonsScanned++;
                    if (this.CartonCreated != null)
                    {
                        CartonCreated(this, new CartonEventArgs(carton.ScanData));
                    }
                }
            }
            catch (Exception ex) { throw new WorkflowException("Carton may not have saved. PLEASE RESCAN CARTON.", ex); }
        }
Пример #2
0
        public void AddBook(string bookScan, bool damaged)
        {
            //Add a book to this carton sample
            string scan = "";

            try {
                //Determine ISBN, UPC, or EAN
                if (bookScan.Length == global::Argix.Properties.Settings.Default.ISBNScanSize)
                {
                    //ISBN: validate; convert to EAN
                    if (!Carton.ValidateISBN(bookScan))
                    {
                        throw new WorkflowException("Book " + bookScan + " failed the ISBN check digit validation.");
                    }
                    scan = Carton.ConvertISBNtoEAN(bookScan);
                }
                else if (bookScan.Length == global::Argix.Properties.Settings.Default.UPCScanSize)
                {
                    //UPC: validate; no conversion
                    if (!Carton.ValidateUPC(bookScan))
                    {
                        throw new WorkflowException("Book " + bookScan + " failed the UPC check digit validation.");
                    }
                    scan = bookScan;
                }
                else if (bookScan.Length == global::Argix.Properties.Settings.Default.EANScanSize)
                {
                    //EAN: check for EAN prefix & validate; no conversion
                    if (bookScan.Substring(0, global::Argix.Properties.Settings.Default.EANPrefix.Length) != global::Argix.Properties.Settings.Default.EANPrefix)
                    {
                        throw new WorkflowException("An EAN identifier (" + global::Argix.Properties.Settings.Default.EANPrefix + ") was not found in EAN book " + bookScan + ".");
                    }
                    if (!Carton.ValidateEAN(bookScan))
                    {
                        throw new WorkflowException("Book " + bookScan + " failed the EAN check digit validation.");
                    }
                    scan = bookScan;
                }
                else
                {
                    throw new WorkflowException("The scan length was not valid (i.e. EAN=" + global::Argix.Properties.Settings.Default.EANScanSize.ToString() + "; ISBN=" + global::Argix.Properties.Settings.Default.ISBNScanSize.ToString() + ")");
                }

                //Add to book/damaged book collection- increment count of existing book or add new isbn#
                if (this.mBooks.ContainsKey(scan))
                {
                    this.mBooks[scan]        = Convert.ToInt32(this.mBooks[scan]) + 1;
                    this.mDamagedBooks[scan] = Convert.ToInt32(this.mDamagedBooks[scan]) + (damaged ? 1 : 0);
                }
                else
                {
                    this.mBooks.Add(scan, 1);
                    this.mDamagedBooks.Add(scan, (damaged ? 1 : 0));
                }
            }
            catch (WorkflowException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error adding book " + bookScan + ".", ex); }
        }
Пример #3
0
        public static bool DeleteCarton(Carton carton)
        {
            //Delete an existing carton
            bool ret = false;

            try {
                ret = App.Mediator.ExecuteNonQuery(USP_CARTON_DELETE, new object[] { carton.ScanDataFirst23 });
            }
            catch (Exception ex) { throw new ApplicationException("Unexpected error deleting a carton from the database.", ex); }
            return(ret);
        }
Пример #4
0
        public static bool CreateCarton(Carton carton, string tripNumber, string stationNumber)
        {
            //Create a new carton
            bool ret = false;

            try {
                ret = App.Mediator.ExecuteNonQuery(USP_CARTON_CREATE, new object[] { carton.ScanDataFirst23, tripNumber, DateTime.Now, stationNumber });
            }
            catch (Exception ex) { throw new ApplicationException("Unexpected error creating a carton in the database.", ex); }
            return(ret);
        }
Пример #5
0
        public static bool CartonExists(Carton carton)
        {
            //Determine if this carton already exists in the system
            bool bRet = false;

            try {
                DataSet ds = App.Mediator.FillDataset(USP_CARTON_DETAIL, TBL_CARTON_DETAIL, new object[] { carton.ScanDataFirst23 });
                bRet = (ds.Tables[TBL_CARTON_DETAIL].Rows.Count > 0);
            }
            catch (Exception ex) { throw new ApplicationException("Unexpected error reading carton details.", ex); }
            return(bRet);
        }
Пример #6
0
 public void Reset()
 {
     //Create a new empty carton
     try {
         this.mCarton = null;
     }
     catch (Exception ex) { throw new ApplicationException("Failed to clear the current carton sample.", ex); }
     finally { if (this.ResetCarton != null)
               {
                   this.ResetCarton(this, EventArgs.Empty);
               }
     }
 }
Пример #7
0
 public void DeleteCarton(string labelScan)
 {
     //Delete an existing carton from the system
     try {
         Carton carton = new Carton(labelScan);
         if (!carton.isValid)
         {
             throw new ApplicationException("Invalid carton.");
         }
         if (FreightService.DeleteCarton(carton))
         {
             if (this.CartonDeleted != null)
             {
                 CartonDeleted(this, new CartonEventArgs(labelScan));
             }
         }
     }
     catch (Exception ex) { throw new WorkflowException("Carton was not deleted.", ex); }
 }
Пример #8
0
        public void ValidateCartonNumber(string cartonNumber, string shipperNumber)
        {
            //Validate a carton number exists for this book
            try {
                //Validate carton input
                if (cartonNumber.Length == 0)
                {
                    if (this.CartonNumberRequired != null)
                    {
                        this.CartonNumberRequired(this, EventArgs.Empty);
                    }
                }

                if (cartonNumber.Length > 0 && shipperNumber.Length > 0)
                {
                    //Validate unique carton number for the specified vendor
                    StatSampleDS sample = new StatSampleDS();
                    sample.Merge(App.Mediator.FillDataset(App.USP_CARTON_READ, App.TBL_CARTON_READ, new object[] { cartonNumber, shipperNumber }));
                    if (sample.HeaderTable.Rows.Count > 0)
                    {
                        throw new WorkflowException("Carton# " + cartonNumber + " is a duplicate for vendor#" + shipperNumber + ".");
                    }
                    else
                    {
                        this.mCarton = new Carton(cartonNumber, shipperNumber);
                        if (this.CartonNumberValidated != null)
                        {
                            this.CartonNumberValidated(this, EventArgs.Empty);
                        }
                    }
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (WorkflowException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while validating carton number.", ex); }
        }
Пример #9
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);
        }