Ejemplo n.º 1
0
        private void ProcessEvent(TraceEvent e)
        {
            int sizeIndex = e.PayloadIndex("size");

            if (sizeIndex >= 0)
            {
                try
                {
                    int pidIndex = e.PayloadIndex("PID");
                    int pid      = (int)e.PayloadValue(pidIndex);
                    int bytes    = (int)e.PayloadValue(sizeIndex);
                    lock (sessionData)
                    {
                        if (sessionData.TryGetValue(pid, out DownloadSession info))
                        {
                            info.AddTotal(bytes);
                        }
                        else
                        {
                            sessionData[pid] = new DownloadSession(pid, (int)e.PayloadValue(sizeIndex));
                        }
                    }
                }
                catch { }
            }
        }
Ejemplo n.º 2
0
            public string GetAllPayloads(TraceEvent data)
            {
                string msg = "";

                foreach (string name in data.PayloadNames)
                {
                    msg += String.Format("{0}[{1}]='{2}' ", name, data.PayloadIndex(name), data.PayloadStringByName(name));
                }
                return(msg);
            }
Ejemplo n.º 3
0
        private static object GetValue(this TraceEvent data, string payLoadName)
        {
            var index = data.PayloadIndex(payLoadName);

            if (index < 0)
            {
                return(string.Format("Value with name '{0}' not found.", payLoadName));
            }

            return(data.PayloadValue(index));
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="traceEvent"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static object GetPayloadValue(TraceEvent traceEvent, string name)
        {
            int index = traceEvent.PayloadIndex(name);

            if (index < 0)
            {
                return(null);
            }

            return(traceEvent.PayloadValue(index));
        }
Ejemplo n.º 5
0
        private IDictionary <string, string> GetPayload(TraceEvent data)
        {
            var payload = new Dictionary <string, string>();

            foreach (var name in data.PayloadNames)
            {
                var index = data.PayloadIndex(name);
                payload.Add(name, data.PayloadString(index));
            }

            return(payload);
        }
Ejemplo n.º 6
0
        private static object GetItem(TraceEvent eventData, string item)
        {
            object value  = null;
            int    pIndex = eventData.PayloadIndex(item);

            if (pIndex < 0)
            {
                return(value);
            }

            try
            {
                value = eventData.PayloadValue(pIndex);
            }
            catch (ArgumentOutOfRangeException) {}

            return(value);
        }
Ejemplo n.º 7
0
        private void LogMessage(TraceEvent data)
        {
            const int Message       = 0;
            const int Context       = Message + 1;
            const int Member        = Context + 1;
            const int HttpRequest   = Member + 1;
            const int HttpResponse  = HttpRequest + 1;
            const int HttpClient    = HttpResponse + 1;
            const int Socket        = HttpClient + 1;
            const int SecureChannel = Socket + 1;

            var buffer  = new StringBuilder();
            var indexes = new int[SecureChannel + 1];

            indexes[Message]       = data.PayloadIndex("message");
            indexes[Context]       = data.PayloadIndex("thisOrContextObject");
            indexes[Member]        = data.PayloadIndex("memberName");
            indexes[HttpRequest]   = data.PayloadIndex("httpRequestHash");
            indexes[HttpResponse]  = data.PayloadIndex("httpResponseHash");
            indexes[HttpClient]    = data.PayloadIndex("httpClientHash");
            indexes[Socket]        = data.PayloadIndex("socketHash");
            indexes[SecureChannel] = data.PayloadIndex("secureChannelHash");

            if (indexes[Context] >= 0)
            {
                buffer.AppendFormat("[{0}", data.PayloadString(indexes[Context]));
                if (indexes[Member] >= 0)
                {
                    buffer.AppendFormat("::{0}", data.PayloadString(indexes[Member]));
                }
                buffer.Append("] ");
            }
            else
            {
                if (indexes[HttpRequest] >= 0)
                {
                    buffer.AppendFormat("[HttpRequest#{0}] ", data.PayloadValue(indexes[HttpRequest]));
                }
                if (indexes[HttpResponse] >= 0)
                {
                    buffer.AppendFormat("[HttpResponse#{0}] ", data.PayloadValue(indexes[HttpResponse]));
                }
                if (indexes[HttpClient] >= 0)
                {
                    buffer.AppendFormat("[HttpClient#{0}] ", data.PayloadValue(indexes[HttpClient]));
                }
                if (indexes[Socket] >= 0)
                {
                    buffer.AppendFormat("[Socket#{0}] ", data.PayloadValue(indexes[Socket]));
                }
                if (indexes[SecureChannel] >= 0)
                {
                    buffer.AppendFormat("[SecureChannel#{0}] ", data.PayloadValue(indexes[SecureChannel]));
                }
            }
            if (indexes[Message] >= 0)
            {
                buffer.AppendFormat("{0} ", data.PayloadString(indexes[Message]));
            }

            var braceOpened = false;

            for (var i = 0; i < data.PayloadNames.Length; i++)
            {
                if (Array.IndexOf(indexes, i) >= 0)
                {
                    continue; // skip
                }
                if (!braceOpened)
                {
                    buffer.Append("{");
                    braceOpened = true;
                }
                buffer.AppendFormat(" {0}:{1}", data.PayloadNames[i], data.PayloadValue(i));
            }
            if (braceOpened)
            {
                buffer.Append(" }");
            }

            traceOutput.Write(data.TimeStampRelativeMSec, data.ProcessID, data.ThreadID,
                              data.EventName, buffer.ToString());
        }