diff --git a/src/Abp.Zero/Auditing/AuditLog.cs b/src/Abp.Zero/Auditing/AuditLog.cs index a663eece..7af9d637 100644 --- a/src/Abp.Zero/Auditing/AuditLog.cs +++ b/src/Abp.Zero/Auditing/AuditLog.cs @@ -116,18 +116,20 @@ public class AuditLog : Entity /// The object that is created using public static AuditLog CreateFromAuditInfo(AuditInfo auditInfo) { + //TODO: Truncate should return null if argument is null. Implement this in Abp then change here. + return new AuditLog { TenantId = auditInfo.TenantId, UserId = auditInfo.UserId, - ServiceName = auditInfo.ServiceName.Truncate(MaxServiceNameLength), - MethodName = auditInfo.MethodName.Truncate(MaxMethodNameLength), - Parameters = auditInfo.Parameters.Truncate(MaxParametersLength), + ServiceName = (auditInfo.ServiceName ?? "").Truncate(MaxServiceNameLength), + MethodName = (auditInfo.MethodName ?? "").Truncate(MaxMethodNameLength), + Parameters = (auditInfo.Parameters ?? "").Truncate(MaxParametersLength), ExecutionTime = auditInfo.ExecutionTime, ExecutionDuration = auditInfo.ExecutionDuration, - ClientIpAddress = auditInfo.ClientIpAddress.Truncate(MaxClientIpAddressLength), - ClientName = auditInfo.ClientName.Truncate(MaxClientNameLength), - BrowserInfo = auditInfo.BrowserInfo.Truncate(MaxBrowserInfoLength) + ClientIpAddress = (auditInfo.ClientIpAddress ?? "").Truncate(MaxClientIpAddressLength), + ClientName = (auditInfo.ClientName ?? "").Truncate(MaxClientNameLength), + BrowserInfo = (auditInfo.BrowserInfo ?? "").Truncate(MaxBrowserInfoLength) }; }