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); } }