Esempio n. 1
0
        public List<TraceEvent> Index(StreamReader reader)
        {
            List<TraceEvent> events = new List<TraceEvent>();
            long curPos = 0;
            while (true)
            {
                TraceEvent evt = new TraceEvent();

                evt.PositionStart = FindStringInStream(reader, RecordStart, curPos);
                if (evt.PositionStart == -1)
                    break; // No new tracerecord found
                ReadActivityID(reader, evt, evt.PositionStart, 300);
                ReadTimeAndSource(reader, evt, evt.PositionStart, 120);
                evt.PositionEnd = FindStringInStream(reader, RecordEnd, evt.PositionStart);
                if (evt.PositionEnd == -1)
                    break; // A tracerecord was found, but the ending was not found
                evt.PositionEnd = evt.PositionEnd + RecordEnd.Length;
                evt.To = FindTo(reader, evt.PositionStart, evt.PositionEnd);
                evt.Method = FindMethod(reader, evt.PositionStart, evt.PositionEnd);

                // Start searching from the endposition again
                curPos = evt.PositionEnd;

                events.Add(evt);
            }

            OnProgress(reader.BaseStream.Length, reader.BaseStream.Length);
            return events;
        }
Esempio n. 2
0
 private void ReadActivityID(StreamReader reader, TraceEvent evt, long fromPosition, long sizeToScan)
 {
     reader.BaseStream.Seek(fromPosition - sizeToScan, SeekOrigin.Begin);
     reader.DiscardBufferedData();
     char[] buffer = new char[sizeToScan];
     int charsRead = reader.ReadBlock(buffer, 0, buffer.Length);
     string str = new string(buffer, 0, charsRead);
     Match m = Regex.Match(str, ".*?ActivityID=\"{(.*?)}.*", RegexOptions.IgnoreCase);
     if (m != null && m.Success)
     {
         string guid = m.Groups[1].Value;
         Guid parsedGuid;
         if (Guid.TryParse(guid, out parsedGuid))
             evt.ActivityID = parsedGuid;
     }
 }
Esempio n. 3
0
 private void ReadTimeAndSource(StreamReader reader, TraceEvent evt, long fromPosition, long sizeToScan)
 {
     reader.BaseStream.Seek(fromPosition, SeekOrigin.Begin);
     reader.DiscardBufferedData();
     char[] buffer = new char[sizeToScan];
     int charsRead = reader.ReadBlock(buffer, 0, buffer.Length);
     string str = new string(buffer, 0, charsRead);
     Match m = Regex.Match(str, @"Time=""(.*?)"".*?Source=""(.*?)""", RegexOptions.IgnoreCase);
     if (m != null && m.Success)
     {
         string dt = m.Groups[1].Value;
         DateTime parsedDt;
         if (DateTime.TryParse(dt, out parsedDt))
             evt.TimeCreated = parsedDt;
         evt.Source = m.Groups[2].Value;
         evt.Source = evt.Source.Replace("SendRequest", "").Replace("ReceiveReply", "").Replace("Send", "").Replace("Receive", "");
     }
 }