private void OnMessageReceived(object sender, XDMessageEventArgs e)
        {
            try
            {
                esTracePacket entry = new esTracePacket();

                string[] fields = e.DataGram.Message.Split('±');

                if (fields[0].Length > 0)
                {
                    entry.TransactionId = Convert.ToInt32(fields[0]);
                }

                if (fields[1].Length > 0)
                {
                    entry.ObjectType = fields[1];
                }

                entry.CallStack       = fields[2];
                entry.ApplicationName = fields[3];
                entry.TraceChannel    = fields[4];
                entry.ThreadId        = Convert.ToInt32(fields[5]);
                entry.Sql             = fields[6];
                entry.Duration        = Convert.ToInt64(fields[7]);
                entry.Ticks           = Convert.ToInt64(fields[8]);
                entry.PacketOrder     = Convert.ToInt64(fields[9]);
                entry.Action          = fields[10];
                entry.Syntax          = fields[11];
                entry.Exception       = fields[12];

                if (fields[13].Length > 0)
                {
                    // Parse Parameters
                    string[] parameters = fields[13].Split('«');

                    esParameter param = null;
                    for (int i = 0; i < parameters.Length; i += 5)
                    {
                        if (param == null)
                        {
                            param = new esParameter();
                        }

                        param.Name      = parameters[i];
                        param.Direction = parameters[i + 1];
                        param.ParamType = parameters[i + 2];

                        if (parameters[i + 3] != "null")
                        {
                            param.BeforeValue = parameters[i + 3];
                        }

                        if (parameters[i + 4] != "null")
                        {
                            param.AfterValue = parameters[i + 4];
                        }

                        entry.SqlParameters.Add(param);
                        param = null;
                    }
                }

                switch (entry.TraceChannel)
                {
                case Channels.Channel_1: AddEntryToList(channel_1, entry); break;

                case Channels.Channel_2: AddEntryToList(channel_2, entry); break;

                case Channels.Channel_3: AddEntryToList(channel_3, entry); break;

                case Channels.Channel_4: AddEntryToList(channel_4, entry); break;

                case Channels.Channel_5: AddEntryToList(channel_5, entry); break;

                case Channels.Channel_6: AddEntryToList(channel_6, entry); break;

                case Channels.Channel_7: AddEntryToList(channel_7, entry); break;

                case Channels.Channel_8: AddEntryToList(channel_8, entry); break;

                case Channels.Channel_9: AddEntryToList(channel_9, entry); break;

                case Channels.Channel_10: AddEntryToList(channel_10, entry); break;
                }
            }
            catch { }
        }
Beispiel #2
0
        private void OnMessageReceived(object sender, XDMessageEventArgs e)
        {
#if PROFILER_TRIAL
            if (++mod % 1000 == 0)
            {
                Licensing license = new Licensing();
                string    id      = license.getUniqueID("C");

                int result = licensing.ValidateLicense("trial", "b69e3783-9f56-47a7-82e0-6eee6d0779bf", System.Environment.MachineName, id, version, proxySettings);

                if (1 != result)
                {
                    result = licensing.RegisterLicense("trial", "b69e3783-9f56-47a7-82e0-6eee6d0779bf", System.Environment.MachineName, id, version, proxySettings);
                }

                if (result != 1)
                {
                    listener.UnRegisterChannel(Channels.Channel_1);
                    listener.UnRegisterChannel(Channels.Channel_2);
                    listener.UnRegisterChannel(Channels.Channel_3);
                    listener.UnRegisterChannel(Channels.Channel_4);
                    listener.UnRegisterChannel(Channels.Channel_5);
                    listener.UnRegisterChannel(Channels.Channel_6);
                    listener.UnRegisterChannel(Channels.Channel_7);
                    listener.UnRegisterChannel(Channels.Channel_8);
                    listener.UnRegisterChannel(Channels.Channel_9);
                    listener.UnRegisterChannel(Channels.Channel_10);
                    return;
                }
            }
#endif

            try
            {
                esTracePacket entry = new esTracePacket();

                string[] fields = e.DataGram.Message.Split('±');

                if (fields[0].Length > 0)
                {
                    entry.TransactionId = Convert.ToInt32(fields[0]);
                }

                if (fields[1].Length > 0)
                {
                    entry.ObjectType = fields[1];
                }

                entry.CallStack       = fields[2];
                entry.ApplicationName = fields[3];
                entry.TraceChannel    = fields[4];
                entry.ThreadId        = Convert.ToInt32(fields[5]);
                entry.Sql             = fields[6];
                entry.Duration        = Convert.ToInt64(fields[7]);
                entry.Ticks           = Convert.ToInt64(fields[8]);
                entry.PacketOrder     = Convert.ToInt64(fields[9]);
                entry.Action          = fields[10];
                entry.Syntax          = fields[11];
                entry.Exception       = fields[12];

                if (fields[13].Length > 0)
                {
                    // Parse Parameters
                    string[] parameters = fields[13].Split('«');

                    esParameter param = null;
                    for (int i = 0; i < parameters.Length; i += 5)
                    {
                        if (param == null)
                        {
                            param = new esParameter();
                        }

                        param.Name      = parameters[i];
                        param.Direction = parameters[i + 1];
                        param.ParamType = parameters[i + 2];

                        if (parameters[i + 3] != "null")
                        {
                            param.BeforeValue = parameters[i + 3];
                        }

                        if (parameters[i + 4] != "null")
                        {
                            param.AfterValue = parameters[i + 4];
                        }

                        entry.SqlParameters.Add(param);
                        param = null;
                    }
                }

                switch (entry.TraceChannel)
                {
                case Channels.Channel_1: AddEntryToList(channel_1, entry); break;

                case Channels.Channel_2: AddEntryToList(channel_2, entry); break;

                case Channels.Channel_3: AddEntryToList(channel_3, entry); break;

                case Channels.Channel_4: AddEntryToList(channel_4, entry); break;

                case Channels.Channel_5: AddEntryToList(channel_5, entry); break;

                case Channels.Channel_6: AddEntryToList(channel_6, entry); break;

                case Channels.Channel_7: AddEntryToList(channel_7, entry); break;

                case Channels.Channel_8: AddEntryToList(channel_8, entry); break;

                case Channels.Channel_9: AddEntryToList(channel_9, entry); break;

                case Channels.Channel_10: AddEntryToList(channel_10, entry); break;
                }
            }
            catch { }
        }