public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { // Get the request lifetime scope so you can resolve services. var requestScope = actionExecutedContext.Request.GetDependencyScope(); // Resolve the service you want to use. var auditAppService = requestScope.GetService(typeof(IAuditAppService)) as IAuditAppService; var auditLogEdit = new AuditLogEdit() { Id = m_auditId, IsExecSuccess = true, }; if (actionExecutedContext.Exception != null) { auditLogEdit.Exception = actionExecutedContext.Exception.ToString(); auditLogEdit.IsExecSuccess = false; } _stopwatch.Stop(); auditLogEdit.ExecutionDuration = _stopwatch.Elapsed.Milliseconds; auditAppService.UpdateAuditLog(auditLogEdit); base.OnActionExecuted(actionExecutedContext); _stopwatch.Reset(); }
public void UpdateAuditLog(AuditLogEdit input) { var auditLog = input.DtoConvertEntity(_auditLogService.Get(input.Id)); WriteData(_auditLogService.Update, auditLog); if (!ValidationResult.IsValid) { throw new LSException("更新Api执行时间失败"); } }