Browse Source

Merge pull request #3935 from abpframework/maliming/audit-patch

Check whether MethodInfo's DeclaringType has auditing disabled.
pull/3970/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
1da901ee15
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs
  2. 10
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptorRegistrar.cs

19
framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs

@ -36,7 +36,7 @@ namespace Volo.Abp.Auditing
IClock clock, IClock clock,
IAuditingStore auditingStore, IAuditingStore auditingStore,
ILogger<AuditingHelper> logger, ILogger<AuditingHelper> logger,
IServiceProvider serviceProvider, IServiceProvider serviceProvider,
ICorrelationIdProvider correlationIdProvider) ICorrelationIdProvider correlationIdProvider)
{ {
Options = options.Value; Options = options.Value;
@ -77,9 +77,10 @@ namespace Volo.Abp.Auditing
var classType = methodInfo.DeclaringType; var classType = methodInfo.DeclaringType;
if (classType != null) if (classType != null)
{ {
if (AuditingInterceptorRegistrar.ShouldAuditTypeByDefault(classType)) var shouldAudit = AuditingInterceptorRegistrar.ShouldAuditTypeByDefaultOrNull(classType);
if (shouldAudit != null)
{ {
return true; return shouldAudit.Value;
} }
} }
@ -123,7 +124,7 @@ namespace Volo.Abp.Auditing
return defaultValue; return defaultValue;
} }
public virtual AuditLogInfo CreateAuditLogInfo() public virtual AuditLogInfo CreateAuditLogInfo()
{ {
var auditInfo = new AuditLogInfo var auditInfo = new AuditLogInfo
@ -147,8 +148,8 @@ namespace Volo.Abp.Auditing
public virtual AuditLogActionInfo CreateAuditLogAction( public virtual AuditLogActionInfo CreateAuditLogAction(
AuditLogInfo auditLog, AuditLogInfo auditLog,
Type type, Type type,
MethodInfo method, MethodInfo method,
object[] arguments) object[] arguments)
{ {
return CreateAuditLogAction(auditLog, type, method, CreateArgumentsDictionary(method, arguments)); return CreateAuditLogAction(auditLog, type, method, CreateArgumentsDictionary(method, arguments));
@ -156,8 +157,8 @@ namespace Volo.Abp.Auditing
public virtual AuditLogActionInfo CreateAuditLogAction( public virtual AuditLogActionInfo CreateAuditLogAction(
AuditLogInfo auditLog, AuditLogInfo auditLog,
Type type, Type type,
MethodInfo method, MethodInfo method,
IDictionary<string, object> arguments) IDictionary<string, object> arguments)
{ {
var actionInfo = new AuditLogActionInfo var actionInfo = new AuditLogActionInfo
@ -240,4 +241,4 @@ namespace Volo.Abp.Auditing
return dictionary; return dictionary;
} }
} }
} }

10
framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptorRegistrar.cs

@ -21,8 +21,8 @@ namespace Volo.Abp.Auditing
{ {
return false; return false;
} }
if (ShouldAuditTypeByDefault(type)) if (ShouldAuditTypeByDefaultOrNull(type) == true)
{ {
return true; return true;
} }
@ -36,7 +36,7 @@ namespace Volo.Abp.Auditing
} }
//TODO: Move to a better place //TODO: Move to a better place
public static bool ShouldAuditTypeByDefault(Type type) public static bool? ShouldAuditTypeByDefaultOrNull(Type type)
{ {
//TODO: In an inheritance chain, it would be better to check the attributes on the top class first. //TODO: In an inheritance chain, it would be better to check the attributes on the top class first.
@ -55,7 +55,7 @@ namespace Volo.Abp.Auditing
return true; return true;
} }
return false; return null;
} }
} }
} }

Loading…
Cancel
Save