예제 #1
0
파일: brain.cs 프로젝트: jpheary/Argix08
        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); }
        }