public static void Migrate(string headerCSV, string itemsCSV, string outputFileNameSuffix) { string timeStamp = DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss"); string outputXmlFileName = $"{timeStamp}_TallyInventoryImport_{outputFileNameSuffix}.xml"; //Load the main Tally XML document to which data is to be added XElement tallyXmlDoc = XmlComponentGenerator.TallyXml; //Parse the input CSVs using CSVHelper library var headerCSVParams = ParseCSVFiles.ParseCSV <HeaderCSVParams, HeaderCSVParamsMap>(headerCSV); var itemsCSVParams = ParseCSVFiles.ParseCSV <ItemsCSVParams, ItemsCSVParamsMap>(itemsCSV); //Create the XML data components to be added using the parsed CSV and template Xmls TallyXmlCreator tallyXmlCreator = new TallyXmlCreator(headerCSVParams.First(), itemsCSVParams, tallyXmlDoc); tallyXmlCreator.Create(outputXmlFileName); //Write final xml to disk if (!Directory.Exists(Configurations.OutputDir)) { Directory.CreateDirectory(Configurations.OutputDir); } FileStream fs = new FileStream(Configurations.OutputDir + "/" + outputXmlFileName, FileMode.Create); tallyXmlDoc.Save(fs); }
private int RetrieveLastUsedBarcodeFromFile() { var barcodesCSVParams = ParseCSVFiles.ParseCSV <BarcodeCSVParams, BarcodeCSVParamsMap>(Configurations.BarcodeCSVFilePath); string lastUsedBarcodeStr = barcodesCSVParams.Last().LastBarcodeAssigned; int lastUsedBarcodeInt; if (!int.TryParse(lastUsedBarcodeStr, out lastUsedBarcodeInt)) { throw new Exception($"Barcode {lastUsedBarcodeStr} not an integer! Please check the barcodes CSV file"); } return(lastUsedBarcodeInt); }