private void ParseFileTimePeriod(string filePath, string targetTime) { var sr = new StreamReader(filePath); string timeStart = TimeToString(Math.Max(TimeToInt(targetTime) - (int)numericUpDown1.Value, 0)); string timeEnd = TimeToString(Math.Min(TimeToInt(targetTime) + (int)numericUpDown1.Value, 1339)); long streamPointer = FindStartWith(sr, timeStart); sr.BaseStream.Position = streamPointer; List <string> scp = new List <string>(); while (!sr.EndOfStream) { string tempRead = sr.ReadLine(); scp.Add(tempRead); if (tempRead.StartsWith(timeEnd)) { break; } } int ddd = 0; string toParse = scp.Aggregate((a, b) => a + "\n" + b); LogDocument doc = new LogDocument(toParse, Path.GetFileNameWithoutExtension(filePath)); doc.ProgressUpdated += Doc_ProgressUpdated; context.AddDocument(doc); sr.Dispose(); }
private void Doc_ProgressUpdated(LogDocument obj) { double progress = 0; foreach (var item in context.Documents) { progress += item.ParseProgress; } progress = progress / parsingFilesCount; progressBar1.BeginInvoke((MethodInvoker)(() => progressBar1.Value = (int)progress)); }
public void AddDocument(LogDocument document) { Documents.Add(document); document.ParseDocument(); }
public LogContextParser(LogDocument document) { Documents = new List <LogDocument>(); Documents.Add(document); }