public void Intercept(IInvocation invocation) { if (AbpCrossCuttingConcerns.IsApplied(invocation.InvocationTarget, AbpCrossCuttingConcerns.Auditing)) { invocation.Proceed(); return; } if (!AuditingHelper.ShouldSaveAudit(invocation.MethodInvocationTarget, _configuration, AbpSession)) { invocation.Proceed(); return; } var auditInfo = CreateAuditInfo(invocation); if (AsyncHelper.IsAsyncMethod(invocation.Method)) { PerformAsyncAuditing(invocation, auditInfo); } else { PerformSyncAuditing(invocation, auditInfo); } }
public void Intercept(IInvocation invocation) { if (!AuditingHelper.ShouldSaveAudit(invocation.MethodInvocationTarget, _configuration, AbpSession)) { invocation.Proceed(); return; } var auditInfo = new AuditInfo { TenantId = AbpSession.TenantId, UserId = AbpSession.UserId, ServiceName = invocation.MethodInvocationTarget.DeclaringType != null ? invocation.MethodInvocationTarget.DeclaringType.FullName : "", MethodName = invocation.MethodInvocationTarget.Name, Parameters = ConvertArgumentsToJson(invocation), ExecutionTime = Clock.Now }; _auditInfoProvider.Fill(auditInfo); var stopwatch = Stopwatch.StartNew(); try { invocation.Proceed(); } catch (Exception ex) { auditInfo.Exception = ex; throw; } finally { stopwatch.Stop(); auditInfo.ExecutionDuration = Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds); AuditingStore.Save(auditInfo); //TODO: Call async when target method is async. } }