/// <summary> /// 获取请求信息 /// </summary> /// <param name="filterOption"></param> /// <returns></returns> public async Task <RequestInfoSearchResult> SearchRequestInfoAsync(RequestInfoSearchFilterOption filterOption) { var whereBuilder = new StringBuilder(BuildSqlFilter(filterOption), 512); var sqlBuilder = new StringBuilder($"Select * From [{Prefix}RequestInfo] ", 512); if (whereBuilder.Length == 0) { whereBuilder.Append("Where 1=1 "); } if (!filterOption.IP.IsEmpty()) { whereBuilder.Append($" AND IP = '{filterOption.IP}' "); } if (!filterOption.Url.IsEmpty()) { whereBuilder.Append($" AND Url like '%{filterOption.Url}%' "); } if (!filterOption.TraceId.IsEmpty()) { whereBuilder.Append($" AND ID = '{filterOption.TraceId}' "); } if (filterOption.StatusCodes != null) { if (filterOption.StatusCodes.Length == 1) { whereBuilder.Append($" AND StatusCode = {filterOption.StatusCodes[0]} "); } else { whereBuilder.Append($" AND StatusCode in ({string.Join(",", filterOption.StatusCodes)}) "); } } // Query Detail IEnumerable <string> RequestIdCollection = await QueryDetailAsync(filterOption); if (RequestIdCollection != null && RequestIdCollection.Any()) { whereBuilder.Append($" AND Id IN ({string.Join(",", RequestIdCollection.Select(x => "'" + x + "'"))}) "); } var where = whereBuilder.ToString(); sqlBuilder.Append(where); var sql = sqlBuilder.ToString(); TraceLogSql(sql); var countSql = $"Select count(1) From [{Prefix}RequestInfo] " + where; TraceLogSql(countSql); var result = new RequestInfoSearchResult() { SearchOption = filterOption, }; await LoggingSqlOperation(async connection => { result.AllItemCount = connection.QueryFirstOrDefault <int>(countSql); result.List.AddRange((await connection.GetListBySqlAsync <RequestInfo>(sql, "CreateTime desc", filterOption.PageSize, filterOption.Page, result.AllItemCount)).ToArray()); }, "查询请求信息列表异常"); return(result); }
/// <summary> /// 获取请求信息 /// </summary> /// <param name="filterOption"></param> /// <returns></returns> public async Task <RequestInfoSearchResult> SearchRequestInfoAsync(RequestInfoSearchFilterOption filterOption) { var whereBuilder = new StringBuilder(BuildSqlFilter(filterOption), 512); var sqlBuilder = new StringBuilder("Select * From RequestInfo ", 512); if (!filterOption.IP.IsEmpty()) { whereBuilder.Append($" AND IP = '{filterOption.IP}' "); } if (!filterOption.Url.IsEmpty()) { whereBuilder.Append($" AND Url like '%{filterOption.Url}%' "); } if (!filterOption.TraceId.IsEmpty()) { whereBuilder.Append($" AND ID = '{filterOption.TraceId}' "); } if (filterOption.StatusCodes != null) { if (filterOption.StatusCodes.Length == 1) { whereBuilder.Append($" AND StatusCode = {filterOption.StatusCodes[0]} "); } else { whereBuilder.Append($" AND StatusCode in ({string.Join(",", filterOption.StatusCodes)}) "); } } var where = whereBuilder.ToString(); sqlBuilder.Append(where); var sql = sqlBuilder.ToString(); TraceLogSql(sql); var countSql = "Select count(1) From RequestInfo " + where; TraceLogSql(countSql); var result = new RequestInfoSearchResult() { SearchOption = filterOption, }; await LoggingSqlOperation(async _ => { result.AllItemCount = await _.QueryFirstOrDefaultAsync <int>(countSql); var listSql = GetListSql(sql, "CreateTime Desc", filterOption.Page, filterOption.PageSize); result.List.AddRange((await _.QueryAsync <RequestInfo>(listSql)).ToArray()); }, "查询请求信息列表异常"); return(result); }
public Task <RequestInfoSearchResult> SearchRequestInfoAsync(RequestInfoSearchFilterOption filterOption) { throw new NotImplementedException(); }