public bool ExtractData() { try { _MyLogItems = new List <LogItem>(); DefaultLog.Break(); DefaultLog.Break(); DefaultLog.Break(); LogItem PreviousItem = null; using (StreamReader reader = new StreamReader(MyFileDir)) { while (!reader.EndOfStream) { var MyRecord = reader.ReadLine(); string MyRecordInfo = MyRecord.Split('-')[0]; DefaultLog.Debug(String.Format("MyRecordInfo = \"{0}\"", MyRecordInfo)); if (MyRecordInfo.Contains('<') && MyRecordInfo.Contains('>')) { string MyRecordTag = MyRecordInfo.Substring(1, MyRecordInfo.LastIndexOf('>') - 1); DefaultLog.Debug(String.Format("MyRecordTag = \"{0}\"", MyRecordTag)); string MyRecordDateTimeString = MyRecordInfo.Substring(MyRecordInfo.LastIndexOf('>') + 2, MyRecordInfo.Length - 3 - MyRecordInfo.LastIndexOf('>')); DefaultLog.Debug(String.Format("MyRecordDateTimeString = \"{0}\"", MyRecordDateTimeString)); DateTime MyRecordDateTime = Convert.ToDateTime(MyRecordDateTimeString); DefaultLog.Debug(String.Format("MyRecordDateTime = \"{0}\"", MyRecordDateTime)); string MyRecordText = MyRecord.Substring(MyRecordInfo.Length + 2, MyRecord.Length - MyRecordInfo.Length - 2); DefaultLog.Debug(String.Format("MyRecordText = \"{0}\"", MyRecordText)); LogItem Temp = new LogItem(MyRecordTag, MyRecordDateTime, MyRecordText); PreviousItem = Temp; _MyLogItems.Add(Temp); } else { if (PreviousItem != null) { PreviousItem.AppendContent(MyRecordInfo); } else { //Shouldn't get here! throw new NullReferenceException("'LogItem' called \"Previous Item\" is null!"); } } DefaultLog.Break(); DefaultLog.Break(); DefaultLog.Break(); } } return(true); } catch (Exception e) { return(false); } }
public LogReader(string pDir) { DefaultLog.Info("Test"); MyFileDir = pDir; }