internal bool IsDuplicateCarton(SortedItem sortedItem) { //Check if the specified sortedItem is a duplicate of this sorted item return(!this.IsError() && !sortedItem.IsError() && this.CartonNumber == sortedItem.CartonNumber && this.Client.Number == sortedItem.Client.Number && this.Freight.Shipper.NUMBER == sortedItem.Freight.Shipper.NUMBER); }
public bool IsDuplicateCarton(SortedItem sortedItem) { //Check last DuplicateCheckCount number of Cartons for duplicate, ignore error cartons // int i=0, cartonsToCheck=DuplicateCheckCount; bool isDuplicate = false; try { //Validate if this carton is not already in an error condition if (!sortedItem.IsError()) { //while((i++ < cartonsToCheck) && !isDuplicate && (this.mSortedList.Count - i > 0)) { // SortedItem item = (SortedItem)this.mSortedList[this.mSortedList.Count - i]; // if(item.IsError()) // cartonsToCheck++; // else // isDuplicate = sortedItem.IsDuplicateCarton(item); //} //Work backwards through the list starting with previous sorted item (last in the list is the current sorted item) if (this.mSortedList.Count > 1) { //At least 2 sorted items exist; determine how many to check int itemsToCheck = (DuplicateCheckCount < this.mSortedList.Count) ? DuplicateCheckCount : this.mSortedList.Count - 1; for (int j = 1; j <= itemsToCheck; j++) { //Get a previous sorted item and check as duplicate SortedItem item = (SortedItem)this.mSortedList.GetByIndex(this.mSortedList.Count - j - 1); if (!item.IsError()) { isDuplicate = sortedItem.IsDuplicateCarton(item); } if (isDuplicate) { break; } } } } } catch (Exception ex) { throw new ApplicationException("Unexpected error while checking for duplicate carton in the collection.", ex); } return(isDuplicate); }
public bool StoreSortedItem(SortedItem sortedItem) { // if (sortedItem.IsError()) { throw new SavingException("Item was marked as error during processing - saving stopped " + sortedItem.LabelNumber); } try { SortFactory.SaveSortedItem(sortedItem); this.mStation.SortStatistics.AddSortedCarton(); //02/18/08 (jph): leave this sorted item in the collection for duplicate carton checks //this.mSortedItems.Remove(sortedItem.LabelSeqNumber); } catch (Exception ex) { throw new SavingException("Error saving sorted item " + sortedItem.LabelNumber, ex); } finally { if (this.SortedItemComplete != null) { this.SortedItemComplete(this, new SortedItemEventArgs(sortedItem)); } } return(true); }
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); }