public virtual async Task <List <EntityChange> > GetEntityChangeListAsync( string sorting = null, int maxResultCount = 50, int skipCount = 0, Guid?auditLogId = null, DateTime?startTime = null, DateTime?endTime = null, EntityChangeType?changeType = null, string entityId = null, string entityTypeFullName = null, bool includeDetails = false, CancellationToken cancellationToken = default) { var query = GetEntityChangeListQuery(auditLogId, startTime, endTime, changeType, entityId, entityTypeFullName); var auditLogs = await query.As <IMongoQueryable <AuditLog> >() .PageBy <AuditLog, IMongoQueryable <AuditLog> >(skipCount, maxResultCount) .ToListAsync(GetCancellationToken(cancellationToken)); // TODO: Improve this specification return(auditLogs .SelectMany(x => x.EntityChanges.Where(y => IsSatisfiedEntityChange(y, auditLogId, startTime, endTime, changeType, entityId, entityTypeFullName))) .AsQueryable().OrderBy(sorting ?? "changeTime desc").ToList()); }
public virtual async Task <long> GetEntityChangeCountAsync( Guid?auditLogId = null, DateTime?startTime = null, DateTime?endTime = null, EntityChangeType?changeType = null, string entityId = null, string entityTypeFullName = null, CancellationToken cancellationToken = default) { var query = await GetEntityChangeListQueryAsync(auditLogId, startTime, endTime, changeType, entityId, entityTypeFullName); var totalCount = await query.LongCountAsync(GetCancellationToken(cancellationToken)); return(totalCount); }
protected virtual IQueryable <EntityChange> GetEntityChangeListQuery( Guid?auditLogId = null, DateTime?startTime = null, DateTime?endTime = null, EntityChangeType?changeType = null, string entityId = null, string entityTypeFullName = null, bool includeDetails = false) { return(DbContext.Set <EntityChange>().AsNoTracking().IncludeDetails(includeDetails) .WhereIf(auditLogId.HasValue, e => e.AuditLogId == auditLogId) .WhereIf(startTime.HasValue, e => e.ChangeTime >= startTime) .WhereIf(endTime.HasValue, e => e.ChangeTime <= endTime) .WhereIf(changeType.HasValue, e => e.ChangeType == changeType) .WhereIf(!string.IsNullOrWhiteSpace(entityId), e => e.EntityId == entityId) .WhereIf(!string.IsNullOrWhiteSpace(entityTypeFullName), e => e.EntityTypeFullName.Contains(entityTypeFullName))); }
protected virtual async Task <IQueryable <EntityChange> > GetEntityChangeListQueryAsync( Guid?auditLogId = null, DateTime?startTime = null, DateTime?endTime = null, EntityChangeType?changeType = null, string entityId = null, string entityTypeFullName = null) { return((await GetMongoQueryableAsync()) .SelectMany(x => x.EntityChanges) .WhereIf(auditLogId.HasValue, e => e.Id == auditLogId) .WhereIf(startTime.HasValue, e => e.ChangeTime >= startTime) .WhereIf(endTime.HasValue, e => e.ChangeTime <= endTime) .WhereIf(changeType.HasValue, e => e.ChangeType == changeType) .WhereIf(!string.IsNullOrWhiteSpace(entityId), e => e.EntityId == entityId) .WhereIf(!string.IsNullOrWhiteSpace(entityTypeFullName), e => e.EntityTypeFullName.Contains(entityTypeFullName))); }
protected virtual IQueryable <AuditLog> GetEntityChangeListQuery( Guid?auditLogId = null, DateTime?startTime = null, DateTime?endTime = null, EntityChangeType?changeType = null, string entityId = null, string entityTypeFullName = null) { return(GetMongoQueryable() .Where(x => x.EntityChanges != null) .WhereIf(auditLogId.HasValue, e => e.Id == auditLogId) .WhereIf(startTime.HasValue, e => e.EntityChanges.Any(ec => ec.ChangeTime >= startTime)) .WhereIf(endTime.HasValue, e => e.EntityChanges.Any(ec => ec.ChangeTime >= endTime)) .WhereIf(changeType.HasValue, e => e.EntityChanges.Any(ec => ec.ChangeType == changeType)) .WhereIf(!string.IsNullOrWhiteSpace(entityId), e => e.EntityChanges.Any(ec => ec.EntityId == entityId)) .WhereIf(!string.IsNullOrWhiteSpace(entityTypeFullName), e => e.EntityChanges.Any(ec => ec.EntityTypeFullName.Contains(entityTypeFullName)))); }
public virtual async Task <List <EntityChange> > GetEntityChangeListAsync( string sorting = null, int maxResultCount = 50, int skipCount = 0, Guid?auditLogId = null, DateTime?startTime = null, DateTime?endTime = null, EntityChangeType?changeType = null, string entityId = null, string entityTypeFullName = null, bool includeDetails = false, CancellationToken cancellationToken = default) { var query = await GetEntityChangeListQueryAsync(auditLogId, startTime, endTime, changeType, entityId, entityTypeFullName, includeDetails); return(await query.OrderBy(sorting.IsNullOrWhiteSpace()?(nameof(EntityChange.ChangeTime) + " DESC") : sorting) .PageBy(skipCount, maxResultCount) .ToListAsync(GetCancellationToken(cancellationToken))); }
protected virtual bool IsSatisfiedEntityChange( EntityChange entityChange, Guid?auditLogId = null, DateTime?startTime = null, DateTime?endTime = null, EntityChangeType?changeType = null, string entityId = null, string entityTypeFullName = null) { if (auditLogId != null && auditLogId != entityChange.AuditLogId) { return(false); } if (startTime != null && startTime.Value >= entityChange.ChangeTime) { return(false); } if (endTime != null && endTime.Value <= entityChange.ChangeTime) { return(false); } if (changeType != null && changeType != entityChange.ChangeType) { return(false); } if (entityId != null && entityId != entityChange.EntityId) { return(false); } if (entityTypeFullName != null && entityChange.EntityTypeFullName.Contains(entityTypeFullName)) { return(false); } return(true); }
public virtual async Task <List <EntityChange> > GetEntityChangeListAsync( string sorting = null, int maxResultCount = 50, int skipCount = 0, Guid?auditLogId = null, DateTime?startTime = null, DateTime?endTime = null, EntityChangeType?changeType = null, string entityId = null, string entityTypeFullName = null, bool includeDetails = false, CancellationToken cancellationToken = default) { var query = await GetEntityChangeListQueryAsync(auditLogId, startTime, endTime, changeType, entityId, entityTypeFullName, cancellationToken); return(await query .OrderBy(sorting ?? "changeTime desc") .As <IMongoQueryable <EntityChange> >() .PageBy <EntityChange, IMongoQueryable <EntityChange> >(skipCount, maxResultCount) .ToListAsync(GetCancellationToken(cancellationToken))); }
public Task <long> GetEntityChangeCountAsync(Guid?auditLogId = null, DateTime?startTime = null, DateTime?endTime = null, EntityChangeType?changeType = null, string entityId = null, string entityTypeFullName = null, CancellationToken cancellationToken = default) { throw new NotImplementedException(); }
public Task <List <EntityChange> > GetEntityChangeListAsync(string sorting = null, int maxResultCount = 50, int skipCount = 0, Guid?auditLogId = null, DateTime?startTime = null, DateTime?endTime = null, EntityChangeType?changeType = null, string entityId = null, string entityTypeFullName = null, bool includeDetails = false) { throw new NotImplementedException(); }