Browse Source

Improve

pull/7359/head
liangshiwei 6 years ago
parent
commit
5a6751f10b
  1. 6
      modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/MongoBackgroundJobRepository.cs
  2. 2
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Contents/MongoContentRepository.cs
  3. 11
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentitySecurityLogRepository.cs
  4. 9
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistedGrantRepository.cs

6
modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/MongoBackgroundJobRepository.cs

@ -24,15 +24,15 @@ namespace Volo.Abp.BackgroundJobs.MongoDB
public virtual async Task<List<BackgroundJobRecord>> GetWaitingListAsync(
int maxResultCount,
CancellationToken cancellationToken)
CancellationToken cancellationToken = default)
{
return await (await GetWaitingListQuery(maxResultCount)).ToListAsync(GetCancellationToken(cancellationToken));
}
protected virtual async Task<IMongoQueryable<BackgroundJobRecord>> GetWaitingListQuery(int maxResultCount)
protected virtual async Task<IMongoQueryable<BackgroundJobRecord>> GetWaitingListQuery(int maxResultCount, CancellationToken cancellationToken = default)
{
var now = Clock.Now;
return (await GetMongoQueryableAsync())
return (await GetMongoQueryableAsync(cancellationToken))
.Where(t => !t.IsAbandoned && t.NextTryTime <= now)
.OrderByDescending(t => t.Priority)
.ThenBy(t => t.TryCount)

2
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Contents/MongoContentRepository.cs

@ -54,7 +54,7 @@ namespace Volo.CmsKit.MongoDB.Contents
public async Task<bool> ExistsAsync([NotNull] string entityType, [NotNull] string entityId, Guid? tenantId = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync()).AnyAsync(x =>
return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x =>
x.EntityType == entityType &&
x.EntityId == entityId &&
x.TenantId == tenantId,

11
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentitySecurityLogRepository.cs

@ -44,7 +44,8 @@ namespace Volo.Abp.Identity.MongoDB
userId,
userName,
clientId,
correlationId
correlationId,
cancellationToken
);
return await query.OrderBy(sorting ?? nameof(IdentitySecurityLog.CreationTime) + " desc")
@ -74,7 +75,8 @@ namespace Volo.Abp.Identity.MongoDB
userId,
userName,
clientId,
correlationId
correlationId,
cancellationToken
);
return await query.As<IMongoQueryable<IdentitySecurityLog>>()
@ -98,9 +100,10 @@ namespace Volo.Abp.Identity.MongoDB
Guid? userId = null,
string userName = null,
string clientId = null,
string correlationId = null)
string correlationId = null,
CancellationToken cancellationToken = default)
{
return (await GetMongoQueryableAsync())
return (await GetMongoQueryableAsync(cancellationToken))
.WhereIf(startTime.HasValue, securityLog => securityLog.CreationTime >= startTime.Value)
.WhereIf(endTime.HasValue, securityLog => securityLog.CreationTime < endTime.Value.AddDays(1).Date)
.WhereIf(!applicationName.IsNullOrWhiteSpace(),

9
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistedGrantRepository.cs

@ -21,7 +21,7 @@ namespace Volo.Abp.IdentityServer.MongoDB
public async Task<List<PersistedGrant>> GetListAsync(string subjectId, string sessionId, string clientId, string type, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await FilterAsync(subjectId, sessionId, clientId, type))
return await (await FilterAsync(subjectId, sessionId, clientId, type, cancellationToken))
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -57,7 +57,7 @@ namespace Volo.Abp.IdentityServer.MongoDB
string type = null,
CancellationToken cancellationToken = default)
{
var persistedGrants = await (await FilterAsync(subjectId, sessionId, clientId, type))
var persistedGrants = await (await FilterAsync(subjectId, sessionId, clientId, type, cancellationToken))
.ToListAsync(GetCancellationToken(cancellationToken));
foreach (var persistedGrant in persistedGrants)
@ -86,9 +86,10 @@ namespace Volo.Abp.IdentityServer.MongoDB
string subjectId,
string sessionId,
string clientId,
string type)
string type,
CancellationToken cancellationToken = default)
{
return (await GetMongoQueryableAsync())
return (await GetMongoQueryableAsync(cancellationToken))
.WhereIf<PersistedGrant, IMongoQueryable<PersistedGrant>>(!subjectId.IsNullOrWhiteSpace(), x => x.SubjectId == subjectId)
.WhereIf<PersistedGrant, IMongoQueryable<PersistedGrant>>(!sessionId.IsNullOrWhiteSpace(), x => x.SessionId == sessionId)
.WhereIf<PersistedGrant, IMongoQueryable<PersistedGrant>>(!clientId.IsNullOrWhiteSpace(), x => x.ClientId == clientId)

Loading…
Cancel
Save