From bb49c74761195ced3a5455f3da71d6e5327700b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 8 Nov 2020 14:58:41 +0300 Subject: [PATCH] Fix ExtraProperties erorrs on the audit log module --- .../Volo/Abp/AuditLogging/AuditLog.cs | 17 ++++++++++------ .../Volo/Abp/AuditLogging/AuditLogAction.cs | 9 +++------ .../Volo/Abp/AuditLogging/EntityChange.cs | 20 +++++++++++-------- 3 files changed, 26 insertions(+), 20 deletions(-) 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 63dbd4802b..25e0c9d9dc 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 @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using Volo.Abp.Auditing; +using Volo.Abp.Data; using Volo.Abp.Domain.Entities; using Volo.Abp.Guids; using Volo.Abp.MultiTenancy; @@ -55,12 +56,12 @@ namespace Volo.Abp.AuditLogging protected AuditLog() { - ExtraProperties = new Dictionary(); + } public AuditLog(IGuidGenerator guidGenerator, AuditLogInfo auditInfo) + : base(guidGenerator.Create()) { - Id = guidGenerator.Create(); ApplicationName = auditInfo.ApplicationName.Truncate(AuditLogConsts.MaxApplicationNameLength); TenantId = auditInfo.TenantId; TenantName = auditInfo.TenantName.Truncate(AuditLogConsts.MaxTenantNameLength); @@ -79,10 +80,14 @@ namespace Volo.Abp.AuditLogging ImpersonatorUserId = auditInfo.ImpersonatorUserId; ImpersonatorTenantId = auditInfo.ImpersonatorTenantId; - ExtraProperties = auditInfo - .ExtraProperties? - .ToDictionary(pair => pair.Key, pair => pair.Value) - ?? new Dictionary(); + ExtraProperties = new ExtraPropertyDictionary(); + if (auditInfo.ExtraProperties != null) + { + foreach (var pair in auditInfo.ExtraProperties) + { + ExtraProperties.Add(pair.Key, pair.Value); + } + } EntityChanges = auditInfo .EntityChanges? diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLogAction.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLogAction.cs index b6253e3f0e..7f6db9af5f 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLogAction.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLogAction.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using Volo.Abp.Auditing; using Volo.Abp.Data; using Volo.Abp.Domain.Entities; @@ -25,11 +23,10 @@ namespace Volo.Abp.AuditLogging public virtual int ExecutionDuration { get; protected set; } - public virtual Dictionary ExtraProperties { get; protected set; } - + public virtual ExtraPropertyDictionary ExtraProperties { get; protected set; } + protected AuditLogAction() { - ExtraProperties = new Dictionary(); } public AuditLogAction(Guid id, Guid auditLogId, AuditLogActionInfo actionInfo, Guid? tenantId = null) @@ -40,7 +37,7 @@ namespace Volo.Abp.AuditLogging AuditLogId = auditLogId; ExecutionTime = actionInfo.ExecutionTime; ExecutionDuration = actionInfo.ExecutionDuration; - ExtraProperties = actionInfo.ExtraProperties.ToDictionary(pair => pair.Key, pair => pair.Value); + ExtraProperties = new ExtraPropertyDictionary(actionInfo.ExtraProperties); ServiceName = actionInfo.ServiceName.TruncateFromBeginning(AuditLogActionConsts.MaxServiceNameLength); MethodName = actionInfo.MethodName.TruncateFromBeginning(AuditLogActionConsts.MaxMethodNameLength); Parameters = actionInfo.Parameters.Length > AuditLogActionConsts.MaxParametersLength ? "" : actionInfo.Parameters; diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/EntityChange.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/EntityChange.cs index b90843dfc0..6bb86b7980 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/EntityChange.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/EntityChange.cs @@ -28,16 +28,16 @@ namespace Volo.Abp.AuditLogging public virtual ICollection PropertyChanges { get; protected set; } - public virtual Dictionary ExtraProperties { get; protected set; } + public virtual ExtraPropertyDictionary ExtraProperties { get; protected set; } protected EntityChange() { - ExtraProperties = new Dictionary(); + ExtraProperties = new ExtraPropertyDictionary(); } public EntityChange( - IGuidGenerator guidGenerator, - Guid auditLogId, + IGuidGenerator guidGenerator, + Guid auditLogId, EntityChangeInfo entityChangeInfo, Guid? tenantId = null) { @@ -55,10 +55,14 @@ namespace Volo.Abp.AuditLogging .ToList() ?? new List(); - ExtraProperties = entityChangeInfo - .ExtraProperties? - .ToDictionary(pair => pair.Key, pair => pair.Value) - ?? new Dictionary(); + ExtraProperties = new ExtraPropertyDictionary(); + if (entityChangeInfo.ExtraProperties != null) + { + foreach (var pair in entityChangeInfo.ExtraProperties) + { + ExtraProperties.Add(pair.Key, pair.Value); + } + } } } }