public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { using (AbpCrossCuttingConcerns.Applying(context.Controller, AbpCrossCuttingConcerns.Auditing)) { if (!ShouldSaveAudit(context)) { await next(); return; } var auditInfo = CreateAuditInfo(context); var stopwatch = Stopwatch.StartNew(); try { await next(); } catch (Exception ex) { auditInfo.Exception = ex; throw; } finally { stopwatch.Stop(); auditInfo.ExecutionDuration = Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds); AuditInfoProvider?.Fill(auditInfo); await AuditingStore.SaveAsync(auditInfo); } } }
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { //TODO: VALIDATION var auditInfo = CreateAuditInfo(context); var stopwatch = Stopwatch.StartNew(); try { await base.OnActionExecutionAsync(context, next); } catch (Exception ex) { auditInfo.Exception = ex; throw; } finally { stopwatch.Stop(); auditInfo.ExecutionDuration = Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds); AuditInfoProvider?.Fill(auditInfo); await AuditingStore.SaveAsync(auditInfo); } }
public async Task <HttpResponseMessage> ExecuteActionFilterAsync(HttpActionContext actionContext, CancellationToken cancellationToken, Func <Task <HttpResponseMessage> > continuation) { if (actionContext.ActionDescriptor.GetMethodInfoOrNull() == null || !ShouldSaveAudit(actionContext)) { return(await continuation()); } var auditInfo = CreateAuditInfo(actionContext); var stopwatch = Stopwatch.StartNew(); try { return(await continuation()); } catch (Exception ex) { auditInfo.Exception = ex; throw; } finally { stopwatch.Stop(); auditInfo.ExecutionDuration = Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds); AuditInfoProvider?.Fill(auditInfo); await AuditingStore.SaveAsync(auditInfo); } }
private void HandleAuditingAfterAction(ActionExecutedContext filterContext) { if (_auditInfo == null || _actionStopwatch == null) { return; } _actionStopwatch.Stop(); _auditInfo.ExecutionDuration = Convert.ToInt32(_actionStopwatch.Elapsed.TotalMilliseconds); _auditInfo.Exception = filterContext.Exception; AuditInfoProvider?.Fill(_auditInfo); AuditingStore.Save(_auditInfo); }
public void OnActionExecuted(ActionExecutedContext filterContext) { var auditData = AbpAuditFilterData.GetOrNull(filterContext.HttpContext); if (auditData == null) { return; } auditData.Stopwatch.Stop(); auditData.AuditInfo.ExecutionDuration = Convert.ToInt32(auditData.Stopwatch.Elapsed.TotalMilliseconds); auditData.AuditInfo.Exception = filterContext.Exception; AuditInfoProvider?.Fill(auditData.AuditInfo); AuditingStore.Save(auditData.AuditInfo); }