Ejemplo n.º 1
0
        public void Load(string path, IProgressFeedback progress)
        {
            BZip2InputStream inStream = new BZip2InputStream(new FileStream(path, FileMode.Open));
            XmlTextReader    xtr      = new XmlTextReader(inStream);

            tmpPath = Path.GetTempFileName();
            FileStream tmpFileStream = new FileStream(tmpPath, FileMode.Create, FileAccess.ReadWrite);

            tmpReader = new StreamReader(tmpFileStream);
            StreamWriter tmpFileWriter = new StreamWriter(tmpFileStream, Encoding.UTF8);

            events = new SortedDictionary <uint, DumpEvent>();

            int prevPct = -1, pct;

            while (xtr.Read())
            {
                pct = (int)(((float)inStream.Position / (float)inStream.Length) * 100.0f);
                if (pct != prevPct)
                {
                    prevPct = pct;
                    progress.ProgressUpdate("Loading", pct);
                }

                if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "event")
                {
                    tmpFileWriter.Flush();
                    long startOffset = tmpFileStream.Position;

                    XmlReader   rdr = xtr.ReadSubtree();
                    XmlDocument doc = new XmlDocument();
                    doc.Load(rdr);

                    XmlAttributeCollection attrs = doc.DocumentElement.Attributes;
                    uint          id             = Convert.ToUInt32(attrs["id"].Value);
                    DumpEventType type           = (DumpEventType)Enum.Parse(typeof(DumpEventType), attrs["type"].Value);
                    DateTime      timestamp      = DateTime.FromFileTimeUtc(Convert.ToInt64(attrs["timestamp"].Value));
                    string        processName    = attrs["processName"].Value;
                    uint          processId      = Convert.ToUInt32(attrs["processId"].Value);
                    uint          threadId       = Convert.ToUInt32(attrs["threadId"].Value);

                    string eventStr = doc.DocumentElement.InnerXml;
                    tmpFileWriter.Write(eventStr);

                    events[id] = new DumpEvent(this, id, type, timestamp, processName, processId, threadId, startOffset, eventStr.Length);
                }
            }

            xtr.Close();

            tmpFileStream.Seek(0, SeekOrigin.Begin);
        }
Ejemplo n.º 2
0
        public void WriteEvent(DumpEventType type, params string[] data)
        {
            var time = DateTimeOffset.Now.ToUnixTimeSeconds();

            writer.Write((byte)type);
            writer.Write(time);
            writer.Write(data.Length);
            foreach (var text in data)
            {
                writer.Write(text);
            }

            writer.Flush();
        }
Ejemplo n.º 3
0
        public DumpEvent(DumpFile file,
            uint id, DumpEventType type, DateTime timestamp, string processName, uint processId, uint threadId,
            long dataOffset, int dataLength)
        {
            this.file = file;

            this.id = id;
            this.type = type;
            this.timestamp = timestamp;
            this.processName = processName;
            this.processId = processId;
            this.threadId = threadId;

            this.dataOffset = dataOffset;
            this.dataLength = dataLength;
        }
Ejemplo n.º 4
0
        public DumpEvent(DumpFile file,
                         uint id, DumpEventType type, DateTime timestamp, string processName, uint processId, uint threadId,
                         long dataOffset, int dataLength)
        {
            this.file = file;

            this.id          = id;
            this.type        = type;
            this.timestamp   = timestamp;
            this.processName = processName;
            this.processId   = processId;
            this.threadId    = threadId;

            this.dataOffset = dataOffset;
            this.dataLength = dataLength;
        }
Ejemplo n.º 5
0
 public DumpEvent(DumpEventType type, DateTimeOffset time, string[] data)
 {
     Type = type;
     Time = time;
     Data = data;
 }