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 e94eee3d88..1da98f36aa 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 @@ -13,6 +13,8 @@ namespace Volo.Abp.AuditLogging string sorting = null, int maxResultCount = 50, int skipCount = 0, + DateTime? startTime = null, + DateTime? endTime = null, string httpMethod = null, string url = null, string userName = null, @@ -26,6 +28,8 @@ namespace Volo.Abp.AuditLogging CancellationToken cancellationToken = default); Task GetCountAsync( + DateTime? startTime = null, + DateTime? endTime = null, string httpMethod = null, string url = null, string userName = null, 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 ff49909f84..c60dfcc4d7 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 @@ -23,6 +23,8 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore string sorting = null, int maxResultCount = 50, int skipCount = 0, + DateTime? startTime = null, + DateTime? endTime = null, string httpMethod = null, string url = null, string userName = null, @@ -35,7 +37,20 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore bool includeDetails = false, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxExecutionDuration, minExecutionDuration, hasException, httpStatusCode, includeDetails); + var query = GetListQuery( + startTime, + endTime, + httpMethod, + url, + userName, + applicationName, + correlationId, + maxExecutionDuration, + minExecutionDuration, + hasException, + httpStatusCode, + includeDetails + ); var auditLogs = await query.OrderBy(sorting ?? "executionTime desc") .PageBy(skipCount, maxResultCount) @@ -45,6 +60,8 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore } public async Task GetCountAsync( + DateTime? startTime = null, + DateTime? endTime = null, string httpMethod = null, string url = null, string userName = null, @@ -56,7 +73,19 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore HttpStatusCode? httpStatusCode = null, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxExecutionDuration, minExecutionDuration, hasException, httpStatusCode); + var query = GetListQuery( + startTime, + endTime, + httpMethod, + url, + userName, + applicationName, + correlationId, + maxExecutionDuration, + minExecutionDuration, + hasException, + httpStatusCode + ); var totalCount = await query.LongCountAsync(GetCancellationToken(cancellationToken)); @@ -64,6 +93,8 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore } private IQueryable GetListQuery( + DateTime? startTime = null, + DateTime? endTime = null, string httpMethod = null, string url = null, string userName = null, @@ -77,16 +108,18 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore { 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 == httpMethod) + .WhereIf(startTime.HasValue, auditLog => auditLog.ExecutionTime >= startTime) + .WhereIf(endTime.HasValue, auditLog => auditLog.ExecutionTime <= endTime) + .WhereIf(hasException.HasValue && hasException.Value, auditLog => auditLog.Exceptions != null) + .WhereIf(hasException.HasValue && !hasException.Value, auditLog => auditLog.Exceptions == null) + .WhereIf(httpMethod != null, auditLog => auditLog.HttpMethod == httpMethod) .WhereIf(url != null, auditLog => auditLog.Url != null && auditLog.Url.Contains(url)) - .WhereIf(userName != null, auditLog => auditLog.UserName != null && auditLog.UserName == userName) - .WhereIf(applicationName != null, auditLog => auditLog.ApplicationName != null && auditLog.ApplicationName == applicationName) - .WhereIf(correlationId != null, auditLog => auditLog.CorrelationId != null && auditLog.CorrelationId == correlationId) + .WhereIf(userName != null, auditLog => auditLog.UserName == userName) + .WhereIf(applicationName != null, auditLog => auditLog.ApplicationName == applicationName) + .WhereIf(correlationId != null, auditLog => auditLog.CorrelationId == correlationId) .WhereIf(httpStatusCode != null && httpStatusCode > 0, auditLog => auditLog.HttpStatusCode == (int?)httpStatusCode) - .WhereIf(maxExecutionDuration != null && maxExecutionDuration > 0, auditLog => auditLog.ExecutionDuration <= maxExecutionDuration) - .WhereIf(minExecutionDuration != null && minExecutionDuration > 0, auditLog => auditLog.ExecutionDuration >= minExecutionDuration); + .WhereIf(maxExecutionDuration != null && maxExecutionDuration.Value > 0, auditLog => auditLog.ExecutionDuration <= maxExecutionDuration) + .WhereIf(minExecutionDuration != null && minExecutionDuration.Value > 0, auditLog => auditLog.ExecutionDuration >= minExecutionDuration); } public override IQueryable WithDetails() 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 f70bd1deaf..cead3fa2a9 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 @@ -24,6 +24,8 @@ namespace Volo.Abp.AuditLogging.MongoDB string sorting = null, int maxResultCount = 50, int skipCount = 0, + DateTime? startTime = null, + DateTime? endTime = null, string httpMethod = null, string url = null, string userName = null, @@ -36,14 +38,29 @@ namespace Volo.Abp.AuditLogging.MongoDB bool includeDetails = false, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxDuration, minDuration, hasException, httpStatusCode, includeDetails); + var query = GetListQuery( + startTime, + endTime, + httpMethod, + url, + userName, + applicationName, + correlationId, + maxDuration, + minDuration, + hasException, + httpStatusCode, + includeDetails + ); return await query.OrderBy(sorting ?? "executionTime desc").As>() .PageBy>(skipCount, maxResultCount) - .ToListAsync(); + .ToListAsync(GetCancellationToken(cancellationToken)); } public async Task GetCountAsync( + DateTime? startTime = null, + DateTime? endTime = null, string httpMethod = null, string url = null, string userName = null, @@ -55,14 +72,29 @@ namespace Volo.Abp.AuditLogging.MongoDB HttpStatusCode? httpStatusCode = null, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxDuration, minDuration, hasException, httpStatusCode); + var query = GetListQuery( + startTime, + endTime, + httpMethod, + url, + userName, + applicationName, + correlationId, + maxDuration, + minDuration, + hasException, + httpStatusCode + ); - var count = await query.As>().LongCountAsync(); + var count = await query.As>() + .LongCountAsync(GetCancellationToken(cancellationToken)); return count; } private IQueryable GetListQuery( + DateTime? startTime = null, + DateTime? endTime = null, string httpMethod = null, string url = null, string userName = null, @@ -75,13 +107,15 @@ namespace Volo.Abp.AuditLogging.MongoDB 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()) - .WhereIf(applicationName != null, auditLog => auditLog.ApplicationName != null && auditLog.ApplicationName.ToLowerInvariant() == applicationName.ToLowerInvariant()) - .WhereIf(correlationId != null, auditLog => auditLog.CorrelationId != null && auditLog.CorrelationId.ToLowerInvariant() == correlationId.ToLowerInvariant()) + .WhereIf(startTime.HasValue, auditLog => auditLog.ExecutionTime >= startTime) + .WhereIf(endTime.HasValue, auditLog => auditLog.ExecutionTime <= endTime) + .WhereIf(hasException.HasValue && hasException.Value, auditLog => auditLog.Exceptions != null) + .WhereIf(hasException.HasValue && !hasException.Value, auditLog => auditLog.Exceptions == null) + .WhereIf(httpMethod != null, auditLog => auditLog.HttpMethod == httpMethod) + .WhereIf(url != null, auditLog => auditLog.Url != null && auditLog.Url.Contains(url)) + .WhereIf(userName != null, auditLog => auditLog.UserName == userName) + .WhereIf(applicationName != null, auditLog => auditLog.ApplicationName == applicationName) + .WhereIf(correlationId != null, auditLog => auditLog.CorrelationId == correlationId) .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); diff --git a/modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs b/modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs index 3f6d0936f5..3402f62622 100644 --- a/modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs +++ b/modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs @@ -103,8 +103,7 @@ namespace VoloDocs.Web options.DocInclusionPredicate((docName, description) => true); options.CustomSchemaIds(type => type.FullName); }); - - + Configure(options => { options.FileSets.AddEmbedded("VoloDocs.Web");