public void ParseFileToUPD(string fullPath, string fileName, string location) { SaveHDFFile(fileName, location); var content = File.ReadAllText(fullPath); string[] transactionKeys = { "TheRecordSale", "TheRecordLayawaySale", "TheRecordApproAppro" }; bool containTransactionKey = false; foreach (var key in transactionKeys) { if (IsRecordSale(content, key)) { if (key == "TheRecordApproAppro") { Console.WriteLine("Processing:" + key); } containTransactionKey = true; break; } } if (!containTransactionKey) { new LogWriter("File: " + fileName + " contains no transaction keys for processing."); return; } var skus = RegexMatch(content, "Code\\s*.\\d{12}"); if (skus.Count() == 0) { new LogWriter("No SKUs found for HDF file: " + fileName); return; } for (var i = 0; i < skus.Count(); i++) { var sku = skus[i].Split(new string[] { "Code \"" }, StringSplitOptions.None)?[1]; if (sku != null && sku?.Length > 11) { var hdfModel = new HDFModel { FileName = fileName, Location = location, SKU = sku }; AppendToUPDFile(hdfModel); } } }
private void AppendToUPDFile(HDFModel hdfModel) { File.AppendAllText($"{ System.Configuration.ConfigurationManager.AppSettings["UPD"]}{guid}{".upd"}", hdfModel.ToString()); }