public bool WriteFile(string filename, List <Models.Files.ShipNotice.DataSequence.V3> data) { List <object> writelist = new List <object>(); bool success = false; string ClientOrderNumber = string.Empty; try { //build list foreach (Models.Files.ShipNotice.DataSequence.V3 dataitem in data) { writelist.Add(dataitem.CompanyRecord); if (dataitem.Shipments != null && dataitem.Shipments.Count > 0) { foreach (Models.Files.ShipNotice.DataSequence.Shipment item in dataitem.Shipments) { if (Common.IsValid(item.OrderRecord, false)) { writelist.Add(item.OrderRecord); ClientOrderNumber = item.OrderDetail.LastItem().ClientOrderID; } foreach (Models.Files.ShipNotice.OD_OrderDetailRecord detail in (from od in item.OrderDetail.AsEnumerable() where od.ClientOrderID == ClientOrderNumber select od)) { if (Common.IsValid(detail, false)) { writelist.Add(detail); } } } } } MultiRecordEngine engine = new MultiRecordEngine ( typeof(Models.Files.ShipNotice.CR_CompanyRecord), typeof(Models.Files.ShipNotice.OD_OrderDetailRecord), typeof(Models.Files.ShipNotice.OR_OrderRecord) ) { RecordSelector = new RecordTypeSelector(Models.Files.Invoice.Selectors.V3.Custom) }; engine.WriteFile(filename, writelist.ToArray()); success = true; } catch (Exception ex) { log.Error(ex); success = false; } return(success); }
public bool WriteFile(string filename, Models.Files.ShipNotice.DataSequence.V3 data) { List <object> writelist = new List <object>(); bool success = false; try { //build list writelist.Add(data.FileHeaderRecord); if (Common.IsValid(data.PackRecord, false)) { writelist.Add(data.PackRecord); } if (data.Shipments != null && data.Shipments.Count > 0) { foreach (Models.Files.ShipNotice.DataSequence.Shipment item in data.Shipments) { if (Common.IsValid(item.ShipmentRecord, false)) { writelist.Add(item.ShipmentRecord); } foreach (Models.Files.ShipNotice.OD_ASNShipmentDetail detail in item.LineItemDetailRecords) { if (Common.IsValid(detail, false)) { writelist.Add(detail); } } } } MultiRecordEngine engine = new MultiRecordEngine ( typeof(Models.Files.ShipNotice.CR_ASNCompany), typeof(Models.Files.ShipNotice.OP_ASNPack), typeof(Models.Files.ShipNotice.OR_ASNShipment), typeof(Models.Files.ShipNotice.OD_ASNShipmentDetail) ) { RecordSelector = new RecordTypeSelector(Models.Files.Invoice.Selectors.V3.Custom) }; engine.WriteFile(filename, writelist.ToArray()); success = true; } catch (Exception ex) { log.Error(ex); success = false; } return(success); }
public void GivenOnlyFirstTypeHasNotifyWrite_WhenWritingToFile_EventIsRaised() { var lobamba = new NotifyCity { Name = "Lobamba", Population = 11000 }; var rhine = new River { Name = "Rhine", LengthKilometers = 1230 }; var geography = new object[] { lobamba, rhine }; var cityRiverEngine = new MultiRecordEngine(typeof(NotifyCity), typeof(River)); cityRiverEngine.WriteFile("geography.txt", geography); Assert.AreEqual(2, mCityEventCount); }
public void MultpleRecordsFileRW() { engine = new MultiRecordEngine(typeof(OrdersVerticalBar), typeof(CustomersSemiColon), typeof(SampleType)); engine.RecordSelector = new RecordTypeSelector(CustomSelector); object[] res2 = engine.ReadFile(FileTest.Good.MultiRecord1.Path); Assert.AreEqual(12, res2.Length); Assert.AreEqual(12, engine.TotalRecords); engine.WriteFile("tempMR.txt", res2); object[] res = engine.ReadFile("tempMR.txt"); File.Delete("tempMR.txt"); Assert.AreEqual(12, res.Length); Assert.AreEqual(12, engine.TotalRecords); Assert.AreEqual(typeof(OrdersVerticalBar), res[0].GetType()); Assert.AreEqual(typeof(OrdersVerticalBar), res[1].GetType()); Assert.AreEqual(typeof(CustomersSemiColon), res[2].GetType()); Assert.AreEqual(typeof(SampleType), res[5].GetType()); }
public bool WriteFile(string filename, Models.Files.PurchaseAcknowledgement.DataSequence.V3 data) { List <object> writelist = new List <object>(); bool success = false; try { //build list writelist.Add(data.FileHeaderRecord); if (Common.IsValid(data.PurchaseOrderHeaderRecord)) { writelist.Add(data.PurchaseOrderHeaderRecord); } if (data.FreeFormVendor != null && data.FreeFormVendor.Count > 0) { foreach (Models.Files.PurchaseAcknowledgement.R21_FreeFormVendor item in data.FreeFormVendor) { if (Common.IsValid(item)) { writelist.Add(item); } } } if (Common.IsValid(data.RecipShipToNameAndAddressRecord)) { writelist.Add(data.RecipShipToNameAndAddressRecord); } if (data.RecipShipToAdditionalShippingInfo != null && data.RecipShipToAdditionalShippingInfo.Count > 0) { foreach (Models.Files.PurchaseAcknowledgement.R32_RecipientShipToAdditionalShippingInformation item in data.RecipShipToAdditionalShippingInfo) { if (Common.IsValid(item)) { writelist.Add(item); } } } if (Common.IsValid(data.RecipShipToCityStateAndZipRecord)) { writelist.Add(data.RecipShipToCityStateAndZipRecord); } if (data.LineItems != null && data.LineItems.Count > 0) { foreach (Models.Files.PurchaseAcknowledgement.DataSequence.LineItem item in data.LineItems) { if (Common.IsValid(item.LineItemRecord)) { writelist.Add(item.LineItemRecord); } if (Common.IsValid(item.AdditionalDetailRecord)) { writelist.Add(item.AdditionalDetailRecord); } if (Common.IsValid(item.AddtionalLineItemTitleRecord)) { writelist.Add(item.AddtionalLineItemTitleRecord); } if (Common.IsValid(item.AdditionalLineItemPublisherRecord)) { writelist.Add(item.AdditionalLineItemPublisherRecord); } if (Common.IsValid(item.ItemNumberOrPriceRecord)) { writelist.Add(item.ItemNumberOrPriceRecord); } } } if (Common.IsValid(data.PurchaseOrderControlTotalsRecord)) { writelist.Add(data.PurchaseOrderControlTotalsRecord); } if (Common.IsValid(data.FileTrailerRecord)) { writelist.Add(data.FileTrailerRecord); } MultiRecordEngine engine = new MultiRecordEngine ( typeof(Models.Files.PurchaseAcknowledgement.R02_FileHeader), typeof(Models.Files.PurchaseAcknowledgement.R11_PurchaseOrderHeader), typeof(Models.Files.PurchaseAcknowledgement.R21_FreeFormVendor), typeof(Models.Files.PurchaseAcknowledgement.R30_RecipientShipToNameAndAddress), typeof(Models.Files.PurchaseAcknowledgement.R32_RecipientShipToAdditionalShippingInformation), typeof(Models.Files.PurchaseAcknowledgement.R34_RecipientShipToCityStateAndZip), typeof(Models.Files.PurchaseAcknowledgement.R40_LineItem), typeof(Models.Files.PurchaseAcknowledgement.R41_AdditionalDetail), typeof(Models.Files.PurchaseAcknowledgement.R42_AdditionalLineItem), typeof(Models.Files.PurchaseAcknowledgement.R43_AdditionalLineItem), typeof(Models.Files.PurchaseAcknowledgement.R44_ItemNumberOrPrice), typeof(Models.Files.PurchaseAcknowledgement.R59_PurchaseOrderControlTotals), typeof(Models.Files.PurchaseAcknowledgement.R91_FileTrailer) ) { RecordSelector = new RecordTypeSelector(Models.Files.Invoice.Selectors.V3.Custom) }; engine.WriteFile(filename, writelist.ToArray()); success = true; } catch (Exception ex) { log.Error(ex); success = false; } return(success); }
public bool WriteFile(string filename, Models.Files.Invoice.DataSequence.V3 data) { List <object> writelist = new List <object>(); bool success = false; try { //build list writelist.Add(data.InvoiceFileHeaderRecord); if (data.Invoices != null && data.Invoices.Count > 0) { foreach (Models.Files.Invoice.DataSequence.InvoiceItem item in data.Invoices) { if (Common.IsValid(item.InvoiceHeaderRecord)) { writelist.Add(item.InvoiceHeaderRecord); } foreach (Models.Files.Invoice.DataSequence.InvoiceDetail detail in item.InvoiceDetails) { if (Common.IsValid(detail.InvoiceDetailRecord)) { writelist.Add(detail.InvoiceDetailRecord); } if (Common.IsValid(detail.InvoiceDetail2Record)) { writelist.Add(detail.InvoiceDetail2Record); } if (Common.IsValid(detail.DetailTotalRecord)) { writelist.Add(detail.DetailTotalRecord); } if (Common.IsValid(detail.DetailTotalOrFreightAndFeesRecord)) { writelist.Add(detail.DetailTotalOrFreightAndFeesRecord); } } if (Common.IsValid(item.InvoiceTotalRecord)) { writelist.Add(item.InvoiceTotalRecord); } if (Common.IsValid(item.InvoiceTrailerRecord)) { writelist.Add(item.InvoiceTrailerRecord); } } } if (Common.IsValid(data.InvoiceFileTrailerRecord)) { writelist.Add(data.InvoiceFileTrailerRecord); } MultiRecordEngine engine = new MultiRecordEngine ( typeof(Models.Files.Invoice.R01_InvoiceFileHeader), typeof(Models.Files.Invoice.R15_InvoiceHeader), typeof(Models.Files.Invoice.R45_InvoiceDetail), typeof(Models.Files.Invoice.R46_InvoiceDetail), typeof(Models.Files.Invoice.R48_DetailTotal), typeof(Models.Files.Invoice.R49_DetailTotalOrFreightAndFees), typeof(Models.Files.Invoice.R55_InvoiceTotals), typeof(Models.Files.Invoice.R57_InvoiceTrailer), typeof(Models.Files.Invoice.R95_InvoiceFileTrailer) ) { RecordSelector = new RecordTypeSelector(Models.Files.Invoice.Selectors.V3.Custom) }; engine.WriteFile(filename, writelist.ToArray()); success = true; } catch (Exception ex) { log.Error(ex); success = false; } return(success); }
public bool WriteFile(string filename, Models.Files.Invoice.DataSequence.V3 data) { List <object> writelist = new List <object>(); List <(string code, Type type)> used = new List <(string code, Type type)>(); bool success = false; try { //build list writelist.Add(data.InvoiceFileHeaderRecord); //++if((from u in used where u.code == data.InvoiceFileHeaderRecord.InvoiceFileHeader select u.code).Count() == 0) { used.Add((data.InvoiceFileHeaderRecord.InvoiceFileHeader,typeof(Models.Files.Invoice.R01_InvoiceFileHeader)); } if (data.Invoices != null && data.Invoices.Count > 0) { foreach (Models.Files.Invoice.DataSequence.InvoiceItem item in data.Invoices) { if (Common.IsValid(item.InvoiceHeaderRecord)) { writelist.Add(item.InvoiceHeaderRecord); } if (Common.IsValid(item.InvoiceVendorDetailRecord)) { writelist.Add(item.InvoiceVendorDetailRecord); } foreach (Models.Files.Invoice.DataSequence.InvoiceDetail detail in item.InvoiceDetails) { if (Common.IsValid(detail.InvoiceDetailRecord)) { writelist.Add(detail.InvoiceDetailRecord); } if (Common.IsValid(detail.DetailISBN13OrEANRecord)) { writelist.Add(detail.DetailISBN13OrEANRecord); } if (Common.IsValid(detail.DetailTotalRecord)) { writelist.Add(detail.DetailTotalRecord); } } if (Common.IsValid(item.InvoiceTotalRecord)) { writelist.Add(item.InvoiceTotalRecord); } if (Common.IsValid(item.InvoiceTrailerRecord)) { writelist.Add(item.InvoiceTrailerRecord); } } } if (Common.IsValid(data.InvoiceFileTrailer, false)) { writelist.Add(data.InvoiceFileTrailer); } MultiRecordEngine engine = new MultiRecordEngine ( typeof(Models.Files.Invoice.R01_InvoiceFileHeader), typeof(Models.Files.Invoice.R15_InvoiceHeader), typeof(Models.Files.Invoice.R16_InvoiceVendorDetail), typeof(Models.Files.Invoice.R45_InvoiceDetail), typeof(Models.Files.Invoice.R46_DetailISBN13OrEAN), typeof(Models.Files.Invoice.R48_DetailTotal), typeof(Models.Files.Invoice.R55_InvoiceTotals), typeof(Models.Files.Invoice.R57_InvoiceTrailer), typeof(Models.Files.Invoice.R95_InvoiceFileTrailer) ) { RecordSelector = new RecordTypeSelector(Models.Files.Invoice.Selectors.V3.Custom) }; engine.WriteFile(filename, writelist.ToArray()); success = true; } catch (Exception ex) { Console.WriteLine(ex.ToString()); success = false; } return(success); }
public bool WriteFileAddingSequence(string filename, Models.Files.PurchaseOrder.DataSequence.V3 data, bool checkseq) { List <object> writelist = new List <object>(); List <(string code, Type type)> used = new List <(string code, Type type)>(); bool success = false; short seqnum = 1; try { //build list data.FileHeaderRecord.SequenceNumber = seqnum++; writelist.Add(data.FileHeaderRecord); if ((from u in used where u.code == data.FileHeaderRecord.RecordCode select u.code).Count() == 0) { used.Add((data.FileHeaderRecord.RecordCode, typeof(Models.Files.PurchaseOrder.R00_ClientFileHeader))); } if (data.PurchaseOrders != null && data.PurchaseOrders.Count > 0) { foreach (Models.Files.PurchaseOrder.DataSequence.PurchaseOrder item in data.PurchaseOrders) { item.ClientHeaderRecord.SequenceNumber = seqnum++; writelist.Add(item.ClientHeaderRecord); if ((from u in used where u.code == item.ClientHeaderRecord.RecordCode select u.code).Count() == 0) { used.Add((item.ClientHeaderRecord.RecordCode, typeof(Models.Files.PurchaseOrder.R10_ClientHeader))); } if (Common.IsValid(item.FixedHandlingInstructionsRecord, checkseq) && !string.IsNullOrEmpty(item.FixedHandlingInstructionsRecord.PONumber)) { item.FixedHandlingInstructionsRecord.SequenceNumber = seqnum++; writelist.Add(item.FixedHandlingInstructionsRecord); if ((from u in used where u.code == item.FixedHandlingInstructionsRecord.RecordCode select u.code).Count() == 0) { used.Add((item.FixedHandlingInstructionsRecord.RecordCode, typeof(Models.Files.PurchaseOrder.R20_FixedSpecialHandlingInstructions))); } } if (Common.IsValid(item.PurchaseOrderOptionsRecord, checkseq)) { item.PurchaseOrderOptionsRecord.SequenceNumber = seqnum++; writelist.Add(item.PurchaseOrderOptionsRecord); if ((from u in used where u.code == item.PurchaseOrderOptionsRecord.RecordCode select u.code).Count() == 0) { used.Add((item.PurchaseOrderOptionsRecord.RecordCode, typeof(Models.Files.PurchaseOrder.R21_PurchaseOrderOptions))); } } if (item.PurchaseOrderDetails != null && item.PurchaseOrderDetails.Count > 0) { foreach (Models.Files.PurchaseOrder.DataSequence.PurchaseOrderDetail detail in item.PurchaseOrderDetails) { if (Common.IsValid(detail.LineItemDetail, checkseq)) { detail.LineItemDetail.SequenceNumber = seqnum++; writelist.Add(detail.LineItemDetail); if ((from u in used where u.code == detail.LineItemDetail.RecordCode select u.code).Count() == 0) { used.Add((detail.LineItemDetail.RecordCode, typeof(Models.Files.PurchaseOrder.R40_LineItemDetail))); } } if (Common.IsValid(detail.AdditionalLineItemDetail, checkseq)) { detail.AdditionalLineItemDetail.SequenceNumber = seqnum++; writelist.Add(detail.AdditionalLineItemDetail); if ((from u in used where u.code == detail.AdditionalLineItemDetail.RecordCode select u.code).Count() == 0) { used.Add((detail.AdditionalLineItemDetail.RecordCode, typeof(Models.Files.PurchaseOrder.R41_AdditionalLineItemDetail))); } } if (detail.Imprint != null && detail.Imprint.Count > 0) { foreach (Models.Files.PurchaseOrder.R45_Imprint imprint in detail.Imprint) { if (Common.IsValid(imprint, checkseq) && !string.IsNullOrEmpty(imprint.PONumber)) { imprint.SequenceNumber = seqnum++; writelist.Add(imprint); if ((from u in used where u.code == imprint.RecordCode select u.code).Count() == 0) { used.Add((imprint.RecordCode, typeof(Models.Files.PurchaseOrder.R45_Imprint))); } } } } if (Common.IsValid(detail.StickerBarcodeDataRecord, checkseq) && !string.IsNullOrEmpty(detail.StickerBarcodeDataRecord.PONumber)) { detail.StickerBarcodeDataRecord.SequenceNumber = seqnum++; writelist.Add(detail.StickerBarcodeDataRecord); if ((from u in used where u.code == detail.StickerBarcodeDataRecord.RecordCode select u.code).Count() == 0) { used.Add((detail.StickerBarcodeDataRecord.RecordCode, typeof(Models.Files.PurchaseOrder.R46_StickerBarcodeData))); } } if (detail.StickerTextLines != null && detail.StickerTextLines.Count > 0) { foreach (Models.Files.PurchaseOrder.R46_StickerTextLines text in detail.StickerTextLines) { if (Common.IsValid(text, checkseq) && !string.IsNullOrEmpty(text.PONumber)) { text.SequenceNumber = seqnum++; writelist.Add(text); if ((from u in used where u.code == text.RecordCode select u.code).Count() == 0) { used.Add((text.RecordCode, typeof(Models.Files.PurchaseOrder.R46_StickerBarcodeData))); } } } } } } } } if (Common.IsValid(data.PurchaseOrderTrailerRecord, checkseq)) { data.PurchaseOrderTrailerRecord.SequenceNumber = seqnum++; writelist.Add(data.PurchaseOrderTrailerRecord); if ((from u in used where u.code == data.PurchaseOrderTrailerRecord.RecordCode select u.code).Count() == 0) { used.Add((data.PurchaseOrderTrailerRecord.RecordCode, typeof(Models.Files.PurchaseOrder.R50_PurchaseOrderTrailer))); } } if (Common.IsValid(data.FileTrailerRecord, checkseq)) { data.FileTrailerRecord.SequenceNumber = seqnum++; writelist.Add(data.FileTrailerRecord); if ((from u in used where u.code == data.FileTrailerRecord.RecordCode select u.code).Count() == 0) { used.Add((data.FileTrailerRecord.RecordCode, typeof(Models.Files.PurchaseOrder.R90_FileTrailer))); } } MultiRecordEngine engine = new MultiRecordEngine ( (from u in used orderby u.code select u.type).Distinct().ToArray() ) { RecordSelector = new RecordTypeSelector(Models.Files.Invoice.Selectors.V3.Custom) }; engine.WriteFile(filename, writelist.ToArray()); success = true; } catch (Exception ex) { log.Error(ex); success = false; } return(success); }
public bool WriteFile(string filename, Models.Files.PurchaseOrder.DataSequence.V3 data, bool checkseq) { List <object> writelist = new List <object>(); bool success = false; try { //build list writelist.Add(data.FileHeaderRecord); if (data.PurchaseOrders != null && data.PurchaseOrders.Count > 0) { foreach (Models.Files.PurchaseOrder.DataSequence.PurchaseOrder item in data.PurchaseOrders) { writelist.Add(item.ClientHeaderRecord); if (Common.IsValid(item.FixedHandlingInstructionsRecord, checkseq)) { writelist.Add(item.FixedHandlingInstructionsRecord); } if (Common.IsValid(item.PurchaseOrderOptionsRecord, checkseq)) { writelist.Add(item.PurchaseOrderOptionsRecord); } if (item.PurchaseOrderDetails != null && item.PurchaseOrderDetails.Count > 0) { foreach (Models.Files.PurchaseOrder.DataSequence.PurchaseOrderDetail detail in item.PurchaseOrderDetails) { if (Common.IsValid(detail.LineItemDetail, checkseq)) { writelist.Add(detail.LineItemDetail); } if (Common.IsValid(detail.AdditionalLineItemDetail, checkseq)) { writelist.Add(detail.AdditionalLineItemDetail); } if (detail.Imprint != null && detail.Imprint.Count > 0) { foreach (Models.Files.PurchaseOrder.R45_Imprint imprint in detail.Imprint) { if (Common.IsValid(imprint, checkseq)) { writelist.Add(imprint); } } } if (Common.IsValid(detail.StickerBarcodeDataRecord, checkseq)) { writelist.Add(detail.StickerBarcodeDataRecord); } if (detail.StickerTextLines != null && detail.StickerTextLines.Count > 0) { foreach (Models.Files.PurchaseOrder.R46_StickerTextLines text in detail.StickerTextLines) { if (Common.IsValid(text, checkseq)) { writelist.Add(text); } } } } } } } if (Common.IsValid(data.PurchaseOrderTrailerRecord, checkseq)) { writelist.Add(data.PurchaseOrderTrailerRecord); } if (Common.IsValid(data.FileTrailerRecord, checkseq)) { writelist.Add(data.FileTrailerRecord); } MultiRecordEngine engine = new MultiRecordEngine ( typeof(Models.Files.PurchaseOrder.R00_ClientFileHeader), typeof(Models.Files.PurchaseOrder.R10_ClientHeader), typeof(Models.Files.PurchaseOrder.R20_FixedSpecialHandlingInstructions), typeof(Models.Files.PurchaseOrder.R21_PurchaseOrderOptions), typeof(Models.Files.PurchaseOrder.R40_LineItemDetail), typeof(Models.Files.PurchaseOrder.R41_AdditionalLineItemDetail), typeof(Models.Files.PurchaseOrder.R45_Imprint), typeof(Models.Files.PurchaseOrder.R46_StickerBarcodeData), typeof(Models.Files.PurchaseOrder.R46_StickerTextLines), typeof(Models.Files.PurchaseOrder.R50_PurchaseOrderTrailer), typeof(Models.Files.PurchaseOrder.R90_FileTrailer) ) { RecordSelector = new RecordTypeSelector(Models.Files.Invoice.Selectors.V3.Custom) }; engine.WriteFile(filename, writelist.ToArray()); success = true; } catch (Exception ex) { log.Error(ex); success = false; } return(success); }
public bool WriteFile(string filename, Models.Files.PurchaseOrder.DataSequence.V3 data) { List <object> writelist = new List <object>(); bool success = false; try { //build list writelist.Add(data.FileHeaderRecord); if (data.PurchaseOrders != null && data.PurchaseOrders.Count > 0) { foreach (Models.Files.PurchaseOrder.DataSequence.PurchaseOrder item in data.PurchaseOrders) { writelist.Add(item.ClientHeaderRecord); if (Common.IsValid(item.FixedHandlingInstructionsRecord)) { writelist.Add(item.FixedHandlingInstructionsRecord); } if (Common.IsValid(item.PurchaseOrderOptionsRecord)) { writelist.Add(item.PurchaseOrderOptionsRecord); } if (Common.IsValid(item.CustomerCostRecord)) { writelist.Add(item.CustomerCostRecord); } if (Common.IsValid(item.CustomerBillToNameRecord)) { writelist.Add(item.CustomerBillToNameRecord); } if (Common.IsValid(item.CustomerBillToPhoneNumberRecord)) { writelist.Add(item.CustomerBillToPhoneNumberRecord); } if (item.CustomerBillToAddressLine != null && item.CustomerBillToAddressLine.Count > 0) { foreach (Models.Files.PurchaseOrder.R27_CustomerBillToAddressLine detail in item.CustomerBillToAddressLine) { if (Common.IsValid(detail)) { writelist.Add(detail); } } } if (Common.IsValid(item.CustomerBillToCityStateZipRecord)) { writelist.Add(item.CustomerBillToCityStateZipRecord); } if (Common.IsValid(item.RecipientShipToNameRecord)) { writelist.Add(item.RecipientShipToNameRecord); } if (Common.IsValid(item.RecipientShipToPhoneRecord)) { writelist.Add(item.RecipientShipToPhoneRecord); } if (item.ShipRecordRecipientAddressLine != null && item.ShipRecordRecipientAddressLine.Count > 0) { foreach (Models.Files.PurchaseOrder.R32_ShippingRecordRecipientAddressLine detail in item.ShipRecordRecipientAddressLine) { if (Common.IsValid(detail)) { writelist.Add(detail); } } } if (Common.IsValid(item.RecipShippingRecordCityStateZipRecord)) { writelist.Add(item.RecipShippingRecordCityStateZipRecord); } if (Common.IsValid(item.DropShipDetailRecord)) { writelist.Add(item.DropShipDetailRecord); } if (item.SpecialDeliveryInstructions != null && item.SpecialDeliveryInstructions.Count > 0) { foreach (Models.Files.PurchaseOrder.R36_SpecialDeliveryInstructions detail in item.SpecialDeliveryInstructions) { if (Common.IsValid(detail)) { writelist.Add(detail); } } } if (item.MarketingMessage != null && item.MarketingMessage.Count > 0) { foreach (Models.Files.PurchaseOrder.R37_MarketingMessage detail in item.MarketingMessage) { if (Common.IsValid(detail)) { writelist.Add(detail); } } } if (item.GiftMessage != null && item.GiftMessage.Count > 0) { foreach (Models.Files.PurchaseOrder.R38_GiftMessage detail in item.GiftMessage) { if (Common.IsValid(detail)) { writelist.Add(detail); } } } if (item.Items != null && item.Items.Count > 0) { foreach (Models.Files.PurchaseOrder.DataSequence.Item lineitem in item.Items) { if (Common.IsValid(lineitem.LineItemRecord)) { writelist.Add(lineitem.LineItemRecord); } if (Common.IsValid(lineitem.AdditionalLineItemRecord)) { writelist.Add(lineitem.AdditionalLineItemRecord); } if (lineitem.LineItemGiftMessage != null && lineitem.LineItemGiftMessage.Count > 0) { foreach (Models.Files.PurchaseOrder.R42_LineItemGiftMessage detail in lineitem.LineItemGiftMessage) { if (Common.IsValid(detail)) { writelist.Add(detail); } } } if (lineitem.Imprint != null && lineitem.Imprint.Count > 0) { foreach (Models.Files.PurchaseOrder.R45_Imprint detail in lineitem.Imprint) { if (Common.IsValid(detail)) { writelist.Add(detail); } } } } } if (Common.IsValid(item.PurchaseOrderControlRecord)) { writelist.Add(item.PurchaseOrderControlRecord); } } } if (Common.IsValid(data.FileTrailerRecord)) { writelist.Add(data.FileTrailerRecord); } MultiRecordEngine engine = new MultiRecordEngine ( typeof(Models.Files.PurchaseOrder.R00_FileHeader), typeof(Models.Files.PurchaseOrder.R10_ClientHeader), typeof(Models.Files.PurchaseOrder.R20_FixedSpecialHandlingInstructions), typeof(Models.Files.PurchaseOrder.R21_PurchaseOrderOptions), typeof(Models.Files.PurchaseOrder.R24_CustomerCost), typeof(Models.Files.PurchaseOrder.R25_CustomerBillToName), typeof(Models.Files.PurchaseOrder.R26_CustomerBillToPhoneNumber), typeof(Models.Files.PurchaseOrder.R27_CustomerBillToAddressLine), typeof(Models.Files.PurchaseOrder.R29_CustomerBillToCityStateZip), typeof(Models.Files.PurchaseOrder.R30_RecipientShipToName), typeof(Models.Files.PurchaseOrder.R31_RecipientShipToPhone), typeof(Models.Files.PurchaseOrder.R32_ShippingRecordRecipientAddressLine), typeof(Models.Files.PurchaseOrder.R34_RecipientShippingRecordCityStateZip), typeof(Models.Files.PurchaseOrder.R35_DropShipDetail), typeof(Models.Files.PurchaseOrder.R36_SpecialDeliveryInstructions), typeof(Models.Files.PurchaseOrder.R37_MarketingMessage), typeof(Models.Files.PurchaseOrder.R38_GiftMessage), typeof(Models.Files.PurchaseOrder.R40_LineItem), typeof(Models.Files.PurchaseOrder.R41_AdditionalLineItem), typeof(Models.Files.PurchaseOrder.R42_LineItemGiftMessage), typeof(Models.Files.PurchaseOrder.R45_Imprint), typeof(Models.Files.PurchaseOrder.R50_PurchaseOrderControl), typeof(Models.Files.PurchaseOrder.R90_FileTrailer) ) { RecordSelector = new RecordTypeSelector(Models.Files.Invoice.Selectors.V3.Custom) }; engine.WriteFile(filename, writelist.ToArray()); success = true; } catch (Exception ex) { log.Error(ex); success = false; } return(success); }