private void ProcessRequest() { LogRecorder.BeginStepMonitor("LoadAuthority"); var canDo = LoadAuthority(); LogRecorder.MonitorTrace(canDo.ToString()); LogRecorder.EndStepMonitor(); if (!canDo) { ModelContext.LastMessage = "非法访问"; return; } LogRecorder.BeginStepMonitor("Prepare"); OnPrepare(); LogRecorder.EndStepMonitor(); LogRecorder.BeginStepMonitor("CheckCanDo"); canDo = IsPublicPage || CheckCanDo(); LogRecorder.MonitorTrace(canDo.ToString()); LogRecorder.EndStepMonitor(); if (!canDo) { return; } LogRecorder.BeginStepMonitor("OnPageLoaded"); OnPageLoaded(); LogRecorder.EndStepMonitor(); }
/// <summary> /// 远程调用 /// </summary> /// <returns></returns> private string CallHttp() { // 当前请求调用的模型对应的主机名称 string httpHost; // 当前请求调用的Api名称 var httpApi = Data.RouteHost == HostConfig.DefaultHost ? Data.Uri.PathAndQuery : $"{Data.ApiName}{Data.Uri.Query}"; // 查找主机 if (Data.RouteHost.Hosts.Length == 1) { httpHost = Data.RouteHost.Hosts[0]; } else { lock (Data.RouteHost) { //平均分配 httpHost = Data.RouteHost.Hosts[Data.RouteHost.Next]; if (++Data.RouteHost.Next >= Data.RouteHost.Hosts.Length) { Data.RouteHost.Next = 0; } } } // 远程调用 var caller = new HttpApiCaller(httpHost) { Bearer = $"Bearer {ApiContext.RequestContext.Bear}" }; var req = caller.CreateRequest(httpApi, Data.HttpMethod, Request, Data); LogRecorder.BeginStepMonitor("内部HTTP调用"); LogRecorder.MonitorTrace($"Url:{req.RequestUri.PathAndQuery}"); LogRecorder.MonitorTrace($"Auth:{caller.Bearer}"); try { // 远程调用状态 Data.ResultMessage = caller.GetResult(req, out var webStatus); LogRecorder.MonitorTrace(webStatus.ToString()); if (webStatus != WebExceptionStatus.Success) { Data.Status = RouteStatus.RemoteError; } } catch (Exception ex) { LogRecorder.Exception(ex); LogRecorder.MonitorTrace($"发生异常:{ex.Message}"); Data.ResultMessage = RouteRuntime.NetworkError; Data.Status = RouteStatus.RemoteError; } finally { LogRecorder.MonitorTrace(Data.ResultMessage); LogRecorder.EndStepMonitor(); } return(Data.ResultMessage); }
/// <summary> /// 通过Post调用 /// </summary> /// <param name="apiName"></param> /// <param name="form"></param> /// <returns></returns> public ApiValueResult <string> Post(string apiName, string form) { LogRecorder.BeginStepMonitor("内部API调用" + ToUrl(apiName)); var ctx = string.IsNullOrEmpty(Bearer) ? null : $"Bearer {Bearer}"; LogRecorder.MonitorTrace(ctx); LogRecorder.MonitorTrace("Arguments:" + form); var req = (HttpWebRequest)WebRequest.Create(ToUrl(apiName)); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.Headers.Add(HttpRequestHeader.Authorization, ctx); try { using (var rs = req.GetRequestStream()) { var formData = Encoding.UTF8.GetBytes(form); rs.Write(formData, 0, formData.Length); } } catch (Exception e) { LogRecorder.Exception(e); LogRecorder.EndStepMonitor(); return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError)); } return(GetResult(req)); }
/// <summary> /// 页面操作处理入口 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { CurrentPageName = GetFriendPageUrl(); LogRecorder.BeginMonitor(CurrentPageName); LogRecorder.MonitorTrace(Request.Url.AbsolutePath); LogRequestInfo(); try { ProcessRequest(); } catch (Exception exception) { LogRecorder.EndStepMonitor(); LogRecorder.BeginStepMonitor("Exception"); LogRecorder.MonitorTrace(exception.Message); LogRecorder.Exception(exception); Debug.WriteLine(exception); OnFailed(exception); LogRecorder.EndStepMonitor(); } LogRecorder.BeginStepMonitor("Result"); OnResult(); LogRecorder.EndStepMonitor(); LogRecorder.EndMonitor(); }
/// <summary> /// 通过Post调用 /// </summary> /// <param name="apiName"></param> /// <param name="form"></param> /// <returns></returns> public ApiValueResult Post(string apiName, string form) { LogRecorder.BeginStepMonitor("内部API调用" + ToUrl(apiName)); string ctx = string.IsNullOrEmpty(Bearer) ? null : $"Bearer {Bearer}"; LogRecorder.MonitorTrace(ctx); LogRecorder.MonitorTrace("Arguments:" + form); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(ToUrl(apiName)); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.Headers.Add(HttpRequestHeader.Authorization, ctx); try { using (Stream rs = req.GetRequestStream()) { byte[] formData = Encoding.UTF8.GetBytes(form); rs.Write(formData, 0, formData.Length); } } catch (Exception ex) { LogRecorder.Exception(ex); LogRecorder.EndStepMonitor(); return(ErrorResult(-3)); } using (MonitorScope.CreateScope("Caller Remote")) { return(GetResult(req)); } }
/// <summary> /// 开始日志监测 /// </summary> /// <param name="data"></param> private static void BeginMonitor(RouteData data) { if (!LogRecorder.LogMonitor) { return; } try { LogRecorder.BeginMonitor(data.Uri.ToString()); LogRecorder.BeginStepMonitor("HTTP"); var args = new StringBuilder(); args.Append("Headers:"); args.Append(JsonConvert.SerializeObject(data.Headers)); LogRecorder.MonitorTrace(args.ToString()); LogRecorder.MonitorTrace($"Method:{data.HttpMethod}"); } catch (Exception e) { LogRecorder.MonitorTrace(e.Message); LogRecorder.Exception(e); } finally { LogRecorder.EndStepMonitor(); } }
/// <summary> /// 远程调用 /// </summary> /// <returns></returns> private string CallZero() { var values = new Dictionary <string, string>(); //参数解析 foreach (var query in Request.Query.Keys) { if (!values.ContainsKey(query)) { values.Add(query, Request.Query[query]); } } if (Data.HttpMethod == "POST") { if (Request.ContentLength > 0) { foreach (var form in Request.Form.Keys) { if (!values.ContainsKey(form)) { values.Add(form, Request.Form[form]); } } } } LogRecorder.BeginStepMonitor("内部Zero调用"); LogRecorder.MonitorTrace($"Station:{Data.HostName}"); LogRecorder.MonitorTrace($"Command:{Data.ApiName}"); // 远程调用状态 try { Data.ResultMessage = StationProgram.Call(Data.HostName, Data.ApiName, JsonConvert.SerializeObject(values)); } catch (Exception ex) { LogRecorder.Exception(ex); LogRecorder.MonitorTrace($"发生异常:{ex.Message}"); Data.ResultMessage = RouteRuntime.NetworkError; Data.Status = RouteStatus.RemoteError; } finally { LogRecorder.MonitorTrace(Data.ResultMessage); LogRecorder.EndStepMonitor(); } return(Data.ResultMessage); }
/// <summary> /// 缓存类型对应的权限用户 /// </summary> public void CacheTypeUser() { LogRecorder.BeginStepMonitor("CacheEditUser"); using (SystemContextScope.CreateScope()) { _allPowers = _rpAccess.All(); using (var proxy = new RedisProxy(RedisProxy.DbAuthority)) { CacheUser(proxy, "edit", edits); CacheUser(proxy, "audit", audits); } } LogRecorder.EndStepMonitor(); }
/// <summary> /// 通过Post调用 /// </summary> /// <typeparam name="TResult"></typeparam> /// <param name="apiName"></param> /// <param name="form"></param> /// <returns></returns> public ApiResult <TResult> Post <TResult>(string apiName, string form) where TResult : IApiResultData { var req = CreateRequest(apiName, "POST", form); LogRecorder.MonitorTrace("Form:" + form); try { } catch (Exception e) { LogRecorder.Exception(e); LogRecorder.EndStepMonitor(); return(ApiResult <TResult> .ErrorResult(ErrorCode.NetworkError)); } return(GetResult <TResult>(req)); }
/// <summary> /// 开始时的处理 /// </summary> /// <returns>如果返回内容不为空,直接返回,后续的处理不再继续</returns> public static int OnBegin(RouteData data) { if (!LogRecorder.LogMonitor) { return(0); } try { LogRecorder.BeginMonitor(data.Uri.ToString()); LogRecorder.BeginStepMonitor("HTTP"); var args = new StringBuilder(); args.Append("Headers:"); foreach (var head in data.Headers) { args.Append($"【{head.Key}】{head.Value.LinkToString('|')}"); } LogRecorder.MonitorTrace(args.ToString()); LogRecorder.MonitorTrace($"Method:{data.HttpMethod}"); if (!string.IsNullOrWhiteSpace(data.QueryString)) { LogRecorder.MonitorTrace($"Query:{data.QueryString}"); } if (!string.IsNullOrWhiteSpace(data.Form)) { LogRecorder.MonitorTrace($"Form:{data.Form}"); } if (!string.IsNullOrWhiteSpace(data.Context)) { LogRecorder.MonitorTrace("Context:" + data.Context); } } catch (Exception e) { LogRecorder.MonitorTrace(e.Message); LogRecorder.Exception(e); } finally { LogRecorder.EndStepMonitor(); } return(0); }
/// <summary> /// 开始日志监测 /// </summary> /// <param name="data"></param> private static void BeginMonitor(RouteData data) { if (!LogRecorder.LogMonitor) { return; } try { LogRecorder.BeginMonitor(data.Uri.ToString()); LogRecorder.BeginStepMonitor("HTTP"); var args = new StringBuilder(); args.Append("Headers:"); args.Append(JsonConvert.SerializeObject(data.Headers)); LogRecorder.MonitorTrace(args.ToString()); LogRecorder.MonitorTrace($"Method:{data.HttpMethod}"); if (!string.IsNullOrWhiteSpace(data.QueryString)) { LogRecorder.MonitorTrace($"Query:{data.QueryString}"); } if (!string.IsNullOrWhiteSpace(data.Form)) { LogRecorder.MonitorTrace($"Form:{data.Form}"); } if (!string.IsNullOrWhiteSpace(data.Context)) { LogRecorder.MonitorTrace("Context:" + data.Context); } } catch (Exception e) { LogRecorder.MonitorTrace(e.Message); LogRecorder.Exception(e); } finally { LogRecorder.EndStepMonitor(); } }
/// <summary> /// 取返回值 /// </summary> /// <param name="req"></param> /// <returns></returns> public ApiValueResult GetResult(HttpWebRequest req) { string jsonResult; try { using (WebResponse response = req.GetResponse()) { Stream receivedStream2 = response.GetResponseStream(); if (receivedStream2 == null) { LogRecorder.EndStepMonitor(); return(ErrorResult(-1, "服务器无返回值")); } jsonResult = new StreamReader(receivedStream2).ReadToEnd(); receivedStream2.Dispose(); response.Close(); } } catch (WebException e3) { try { if (e3.Status != WebExceptionStatus.ProtocolError) { LogRecorder.EndStepMonitor(); switch (e3.Status) { case WebExceptionStatus.CacheEntryNotFound: return(ErrorResult(-3, "找不到指定的缓存项")); case WebExceptionStatus.ConnectFailure: return(ErrorResult(-3, "在传输级别无法联系远程服务点")); case WebExceptionStatus.ConnectionClosed: return(ErrorResult(-3, "过早关闭连接")); case WebExceptionStatus.KeepAliveFailure: return(ErrorResult(-3, "指定保持活动状态的标头的请求的连接意外关闭")); case WebExceptionStatus.MessageLengthLimitExceeded: return(ErrorResult(-3, "已收到一条消息的发送请求时超出指定的限制或从服务器接收响应")); case WebExceptionStatus.NameResolutionFailure: return(ErrorResult(-3, "名称解析程序服务或无法解析主机名")); case WebExceptionStatus.Pending: return(ErrorResult(-3, "内部异步请求处于挂起状态")); case WebExceptionStatus.PipelineFailure: return(ErrorResult(-3, "该请求是管线请求和连接被关闭之前收到响应")); case WebExceptionStatus.ProxyNameResolutionFailure: return(ErrorResult(-3, "名称解析程序服务无法解析代理服务器主机名")); case WebExceptionStatus.ReceiveFailure: return(ErrorResult(-3, "从远程服务器未收到完整的响应")); case WebExceptionStatus.RequestCanceled: return(ErrorResult(-3, "请求已取消")); case WebExceptionStatus.RequestProhibitedByCachePolicy: return(ErrorResult(-3, "缓存策略不允许该请求")); case WebExceptionStatus.RequestProhibitedByProxy: return(ErrorResult(-3, "由该代理不允许此请求")); case WebExceptionStatus.SecureChannelFailure: return(ErrorResult(-3, "使用 SSL 建立连接时出错")); case WebExceptionStatus.SendFailure: return(ErrorResult(-3, "无法与远程服务器发送一个完整的请求")); case WebExceptionStatus.ServerProtocolViolation: return(ErrorResult(-3, "服务器响应不是有效的 HTTP 响应")); case WebExceptionStatus.Timeout: return(ErrorResult(-3, "请求的超时期限内未不收到任何响应")); case WebExceptionStatus.TrustFailure: LogRecorder.EndStepMonitor(); return(ErrorResult(-3, "无法验证服务器证书")); default: return(ErrorResult(-3, "发生未知类型的异常")); } } string[] codes = e3.Message.Split(new[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries); if (codes.Length == 3 && int.TryParse(codes[1], out var s) && s == 404) { return(ErrorResult(-3, "服务器内部错误", "页面不存在")); } using (WebResponse webResponse = e3.Response) { Stream receivedStream = webResponse.GetResponseStream(); if (receivedStream == null) { LogRecorder.EndStepMonitor(); return(ErrorResult(-1, "服务器无返回值")); } jsonResult = new StreamReader(receivedStream).ReadToEnd(); receivedStream.Dispose(); webResponse.Close(); } } catch (Exception e) { LogRecorder.Exception(e); LogRecorder.EndStepMonitor(); return(ErrorResult(-1, "未知错误", e.Message)); } } catch (Exception e2) { LogRecorder.Exception(e2); LogRecorder.EndStepMonitor(); return(ErrorResult(-1, "未知错误", e2.Message)); } LogRecorder.MonitorTrace(jsonResult); try { if (!string.IsNullOrWhiteSpace(jsonResult)) { ApiResult baseResult = JsonConvert.DeserializeObject <ApiResult>(jsonResult); return((!baseResult.Success) ? ErrorResult(baseResult.Status.ErrorCode, baseResult.Status.ClientMessage) : ApiValueResult.Succees(ReadResultData(jsonResult, "ResultData"))); } return(ErrorResult(-1)); } catch (Exception e) { LogRecorder.Exception(e); return(ErrorResult(-1, "未知错误", e.Message)); } }
/// <summary> /// 取返回值 /// </summary> /// <typeparam name="TResult"></typeparam> /// <param name="req"></param> /// <returns></returns> public ApiResult <TResult> GetResult <TResult>(HttpWebRequest req) { string jsonResult = default(string); try { using (WebResponse webResponse = req.GetResponse()) { Stream receivedStream2 = webResponse.GetResponseStream(); if (receivedStream2 == null) { LogRecorder.EndStepMonitor(); return(ApiResult.Error <TResult>(-1, "服务器无返回值")); } jsonResult = new StreamReader(receivedStream2).ReadToEnd(); receivedStream2.Dispose(); webResponse.Close(); } } catch (WebException e) { if (e.Status != WebExceptionStatus.ProtocolError) { LogRecorder.EndStepMonitor(); switch (e.Status) { case WebExceptionStatus.CacheEntryNotFound: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "找不到指定的缓存项")); case WebExceptionStatus.ConnectFailure: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "在传输级别无法联系远程服务点")); case WebExceptionStatus.ConnectionClosed: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "过早关闭连接")); case WebExceptionStatus.KeepAliveFailure: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "指定保持活动状态的标头的请求的连接意外关闭")); case WebExceptionStatus.MessageLengthLimitExceeded: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "已收到一条消息的发送请求时超出指定的限制或从服务器接收响应")); case WebExceptionStatus.NameResolutionFailure: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "名称解析程序服务或无法解析主机名")); case WebExceptionStatus.Pending: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "内部异步请求处于挂起状态")); case WebExceptionStatus.PipelineFailure: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "该请求是管线请求和连接被关闭之前收到响应")); case WebExceptionStatus.ProxyNameResolutionFailure: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "名称解析程序服务无法解析代理服务器主机名")); case WebExceptionStatus.ReceiveFailure: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "从远程服务器未收到完整的响应")); case WebExceptionStatus.RequestCanceled: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "请求已取消")); case WebExceptionStatus.RequestProhibitedByCachePolicy: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "缓存策略不允许该请求")); case WebExceptionStatus.RequestProhibitedByProxy: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "由该代理不允许此请求")); case WebExceptionStatus.SecureChannelFailure: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "使用 SSL 建立连接时出错")); case WebExceptionStatus.SendFailure: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "无法与远程服务器发送一个完整的请求")); case WebExceptionStatus.ServerProtocolViolation: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "服务器响应不是有效的 HTTP 响应")); case WebExceptionStatus.Timeout: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "请求的超时期限内未不收到任何响应")); case WebExceptionStatus.TrustFailure: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "无法验证服务器证书")); default: return(ApiResult.Error <TResult>(ErrorCode.RemoteError, "发生未知类型的异常")); } } using (WebResponse response = e.Response) { Stream receivedStream = response.GetResponseStream(); if (receivedStream == null) { LogRecorder.EndStepMonitor(); return(ApiResult.Error <TResult>(-1, "服务器无返回值")); } jsonResult = new StreamReader(receivedStream).ReadToEnd(); receivedStream.Dispose(); response.Close(); } } catch (Exception ex) { LogRecorder.Exception(ex); LogRecorder.EndStepMonitor(); return(ApiResult.Error <TResult>(ErrorCode.RemoteError)); } LogRecorder.MonitorTrace(jsonResult); try { if (!string.IsNullOrWhiteSpace(jsonResult)) { return(JsonConvert.DeserializeObject <ApiResult <TResult> >(jsonResult)); } return(ApiResult.Error <TResult>(-1)); } catch (Exception ex2) { LogRecorder.Exception(ex2); return(ApiResult.Error <TResult>(-1)); } finally { LogRecorder.EndStepMonitor(); } }
/// <summary> /// 取返回值 /// </summary> /// <param name="req"></param> /// <returns></returns> public ApiValueResult <string> GetResult(HttpWebRequest req) { string jsonResult; try { using (var response = req.GetResponse()) { var receivedStream = response.GetResponseStream(); if (receivedStream != null) { var streamReader = new StreamReader(receivedStream); jsonResult = streamReader.ReadToEnd(); receivedStream.Dispose(); } else { LogRecorder.EndStepMonitor(); return(ApiValueResult <string> .ErrorResult(ErrorCode.UnknowError, "服务器无返回值")); } response.Close(); } } catch (WebException e) { if (e.Status != WebExceptionStatus.ProtocolError) { LogRecorder.EndStepMonitor(); switch (e.Status) { case WebExceptionStatus.CacheEntryNotFound: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "找不到指定的缓存项")); case WebExceptionStatus.ConnectFailure: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "在传输级别无法联系远程服务点")); case WebExceptionStatus.ConnectionClosed: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "过早关闭连接")); case WebExceptionStatus.KeepAliveFailure: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "指定保持活动状态的标头的请求的连接意外关闭")); case WebExceptionStatus.MessageLengthLimitExceeded: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "已收到一条消息的发送请求时超出指定的限制或从服务器接收响应")); case WebExceptionStatus.NameResolutionFailure: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "名称解析程序服务或无法解析主机名")); case WebExceptionStatus.Pending: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "内部异步请求处于挂起状态")); case WebExceptionStatus.PipelineFailure: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "该请求是管线请求和连接被关闭之前收到响应")); case WebExceptionStatus.ProxyNameResolutionFailure: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "名称解析程序服务无法解析代理服务器主机名")); case WebExceptionStatus.ReceiveFailure: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "从远程服务器未收到完整的响应")); case WebExceptionStatus.RequestCanceled: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "请求已取消")); case WebExceptionStatus.RequestProhibitedByCachePolicy: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "缓存策略不允许该请求")); case WebExceptionStatus.RequestProhibitedByProxy: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "由该代理不允许此请求")); case WebExceptionStatus.SecureChannelFailure: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "使用 SSL 建立连接时出错")); case WebExceptionStatus.SendFailure: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "无法与远程服务器发送一个完整的请求")); case WebExceptionStatus.ServerProtocolViolation: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "服务器响应不是有效的 HTTP 响应")); case WebExceptionStatus.Timeout: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "请求的超时期限内未不收到任何响应")); case WebExceptionStatus.TrustFailure: LogRecorder.EndStepMonitor(); return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "无法验证服务器证书")); default: //case WebExceptionStatus.UnknownError: return(ApiValueResult <string> .ErrorResult(ErrorCode.NetworkError, "发生未知类型的异常")); } } using (var response = e.Response) { var receivedStream = response.GetResponseStream(); if (receivedStream != null) { var streamReader = new StreamReader(receivedStream); jsonResult = streamReader.ReadToEnd(); receivedStream.Dispose(); } else { LogRecorder.EndStepMonitor(); return(ApiValueResult <string> .ErrorResult(ErrorCode.UnknowError, "服务器无返回值")); } response.Close(); } } catch (Exception e) { LogRecorder.Exception(e); LogRecorder.EndStepMonitor(); return(ApiValueResult <string> .ErrorResult(ErrorCode.UnknowError, "未知错误", e.Message)); } LogRecorder.MonitorTrace(jsonResult); try { if (string.IsNullOrWhiteSpace(jsonResult)) { return(ApiValueResult <string> .ErrorResult(ErrorCode.UnknowError)); } var baseResult = JsonConvert.DeserializeObject <ApiResult>(jsonResult); return(!baseResult.Result ? ApiValueResult <string> .ErrorResult(baseResult.Status.ErrorCode, baseResult.Status.Message) : ApiValueResult <string> .Succees( ReadResultData(jsonResult, nameof(ApiValueResult <string> .ResultData)))); } catch (Exception e) { LogRecorder.Exception(e); return(ApiValueResult <string> .ErrorResult(ErrorCode.UnknowError, "未知错误", e.Message)); } finally { LogRecorder.EndStepMonitor(); } }