Browse Source

Added startTime & endTime on IAuditLogRepository.

pull/1810/head
Halil İbrahim Kalkan 7 years ago
parent
commit
65c05a885d
  1. 4
      modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/IAuditLogRepository.cs
  2. 53
      modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs
  3. 56
      modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs
  4. 3
      modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs

4
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<long> GetCountAsync(
DateTime? startTime = null,
DateTime? endTime = null,
string httpMethod = null,
string url = null,
string userName = null,

53
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<long> 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<AuditLog> 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<AuditLog> WithDetails()

56
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<IMongoQueryable<AuditLog>>()
.PageBy<AuditLog, IMongoQueryable<AuditLog>>(skipCount, maxResultCount)
.ToListAsync();
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> 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<IMongoQueryable<AuditLog>>().LongCountAsync();
var count = await query.As<IMongoQueryable<AuditLog>>()
.LongCountAsync(GetCancellationToken(cancellationToken));
return count;
}
private IQueryable<AuditLog> 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);

3
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<VirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<VoloDocsWebModule>("VoloDocs.Web");

Loading…
Cancel
Save