Ejemplo n.º 1
0
        internal override void DetermineDestinationAndRounting(SortedItem sortedItem, InboundLabel label)
        {
            //
            string sanNumber = label.GetElementValue("SAN").Substring(0, 6);

            sanNumber           += Helper.CheckDigitMod11(sanNumber);
            sortedItem.SANNUmber = sanNumber;
            //sortedItem.CartonNumber = label.GetElementValue("CARTON");
            sortedItem.PONumber = label.GetElementValue("PO");
            string shipOverride = (ShipOverride.Length > 0 ? ShipOverride : label.GetElementValue("OSOVERRIDE"));

            try {
                sortedItem.SpecialAgent = SortFactory.CreateSpecialAgent(sortedItem.Client.Number, sortedItem.Client.Division, shipOverride);
                ArgixTrace.WriteLine(new TraceMessage("Special Agent: " + sortedItem.SpecialAgent.Type, AppLib.EVENTLOGNAME, LogLevel.Debug, "Brain    "));
                sortedItem.DestinationRouting = SortFactory.CreateSANDestinationRouting(sortedItem.Client.Number, sortedItem.Client.Division, sortedItem.Freight.Shipper.NUMBER, Self.Station.TerminalID.ToString().PadLeft(2, '0'), sanNumber, sortedItem.SpecialAgent.ZONE_CODE.Trim(), sortedItem.CartonNumber, !label.IsDuplicateElementAllowed("CARTON"));
                if (sortedItem.SpecialAgent.IsDefault)
                {
                    sortedItem.SpecialAgent = SortFactory.CreateSpecialAgentByZone(sortedItem.Client.Number, sortedItem.Client.Division, sortedItem.DestinationRouting.ZoneCode.Trim());
                }
                ArgixTrace.WriteLine(new TraceMessage("Special Agent: " + sortedItem.SpecialAgent.Type, AppLib.EVENTLOGNAME, LogLevel.Debug, "Brain    "));
                if (!UPSAllowed && sortedItem.SpecialAgent.Type == "UPSSpecialAgent")
                {
                    sortedItem.SpecialAgent = null;
                    throw new ApplicationException("UPS processing disabled.");
                }
                sortedItem.TrackingNumber = sortedItem.SpecialAgent.MakeTrackingNumber(sortedItem.DestinationRouting.OSSequence);
                sortedItem.LabelTemplate  = SortFactory.CreateOBLabelTemplate(sortedItem.DestinationRouting.OutboundLabelType, Self.Station.PrinterType);
            }
            catch (Exception ex) { sortedItem.ThrowException(new DestinationRoutingException(ex)); }
        }
Ejemplo n.º 2
0
 internal void DuplicateCartonValidation(SortedItem sortedItem)
 {
     //Determine if this is a duplicate carton
     if (this.mSortedItems.IsDuplicateCarton(sortedItem))
     {
         sortedItem.ThrowException(new DuplicateCartonException());
     }
 }
Ejemplo n.º 3
0
        public override SortedItem CreateSortedItem(string[] inputs, int weight)
        {
            //
            SortedItem sortedItem = Self.NewSortedItem();

            sortedItem.ThrowException(new NoAssignmentException());
            sortedItem.ApplyOutboundLabel();
            return(sortedItem);
        }
Ejemplo n.º 4
0
        protected override void DetermineAssignment(string[] inputs, SortedItem sortedItem)
        {
            //Override the default implementation to determine the correct assignment
            //dynamically; if station has only one assignment, default implementation is OK
            try {
                if (Self.Assignments.Count == 1)
                {
                    //One assignment: use base implementation
                    base.DetermineAssignment(inputs, sortedItem);
                }
                else
                {
                    //Multiple assignments: determine assignment by associating the assignment
                    //with the client who has a store with the input SAN number
                    //Create a default SAN label (for the purpose of extracting the SAN number only)
                    //and determine the SAN number from the inputs
                    InboundLabel label = FreightFactory.DefaultSanInboundLabel.Copy();
                    label.ClearData();
                    try { label.DetermineInputs(inputs); }
                    catch (Exception ex) { sortedItem.ThrowException(new InboundLabelException(ex)); }
                    string sanNumber = label.GetElementValue("SAN").Substring(0, 6);
                    sanNumber += Helper.CheckDigitMod11(sanNumber);

                    //Determine the client for this SAN number and associate with an assignment
                    Client            client     = EnterpriseFactory.CreateClientForStoreSAN(Self.Assignments.Item(0).InboundFreight.Client.Division, sanNumber);
                    StationAssignment assignment = Self.Assignments.Item(client);
                    if (assignment == null)
                    {
                        sortedItem.ThrowException(new ClientForSanException());
                    }

                    //Associate freight and sort information
                    sortedItem.Freight     = assignment.InboundFreight;
                    sortedItem.SortProfile = assignment.SortProfile;
                }
            }
            catch (InboundLabelException ex) { throw ex; }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while determining freight assignment for multiple SAN freight assignments.", ex); }
        }
Ejemplo n.º 5
0
        public virtual SortedItem CreateSortedItem(string[] inputs, int weight)
        {
            //
            SortedItem sortedItem = Self.NewSortedItem();

            try {
                ArgixTrace.WriteLine(new TraceMessage("Determine assignment...", AppLib.EVENTLOGNAME, LogLevel.Debug, "Brain    "));
                DetermineAssignment(inputs, sortedItem);
                ArgixTrace.WriteLine(new TraceMessage("Get inbound label with data...", AppLib.EVENTLOGNAME, LogLevel.Debug, "Brain    "));
                InboundLabel label = getInboundLabelWithData(sortedItem, inputs);
                sortedItem.CartonNumber = label.GetElementValue("CARTON");
                if (!label.IsDuplicateElementAllowed("CARTON"))
                {
                    Self.DuplicateCartonValidation(sortedItem);
                }
                ArgixTrace.WriteLine(new TraceMessage("Determine destination and rounting...", AppLib.EVENTLOGNAME, LogLevel.Debug, "Brain    "));
                DetermineDestinationAndRounting(sortedItem, label);
                if (weight == 0)
                {
                    sortedItem.ThrowException(new ZeroWeightException());
                }
                if (weight > SortedItem.WeightMax)
                {
                    sortedItem.ThrowException(new OverWeightException(weight));
                }
                sortedItem.Weight = weight;
                sortedItem.ApplyOutboundLabel();
            }
            catch (Exception ex) {
                if (!sortedItem.IsError())
                {
                    sortedItem.SortException = new HaveNoIdeaWhatItIsException(ex);
                }
                sortedItem.ApplyOutboundLabel(); //Apply error label
            }
            return(sortedItem);
        }
Ejemplo n.º 6
0
        private InboundLabel getInboundLabelWithData(SortedItem sortedItem, string[] inputs)
        {
            //Create a copy of the inbound label for the current assignment
            InboundLabel label = sortedItem.SortProfile.InboundLabel.Copy();

            sortedItem.InboundLabel  = label;
            label.HasDataChanged    += new LabelDataEventHandler(OnHasDataChanged);
            label.InputReceived     += new LabelDataEventHandler(OnInputReceived);
            label.AllInputsReceived += new EventHandler(OnAllInputsReceived);
            label.ClearData();

            //Map the inputs to the inbound label and complete sorted item processing
            try { label.DetermineInputs(inputs); }
            catch (Exception ex) { sortedItem.ThrowException(new InboundLabelException(ex)); }
            return(label);
        }
Ejemplo n.º 7
0
        public PandaDS ProcessLabelDataRequest(string[] inputs, decimal weight)
        {
            //Create a new carton
            string cartonID = "", zpl = "";
            int    statusCode        = STATUS_NONE;
            ApplicationException aex = null;
            PandaDS ds = new PandaDS();

            //Validate for non-carton requests (scanner tripped)
            bool   hasInputData = false;
            string _inputs      = "";

            for (int i = 0; i < inputs.Length; i++)
            {
                if (inputs[i].Trim().Length > 0)
                {
                    hasInputData = true;
                }
                _inputs += (i + 1).ToString() + "=" + inputs[i] + "; ";
            }
            ArgixTrace.WriteLine(new TraceMessage("LABEL DATA REQUEST: " + _inputs + "weight=" + weight.ToString(), App.EventLogName, LogLevel.Information, "PandaSvc"));
            if (!hasInputData && weight == 0)
            {
                ArgixTrace.WriteLine(new TraceMessage("LABEL DATA RESPONSE: no inputs; no weight; processing aborted...", App.EventLogName, LogLevel.Information, "PandaSvc"));
                return(ds);
            }
            try {
                //Begin processing a new message request
                //if(this.LabelDataRequest != null) this.LabelDataRequest(null,EventArgs.Empty);
                try {
                    //Create a default carton identifier
                    DateTime dt  = DateTime.Now;
                    int      sec = ((3600 * dt.Hour) + (60 * dt.Minute) + dt.Second);
                    cartonID = dt.ToString("yyyy").Substring(3, 1) + dt.ToString("MM") + dt.ToString("dd") + sec.ToString("00000") + "0000";

                    //Get an outbound label for this carton
                    SortedItem sortedItem = this.mOperator.ProcessInputs(inputs, weight);
                    if (sortedItem != null)
                    {
                        try {
                            cartonID = sortedItem.LabelNumber;
                            zpl      = sortedItem.LabelFormat;
                            sortedItem.ThrowException();
                            statusCode = STATUS_CARTON_OK;
                            ArgixTrace.WriteLine(new TraceMessage("Carton processing successful [label data]...", App.EventLogName, LogLevel.Debug, "PandaSvc"));
                        }
                        catch (Tsort.InboundLabelException ex) {
                            //Test for various inbound label exceptions
                            bool allInvalid = true;
                            for (int i = 0; i < inputs.Length; i++)
                            {
                                if (inputs[i].Trim().Length > 0)
                                {
                                    allInvalid = false; break;
                                }
                            }
                            if (allInvalid)
                            {
                                statusCode = STATUS_SCANERROR_NODATA;
                                ArgixTrace.WriteLine(new TraceMessage("Message data validation failed [no data from scanner]-->" + ex.Message + (ex.InnerException != null?"-->" + ex.InnerException.Message:"") + "...", App.EventLogName, LogLevel.Warning, "PandaSvc"));
                            }
                            allInvalid = true;
                            for (int i = 0; i < inputs.Length; i++)
                            {
                                if (inputs[i].Replace("?", "").Trim().Length > 0)
                                {
                                    allInvalid = false; break;
                                }
                            }
                            if (allInvalid && statusCode == STATUS_NONE)
                            {
                                statusCode = STATUS_SCANERROR_NOREAD;
                                ArgixTrace.WriteLine(new TraceMessage("Message data validation failed [no read: ?]-->" + ex.Message + (ex.InnerException != null?"-->" + ex.InnerException.Message:"") + "...", App.EventLogName, LogLevel.Warning, "PandaSvc"));
                            }
                            allInvalid = true;
                            for (int i = 0; i < inputs.Length; i++)
                            {
                                if (inputs[i].Replace("#", "").Trim().Length > 0)
                                {
                                    allInvalid = false; break;
                                }
                            }
                            if (allInvalid && statusCode == STATUS_NONE)
                            {
                                statusCode = STATUS_SCANERROR_CONFLICT;
                                ArgixTrace.WriteLine(new TraceMessage("Message data validation failed [label conflict: #]-->" + ex.Message + (ex.InnerException != null?"-->" + ex.InnerException.Message:"") + "...", App.EventLogName, LogLevel.Warning, "PandaSvc"));
                            }
                            if (statusCode == STATUS_NONE)
                            {
                                statusCode = STATUS_SCANERROR_LABELFAILED;
                                ArgixTrace.WriteLine(new TraceMessage("Message data validation failed [inbound label exception]-->" + ex.Message + (ex.InnerException != null?"-->" + ex.InnerException.Message:"") + "...", App.EventLogName, LogLevel.Warning, "PandaSvc"));
                            }
                        }
                        catch (Tsort.ZeroWeightException ex) {
                            statusCode = STATUS_SCANERROR_WEIGHTBAD;
                            ArgixTrace.WriteLine(new TraceMessage("Message data validation failed [zero weight exception]-->" + ex.Message + (ex.InnerException != null?"-->" + ex.InnerException.Message:"") + "...", App.EventLogName, LogLevel.Warning, "PandaSvc"));
                        }
                        catch (Tsort.OverWeightException ex) {
                            statusCode = STATUS_SCANERROR_WEIGHTBAD;
                            ArgixTrace.WriteLine(new TraceMessage("Message data validation failed [over weight exception]-->" + ex.Message + (ex.InnerException != null?"-->" + ex.InnerException.Message:"") + "...", App.EventLogName, LogLevel.Warning, "PandaSvc"));
                        }
                        catch (Tsort.DestinationRoutingException ex) {
                            statusCode = STATUS_SCANERROR_LABELFAILED;
                            ArgixTrace.WriteLine(new TraceMessage("Sorted item processing failed [destination/routing exception]-->" + ex.Message + (ex.InnerException != null?"-->" + ex.InnerException.Message:"") + "...", App.EventLogName, LogLevel.Warning, "PandaSvc"));
                        }
                        catch (Exception ex) {
                            statusCode = STATUS_SCANERROR_LABELFAILED;
                            ArgixTrace.WriteLine(new TraceMessage("Sorted item processing failed [unexpected exception]-->" + ex.Message + (ex.InnerException != null?"-->" + ex.InnerException.Message:"") + "...", App.EventLogName, LogLevel.Warning, "PandaSvc"));
                        }
                        zpl = zpl.Replace(Tsort.Labels.TokenLibrary.STATUSCODE, statusCode.ToString());
                    }
                    else
                    {
                        aex        = new ApplicationException("Carton processing failed [no sorted item]...");
                        statusCode = STATUS_SCANERROR_LABELFAILED;
                        zpl        = createErrorLabelFormat(STATUS_SCANERROR_LABELFAILED, aex);
                        ArgixTrace.WriteLine(new TraceMessage(aex.Message, App.EventLogName, LogLevel.Warning, "PandaSvc"));
                    }
                }
                catch (Exception ex) {
                    aex        = new ApplicationException("Carton processing failed [sorted item processing threw an exception]-->" + ex.Message + (ex.InnerException != null?"-->" + ex.InnerException.Message:"") + "...", ex);
                    statusCode = STATUS_SCANERROR_LABELFAILED;
                    zpl        = createErrorLabelFormat(STATUS_SCANERROR_LABELFAILED, ex);
                    ArgixTrace.WriteLine(new TraceMessage(aex.Message, App.EventLogName, LogLevel.Warning, "PandaSvc"));
                }
                ds.PandaTable.AddPandaTableRow(cartonID, statusCode, zpl);
                ds.AcceptChanges();
            }
            catch (Exception ex) {
                aex        = new ApplicationException("Carton processing failed [unexpected exception]-->" + ex.Message + (ex.InnerException != null?"-->" + ex.InnerException.Message:"") + "...", ex);
                statusCode = STATUS_ERROR_UNKNOWN;
                zpl        = createErrorLabelFormat(STATUS_ERROR_UNKNOWN, ex);
                ds.PandaTable.AddPandaTableRow(cartonID, statusCode, zpl);
                ds.AcceptChanges();
                ArgixTrace.WriteLine(new TraceMessage(aex.Message, App.EventLogName, LogLevel.Warning, "PandaSvc"));
            }
            finally {
                ArgixTrace.WriteLine(new TraceMessage("LABEL DATA RESPONSE: " + cartonID + "; " + statusCode.ToString(), App.EventLogName, LogLevel.Information, "PandaSvc"));
                //    if(this.LabelDataRequestComplete != null) {
                //        PandaDS _ds = new PandaDS();
                //        _ds.CartonTable.AddCartonTableRow(cartonID,(inputs.Length>0?inputs[0]:""),(inputs.Length>1?inputs[1]:""),(inputs.Length>2?inputs[2]:""),(inputs.Length>3?inputs[3]:""),(inputs.Length>4?inputs[4]:""),(inputs.Length>5?inputs[5]:""),weight,statusCode,zpl,"",(aex!=null?aex.Message:""),"");
                //        this.LabelDataRequestComplete(this,new PandaLabelDataEventArgs(_ds.CartonTable[0]));
                //    }
            }
            return(ds);
        }