private async Task <int> Insert(SysUser user) { var log = new SysLoginLog { LoginName = user.LoginName, Name = user.Name, UserId = user.UserId, LoginIp = IpAddressHelper.GetIPAddress() }; var result = repository.Insert(log); return(result); }
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { if (!string.IsNullOrEmpty(BusinessName)) { _stopwatch.Stop(); long executeElapsedTime = _stopwatch.ElapsedMilliseconds; string request = LogAssistant.GetRequestParameter(actionExecutedContext); var response = actionExecutedContext.Response; if (response != null) { try { var result = response.Content.ReadAsStringAsync().Result; var briefResult = JsonConvert.DeserializeObject <BaseViewModel>(result); if (briefResult.BusinessStatus != -10003) { AspectFExtensions.LogBuriedPoint(actionExecutedContext, BusinessName, StepName, ExecuteLot, executeElapsedTime, request, result, true, IpAddressHelper.GetIPAddress(), "服务器响应成功"); } else { AspectFExtensions.LogBuriedPoint(actionExecutedContext, BusinessName, StepName, ExecuteLot, executeElapsedTime, request, result, false, IpAddressHelper.GetIPAddress(), "服务器响应失败"); } } catch (Exception ex) { AspectFExtensions.LogBuriedPoint(actionExecutedContext, BusinessName, StepName, ExecuteLot, executeElapsedTime, request, ex.Message, false, IpAddressHelper.GetIPAddress(), "接口执行成功,OnActionExecuted执行失败"); } } else { AspectFExtensions.LogBuriedPoint(actionExecutedContext, BusinessName, StepName, ExecuteLot, executeElapsedTime, request, "", false, IpAddressHelper.GetIPAddress(), "服务器没有返回任何数据,请对接口代码进行异常捕获"); } } }