/// <summary> /// 根据HttpContext创建并填充PerformanceInfo对象 /// </summary> /// <param name="context"></param> /// <param name="message"></param> /// <param name="executeTime"></param> /// <returns></returns> public static PerformanceInfo CreateByHttp(HttpContext context, string message, TimeSpan executeTime) { PerformanceInfo info = new PerformanceInfo(); info.FillBaseInfo(); info.HttpInfo = HttpInfo.Create(context); info.PerformanceType = "HTTP"; info.ExecuteTime = executeTime; info.Message = message; return(info); }
/// <summary> /// 根据DbCommand创建并填充PerformanceInfo对象 /// </summary> /// <param name="command"></param> /// <param name="message"></param> /// <param name="executeTime"></param> /// <returns></returns> public static PerformanceInfo CreateBySql(DbCommand command, string message, TimeSpan executeTime) { PerformanceInfo info = new PerformanceInfo(); info.FillBaseInfo(); info.SqlInfo = SqlInfo.Create(command); // 尽量尝试记录本次HTTP请求相关信息 info.HttpInfo = HttpInfo.Create(HttpContext.Current); info.PerformanceType = "SQL"; info.ExecuteTime = executeTime; info.Message = message; return(info); }