/// <summary> /// This fires when a product is successfully read from the message /// </summary> /// <param name="currentLineNumber">The current line number.</param> /// <param name="fields">The fields.</param> /// <param name="lineText">The line text.</param> private void RecordFound(ref int currentLineNumber, TextFieldCollection fields, string lineText) { string type; string subType; GetRowTypeAndSubType(lineText, out type, out subType); if (type == GetItemType() && subType == GetSubItemType()) //add { //get commander product by product code string productCode = fields["ProductCode"].Value.ToString().Trim(); if (string.IsNullOrEmpty(site)) { site = fields["Site"].Value.ToString().Trim(); } CommanderProduct commanderProduct = CommanderController.GetProduct(productCode); if (commanderProduct == null) //there is no matching HSPG product in our product list { hspgItems.Add(lineText); } else { tpcItems.Add(lineText); } } else if (type == HeaderOrFooter && subType == "L") //footer { footerLine = lineText; } else if (type == HeaderOrFooter && subType == "F") //header { headerLine = lineText; } }
/// <summary> /// Saves the commander orders. /// </summary> /// <param name="requestMessage">The request message.</param> /// <returns></returns> private SubscriberStatusEnum SaveProducts(RequestMessage requestMessage) { foreach (CommanderProduct product in products) { if (product.IsUpdate) { //this should be an update so check to see if this record already exists CommanderProduct previousRecord = CommanderController.GetProduct(product.ProductCode); if (previousRecord != null) { //the record did not exist so log an exception ////log //LogEntry logEntry=new LogEntry(); //logEntry.Message = "blah"; //Logger.Write(logEntry); // throw new Exception("This message has already been sent to the warehouse."); return(SubscriberStatusEnum.Processed); } product.Id = previousRecord.Id; } //save salesOrder and lines try { int savedId = CommanderController.SaveProduct(product); } catch (InValidBusinessObjectException ex) { //log exception return(SubscriberStatusEnum.Failed); } } return(SubscriberStatusEnum.Processed); }