From 700a22423f7f6d165bc9f43aa5b6cbb002c7e10e Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 19 Mar 2019 14:18:23 +0300 Subject: [PATCH] Add TenantName to Audit logs #891 --- .../Volo/Abp/Auditing/AuditLogActionInfo.cs | 1 + .../Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs | 4 +++- .../Volo/Abp/Auditing/AuditingHelper.cs | 1 + .../Volo/Abp/Auditing/EntityChangeInfo.cs | 1 + .../Volo/Abp/Auditing/EntityPropertyChangeInfo.cs | 1 + .../Volo/Abp/AuditLogging/AuditLogConsts.cs | 2 ++ .../Volo/Abp/AuditLogging/AuditLog.cs | 9 ++++++--- 7 files changed, 15 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs index 067f4b2431..0959637ffb 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogActionInfo.cs @@ -5,6 +5,7 @@ using Volo.Abp.MultiTenancy; namespace Volo.Abp.Auditing { + [Serializable] public class AuditLogActionInfo : IMultiTenant, IHasExtraProperties { public Guid? TenantId { get; set; } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs index 79becb4ea0..d6b77313f0 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs @@ -7,7 +7,7 @@ using Volo.Abp.MultiTenancy; namespace Volo.Abp.Auditing { - //TODO: Make serializable! + [Serializable] public class AuditLogInfo : IMultiTenant, IHasExtraProperties { public string ApplicationName { get; set; } @@ -18,6 +18,8 @@ namespace Volo.Abp.Auditing public Guid? TenantId { get; set; } + public string TenantName { get; set; } + public Guid? ImpersonatorUserId { get; set; } public Guid? ImpersonatorTenantId { get; set; } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs index c584d322a0..9366c8cc03 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs @@ -92,6 +92,7 @@ namespace Volo.Abp.Auditing { ApplicationName = Options.ApplicationName, TenantId = CurrentTenant.Id, + TenantName = CurrentTenant. UserId = CurrentUser.Id, UserName = CurrentUser.UserName, ClientId = CurrentClient.Id, diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs index f0532e3009..c0dffa09fd 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityChangeInfo.cs @@ -6,6 +6,7 @@ using Volo.Abp.MultiTenancy; namespace Volo.Abp.Auditing { + [Serializable] public class EntityChangeInfo : IMultiTenant, IHasExtraProperties { public DateTime ChangeTime { get; set; } diff --git a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs index 53d45329c0..c1f53b1b70 100644 --- a/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs +++ b/framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/EntityPropertyChangeInfo.cs @@ -3,6 +3,7 @@ using Volo.Abp.MultiTenancy; namespace Volo.Abp.Auditing { + [Serializable] public class EntityPropertyChangeInfo : IMultiTenant { /// diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AuditLogConsts.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AuditLogConsts.cs index f6a73bb19a..1a592fc8b8 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AuditLogConsts.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AuditLogConsts.cs @@ -23,5 +23,7 @@ public const int MaxHttpMethodLength = 16; public const int MaxUserNameLength = 256; + + public const int MaxTenantNameLength = 64; } } 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 5640685b2e..38f32180cb 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 @@ -19,6 +19,8 @@ namespace Volo.Abp.AuditLogging public virtual Guid? TenantId { get; protected set; } + public virtual string TenantName { get; protected set; } + public virtual Guid? ImpersonatorUserId { get; protected set; } public virtual Guid? ImpersonatorTenantId { get; protected set; } @@ -31,9 +33,9 @@ namespace Volo.Abp.AuditLogging public virtual string ClientName { get; protected set; } - public string ClientId { get; set; } + public virtual string ClientId { get; set; } - public string CorrelationId { get; set; } + public virtual string CorrelationId { get; set; } public virtual string BrowserInfo { get; protected set; } @@ -59,8 +61,9 @@ namespace Volo.Abp.AuditLogging public AuditLog(IGuidGenerator guidGenerator, AuditLogInfo auditInfo) { Id = guidGenerator.Create(); - ApplicationName = auditInfo.ApplicationName; + ApplicationName = auditInfo.ApplicationName.Truncate(AuditLogConsts.MaxApplicationNameLength); TenantId = auditInfo.TenantId; + TenantName = auditInfo.TenantName.Truncate(AuditLogConsts.MaxTenantNameLength); UserId = auditInfo.UserId; UserName = auditInfo.UserName.Truncate(AuditLogConsts.MaxUserNameLength); ExecutionTime = auditInfo.ExecutionTime;