/// <summary> /// 创建运行SQL信息 /// </summary> /// <param name="sqlQuery"></param> /// <param name="timeElapsed">消耗时间</param> /// <param name="isSuccess">是否成功</param> /// <param name="dbType">数据库类型</param> /// <param name="dataBaseName">数据库名字</param> /// <returns></returns> private static RuntimeSqlModel Create(SqlQuery sqlQuery, double timeElapsed, bool isSuccess, string dbType = null, string dataBaseName = null) { var runtimeSqlModel = new RuntimeSqlModel { FExecutedTime = DateTimeUtil.Now, FIsSuccess = isSuccess, FProjectName = ConfigurationManage.GetValue($"MQMonitor:ProjectInfo:ProjectName"), FRequestGuid = AsyncLocalUtil.CurrentGID, FServerMac = ComputerUtil.MacAddress, FSource = ConfigurationManage.GetValue <int>($"MQMonitor:ProjectInfo:FSource"), FSqlDbType = dbType, FSqlText = sqlQuery.CommandText, FTimeElapsed = timeElapsed, FMemberName = WebHttpContext.AbsoluteUrl, FDatabaseName = dataBaseName }; if (sqlQuery.ParameterList != null && sqlQuery.ParameterList.Any()) { runtimeSqlModel.ParameterList = new List <SqlParameterModel>(); foreach (var item in sqlQuery.ParameterList) { runtimeSqlModel.ParameterList.Add(new SqlParameterModel { FName = item.ParameterName, FSize = item.Size, FValue = item.Value?.ToString() }); } } return(runtimeSqlModel); }
/// <summary> /// 处理发送的方法 /// </summary> /// <param name="message"></param> private static void MessageHandle(RuntimeSqlModel message) { if (_MessageList.Count > 50) { SendMessage(_MessageList); } _MessageList.Add(message); }
/// <summary> /// 创建运行SQL信息 /// </summary> /// <param name="MemberName">调用方法名字</param> /// <param name="timeElapsed">消耗时间</param> /// <param name="isSuccess">是否成功</param> /// <param name="dbType">数据库类型</param> /// <param name="dataBaseName">数据库名字</param> /// <returns></returns> private static RuntimeSqlModel Create(string MemberName, double timeElapsed, bool isSuccess, string dbType = null, string dataBaseName = null) { var runtimeSqlModel = new RuntimeSqlModel { FExecutedTime = DateTimeUtil.Now, FIsSuccess = isSuccess, FProjectName = ConfigurationManage.GetValue($"MQMonitor:ProjectInfo:ProjectName"), FRequestGuid = AsyncLocalUtil.CurrentGID, FServerMac = ComputerUtil.MacAddress, FSource = ConfigurationManage.GetValue <int>($"MQMonitor:ProjectInfo:FSource"), FSqlDbType = dbType, FSqlText = MemberName, FTimeElapsed = timeElapsed, FMemberName = WebHttpContext.AbsoluteUrl, FDatabaseName = dataBaseName }; return(runtimeSqlModel); }
/// <summary> /// 添加sql运行信息 /// </summary> /// <param name="runtimeSqlModel"></param> public static void AddMessage(RuntimeSqlModel runtimeSqlModel) { _MessageQueue.EnqueueMessage(runtimeSqlModel); }