/// <summary> /// 结束日志 /// </summary> /// <param name="apiLogEntity"></param> /// <param name="request"></param> /// <param name="responseModel"></param> private void _EndLog(ApiLogEntity apiLogEntity, RequestModelType request, ResponseModelType responseModel) { try { apiLogEntity.ElapsedMilliseconds = Stopwatch.ElapsedMilliseconds; apiLogEntity.RespContent = content; if (responseModel == null) { apiLogEntity.AddLogMessage("responseModel为空,EndLog将不被调用"); } else { EndLog(apiLogEntity, request, responseModel); } if (!string.IsNullOrWhiteSpace(postData)) { apiLogEntity.Params = postData; } } catch (Exception) { apiLogEntity.AddLogMessage("调用EndLog时出现异常"); } SaveLog(apiLogEntity); }
/// <summary> /// 结束日志 /// </summary> /// <param name="apiLogEntity"></param> /// <param name="request"></param> /// <param name="responseModel"></param> private void _EndLog(ApiLogEntity apiLogEntity, RequestModelType request, ResponseModelType responseModel) { try { apiLogEntity.ElapsedMilliseconds = Stopwatch.ElapsedMilliseconds; apiLogEntity.RequestURL = HttpRequest.RawUrl; apiLogEntity.HttpMethod = HttpRequest.HttpMethod; EndLog(apiLogEntity, request, responseModel); } catch { } if (responseModel == null) { apiLogEntity.AddLogMessage("responseModel为空,EndLog将不被调用"); } apiLogEntity.RespContent = content ?? string.Empty; apiLogEntity.Params = postData ?? string.Empty; apiLogEntity.ElapsedMilliseconds = Stopwatch.ElapsedMilliseconds; apiLogEntity.ClientIPList = ClientIPList; apiLogEntity.TextBoxFilterItem1 = apiLogEntity.TextBoxFilterItem1 ?? ""; apiLogEntity.TextBoxFilterItem2 = apiLogEntity.TextBoxFilterItem2 ?? string.Empty; apiLogEntity.Message += $"{this.apiMethodMetaInfo.Fap}({this.apiMethodMetaInfo.APIMethodDesc.Desc})"; apiLogEntity.ModuleName = this.ApiMethodMetaInfo.Module; apiLogEntity.CategoryName = this.ApiMethodMetaInfo.Category; apiLogEntity.SubcategoryName = this.ApiMethodMetaInfo.MethodName; apiLogEntity.LogFinish(); SaveLog(apiLogEntity); }
/// <summary> /// 结束日志 /// </summary> /// <param name="apiLogEntity"></param> /// <param name="request"></param> /// <param name="responseModel"></param> private void _EndLog(ApiLogEntity apiLogEntity, RequestModelType request, ResponseModelType responseModel) { apiLogEntity.ElapsedMilliseconds = Stopwatch.ElapsedMilliseconds; try { if (responseModel == null) { apiLogEntity.AddLogMessage("responseModel为空,EndLog将不被调用"); } else { EndLog(apiLogEntity, request, responseModel); } } catch (Exception) { apiLogEntity.AddLogMessage("调用EndLog时出现异常"); } }