From 04abbf3ddb348a58818f39200fb54568652300e6 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Wed, 11 Jul 2018 16:01:18 +0300 Subject: [PATCH] Audit log module improvements --- .../AbpAuditLoggingDomainSharedModule.cs | 9 +++++++ .../Volo/Abp/AuditLogging/AuditLog.cs | 2 +- .../Abp/AuditLogging/EntityPropertyChange.cs | 2 +- ...bpAuditLoggingEfCoreQueryableExtensions.cs | 26 +++++++++++++++++++ ...LoggingtDbContextModelBuilderExtensions.cs | 2 +- .../EfCoreAuditLogRepository.cs | 6 +++++ 6 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/AbpAuditLoggingEfCoreQueryableExtensions.cs diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AbpAuditLoggingDomainSharedModule.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AbpAuditLoggingDomainSharedModule.cs index 9cb51d5a3b..4428185617 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AbpAuditLoggingDomainSharedModule.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AbpAuditLoggingDomainSharedModule.cs @@ -1,4 +1,6 @@ using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AuditLogging.Localization; +using Volo.Abp.Localization; using Volo.Abp.Modularity; namespace Volo.Abp.AuditLogging @@ -7,6 +9,13 @@ namespace Volo.Abp.AuditLogging { public override void ConfigureServices(ServiceConfigurationContext context) { + + + context.Services.Configure(options => + { + options.Resources.Add("en"); + }); + context.Services.AddAssemblyOf(); } } diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLog.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLog.cs index 98caf6acca..8859d515d7 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLog.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLog.cs @@ -38,7 +38,7 @@ namespace Volo.Abp.AuditLogging public virtual string Comments { get; protected set; } - public int? HttpStatusCode { get; set; } + public virtual int? HttpStatusCode { get; set; } public virtual Dictionary ExtraProperties { get; protected set; } diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/EntityPropertyChange.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/EntityPropertyChange.cs index 2335db84b8..c85f5c93b2 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/EntityPropertyChange.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/EntityPropertyChange.cs @@ -9,7 +9,7 @@ namespace Volo.Abp.AuditLogging [DisableAuditing] public class EntityPropertyChange : Entity, IMultiTenant { - public Guid? TenantId { get; protected set; } + public virtual Guid? TenantId { get; protected set; } public virtual Guid EntityChangeId { get; protected set; } diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/AbpAuditLoggingEfCoreQueryableExtensions.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/AbpAuditLoggingEfCoreQueryableExtensions.cs new file mode 100644 index 0000000000..59ade6d90c --- /dev/null +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/AbpAuditLoggingEfCoreQueryableExtensions.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.EntityFrameworkCore; + +namespace Volo.Abp.AuditLogging +{ + public static class AbpAuditLoggingEfCoreQueryableExtensions + { + public static IQueryable IncludeDetails( + this IQueryable queryable, + bool include = true) + { + if (!include) + { + return queryable; + } + + return queryable + .Include(x => x.Actions) + .Include(x => x.EntityChanges); + } + + } +} diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingtDbContextModelBuilderExtensions.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingtDbContextModelBuilderExtensions.cs index 61504646c7..9d33567e20 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingtDbContextModelBuilderExtensions.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingtDbContextModelBuilderExtensions.cs @@ -73,7 +73,7 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore b.Property(x => x.AuditLogId).IsRequired().HasColumnName(nameof(EntityChange.AuditLogId)); b.Property(x => x.ChangeTime).IsRequired().HasColumnName(nameof(EntityChange.ChangeTime)); b.Property(x => x.ChangeType).IsRequired().HasColumnName(nameof(EntityChange.ChangeType)); - b.Property(x => x.TenantId).IsRequired().HasColumnName(nameof(EntityChange.TenantId)); + b.Property(x => x.TenantId).HasColumnName(nameof(EntityChange.TenantId)); b.HasMany().WithOne().HasForeignKey(x => x.EntityChangeId); diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs index 90f71e78dc..44c33b06ea 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; @@ -11,5 +12,10 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore { } + + public override IQueryable WithDetails() + { + return GetQueryable().IncludeDetails(); + } } }