public void Intercept(IInvocation invocation) { //TODO: Refactor! var auditInfo = new AuditInfo { TenantId = AbpSession.TenantId, UserId = AbpSession.UserId, ServiceName = invocation.MethodInvocationTarget.DeclaringType.FullName, MethodName = invocation.MethodInvocationTarget.Name, Parameters = invocation.Arguments.ToString(), //TODO: Convert to JSON? ExecutionTime = DateTime.Now //TODO: UtcNow? }; //TODO: Fill web layer informations 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); } }
public void Save(AuditInfo auditInfo) { using (var uow = _unitOfWorkManager.Begin()) { _auditingStore.Save(auditInfo); uow.Complete(); } }
internal void Save(DisposableSaveHandle saveHandle) { BeforeSave(saveHandle); if (ShouldSave(saveHandle.Info)) { _auditingStore.Save(saveHandle.Info); } }
public void Intercept(IInvocation invocation) { if (!_configuration.IsEnabled) { invocation.Proceed(); return; } if (!ShouldSaveAudit(invocation.MethodInvocationTarget)) { 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. } }
public void Save(AuditInfo auditInfo) { _store.Save(auditInfo); }
/// <summary> /// 保存 /// </summary> /// <param name="entity"></param> public void SaveAuditInfo(AuditInfo entity) { _auditInfoService.Save(entity); }