Пример #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)); }
        }
Пример #2
0
        private void configApplication()
        {
            try {
                //Create event log and database trace listeners, and log application as started
                try {
                    ArgixTrace.AddListener(new DBTraceListener((LogLevel)App.Config.TraceLevel, App.Mediator, App.USP_TRACE, App.EventLogName));
                }
                catch {
                    ArgixTrace.AddListener(new DBTraceListener(LogLevel.Debug, App.Mediator, App.USP_TRACE, App.EventLogName));
                    ArgixTrace.WriteLine(new TraceMessage("Log level not found; setting log levels to Debug.", App.EventLogName, LogLevel.Warning, "Log Level"));
                }
                ArgixTrace.WriteLine(new TraceMessage(App.Version, App.EventLogName, LogLevel.Information, "App Started"));

                //Create business objects with configuration values
                App.Mediator.DataStatusUpdate += new DataStatusHandler(OnDataStatusUpdate);
                EnterpriseFactory.Mediator     = App.Mediator;
                EnterpriseFactory.RefreshCache();
                FinanceFactory.Mediator = App.Mediator;
                FinanceFactory.RefreshCache();
                DriverRatingFactory.Mediator = App.Mediator;
                this.stbMain.SetTerminalPanel(EnterpriseFactory.LocalTerminal.TerminalID.ToString(), EnterpriseFactory.LocalTerminal.Description);
                bool createError = App.Config.ReadOnly;
            }
            catch (Exception ex) { throw new ApplicationException("Configuration Failure", ex); }
        }
Пример #3
0
        public override string MakeTrackingNumber(int sequenceNumber)
        {
            //Make a tracking number from the specified sequence number
            string accNumberinDigits = "", trackingNumber = "";

            //Convert alpha chars to numeric according to UPS gross ref table
            foreach (char c in base._account_number.Trim())
            {
                if (char.IsNumber(c))
                {
                    accNumberinDigits += c;
                }
                else
                {
                    accNumberinDigits += ((Helper.DigitValue(c) + 2) % 10);
                }
            }
            ArgixTrace.WriteLine(new TraceMessage("account#: " + base._account_number.Trim() + ";\taccount# (all numeric): " + accNumberinDigits.ToString(), AppLib.EVENTLOGNAME, LogLevel.Debug, "SpecAgent"));

            //Calculate check digit using UPS Mod 10 calculation
            string checkDigit = Tsort.Enterprise.Helper.CheckDigitMod10_2(accNumberinDigits + base._indicator.Trim() + sequenceNumber.ToString().PadLeft(7, '0'));

            trackingNumber = OSDataIdentifier + base._account_number.Trim() + base._indicator.Trim() + sequenceNumber.ToString().PadLeft(7, '0') + checkDigit;
            return(trackingNumber);
        }
Пример #4
0
 internal static void ReportError(Exception ex, bool displayMessage, LogLevel level)
 {
     //Report an exception to the user
     try {
         string src = (ex.Source != null) ? ex.Source + "-\n" : "";
         string msg = src + ex.Message;
         if (ex.InnerException != null)
         {
             if ((ex.InnerException.Source != null))
             {
                 src = ex.InnerException.Source + "-\n";
             }
             msg = src + ex.Message + "\n\n NOTE: " + ex.InnerException.Message;
         }
         if (displayMessage)
         {
             MessageBox.Show(msg, App.Product, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         if (level != LogLevel.None)
         {
             ArgixTrace.WriteLine(new TraceMessage(ex.ToString(), App.EventLogName, level));
         }
     }
     catch (Exception) { }
 }
Пример #5
0
        /// <summary>Forces the Sort Service to update it's freight sorting assignments. The Sort Service configures itself from database on the first refresh.</summary>
        /// <exceptions cref="ApplicationException">Thrown for unexpected errors.</exceptions>
        public void RefreshSortService()
        {
            //
            try {
                if (!this.mOperatorWorking)
                {
                    ArgixTrace.WriteLine(new TraceMessage("Starting Sort Service Operator...", AppLib.PRODUCTNAME, LogLevel.Information, "PandaSvc"));
                    this.mOperator.StartWork();
                    this.mOperatorWorking = true;
                }
            }
            catch (ApplicationException ex) {
                ArgixTrace.WriteLine(new TraceMessage("Error while starting the Sort Service Operator-->" + ex.Message, AppLib.PRODUCTNAME, LogLevel.Error, "PandaSvc"));
                throw ex;
            }
            catch (Exception ex) {
                ArgixTrace.WriteLine(new TraceMessage("Unexpected error while starting the Sort Service Operator-->" + ex.Message, AppLib.PRODUCTNAME, LogLevel.Error, "PandaSvc"));
                throw new ApplicationException("Unexpected error while starting the Sort Service Operator.", ex);
            }

            try {
                ArgixTrace.WriteLine(new TraceMessage("Refreshing the Sort Service...", AppLib.PRODUCTNAME, LogLevel.Information, "PandaSvc"));
                this.mOperator.RefreshStationAssignments();
            }
            catch (ApplicationException ex) {
                ArgixTrace.WriteLine(new TraceMessage("Error while refreshing the Sort Service-->" + ex.Message, AppLib.PRODUCTNAME, LogLevel.Error, "PandaSvc"));
                throw ex;
            }
            catch (Exception ex) {
                ArgixTrace.WriteLine(new TraceMessage("Unexpected error while refreshing the Sort Service-->" + ex.Message, AppLib.PRODUCTNAME, LogLevel.Error, "PandaSvc"));
                throw new ApplicationException("Unexpected error while refreshing the Sort Service.", ex);
            }
        }
Пример #6
0
        public void RefreshStationAssignments()
        {
            //Refresh current station assignments
            try {
                //Validate operator state
                if (!this.mOperatorWorking)
                {
                    throw new ApplicationException("Station Operator not started for work; call StartWork() before RefreshStationAssignments().");
                }

                //Clear assignment info
                SortFactory.CreateBrain(null);
                this.mAssignments.Clear();

                //Refresh station assignments; select first assignment as current and select the appropriate Brain
                this.mAssignments = SortFactory.GetStationAssignments(this.mStation);
                ArgixTrace.WriteLine(new TraceMessage("Assignments changed... " + this.mAssignments.Count.ToString() + " new assignments...", AppLib.EVENTLOGNAME, LogLevel.Warning, "SortOperator"));
                if (this.mAssignments.Count > 0)
                {
                    this.mBrain         = SortFactory.CreateBrain(this.mAssignments.Item(0).SortProfile);
                    CurrentInboundLabel = this.mAssignments.Item(0).SortProfile.InboundLabel;
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while refreshing station assignments.", ex); }
            finally { if (this.StationAssignmentsChanged != null)
                      {
                          this.StationAssignmentsChanged(this, EventArgs.Empty);
                      }
            }
        }
Пример #7
0
        private void configApplication()
        {
            try {
                //Create event log and database trace listeners
                try {
                    ArgixTrace.AddListener(new DBTraceListener((LogLevel)App.Config.TraceLevel, App.Mediator, App.USP_TRACE, App.EventLogName));
                }
                catch {
                    ArgixTrace.AddListener(new DBTraceListener(LogLevel.Debug, App.Mediator, App.USP_TRACE, App.EventLogName));
                }
                ArgixTrace.WriteLine(new TraceMessage(App.Version, App.Product, LogLevel.Information, "App Started"));

                //Create business objects with configuration values
                App.Mediator.DataStatusUpdate           += new DataStatusHandler(OnDataStatusUpdate);
                StationOperator.ScanSize                 = App.Config.ScanSize;
                StationOperator.LabelTypeOverrideRegular = App.Config.LabelOverrideRegular;
                StationOperator.LabelTypeOverrideReturns = App.Config.LabelOverrideReturn;
                StationOperator.ValidateLane             = App.Config.ValidateLane;
                StationOperator.ValidateSmallLane        = App.Config.ValidateSmallLane;
                Carton.LanePrefix     = App.Config.LanePrefix;
                this.mStationOperator = new StationOperator();
                this.mStationOperator.AssignmentChanged      += new EventHandler(this.OnAssignmentChanged);
                this.mStationOperator.CartonCreated          += new CartonEventHandler(OnCartonCreated);
                this.mStationOperator.CartonDeleted          += new CartonEventHandler(OnCartonDeleted);
                this.mStationOperator.Station.PrinterChanged += new EventHandler(this.OnPrinterChanged);
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Configuration Failure", ex); }
        }
Пример #8
0
 private void OnAssignmentChanged(object sender, EventArgs e)
 {
     //Current station assignment changed
     try {
         if (this.mStationOperator.TripAssignment != null)
         {
             //Enable\disable carton scanning; and display trip details
             this.lblTripNumber.Text   = this.mStationOperator.TripAssignment.Number;
             this.lblCartons.Text      = this.mStationOperator.TripAssignment.CartonCount.ToString();
             this.lblCarrier.Text      = this.mStationOperator.TripAssignment.Carrier;
             this.lblTrailer.Text      = this.mStationOperator.TripAssignment.TrailerNumber;
             this.lblTotalScanned.Text = this.mStationOperator.CartonsScanned.ToString();
             ArgixTrace.WriteLine(new TraceMessage("Current assignment=" + this.mStationOperator.TripAssignment.Number, App.Product, LogLevel.Debug));
         }
         else
         {
             //Enable\disable carton scanning; and display trip details
             this.lblTripNumber.Text   = "";
             this.lblCartons.Text      = this.mStationOperator.isTripAssigned ? this.mStationOperator.TripAssignment.CartonCount.ToString() : "";
             this.lblCarrier.Text      = "";
             this.lblTrailer.Text      = "";
             this.lblTotalScanned.Text = this.mStationOperator.CartonsScanned.ToString();
             ArgixTrace.WriteLine(new TraceMessage("Current assignment=null", App.Product, LogLevel.Debug));
         }
     }
     catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
     finally { setUserServices(); }
 }
Пример #9
0
        public SortedItem ProcessInputs(string[] inputs, decimal weight)
        {
            //Process the first input scan
            SortedItem sortedItem = null;

            try {
                //Create a sorted item and re-initialize the inbound label template
                if (this.mSetup.ScaleType == dlgStationSetup.SCALETYPE_CONSTANT)
                {
                    weight = this.mSetup.ConstantWeight;
                }
                int w = decimal.ToInt32(decimal.Round(weight + 0.5m, 0));
                ArgixTrace.WriteLine(new TraceMessage("Weight rounded from " + weight.ToString() + " to " + w.ToString() + "...", AppLib.EVENTLOGNAME, LogLevel.Debug, "SortOperator"));
                sortedItem = this.mBrain.CreateSortedItem(inputs, w);
                if (this.SortedItemCreated != null)
                {
                    this.SortedItemCreated(this, new SortedItemEventArgs(sortedItem));
                }

                //Determine elapsed & down times for this sorted item
                int duration = this.mStation.SortStatistics.CalcDuration();
                sortedItem.ElapsedSeconds = (duration < Statistics.DOWN_TIME_MAX ? duration : Statistics.DOWN_TIME_MAX);
                sortedItem.DownSeconds    = (duration < Statistics.DOWN_TIME_MAX ? 0 : duration - Statistics.DOWN_TIME_MAX);
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while processing carton inputs.", ex); }
            return(sortedItem);
        }
Пример #10
0
 public SortedItem(Workstation station)
 {
     //Constructor
     try {
         ArgixTrace.WriteLine(new TraceMessage("New sorted item...", AppLib.EVENTLOGNAME, LogLevel.Debug, "SortedItem"));
         this.mSortStation    = station;
         this.mLabelSeqNumber = CreateLabelSequenceNumber(this.mSortStation.Number);
     }
     catch (Exception ex) { this.mException = ex; }
 }
Пример #11
0
 public void Add(SortedItem sortedItem)
 {
     //Add a new sorted item to the collection
     try {
         //Manage collection size; then add new item
         if (this.mSortedList.Count == MaxItems)
         {
             this.mSortedList.RemoveAt(0);
             ArgixTrace.WriteLine(new TraceMessage("SORTED ITEMS PURGE: " + this.mSortedList.Count.ToString() + "...", AppLib.EVENTLOGNAME, LogLevel.Debug, "SortedItems"));
         }
         this.mSortedList.Add(sortedItem.LabelSeqNumber, sortedItem);
     }
     catch (Exception ex) { throw new ApplicationException("Unexpected error while adding new sorted item to the collection.", ex); }
 }
Пример #12
0
 private void OnFormClosed(object sender, FormClosedEventArgs e)
 {
     //Event handler for form closed event
     global::Argix.Properties.Settings.Default.WindowState       = this.WindowState;
     global::Argix.Properties.Settings.Default.Location          = this.Location;
     global::Argix.Properties.Settings.Default.Size              = this.Size;
     global::Argix.Properties.Settings.Default.Toolbar           = this.mnuViewToolbar.Checked;
     global::Argix.Properties.Settings.Default.StatusBar         = this.mnuViewStatusBar.Checked;
     global::Argix.Properties.Settings.Default.TermConfigWindow  = this.mnuViewTermConfigs.Checked;
     global::Argix.Properties.Settings.Default.DriverEquipWindow = this.mnuViewEquip.Checked;
     global::Argix.Properties.Settings.Default.DriverRatesWindow = this.mnuViewRates.Checked;
     global::Argix.Properties.Settings.Default.LastVersion       = App.Version;
     global::Argix.Properties.Settings.Default.Save();
     ArgixTrace.WriteLine(new TraceMessage(App.Version, App.EventLogName, LogLevel.Information, "App Stopped"));
 }
Пример #13
0
 private void OnFormClosing(object sender, FormClosingEventArgs e)
 {
     //Ask only if there are detail forms open
     if (!e.Cancel)
     {
         #region Save user preferences
         global::Argix.Properties.Settings.Default.WindowState = this.WindowState;
         global::Argix.Properties.Settings.Default.Location    = this.Location;
         global::Argix.Properties.Settings.Default.Size        = this.Size;
         global::Argix.Properties.Settings.Default.Toolbar     = this.mnuViewToolbar.Checked;
         global::Argix.Properties.Settings.Default.StatusBar   = this.mnuViewStatusBar.Checked;
         global::Argix.Properties.Settings.Default.LastVersion = App.Version;
         global::Argix.Properties.Settings.Default.Save();
         #endregion
         ArgixTrace.WriteLine(new TraceMessage(App.Version, App.Product, LogLevel.Information, "App Stopped"));
     }
 }
Пример #14
0
        private void configApplication()
        {
            try {
                //Create event log and database trace listeners, and log application as started
                ArgixTrace.ClearListeners();
                ArgixTrace.AddListener(new DBTraceListener((LogLevel)App.Config.TraceLevel, App.Mediator, App.USP_TRACE, App.EventLogName));

                ArgixTrace.WriteLine(new TraceMessage(App.Version, App.EventLogName, LogLevel.Information, "App Started"));

                //Create business objects with configuration values
                App.Mediator.DataStatusUpdate += new DataStatusHandler(OnDataStatusUpdate);
                this.mLocalTerminal            = new EnterpriseTerminal();
                this.stbMain.SetTerminalPanel(this.mLocalTerminal.TerminalID.ToString(), this.mLocalTerminal.Description);
                SortBMCFactory.Mediator = App.Mediator;
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Configuration Failure", ex); }
        }
Пример #15
0
        /// <summary>Creates a new instance of the Tsort.PandA.PandaService class.</summary>
        /// <param name="databaseConnection">An ADO.Net database connection string.</param>
        /// <param name="enableUI">Set to true to have a task tray icon displayed that provides access to the Panda Service user interface.</param>
        /// <exceptions cref="ApplicationException">Thrown for unexpected errors.</exceptions>
        public PandaService(string databaseConnection, bool enableUI)
        {
            //Constructor
            try {
                //Configure user access
                if (enableUI)
                {
                    this.mTrayIcon = new TrayIcon("PandA Library", new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("Tsort.PandA.panda.ico")));
                    #region Tray Icon Menu Configuration
                    ctxOpen             = new MenuItem("Open", new System.EventHandler(this.OnIconMenuClicked));
                    ctxOpen.Index       = MNU_ICON_OPEN;
                    ctxOpen.Enabled     = true;
                    ctxOpen.DefaultItem = true;
                    this.mTrayIcon.MenuItems.AddRange(new MenuItem[] { ctxOpen });
                    #endregion
                    this.mTrayIcon.DoubleClick += new System.EventHandler(OnIconDoubleClicked);
                }

                //Get configuration
                PandaPacket.ValidateMessageLength = Convert.ToBoolean(DllConfig.AppSettings("ValidateMessageLength"));
                PandaPacket.CartonIDLength        = Convert.ToInt32(DllConfig.AppSettings("CartonIDLength"));
                PandaPacket.LabelDataLength       = Convert.ToInt32(DllConfig.AppSettings("LabelDataLength"));
                if (databaseConnection.Trim().Length == 0)
                {
                    databaseConnection = DllConfig.AppSettings("SQLConnection");
                }
                LogLevel level = (LogLevel)Convert.ToInt32(DllConfig.AppSettings("TraceLevel"));

                //Create objects
                ArgixTrace.AddListener(new ArgixEventLogTraceListener(level, AppLib.PRODUCTNAME));
                this.mOperator = new StationOperator(databaseConnection);
                if (enableUI)
                {
                    this.mPandaUI = new frmPanda(this, level);
                }
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new PandaService instance.", ex); }
        }
Пример #16
0
        //Events
        //Interface
        internal static string CreateLabelSequenceNumber(string stationNumber)
        {
            //Generate a sorted item number for this object; format: yMMddssssswww
            string labelSeqNumber = "";

            try {
                int i = 0, wait = 0;
                while (DateTime.Now.ToString("hhmmss").CompareTo(LastSortedItem.ToString("hhmmss")) == 0)
                {
                    //Determine wait time (msec) until the next second of the current time
                    wait = 1000 - int.Parse(DateTime.Now.ToString("fff"));
                    System.Threading.Thread.Sleep(wait);
                    i++;
                }
                DateTime dt = LastSortedItem = DateTime.Now;
                labelSeqNumber = dt.ToString("yyyy").Substring(3, 1) + dt.ToString("MM") + dt.ToString("dd") + getElapsedSeconds(dt) + stationNumber.Trim().PadLeft(3, '0');
                ArgixTrace.WriteLine(new TraceMessage("Created label sequence number (" + i.ToString() + "x; " + wait.ToString() + "msec)...", AppLib.EVENTLOGNAME, LogLevel.Debug, "SortedItem"));
            }
            catch (ApplicationException ex) { throw ex; }
            catch (Exception ex) { throw new ApplicationException("Unexpected error while creating sorted item number.", ex); }
            return(labelSeqNumber);
        }
Пример #17
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            try {
                //Setup Issue Mgt
                try {
                    LogLevel level = App.Config != null ? (LogLevel)App.Config.TraceLevel : LogLevel.None;
                    ArgixTrace.AddListener(new DBTraceListener(level, App.Mediator, App.USP_TRACE, App.EventLogName));
                    IssueInspector.OutlookApp  = this.Application;
                    CRGFactory.TempFolder      = global::Argix.CustomerSvc.Settings.Default.TempFolder;
                    EnterpriseFactory.Mediator = CRGFactory.Mediator = App.Mediator;
                }
                catch (Argix.Data.DataAccessException ex) { App.ReportError(ex, true, LogLevel.Warning); }

                //Set references to Outlook Inspectors
                this.mInspectors = this.Application.Inspectors;
                this.mInspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(OnNewInspector);
                foreach (Outlook.Inspector inspector in this.mInspectors)
                {
                    OnNewInspector(inspector);
                }
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
        }
Пример #18
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);
        }
Пример #19
0
 private void OnFormClosing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     //Ask only if there are detail forms open
     if (this.MdiChildren.Length > 0)
     {
         if (MessageBox.Show("Are you sure you want to close the application.?", App.Product, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
         {
             e.Cancel = true;
         }
     }
     if (!e.Cancel)
     {
         #region Save user preferences
         global::Tsort.Properties.Settings.Default.WindowState = this.WindowState;
         global::Tsort.Properties.Settings.Default.Location    = this.Location;
         global::Tsort.Properties.Settings.Default.Size        = this.Size;
         global::Tsort.Properties.Settings.Default.Toolbar     = this.mnuViewToolbar.Checked;
         global::Tsort.Properties.Settings.Default.StatusBar   = this.mnuViewStatusBar.Checked;
         global::Tsort.Properties.Settings.Default.LastVersion = App.Version;
         global::Tsort.Properties.Settings.Default.Save();
         #endregion
         ArgixTrace.WriteLine(new TraceMessage(App.Version, App.EventLogName, LogLevel.Information, "App Stopped"));
     }
 }
Пример #20
0
 internal virtual void OnAllInputsReceived(object sender, EventArgs e)
 {
     ArgixTrace.WriteLine(new TraceMessage("All label inputs received.", AppLib.EVENTLOGNAME, LogLevel.Debug, "Brain    "));
 }
Пример #21
0
        /// <summary>Processes </summary>
        /// <param name="clientID">A unique identifier for the requestor (can be an empty string).</param>
        /// <param name="request">A Tsort.PandA.PandaPacket request.</param>
        /// <exceptions cref="ApplicationException">Thrown for unexpected errors.</exceptions>
        /// <returns>An instance of Tsort.PandA.PandaPacket containing the response.</returns>
        public PandaPacket ProcessPandARequest(string clientID, PandaPacket request)
        {
            //Process a PandA request from a remote socket client
            PandaPacket response = null;
            DateTime    started  = DateTime.Now;

            try {
                //Process the PandA message; Decode() always returns a non-null request object
                ArgixTrace.WriteLine(new TraceMessage("", AppLib.PRODUCTNAME, LogLevel.Information, "PandaSvc"));
                ArgixTrace.WriteLine(new TraceMessage("REQUEST:" + request.Message, AppLib.PRODUCTNAME, LogLevel.Information, "PandaSvc"));
                if (request.Valid)
                {
                    //Check if this was a prior request
                    PandaPacket priorResponse = isPriorRequest(clientID, request);
                    if (priorResponse != null)
                    {
                        //This was a prior message; return prior response
                        response = priorResponse;
                        ArgixTrace.WriteLine(new TraceMessage("PRIOR RESPONSE: " + priorResponse.Message, AppLib.PRODUCTNAME, LogLevel.Information, "PandaSvc"));
                    }
                    else
                    {
                        //New, valid message; persist request and route to message handler
                        switch (request.MessageCode)
                        {
                        case REQUEST_LABELDATA:
                            DataSet ds = null;
                            try {
                                //Extract message body and process message request
                                string   barcode1 = request.MessageBody.Substring(0, 32).TrimEnd();
                                string   barcode2 = request.MessageBody.Substring(32, 32).TrimEnd();
                                string   barcode3 = request.MessageBody.Substring(64, 32).TrimEnd();
                                string   barcode4 = request.MessageBody.Substring(96, 32).TrimEnd();
                                string   barcode5 = request.MessageBody.Substring(128, 32).TrimEnd();
                                string   barcode6 = request.MessageBody.Substring(160, 32).TrimEnd();
                                decimal  weight   = decimal.Parse(request.MessageBody.Substring(192, 5)) / 100;
                                string[] inputs   = new string[] { barcode1, barcode2, barcode3, barcode4, barcode5, barcode6 };
                                ds = ProcessLabelDataRequest(inputs, weight);
                                if (ds != null)
                                {
                                    response = PandaPacket.Encode(clientID, RESPONSE_LABELDATA, 0, 1, PandaPacket.FormatLabelDataMessageBody(ds.Tables["PandATable"].Rows[0]["CartonID"].ToString(), int.Parse(ds.Tables["PandATable"].Rows[0]["StatusCode"].ToString()), ds.Tables["PandATable"].Rows[0]["LabelData"].ToString()), request.MessageNumber, request);
                                }
                            }
                            catch (Exception ex) {
                                if (ds != null)
                                {
                                    response = PandaPacket.Encode(clientID, RESPONSE_LABELDATA, 0, 1, PandaPacket.FormatLabelDataMessageBody(ds.Tables["PandATable"].Rows[0]["CartonID"].ToString(), int.Parse(ds.Tables["PandATable"].Rows[0]["StatusCode"].ToString()), ds.Tables["PandATable"].Rows[0]["LabelData"].ToString()), request.MessageNumber, request);
                                }
                                ArgixTrace.WriteLine(new TraceMessage("An error occurred while processing Panda label data request-->" + ex.Message, AppLib.PRODUCTNAME, LogLevel.Error, "PandaSvc"));
                            }
                            this.mLastRequest = request;
                            try { request.ProcessingTime = (float)((TimeSpan)DateTime.Now.Subtract(started)).TotalSeconds; } catch {}
                            if (PandaRequestComplete != null)
                            {
                                PandaRequestComplete(null, new PandaPacketEventArgs(request));
                            }
                            break;

                        case REQUEST_VERIFYLABEL:
                            try {
                                //Find the carton
                                string cartonID   = request.MessageBody.Substring(0, PandaPacket.CartonIDLength).TrimEnd();
                                string verifyCode = request.MessageBody.Substring(PandaPacket.CartonIDLength, 1).TrimEnd();
                                string verifyFlag = ProcessVerifyLabelRequest(cartonID, verifyCode);
                                response = PandaPacket.Encode(clientID, RESPONSE_VERIFYLABEL, 0, 1, verifyFlag, request.MessageNumber, request);
                            }
                            catch (Exception ex) {
                                response = PandaPacket.Encode(clientID, RESPONSE_VERIFYLABEL, 0, 1, VERIFY_NO, request.MessageNumber, request);
                                ArgixTrace.WriteLine(new TraceMessage("An error occurred while processing Panda verify label request-->" + ex.Message, AppLib.PRODUCTNAME, LogLevel.Error, "PandaSvc"));
                            }
                            this.mLastRequest = request;
                            try { request.ProcessingTime = (float)((TimeSpan)DateTime.Now.Subtract(started)).TotalSeconds; } catch {}
                            if (PandaRequestComplete != null)
                            {
                                PandaRequestComplete(null, new PandaPacketEventArgs(request));
                            }
                            break;

                        case REQUEST_RESEND:
                            response = this.mLastRequest.Response;
                            ArgixTrace.WriteLine(new TraceMessage("Resend requested.", AppLib.PRODUCTNAME, LogLevel.Warning, "PandaSvc"));
                            if (PandaResendComplete != null)
                            {
                                PandaResendComplete(null, EventArgs.Empty);
                            }
                            break;

                        case REQUEST_HEARTBEAT:
                            try {
                                response = PandaPacket.Encode(clientID, RESPONSE_HEARTBEAT, 0, 1, "", request.MessageNumber, request);
                            }
                            catch (Exception ex) {
                                ArgixTrace.WriteLine(new TraceMessage("An error occurred while processing Panda heartbeat request-->" + ex.Message, AppLib.PRODUCTNAME, LogLevel.Error, "PandaSvc"));
                            }
                            if (HeartbeatRequestComplete != null)
                            {
                                HeartbeatRequestComplete(null, EventArgs.Empty);
                            }
                            break;

                        default:
                            ArgixTrace.WriteLine(new TraceMessage("Unknown message code.", AppLib.PRODUCTNAME, LogLevel.Warning, "PandaSvc"));
                            break;
                        }
                    }
                }
                else
                {
                    //Invalid message packet
                    response = PandaPacket.Encode(clientID, RESPONSE_MSGERROR, 0, 0, "", request.MessageNumber, request);
                    ArgixTrace.WriteLine(new TraceMessage("Message failed (decode) validation...", AppLib.PRODUCTNAME, LogLevel.Warning, "PandaSvc"));
                }
            }
            catch (Exception ex) {
                response = PandaPacket.Encode(clientID, RESPONSE_MSGERROR, 0, 0, "", request.MessageNumber, request);
                ArgixTrace.WriteLine(new TraceMessage("An error occurred while processing Panda message-->" + ex.Message, AppLib.PRODUCTNAME, LogLevel.Error, "PandaSvc"));
            }
            finally {
                if (response != null)
                {
                    ArgixTrace.WriteLine(new TraceMessage("RESPONSE: " + new ASCIIEncoding().GetString(response.Bytes), AppLib.PRODUCTNAME, LogLevel.Information, "PandaSvc"));
                }
                else
                {
                    ArgixTrace.WriteLine(new TraceMessage("RESPONSE: NULL", AppLib.PRODUCTNAME, LogLevel.Warning, "PandaSvc"));
                }
            }
            return(response);
        }
Пример #22
0
        protected override void setLabelTokenValues()
        {
            //Override token values with this objects data
            try {
                ArgixTrace.WriteLine(new TraceMessage("Setting token values...", App.Product, LogLevel.Debug));
                if (this.isTsort)
                {
                    //From store or client vendor
                    base.mTokens[TokenLibrary.SAN]       = (this.mStore != null) ? this.mStore.SANNumber : "";
                    base.mTokens[TokenLibrary.LOCALLANE] = (this.mStore != null) ? this.mStore.LocalLane.TrimEnd().PadLeft(2, '0') : "";
                }
                else
                {
                    //from store or client vendor
                    base.mTokens[TokenLibrary.LOCALLANE] = this.mClientVendor.LOCAL_LANE.TrimEnd().PadLeft(2, '0');
                }
                base.mTokens[TokenLibrary.FREIGHTTYPE]               = this.FreightType;
                base.mTokens[TokenLibrary.CURRENTDATE]               = DateTime.Today.ToShortDateString();
                base.mTokens[TokenLibrary.CURRENTTIME]               = DateTime.Now.ToString("HH:mm:ss");
                base.mTokens[TokenLibrary.CURRENTYEAR]               = DateTime.Today.Year.ToString();
                base.mTokens[TokenLibrary.FREIGHTPICKUPDATE]         = "";
                base.mTokens[TokenLibrary.FREIGHTPICKUPINFO]         = "";
                base.mTokens[TokenLibrary.FREIGHTPICKUPNUMBER]       = "";
                base.mTokens[TokenLibrary.FREIGHTPICKUPNUMBERSTRING] = "";
                base.mTokens[TokenLibrary.FREIGHTVENDORKEY]          = "";
                base.mTokens[TokenLibrary.LANEPREFIX]             = Carton.LanePrefix;
                base.mTokens[TokenLibrary.CARTONNUMBER]           = "";
                base.mTokens[TokenLibrary.CARTONNUMBERORPONUMBER] = "";
                base.mTokens[TokenLibrary.SORTEDITEMLABELNUMBER]  = this.LabelSeqNumber.TrimEnd();
                base.mTokens[TokenLibrary.SORTEDITEMWEIGHTSTRING] = "";
                base.mTokens[TokenLibrary.ITEMDAMAGECODE]         = "";
                base.mTokens[TokenLibrary.ITEMTYPE]                 = "";
                base.mTokens[TokenLibrary.PONUMBER]                 = "";
                base.mTokens[TokenLibrary.RETURNNUMBER]             = "";
                base.mTokens[TokenLibrary.CLIENTNUMBER]             = this.mClient.Number;
                base.mTokens[TokenLibrary.CLIENTNAME]               = this.mClient.Name;
                base.mTokens[TokenLibrary.CLIENTABBREVIATION]       = this.mClient.ABBREVIATION;
                base.mTokens[TokenLibrary.CLIENTDIVISIONNUMBER]     = this.mClient.Division;
                base.mTokens[TokenLibrary.CLIENTADDRESSLINE1]       = this.mClient.AddressLine1;
                base.mTokens[TokenLibrary.CLIENTADDRESSLINE2]       = this.mClient.AddressLine2;
                base.mTokens[TokenLibrary.CLIENTADDRESSCITY]        = this.mClient.City;
                base.mTokens[TokenLibrary.CLIENTADDRESSSTATE]       = this.mClient.State;
                base.mTokens[TokenLibrary.CLIENTADDRESSZIP]         = this.mClient.ZIP;
                base.mTokens[TokenLibrary.CLIENTADDRESSCOUNTRYCODE] = "";
                if (this.mStore != null)
                {
                    base.mTokens[TokenLibrary.STORENUMBER]       = this.mStore.Number.ToString().PadLeft(5, '0');
                    base.mTokens[TokenLibrary.STORENAME]         = this.mStore.Name.TrimEnd();
                    base.mTokens[TokenLibrary.STOREADDRESSLINE1] = this.mStore.AddressLine1.TrimEnd();
                    base.mTokens[TokenLibrary.STOREADDRESSLINE2] = this.mStore.AddressLine2.TrimEnd();
                    base.mTokens[TokenLibrary.STOREADDRESSCITY]  = this.mStore.City.TrimEnd();
                    base.mTokens[TokenLibrary.STOREADDRESSSTATE] = this.mStore.State.TrimEnd();
                    base.mTokens[TokenLibrary.STOREADDRESSZIP]   = this.mStore.Zip.TrimEnd();
                    base.mTokens[TokenLibrary.STOREZIP]          = this.mStore.Zip.TrimEnd();
                    base.mTokens[TokenLibrary.STOREPHONE]        = this.mStore.Phone.TrimEnd();
                    base.mTokens[TokenLibrary.STOREROUTE]        = this.mStore.Route.TrimEnd();

                    string routeLane = this.mStore.Route.TrimEnd().PadRight(5).Substring(0, 2);
                    base.mTokens[TokenLibrary.LOCALROUTELANE] = (char.IsNumber(routeLane, 0) && char.IsNumber(routeLane, 1)) ? routeLane : "00";

                    base.mTokens[TokenLibrary.STOREROUTEFIRSTCHARACTER] = this.mStore.Route.TrimEnd().PadRight(5).Substring(0, 1);
                    base.mTokens[TokenLibrary.STOREROUTEFIRSTTWO]       = this.mStore.Route.TrimEnd().PadRight(5).Substring(0, 2);
                    base.mTokens[TokenLibrary.STOREROUTELASTFOUR]       = this.mStore.Route.TrimEnd().PadRight(5).Substring(1, 4);
                    base.mTokens[TokenLibrary.STOREROUTELASTTHREE]      = this.mStore.Route.TrimEnd().PadRight(5).Substring(2, 3);
                    base.mTokens[TokenLibrary.STOREALTROUTE]            = this.mStore.AltRoute;
                    base.mTokens[TokenLibrary.STOREUSERLABELDATA]       = this.mStore.LabelUserData.TrimEnd();
                }
                if (this.mClientVendor != null)
                {
                    base.mTokens[TokenLibrary.VENDORNUMBER]       = this.mClientVendor.VENDOR_NUMBER.TrimEnd();
                    base.mTokens[TokenLibrary.VENDORNAME]         = this.mClientVendor.NAME.TrimEnd();
                    base.mTokens[TokenLibrary.VENDORADDRESSLINE1] = this.mClientVendor.ADDRESS_LINE1.TrimEnd();
                    base.mTokens[TokenLibrary.VENDORADDRESSLINE2] = this.mClientVendor.ADDRESS_LINE2.TrimEnd();
                    base.mTokens[TokenLibrary.VENDORADDRESSCITY]  = this.mClientVendor.CITY.TrimEnd();
                    base.mTokens[TokenLibrary.VENDORADDRESSSTATE] = this.mClientVendor.STATE.TrimEnd();
                    base.mTokens[TokenLibrary.VENDORADDRESSZIP]   = this.mClientVendor.ZIP.TrimEnd();
                    base.mTokens[TokenLibrary.VENDORUSERDATA]     = this.mClientVendor.USERDATA.TrimEnd();

                    string routeLane = this.mClientVendor.ROUTE.TrimEnd().PadRight(5).Substring(0, 2);
                    base.mTokens[TokenLibrary.LOCALROUTELANE] = (char.IsNumber(routeLane, 0) && char.IsNumber(routeLane, 1)) ? routeLane : "00";
                }
                base.mTokens[TokenLibrary.ZONECODE]                                = this.mZone.Code.TrimEnd();
                base.mTokens[TokenLibrary.ZONELABELTYPE]                           = this.mZone.Type.TrimEnd();
                base.mTokens[TokenLibrary.ZONELANE]                                = this.mZone.Lane.TrimEnd();
                base.mTokens[TokenLibrary.ZONELANESMALLSORT]                       = this.mZone.SmallSortLane.TrimEnd();
                base.mTokens[TokenLibrary.ZONEOUTBOUNDTRAILERLOADNUMBER]           = this.mZone.TrailerLoadNumber.TrimEnd();
                base.mTokens[TokenLibrary.ZONEOUTBOUNDTRAILERLOADNUMBERDIGITSONLY] = "";
                base.mTokens[TokenLibrary.WORKSTATIONID]                           = this.mWorkstation.WorkStationID;
                base.mTokens[TokenLibrary.WORKSTATIONNAME]                         = this.mWorkstation.Name;
                base.mTokens[TokenLibrary.WORKSTATIONNUMBER]                       = this.mWorkstation.Number;
                base.mTokens[TokenLibrary.WORKSTATIONNUMBER2]                      = this.mWorkstation.Number;
                base.mTokens[TokenLibrary.WORKSTATIONDESCRIPTION]                  = this.mWorkstation.Description;
            }
            catch (Exception ex) { throw ex; }
        }
Пример #23
0
        protected override void setTokenValues()
        {
            //Override token values with this objects data
            try {
                ArgixTrace.WriteLine(new TraceMessage("Setting token values...", AppLib.EVENTLOGNAME, LogLevel.Debug, "SortedItem"));
                base.mTokens[TokenLibrary.SAN]                    = TokenLibrary.SAN.Trim();
                base.mTokens[TokenLibrary.CURRENTDATE]            = DateTime.Today.ToShortDateString();
                base.mTokens[TokenLibrary.CURRENTTIME]            = DateTime.Now.ToString("HH:mm:ss");
                base.mTokens[TokenLibrary.TIMENOW]                = DateTime.Now.ToString("HHmmss");
                base.mTokens[TokenLibrary.CURRENTYEAR]            = DateTime.Today.Year.ToString();
                base.mTokens[TokenLibrary.LANEPREFIX]             = SortedItem.LanePrefix.Trim();
                base.mTokens[TokenLibrary.CARTONNUMBER]           = this.mCartonNumber;
                base.mTokens[TokenLibrary.CARTONNUMBERORPONUMBER] = "";
                base.mTokens[TokenLibrary.SORTEDITEMLABELNUMBER]  = this.mLabelSeqNumber.Trim();
                base.mTokens[TokenLibrary.SORTEDITEMWEIGHTSTRING] = this.mWeight;
                base.mTokens[TokenLibrary.ITEMDAMAGECODE]         = this.mDamageCode.Trim();
                base.mTokens[TokenLibrary.ITEMTYPE]               = this.mItemType.Trim();
                base.mTokens[TokenLibrary.PONUMBER]               = this.mPONumber.Trim();
                base.mTokens[TokenLibrary.RETURNNUMBER]           = "";
                base.mTokens[TokenLibrary.WORKSTATIONID]          = this.mSortStation.WorkStationID.Trim();
                base.mTokens[TokenLibrary.WORKSTATIONNAME]        = this.mSortStation.Name.Trim();
                base.mTokens[TokenLibrary.WORKSTATIONNUMBER]      = this.mSortStation.Number.Trim();
                base.mTokens[TokenLibrary.WORKSTATIONDESCRIPTION] = this.mSortStation.Description.Trim();

                if (this.mFreight != null)
                {
                    base.mTokens[TokenLibrary.FREIGHTTYPE]               = (this.mFreight.IsReturns? "88" : "44");
                    base.mTokens[TokenLibrary.FREIGHTPICKUPDATE]         = this.mFreight.PickupDate;
                    base.mTokens[TokenLibrary.FREIGHTPICKUPINFO]         = "";
                    base.mTokens[TokenLibrary.FREIGHTPICKUPNUMBER]       = this.mFreight.PickupNumber;
                    base.mTokens[TokenLibrary.FREIGHTPICKUPNUMBERSTRING] = this.mFreight.PickupNumber;
                    base.mTokens[TokenLibrary.FREIGHTVENDORKEY]          = this.mFreight.VendorKey;

                    base.mTokens[TokenLibrary.CLIENTNUMBER]             = this.Client.Number;
                    base.mTokens[TokenLibrary.CLIENTNAME]               = this.Client.Name.Trim();
                    base.mTokens[TokenLibrary.CLIENTABBREVIATION]       = this.Client.ABBREVIATION;
                    base.mTokens[TokenLibrary.CLIENTDIVISIONNUMBER]     = this.Client.Division;
                    base.mTokens[TokenLibrary.CLIENTADDRESSLINE1]       = this.Client.AddressLine1.Trim();
                    base.mTokens[TokenLibrary.CLIENTADDRESSLINE2]       = this.Client.AddressLine2.Trim();
                    base.mTokens[TokenLibrary.CLIENTADDRESSCITY]        = this.Client.City.Trim();
                    base.mTokens[TokenLibrary.CLIENTADDRESSSTATE]       = this.Client.State.Trim();
                    base.mTokens[TokenLibrary.CLIENTADDRESSZIP]         = this.Client.ZIP.Trim();
                    base.mTokens[TokenLibrary.CLIENTADDRESSCOUNTRYCODE] = "";

                    base.mTokens[TokenLibrary.SHIPPERNUMBER]      = this.mFreight.Shipper.NUMBER;
                    base.mTokens[TokenLibrary.VENDORNUMBER]       = this.mFreight.Shipper.NUMBER;
                    base.mTokens[TokenLibrary.VENDORNAME]         = this.mFreight.Shipper.NAME.Trim();
                    base.mTokens[TokenLibrary.VENDORADDRESSLINE1] = this.mFreight.Shipper.ADDRESS_LINE1.Trim();
                    base.mTokens[TokenLibrary.VENDORADDRESSLINE2] = this.mFreight.Shipper.ADDRESS_LINE2.Trim();
                    base.mTokens[TokenLibrary.VENDORADDRESSCITY]  = this.mFreight.Shipper.CITY.Trim();
                    base.mTokens[TokenLibrary.VENDORADDRESSSTATE] = this.mFreight.Shipper.STATE.Trim();
                    base.mTokens[TokenLibrary.VENDORADDRESSZIP]   = this.mFreight.Shipper.ZIP.Trim();
                    base.mTokens[TokenLibrary.VENDORUSERDATA]     = this.mFreight.Shipper.USERDATA.Trim();
                }
                else
                {
                    base.mTokens[TokenLibrary.FREIGHTTYPE]         = "00";
                    base.mTokens[TokenLibrary.FREIGHTPICKUPDATE]   = "N/A";
                    base.mTokens[TokenLibrary.FREIGHTPICKUPNUMBER] = "0";

                    base.mTokens[TokenLibrary.CLIENTNUMBER]         = "000";
                    base.mTokens[TokenLibrary.CLIENTDIVISIONNUMBER] = "00";
                }

                if (this.mDestinationRouting != null)
                {
                    base.mTokens[TokenLibrary.LOCALLANE]                     = this.mDestinationRouting.LocalLane;
                    base.mTokens[TokenLibrary.DESTINATIONNUMBER]             = this.mDestinationRouting.DestinationNumber.ToString().PadLeft(5, '0');
                    base.mTokens[TokenLibrary.DESTINATIONNAME]               = this.mDestinationRouting.DestinationName.Trim();
                    base.mTokens[TokenLibrary.DESTINATIONADDRESSLINE1]       = this.mDestinationRouting.DestinationAddressLine1.Trim();
                    base.mTokens[TokenLibrary.DESTINATIONADDRESSLINE2]       = this.mDestinationRouting.DestinationAddressLine2.Trim();
                    base.mTokens[TokenLibrary.DESTINATIONADDRESSCITY]        = this.mDestinationRouting.DestinationAddressCity.Trim();
                    base.mTokens[TokenLibrary.DESTINATIONADDRESSSTATE]       = this.mDestinationRouting.DestinationAddressState.Trim();
                    base.mTokens[TokenLibrary.DESTINATIONADDRESSZIP]         = this.mDestinationRouting.DestinationAddressZip.Trim();
                    base.mTokens[TokenLibrary.DESTINATIONZIP]                = this.mDestinationRouting.DestinationAddressZip.Trim();
                    base.mTokens[TokenLibrary.DESTINATIONADDRESSCOUNTRYCODE] = "US";
                    base.mTokens[TokenLibrary.DESTINATIONPHONE]              = this.mDestinationRouting.DestinationPhone.Trim();
                    base.mTokens[TokenLibrary.DESTINATIONROUTE]              = this.mDestinationRouting.DestinationRoute;
                    base.mTokens[TokenLibrary.DESTINATIONALTROUTE]           = this.mDestinationRouting.DestinationAltRoute;

                    string route     = this.mDestinationRouting.DestinationRoute.TrimEnd().PadRight(5);
                    string routeLane = route.Substring(0, 2);
                    base.mTokens[TokenLibrary.LOCALROUTELANE] = (char.IsNumber(routeLane, 0) && char.IsNumber(routeLane, 1)) ? routeLane : "00";

                    base.mTokens[TokenLibrary.DESTINATIONROUTEFIRSTCHARACTER] = route.Substring(0, 1);
                    base.mTokens[TokenLibrary.DESTINATIONROUTEFIRSTTWO]       = route.Substring(0, 2);
                    base.mTokens[TokenLibrary.DESTINATIONROUTELASTFOUR]       = route.Substring(1, 4);
                    base.mTokens[TokenLibrary.DESTINATIONROUTELASTTHREE]      = route.Substring(2, 3);
                    base.mTokens[TokenLibrary.DESTINATIONUSERLABELDATA]       = this.mDestinationRouting.DestinationUserLabelData.Trim();

                    base.mTokens[TokenLibrary.ZONECODE]                                = this.mDestinationRouting.ZoneCode;
                    base.mTokens[TokenLibrary.ZONELABELTYPE]                           = this.mDestinationRouting.ZoneType;
                    base.mTokens[TokenLibrary.ZONELANE]                                = this.mDestinationRouting.ZoneLane;
                    base.mTokens[TokenLibrary.ZONELANESMALLSORT]                       = this.mDestinationRouting.ZoneLaneSmallSort;
                    base.mTokens[TokenLibrary.ZONEOUTBOUNDTRAILERLOADNUMBER]           = this.mDestinationRouting.ZoneTL;
                    base.mTokens[TokenLibrary.ZONEOUTBOUNDTRAILERLOADNUMBERDIGITSONLY] = "";

                    base.mTokens[TokenLibrary.TLDATE]        = this.mDestinationRouting.ZoneTLDate.ToString("MMddyy");
                    base.mTokens[TokenLibrary.TLCLOSENUMBER] = this.mDestinationRouting.ZoneTLCloseNumber.PadLeft(3, '0').Substring(1, 2);

                    // special agent
                    if (this.mSpecialAgent != null)
                    {
                        base.mTokens[TokenLibrary.OSSERVICETITLE]            = this.mSpecialAgent.OSTitle;
                        base.mTokens[TokenLibrary.OSBARCODE1DATAHUMANFORMAT] = this.mSpecialAgent.OSBarcode1DataHumanFormat(this.mTrackingNumber);
                        base.mTokens[TokenLibrary.OSDATAIDENTIFIER]          = this.mSpecialAgent.OSDataIdentifier;
                        base.mTokens[TokenLibrary.OSBARCODE1DATA]            = this.mSpecialAgent.OSBarcode1Data(this.mTrackingNumber);
                        base.mTokens[TokenLibrary.OSROUTINGCODE]             = this.mSpecialAgent.OSRoutingCode(this.mDestinationRouting.OSURSACode);
                        base.mTokens[TokenLibrary.OSSERVICEINDICATOR]        = this.mSpecialAgent.OSServiceIndicator;
                        base.mTokens[TokenLibrary.OSTRACKINGNUMBER10]        = this.mSpecialAgent.OSTrackingNumber10(this.mTrackingNumber);
                        base.mTokens[TokenLibrary.OSSENDERACCOUNTNUMBER]     = this.mSpecialAgent.OSSenderAccountNumber;
                        base.mTokens[TokenLibrary.OSJULIANDATE]  = this.mSpecialAgent.OSJulianDate;
                        base.mTokens[TokenLibrary.OSSERVICEICON] = this.mSpecialAgent.OSServiceIcon;
                    }
                }
                else
                {
                    base.mTokens[TokenLibrary.DESTINATIONNUMBER] = "00000";
                }

                if (this.IsError())
                {
                    base.mTokens[TokenLibrary.LOCALLANE]         = "00";
                    base.mTokens[TokenLibrary.ZONELANE]          = "00";
                    base.mTokens[TokenLibrary.ZONELANESMALLSORT] = "00";

                    string msg = this.mException.Message;
                    if (this.mException.InnerException != null)
                    {
                        msg += " -->" + this.mException.InnerException.Message;
                        if (this.mException.InnerException.InnerException != null)
                        {
                            msg += " -->" + this.mException.InnerException.InnerException.Message;
                        }
                    }
                    base.mTokens[TokenLibrary.MESSAGETEXT] = msg;
                    if (msg.Length > 0)
                    {
                        base.mTokens["<messageText_Line1>"] = (msg.Length < 50 ? msg.Substring(0).PadRight(50, ' ') : msg.Substring(0, 50).PadRight(50, ' '));
                    }
                    else
                    {
                        base.mTokens["<messageText_Line1>"] = "";
                    }
                    if (msg.Length > 50)
                    {
                        base.mTokens["<messageText_Line2>"] = (msg.Length < 100 ?  msg.Substring(50).PadRight(50, ' ') : msg.Substring(50, 50).PadRight(50, ' '));
                    }
                    else
                    {
                        base.mTokens["<messageText_Line2>"] = "";
                    }
                    if (msg.Length > 100)
                    {
                        base.mTokens["<messageText_Line3>"] = (msg.Length < 150 ? msg.Substring(100).PadRight(50, ' ') : msg.Substring(100, 50).PadRight(50, ' '));
                    }
                    else
                    {
                        base.mTokens["<messageText_Line3>"] = "";
                    }
                    if (msg.Length > 150)
                    {
                        base.mTokens["<messageText_Line4>"] = (msg.Length < 200 ? msg.Substring(150).PadRight(50, ' ') : msg.Substring(150, 50).PadRight(50, ' '));
                    }
                    else
                    {
                        base.mTokens["<messageText_Line4>"] = "";
                    }
                    if (msg.Length > 200)
                    {
                        base.mTokens["<messageText_Line5>"] = (msg.Length < 250 ? msg.Substring(200).PadRight(50, ' ') : msg.Substring(200, 50).PadRight(50, ' '));
                    }
                    else
                    {
                        base.mTokens["<messageText_Line5>"] = "";
                    }
                }
            }
            catch (Exception) { }
        }
Пример #24
0
        public string ProcessVerifyLabelRequest(string cartonID, string verifyCode)
        {
            //Verify the requested carton
            string verifyFlag        = VERIFY_NO;
            ApplicationException aex = null;

            try {
                //Begin processing a new message request
                ArgixTrace.WriteLine(new TraceMessage("VERIFY LABEL REQUEST: ID=" + cartonID + "; verify code=" + verifyCode, App.EventLogName, LogLevel.Information, "PandaSvc"));

                //Validate
                if (!(cartonID.Length == 14 || cartonID.Length == 24))
                {
                    throw new ApplicationException("Invalid cartonID length (" + cartonID.Length.ToString() + "; must be 14 0r 24)...");
                }

                //Find the carton
                SortedItem item = this.mOperator.GetSortedItem(cartonID.Length == 24 ? cartonID.Substring(10, 13) : cartonID.Substring(0, 13));
                if (item != null)
                {
                    //Item found
                    if (verifyCode == VERIFY_PASS)
                    {
                        //Pass: Save carton
                        try {
                            this.mOperator.StoreSortedItem(item);
                            verifyFlag = VERIFY_YES;
                            ArgixTrace.WriteLine(new TraceMessage("Carton save succeeded...", App.EventLogName, LogLevel.Information, "PandaSvc"));
                        }
                        catch (Exception ex) {
                            verifyFlag = VERIFY_NO;
                            aex        = new ApplicationException("Carton save failed...-->" + ex.Message, ex);
                            ArgixTrace.WriteLine(new TraceMessage(aex.Message, App.EventLogName, LogLevel.Error, "PandaSvc"));
                        }
                    }
                    else if (verifyCode == VERIFY_FAIL || verifyCode == VERIFY_NOREAD)
                    {
                        //Fail, No Read: Cancel carton
                        verifyFlag = VERIFY_NO;
                        this.mOperator.CancelSortedItem(item.LabelSeqNumber);
                        ArgixTrace.WriteLine(new TraceMessage("Verify flag was fail or no read; carton cancelled...", App.EventLogName, LogLevel.Information, "PandaSvc"));
                    }
                    else
                    {
                        //Fail, No Read: Cancel carton
                        verifyFlag = VERIFY_NO;
                        this.mOperator.CancelSortedItem(item.LabelSeqNumber);
                        ArgixTrace.WriteLine(new TraceMessage("Verify flag was unknown; carton cancelled...", App.EventLogName, LogLevel.Warning, "PandaSvc"));
                    }
                }
                else
                {
                    //Carton not found
                    verifyFlag = VERIFY_NO;
                    ArgixTrace.WriteLine(new TraceMessage("Carton not found...", App.EventLogName, LogLevel.Warning, "PandaSvc"));
                }
            }
            catch (ApplicationException ex) {
                verifyFlag = VERIFY_NO;
                aex        = ex;
                ArgixTrace.WriteLine(new TraceMessage(ex.Message, App.EventLogName, LogLevel.Error, "PandaSvc"));
            }
            catch (Exception ex) {
                verifyFlag = VERIFY_NO;
                aex        = new ApplicationException("An unexpected error occurred while processing verify label request-->" + ex.Message + "...", ex);
                ArgixTrace.WriteLine(new TraceMessage("An unexpected error occurred while processing verify label request-->" + ex.Message + "...", App.EventLogName, LogLevel.Error, "PandaSvc"));
            }
            finally {
                ArgixTrace.WriteLine(new TraceMessage("VERIFY LABEL RESPONSE: " + cartonID + "; " + verifyFlag, App.EventLogName, LogLevel.Information, "PandaSvc"));
                //    if(this.VerifyLabelRequestComplete != null) this.VerifyLabelRequestComplete(this,new PandaVerifyLabelEventArgs(cartonID,verifyFlag,aex));
            }
            return(verifyFlag);
        }
Пример #25
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);
        }
Пример #26
0
 private void reportError(Exception ex)
 {
     //Report an exception to the user
     ArgixTrace.WriteLine(new TraceMessage(ex.ToString(), AppLib.PRODUCTNAME, LogLevel.Error, "PandaSvc"));
 }
Пример #27
0
 internal virtual void OnHasDataChanged(object sender, LabelDataEventArgs e)
 {
     ArgixTrace.WriteLine(new TraceMessage(e.Element + " " + e.Data + " received.", AppLib.EVENTLOGNAME, LogLevel.Debug, "Brain    "));
 }
Пример #28
0
 internal virtual void OnInputReceived(object sender, LabelDataEventArgs e)
 {
     ArgixTrace.WriteLine(new TraceMessage("Label input " + e.Element + " received [input: " + e.Data + " ].", AppLib.EVENTLOGNAME, LogLevel.Debug, "Brain    "));
 }