Ejemplo n.º 1
0
 public static void SendExecuteInfo(ExecuteInfo info)
 {
     lock (s_lock)
     {
         s_executeInfoQueue.Enqueue(info);
     }
 }
Ejemplo n.º 2
0
 public void SendMessage(ExecuteInfo info)
 {
     MessageReceive onMessageReceive = OnMessageReceive;
     if (onMessageReceive != null)
     {
         onMessageReceive(info);
     }
 }
Ejemplo n.º 3
0
 private static void DbContext_OnAfterExecute(DbContext context)
 {
     if (context.Tag != null)
     {
         ContextInfo tag = context.Tag as ContextInfo;
         if (tag != null)
         {
             ExecuteInfo info = new ExecuteInfo {
                 AppName = Profiler.ApplicationName,
                 CommandText = null,
                 ConnectionString = null,
                 EndTime = new DateTime?(DateTime.Now),
                 ExceptionMessage = null,
                 InfoKey = tag.InfoKey,
                 InfoType = InfoType.ExecuteFinished,
                 IsWithTranscation = false,
                 ParameterValues = null,
                 StartTime = tag.StartTime
             };
             ClientHelper.SendExecuteInfo(info);
         }
     }
 }
Ejemplo n.º 4
0
 private static void DbContext_OnOpenConnection(DbContext context)
 {
     ExecuteInfo info = new ExecuteInfo {
         AppName = Profiler.ApplicationName,
         CommandText = null,
         ConnectionString = context.Connection.ConnectionString,
         EndTime = null,
         ExceptionMessage = null,
         InfoKey = Guid.NewGuid().ToString(),
         InfoType = InfoType.OpenConnection,
         IsWithTranscation = false,
         ParameterValues = null,
         StartTime = DateTime.Now
     };
     ClientHelper.SendExecuteInfo(info);
 }
Ejemplo n.º 5
0
 private static void DbContext_OnBeforeExecute(DbContext context)
 {
     ContextInfo info = new ContextInfo {
         InfoKey = Guid.NewGuid().ToString(),
         StartTime = DateTime.Now
     };
     context.Tag = info;
     ExecuteInfo info2 = new ExecuteInfo {
         AppName = Profiler.ApplicationName,
         CommandText = context.CurrentCommand.CommandText,
         CommandType = context.CurrentCommand.CommandType,
         ConnectionString = context.Connection.ConnectionString,
         XmlCommandName = (context.CurrentXmlCommand != null) ? context.CurrentXmlCommand.CommandName : string.Empty,
         EndTime = null,
         ExceptionMessage = null,
         InfoKey = info.InfoKey,
         InfoType = (context.CurrentCommand.CommandType == CommandType.StoredProcedure) ? InfoType.StartExecuteSP : InfoType.StartExecuteSQL,
         IsWithTranscation = context.CurrentCommand.Transaction != null,
         ParameterValues = GetParameterList(context.CurrentCommand),
         StartTime = info.StartTime
     };
     ClientHelper.SendExecuteInfo(info2);
 }
Ejemplo n.º 6
0
 private string method_8(ExecuteInfo executeInfo_0)
 {
     StringBuilder stringBuilder = new StringBuilder();
     stringBuilder.Append("ConnectionString: ").AppendLine(executeInfo_0.ConnectionString);
     stringBuilder.Append("StartTime: ").AppendLine(executeInfo_0.StartTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
     if (executeInfo_0.EndTime.HasValue)
     {
         TimeSpan timeSpan = executeInfo_0.EndTime.Value - executeInfo_0.StartTime;
         string value = string.Format("{0} ({1}.{2})", executeInfo_0.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss.fff"), timeSpan.Seconds, timeSpan.Milliseconds);
         stringBuilder.Append("EndTime:   ").AppendLine(value);
     }
     if (!string.IsNullOrEmpty(executeInfo_0.ExceptionMessage))
     {
         stringBuilder.Append("ExceptionMessage: ").AppendLine(executeInfo_0.ExceptionMessage);
     }
     if (executeInfo_0.ParameterValues != null && executeInfo_0.ParameterValues.Count > 0)
     {
         stringBuilder.AppendLine("Parameters:");
         foreach (ParamValuePair current in executeInfo_0.ParameterValues)
         {
             stringBuilder.AppendFormat("   {0} = ({1}) {2}\r\n", current.Name, current.Description, current.Value);
         }
     }
     if (!string.IsNullOrEmpty(executeInfo_0.CommandText))
     {
         stringBuilder.AppendLine();
         if (executeInfo_0.IsWithTranscation)
         {
             stringBuilder.Append("[Transcation] ");
         }
         if (!string.IsNullOrEmpty(executeInfo_0.XmlCommandName))
         {
             stringBuilder.Append("[XmlCommand] ");
         }
         else
         {
             if (executeInfo_0.CommandType == CommandType.StoredProcedure)
             {
                 stringBuilder.Append("[StoredProcedure] ");
             }
         }
         stringBuilder.AppendLine("CommandText: ");
         stringBuilder.AppendLine("---------------------------------------------------------------------------------");
         stringBuilder.Append(executeInfo_0.CommandText.Replace("\n", "\r\n"));
     }
     return stringBuilder.ToString();
 }
Ejemplo n.º 7
0
 private void method_6(ExecuteInfo executeInfo_0)
 {
     for (int i = this.listView1.Items.Count - 1; i >= 0; i--)
     {
         ListViewItem listViewItem = this.listView1.Items[i];
         ExecuteInfo executeInfo = listViewItem.Tag as ExecuteInfo;
         if (executeInfo.InfoKey == executeInfo_0.InfoKey)
         {
             if (executeInfo_0.InfoType == InfoType.ExecuteFailed)
             {
                 listViewItem.ImageIndex = 2;
                 listViewItem.SubItems[4].Text = "执行失败";
                 listViewItem.ForeColor = Color.Red;
                 executeInfo.ExceptionMessage = executeInfo_0.ExceptionMessage;
             }
             else
             {
                 TimeSpan timeSpan = executeInfo_0.EndTime.Value - executeInfo.StartTime;
                 string text = string.Format("{0} ({1}.{2})", executeInfo_0.EndTime.Value.ToString("HH:mm:ss.fff"), timeSpan.Seconds, timeSpan.Milliseconds);
                 listViewItem.SubItems[4].Text = text;
                 executeInfo.EndTime = new DateTime?(executeInfo_0.EndTime.Value);
             }
             if (this.int_6 == listViewItem.Index)
             {
                 this.listView1_SelectedIndexChanged(null, null);
             }
             return;
         }
     }
 }
Ejemplo n.º 8
0
 private void method_5(ExecuteInfo executeInfo_0)
 {
     ListViewItem listViewItem = new ListViewItem();
     ListViewItem arg_20_0 = listViewItem;
     int num = ++this.int_5;
     arg_20_0.Text = num.ToString();
     listViewItem.ImageIndex = ((executeInfo_0.InfoType == InfoType.StartExecuteSP) ? 0 : 1);
     if (!string.IsNullOrEmpty(executeInfo_0.XmlCommandName))
     {
         listViewItem.SubItems.Add(executeInfo_0.XmlCommandName);
         listViewItem.ImageIndex = 4;
     }
     else
     {
         listViewItem.SubItems.Add(executeInfo_0.CommandText);
     }
     listViewItem.SubItems.Add(executeInfo_0.GetParameterValuesShowText());
     listViewItem.SubItems.Add(executeInfo_0.StartTime.ToString("HH:mm:ss.fff"));
     listViewItem.SubItems.Add(string.Empty);
     listViewItem.SubItems.Add(executeInfo_0.AppName);
     listViewItem.Tag = executeInfo_0;
     if (executeInfo_0.IsWithTranscation)
     {
         listViewItem.ForeColor = Color.Blue;
     }
     if (this.bool_0)
     {
         if (!string.IsNullOrEmpty(executeInfo_0.ExceptionMessage))
         {
             listViewItem.ImageIndex = 2;
             listViewItem.SubItems[4].Text = "执行失败";
             listViewItem.ForeColor = Color.Red;
         }
         else
         {
             TimeSpan timeSpan = executeInfo_0.EndTime.Value - executeInfo_0.StartTime;
             string text = string.Format("{0} ({1}.{2})", executeInfo_0.EndTime.Value.ToString("HH:mm:ss.fff"), timeSpan.Seconds, timeSpan.Milliseconds);
             listViewItem.SubItems[4].Text = text;
         }
     }
     this.listView1.Items.Add(listViewItem);
     this.listView1.SelectedIndices.Clear();
     listViewItem.Selected = true;
     listViewItem.EnsureVisible();
 }
Ejemplo n.º 9
0
 private void method_4(ExecuteInfo executeInfo_0)
 {
     ListViewItem listViewItem = new ListViewItem();
     ListViewItem arg_20_0 = listViewItem;
     int num = ++this.int_5;
     arg_20_0.Text = num.ToString();
     listViewItem.ImageIndex = 3;
     listViewItem.SubItems.Add("<Open connection>");
     listViewItem.SubItems.Add(string.Empty);
     listViewItem.SubItems.Add(executeInfo_0.StartTime.ToString("HH:mm:ss.fff"));
     listViewItem.SubItems.Add(string.Empty);
     listViewItem.SubItems.Add(executeInfo_0.AppName);
     listViewItem.Tag = executeInfo_0;
     listViewItem.ForeColor = Color.Gainsboro;
     this.listView1.Items.Add(listViewItem);
     this.listView1.SelectedIndices.Clear();
     listViewItem.Selected = true;
     listViewItem.EnsureVisible();
 }
Ejemplo n.º 10
0
 private void method_3(ExecuteInfo executeInfo_0)
 {
     if (executeInfo_0.CommandType == (CommandType)0)
     {
         executeInfo_0.CommandType = CommandType.Text;
     }
     switch (executeInfo_0.InfoType)
     {
         case InfoType.OpenConnection:
             this.method_4(executeInfo_0);
             break;
         case InfoType.StartExecuteSP:
         case InfoType.StartExecuteSQL:
             this.method_5(executeInfo_0);
             break;
         case InfoType.ExecuteFinished:
         case InfoType.ExecuteFailed:
             this.method_6(executeInfo_0);
             break;
     }
 }
Ejemplo n.º 11
0
 private void method_2(ExecuteInfo executeInfo_0)
 {
     SQLProfilerFormFix.Class0 @class = new SQLProfilerFormFix.Class0();
     @class.executeInfo_0 = executeInfo_0;
     @class.sqlprofilerForm_0 = this;
     if (this.bool_1)
     {
         this.synchronizationContext_0.Send(new SendOrPostCallback(@class.method_0), @class.executeInfo_0);
     }
 }