|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
|
|
|
@ -15,7 +14,6 @@ using Volo.Abp.Json;
|
|
|
|
|
using Volo.Abp.MultiTenancy;
|
|
|
|
|
using Volo.Abp.Reflection;
|
|
|
|
|
using Volo.Abp.Timing;
|
|
|
|
|
using Volo.Abp.Uow;
|
|
|
|
|
|
|
|
|
|
namespace Volo.Abp.EntityFrameworkCore.EntityHistory
|
|
|
|
|
{
|
|
|
|
@ -26,6 +24,7 @@ namespace Volo.Abp.EntityFrameworkCore.EntityHistory
|
|
|
|
|
protected IAuditingStore AuditingStore { get; }
|
|
|
|
|
protected IJsonSerializer JsonSerializer { get; }
|
|
|
|
|
protected AbpAuditingOptions Options { get; }
|
|
|
|
|
protected IAuditingHelper AuditingHelper { get; }
|
|
|
|
|
|
|
|
|
|
private readonly IClock _clock;
|
|
|
|
|
|
|
|
|
@ -33,11 +32,13 @@ namespace Volo.Abp.EntityFrameworkCore.EntityHistory
|
|
|
|
|
IAuditingStore auditingStore,
|
|
|
|
|
IOptions<AbpAuditingOptions> options,
|
|
|
|
|
IClock clock,
|
|
|
|
|
IJsonSerializer jsonSerializer)
|
|
|
|
|
IJsonSerializer jsonSerializer,
|
|
|
|
|
IAuditingHelper auditingHelper)
|
|
|
|
|
{
|
|
|
|
|
_clock = clock;
|
|
|
|
|
AuditingStore = auditingStore;
|
|
|
|
|
JsonSerializer = jsonSerializer;
|
|
|
|
|
AuditingHelper = auditingHelper;
|
|
|
|
|
Options = options.Value;
|
|
|
|
|
|
|
|
|
|
Logger = NullLogger<EntityHistoryHelper>.Instance;
|
|
|
|
@ -203,39 +204,14 @@ namespace Volo.Abp.EntityFrameworkCore.EntityHistory
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Options.IgnoredTypes.Any(t => t.IsInstanceOfType(entityEntry.Entity)))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
var entityType = entityEntry.Metadata.ClrType;
|
|
|
|
|
|
|
|
|
|
var entityType = entityEntry.Entity.GetType();
|
|
|
|
|
if (!EntityHelper.IsEntity(entityType))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!entityType.IsPublic)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (entityType.IsDefined(typeof(AuditedAttribute), true))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (entityEntry.Metadata.GetProperties()
|
|
|
|
|
.Any(p => p.PropertyInfo?.IsDefined(typeof(AuditedAttribute)) ?? false))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (entityType.IsDefined(typeof(DisableAuditingAttribute), true))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Options.EntityHistorySelectors.Any(selector => selector.Predicate(entityType)))
|
|
|
|
|
if (AuditingHelper.IsEntityHistoryEnabled(entityType))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|