Beispiel #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);
        }
Beispiel #2
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);
        }