public static new void logit(string message, string source = "") { if (message != "") { Log SystemLog = new Log(); Log log = new Tools.Log(applicationPath + logName); log.IncludeTime = includeTime; log.useSql = true; log.connection = AppTools.AppConnection.GetLogConnection(); log.appVersion = AppVersion(); //log.appUser = AppUser(); switch (message) { case "DIV": case "DIVIDER": log.WriteDivider(); break; case "BLANK": case "SPACE": log.WriteBlank(); break; case "CLEAR": case "NEW": log.Clear(); break; default: log.Write(source, message); break; } } }
public static void TraverseFile(string file) { int errorCount = 0; List <PurchaseOrderHeader> listPurchaseOrders = new List <PurchaseOrderHeader>(); PurchaseOrderHeader poHeader; PmTransaction pmTransaction; Log log = new Log(@"C:\Sinex\TraverseLog.txt"); log.Clear(); TextFile.WriteTextFile(@"C:\Sinex\File.txt", file); CurrentStructure currentStructure = CurrentStructure.start; int currentIndex = 0; int fileLength = file.Length; Bracket nextBracket = new Bracket(); nextBracket = NextBracket(file, currentIndex); bool continueLoop = true; int recordStart = 0; int recordEnd = 0; string record = ""; SinexPo po = new SinexPo(); SinexPoLine poLine = new SinexPoLine(); string recordString; Log xmlLog = new Tools.Log(@"C:\Sinex\recordXml.txt"); xmlLog.Clear(); while (continueLoop) { nextBracket = NextBracket(file, currentIndex); // log.Write("Next => " + nextBracket.ToString()); if (nextBracket.Index != -1) { #region switch switch (nextBracket.BracketType) { case "[": switch (currentStructure) { case CurrentStructure.start: currentStructure = CurrentStructure.poLoop; break; case CurrentStructure.poLoop: currentStructure = CurrentStructure.lineLoop; break; case CurrentStructure.lineLoop: MessageBox.Show($"1 - Bad Config " + currentStructure + ", " + currentStructure.ToString()); break; default: MessageBox.Show("Bad Config"); break; } break; case "]": switch (currentStructure) { case CurrentStructure.start: MessageBox.Show($"2 - Bad Config " + currentStructure + ", " + currentStructure.ToString()); break; case CurrentStructure.poLoop: currentStructure = CurrentStructure.start; break; case CurrentStructure.lineLoop: currentStructure = CurrentStructure.poLoop; break; default: MessageBox.Show($"3 - Bad Config " + currentStructure + ", " + currentStructure.ToString()); break; } break; case "{": switch (currentStructure) { case CurrentStructure.poLoop: recordStart = nextBracket.Index; recordEnd = file.IndexOf("lineItems", recordStart) - 2; record = file.SubFromTo(recordStart, recordEnd) + "}"; JsonSerializerSettings microsoftDateFormatSettings = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat }; //log.Write(record); po = JsonConvert.DeserializeObject <SinexPo>(record, microsoftDateFormatSettings); XNode node = JsonConvert.DeserializeXNode(record, "Root"); //xmlLog.Write(node.ToString()); recordString = po.ToString(); log.Write(" "); log.Write(" "); log.Write("HEADER => " + recordString); log.Write($" - {po.requiredBy}, {po.poCreatedBy}, {po.shipTo}"); pmTransaction = new PmTransaction(po, GetGPConnection()); //pmTransaction.Insert("TWO"); string xml = pmTransaction.ToEconnectXML(); //xmlLog.Write("----------------------------------------------"); //xmlLog.Write(xml); //xml = xml.RemoveNode("<connection>"); //xmlLog.Write("----------------------------------------------"); //xmlLog.Write(xml); //xml = xml.RemoveNode("PmTransaction", true); //xmlLog.Write("----------------------------------------------"); //xmlLog.Write(xml); //xml = xml.RemoveNode("?xml", true); //xmlLog.Write("----------------------------------------------"); //xmlLog.Write(xml); //xml = xml.Replace("</PmTransaction>", ""); //xmlLog.Write("----------------------------------------------"); //xmlLog.Write(xml); //string header = "<eConnect xmlns:dt=\"urn:schemas - microsoft - com:datatypes\">"; //header = header + "<PMTransactionType>"; //header = header + "<eConnectProcessInfo>"; //header = header + "</eConnectProcessInfo>"; //header = header + "<taPMTransactionInsert>"; //string footer ="</taPMTransactionInsert>"; //footer = footer + "</PMTransactionType>"; //footer = footer + "</eConnect>"; //xml = header + xml + footer; //xmlLog.Write("----------------------------------------------"); xmlLog.Write(xml); errorCount = errorCount + pmTransaction.InsertXml(xml); break; case CurrentStructure.lineLoop: recordStart = nextBracket.Index; recordEnd = file.IndexOf("}", recordStart) - 1; record = file.SubFromTo(recordStart, recordEnd) + "}"; poLine = JsonConvert.DeserializeObject <SinexPoLine>(record); recordString = poLine.ToString(); log.Write("LINE => " + recordString); po.AddLine(poLine); break; } break; po.ToLog(log); } #endregion Switch currentIndex = nextBracket.Index + 1; if (currentIndex >= fileLength) { continueLoop = false; } } else { continueLoop = false; } } }
public void ClearLog() { Log log = new Tools.Log(applicationPath + logName); log.Clear(); }