diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/IAuditLogRepository.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/IAuditLogRepository.cs index 513861bf11..489a07a0ce 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/IAuditLogRepository.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/IAuditLogRepository.cs @@ -20,6 +20,7 @@ namespace Volo.Abp.AuditLogging string correlationId = null, int? maxExecutionDuration = null, int? minExecutionDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, bool includeDetails = false, CancellationToken cancellationToken = default); @@ -32,6 +33,7 @@ namespace Volo.Abp.AuditLogging string correlationId = null, int? maxExecutionDuration = null, int? minExecutionDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, CancellationToken cancellationToken = default); } 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 e1f720e8cd..043c3d8988 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 @@ -30,11 +30,12 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore string correlationId = null, int? maxExecutionDuration = null, int? minExecutionDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, bool includeDetails = false, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxExecutionDuration, minExecutionDuration, httpStatusCode, includeDetails); + var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxExecutionDuration, minExecutionDuration, hasException, httpStatusCode, includeDetails); var auditLogs = await query.OrderBy(sorting ?? "executionTime desc") .PageBy(skipCount, maxResultCount) @@ -51,10 +52,11 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore string correlationId = null, int? maxExecutionDuration = null, int? minExecutionDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxExecutionDuration, minExecutionDuration, httpStatusCode); + var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxExecutionDuration, minExecutionDuration, hasException, httpStatusCode); var totalCount = await query.LongCountAsync(); @@ -69,11 +71,14 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore string correlationId = null, int? maxExecutionDuration = null, int? minExecutionDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, bool includeDetails = false) { return DbSet.AsNoTracking() .IncludeDetails(includeDetails) + .WhereIf(hasException.HasValue && hasException.Value, auditLog => auditLog.Exceptions != null && auditLog.Exceptions.Length > 0) + .WhereIf(hasException.HasValue && !hasException.Value, auditLog => auditLog.Exceptions == null || auditLog.Exceptions.Length == 0) .WhereIf(httpMethod != null, auditLog => auditLog.HttpMethod != null && auditLog.HttpMethod.ToLowerInvariant() == httpMethod.ToLowerInvariant()) .WhereIf(url != null, auditLog => auditLog.Url != null && auditLog.Url.ToLowerInvariant().Contains(url.ToLowerInvariant())) .WhereIf(userName != null, auditLog => auditLog.UserName != null && auditLog.UserName.ToLowerInvariant() == userName.ToLowerInvariant()) diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs index 09988682af..f70bd1deaf 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs @@ -31,11 +31,12 @@ namespace Volo.Abp.AuditLogging.MongoDB string correlationId = null, int? maxDuration = null, int? minDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, bool includeDetails = false, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxDuration, minDuration, httpStatusCode, includeDetails); + var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxDuration, minDuration, hasException, httpStatusCode, includeDetails); return await query.OrderBy(sorting ?? "executionTime desc").As>() .PageBy>(skipCount, maxResultCount) @@ -50,10 +51,11 @@ namespace Volo.Abp.AuditLogging.MongoDB string correlationId = null, int? maxDuration = null, int? minDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxDuration, minDuration, httpStatusCode); + var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxDuration, minDuration, hasException, httpStatusCode); var count = await query.As>().LongCountAsync(); @@ -68,10 +70,13 @@ namespace Volo.Abp.AuditLogging.MongoDB string correlationId = null, int? maxDuration = null, int? minDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, bool includeDetails = false) { return GetMongoQueryable() + .WhereIf(hasException.HasValue && hasException.Value, auditLog => auditLog.Exceptions != null && auditLog.Exceptions.Length > 0) + .WhereIf(hasException.HasValue && !hasException.Value, auditLog => auditLog.Exceptions == null || auditLog.Exceptions.Length == 0) .WhereIf(httpMethod != null, auditLog => auditLog.HttpMethod != null && auditLog.HttpMethod.ToLowerInvariant() == httpMethod.ToLowerInvariant()) .WhereIf(url != null, auditLog => auditLog.Url != null && auditLog.Url.ToLowerInvariant().Contains(url.ToLowerInvariant())) .WhereIf(userName != null, auditLog => auditLog.UserName != null && auditLog.UserName.ToLowerInvariant() == userName.ToLowerInvariant()) @@ -79,7 +84,7 @@ namespace Volo.Abp.AuditLogging.MongoDB .WhereIf(correlationId != null, auditLog => auditLog.CorrelationId != null && auditLog.CorrelationId.ToLowerInvariant() == correlationId.ToLowerInvariant()) .WhereIf(httpStatusCode != null && httpStatusCode > 0, auditLog => auditLog.HttpStatusCode == (int?)httpStatusCode) .WhereIf(maxDuration != null && maxDuration > 0, auditLog => auditLog.ExecutionDuration <= maxDuration) - .WhereIf(minDuration != null && minDuration > 0, auditLog => auditLog.ExecutionDuration >= minDuration); ; + .WhereIf(minDuration != null && minDuration > 0, auditLog => auditLog.ExecutionDuration >= minDuration); } } }