private void ProcessFile(IEnumerable <DatColPickTicket> listofPickTickets) { var orders = listofPickTickets.GroupBy(x => x.OrderNumber); foreach (var order in orders) { var firstOrder = order.First(); var pickTicketCode = firstOrder.OrderNumber.Substring(0, 2).ToLower(); var isSdPickTicketCode = pickTicketCode == "sd"; var isVoPickTicketCode = pickTicketCode == "vo"; var isSalesOrder = isSdPickTicketCode && !isVoPickTicketCode; var isTransferOrder = isVoPickTicketCode && !isSdPickTicketCode; var isOrderCorrupt = !isSalesOrder && !isTransferOrder; if (isSalesOrder) { if (ProcessSalesOrder(firstOrder, order)) { _log.AuditSuccess(string.Format("Sales Order '{0}' successfully inserted", firstOrder.OrderNumber)); } else { _log.AuditError("Failed to create Sales Order. Please read '.log' file."); } } if (isTransferOrder) { if (ProcessTransferOrder(firstOrder, order)) { _log.AuditSuccess(string.Format("Transfer Order '{0}' successfully inserted", firstOrder.OrderNumber)); } else { _log.AuditError("Failed to create Transfer Order. Please read '.log' file."); } } if (isOrderCorrupt) { _failedPickTicketOrderNumber = firstOrder.OrderNumber; _archiveService.ExportToAxapta(order, SaveTo.CorruptPickTicketDirectory, FailedPickTicketOrderFileName); } } }
private void ProcessFile(IEnumerable <DatColPurchaseOrder> listofPickTickets) { var orders = listofPickTickets.GroupBy(x => x.OrderNumber); foreach (var order in orders) { var firstOrder = order.First(); var code = firstOrder.OrderNumber.Substring(0, 3).ToLower(); var isPurchaseCode = code == "lio"; var isPurchaseOrder = isPurchaseCode; var isOrderCorrupt = !isPurchaseCode; if (isPurchaseOrder) { if (ProcessPurchaseOrder(firstOrder, order)) { _log.AuditSuccess(string.Format("Purchase Order '{0}' successfully inserted", firstOrder.OrderNumber)); } else { _log.AuditError("Failed to create Purchase Order. Please read '.log' file."); } } if (isOrderCorrupt) { _failedPurchaseOrderNumber = firstOrder.OrderNumber; _archiveService.ExportToAxapta(order, SaveTo.CorruptPurchaseOrderDirectory, FailedPurchaseOrderFileName); } } }