Пример #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 static OutboundLabel GetOutboundLabel(string labelType, string printerType)
        {
            //Get an outbound label
            OutboundLabel label = null;

            try {
                DataSet ds = App.Mediator.FillDataset(USP_LABEL_TEMPLATE, TBL_LABEL_DETAIL, new object[] { labelType, printerType });
                if (ds == null || ds.Tables[TBL_LABEL_DETAIL].Rows.Count == 0)
                {
                    throw new ApplicationException("Label " + labelType + " not found for a " + printerType + "printer.");
                }
                else
                {
                    LabelDS labelDS = new LabelDS();
                    labelDS.Merge(ds);
                    label = new OutboundLabel(labelDS.LabelDetailTable[0]);
                }
            }
            catch (Exception ex) { throw new ApplicationException("Unexpected error getting an outbound label for label " + labelType + " on a " + printerType + " printer.", ex); }
            return(label);
        }