1、模块配置
类型是否定义了AuditedAttribute,DisableAuditingAttribute,或派生于IAuditingEnabled,2)类型方法定义AuditedAttribute
添加Auditing的拦截器
[DependsOn( typeof(AbpDataModule), typeof(AbpJsonModule), typeof(AbpTimingModule), typeof(AbpSecurityModule), typeof(AbpThreadingModule), typeof(AbpMultiTenancyModule) )] public class AbpAuditingModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) { context.Services.OnRegistred(AuditingInterceptorRegistrar.RegisterIfNeeded); } }
2、审计的配置信息AbpAuditingOptions
HideErrors:默认为true,auditing will not throw an exceptions and it will log it when an error occurred while saving AuditLog.
IsEnabled: 默认为true
ApplicationName;IsEnabledForAnonymousUsers;List<AuditLogContributor>;List<Type> IgnoredType;IEntityHistorySelectorList EntityHistorySelectors
3、Info信息
1)AuditLogInfo 应用名称,用户Id,用户名,租户Id,租户名,扮演Id,扮演名,执行时间,客户端信息,AuditLogActionInfo列表,Exception列表
2)AuditLogActionInfo
3)EntityChangeInfo
4)EntityPropertyChangeInfo
4)审计类接口
IMayHaveCreator;IMustHaveCreator;IHasModificationTime;IHasCreationTime;IHasCreationTime;IHasDeletionTime
ICreationAuditedObject(IHasCreationTime,IMayHaveCreator)
IModificationAuditedObject(IHasModificationTime)
IDeletionAuditedObject(IHasDeletionTime)
IAuditedObject(ICreationAuditedObject,IModificationAuditedObject)
IFullAuditedObject(IAuditedObject,IDeletionAuditedObject)
public interface IAuditPropertySetter { void SetCreationProperties(object targetObject); void SetModificationProperties(object targetObject); void SetDeletionProperties(object targetObject); }
5)IAuditingManager
public interface IAuditingManager { [CanBeNull] IAuditLogScope Current { get; } IAuditLogSaveHandle BeginScope(); }
保存AuditLogInfo
protected virtual async Task SaveAsync(DisposableSaveHandle saveHandle) { BeforeSave(saveHandle); if (ShouldSave(saveHandle.AuditLog)) { await _auditingStore.SaveAsync(saveHandle.AuditLog); } }
6、IAuditingStore 存储 AuditLogInfo
原文:https://www.cnblogs.com/cloudsu/p/11190576.html