private InboundLabel mInboundLabel = null; //Expected inbound label //Constants //Events //Interface public SortProfile(SortProfileDS.SortProfileTableRow profile) { //Constructor try { if (profile != null) { this.mFreightType = profile.FreightType; this.mSortTypeID = profile.SortTypeID; this.mSortType = profile.SortType; this.mClientNumber = profile.ClientNumber; this.mClientDivision = profile.ClientDivision; if (!profile.IsVendorNumberNull()) { this.mVendorNumber = profile.VendorNumber; } this.mStatus = profile.Status; if (!profile.IsExceptionLocationNull()) { this.mExceptionDeliveryLocation = profile.ExceptionLocation; } if (!profile.IsLabelIDNull()) { this.mLabelID = profile.LabelID; } //Create the inbound label for this profile; this.mInboundLabel = FreightFactory.CreateInboundLabel(this.mLabelID); } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new Sort Profile instance.", ex); } }
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); } } }
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); }
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); } }
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); }
internal override void DetermineDestinationAndRounting(SortedItem sortedItem, InboundLabel label) { // string inputString = label.GetElementValue("STORE"); sortedItem.CartonNumber = label.GetElementValue("CARTON"); sortedItem.PONumber = label.GetElementValue("PO"); sortedItem.TrackingNumber = ""; 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.CreateDestinationRoutingManifestX(sortedItem.Client.Number, sortedItem.Client.Division, sortedItem.Freight.Shipper.NUMBER, Self.Station.TerminalID.ToString().PadLeft(2, '0'), sortedItem.Freight.FreightID, inputString, sortedItem.SpecialAgent.ZONE_CODE.Trim(), sortedItem.CartonNumber, !label.IsDuplicateElementAllowed("CARTON")); sortedItem.DestinationRouting = CreateDestinationRoutingManifest(sortedItem, inputString, !label.IsDuplicateElementAllowed("CARTON")); if (sortedItem.DestinationRouting.ManifestCartonNumber.Length > 0) { sortedItem.CartonNumber = sortedItem.DestinationRouting.ManifestCartonNumber; } if (sortedItem.DestinationRouting.ManifestPONumber.Length > 0) { sortedItem.PONumber = sortedItem.DestinationRouting.ManifestPONumber; } if (sortedItem.DestinationRouting.ManifestTrackingNumber.Length > 0) { sortedItem.TrackingNumber = sortedItem.DestinationRouting.ManifestTrackingNumber; } 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."); } string trackingNum = sortedItem.SpecialAgent.MakeTrackingNumber(sortedItem.DestinationRouting.OSSequence); if (trackingNum.Trim().Length > 0) { sortedItem.TrackingNumber = trackingNum; } sortedItem.LabelTemplate = SortFactory.CreateOBLabelTemplate(sortedItem.DestinationRouting.OutboundLabelType, Self.Station.PrinterType); } catch (Exception ex) { sortedItem.ThrowException(new DestinationRoutingException(ex)); } }
internal virtual void DetermineDestinationAndRounting(SortedItem sortedItem, InboundLabel label) { }