|
|
|
|
@ -34,6 +34,20 @@ namespace Volo.Docs.Documents
|
|
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<DocumentInfo>> GetUniqueListDocumentInfoAsync(CancellationToken cancellationToken = default)
|
|
|
|
|
{
|
|
|
|
|
return await (await GetMongoQueryableAsync(cancellationToken))
|
|
|
|
|
.Select(x=> new DocumentInfo {
|
|
|
|
|
ProjectId = x.ProjectId,
|
|
|
|
|
Version = x.Version,
|
|
|
|
|
LanguageCode = x.LanguageCode,
|
|
|
|
|
Format = x.Format
|
|
|
|
|
})
|
|
|
|
|
.Distinct()
|
|
|
|
|
.OrderByDescending(x=>x.Version)
|
|
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<Document>> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default)
|
|
|
|
|
{
|
|
|
|
|
return await (await GetMongoQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken));
|
|
|
|
|
@ -88,22 +102,21 @@ namespace Volo.Docs.Documents
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return await
|
|
|
|
|
ApplyFilterForGetAll(
|
|
|
|
|
(await ApplyFilterForGetAll(
|
|
|
|
|
await GetMongoQueryableAsync(cancellationToken),
|
|
|
|
|
projectId: projectId,
|
|
|
|
|
name: name,
|
|
|
|
|
version: version,
|
|
|
|
|
languageCode: languageCode,
|
|
|
|
|
format: format,
|
|
|
|
|
fileName: fileName,
|
|
|
|
|
format: format,
|
|
|
|
|
creationTimeMin: creationTimeMin,
|
|
|
|
|
creationTimeMax: creationTimeMax,
|
|
|
|
|
lastUpdatedTimeMin: lastUpdatedTimeMin,
|
|
|
|
|
lastUpdatedTimeMax: lastUpdatedTimeMax,
|
|
|
|
|
lastSignificantUpdateTimeMin: lastSignificantUpdateTimeMin,
|
|
|
|
|
lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax,
|
|
|
|
|
lastCachedTimeMin: lastCachedTimeMin,
|
|
|
|
|
lastCachedTimeMax: lastCachedTimeMax)
|
|
|
|
|
lastCachedTimeMin: lastCachedTimeMin, lastCachedTimeMax: lastCachedTimeMax))
|
|
|
|
|
.OrderBy(string.IsNullOrWhiteSpace(sorting) ? "name asc" : sorting).As<IMongoQueryable<DocumentWithoutContent>>()
|
|
|
|
|
.PageBy<DocumentWithoutContent, IMongoQueryable<DocumentWithoutContent>>(skipCount, maxResultCount)
|
|
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken));
|
|
|
|
|
@ -132,22 +145,21 @@ namespace Volo.Docs.Documents
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await
|
|
|
|
|
ApplyFilterForGetAll(
|
|
|
|
|
(await ApplyFilterForGetAll(
|
|
|
|
|
await GetMongoQueryableAsync(cancellationToken),
|
|
|
|
|
projectId: projectId,
|
|
|
|
|
name: name,
|
|
|
|
|
version: version,
|
|
|
|
|
languageCode: languageCode,
|
|
|
|
|
format: format,
|
|
|
|
|
fileName: fileName,
|
|
|
|
|
format: format,
|
|
|
|
|
creationTimeMin: creationTimeMin,
|
|
|
|
|
creationTimeMax: creationTimeMax,
|
|
|
|
|
lastUpdatedTimeMin: lastUpdatedTimeMin,
|
|
|
|
|
lastUpdatedTimeMax: lastUpdatedTimeMax,
|
|
|
|
|
lastSignificantUpdateTimeMin: lastSignificantUpdateTimeMin,
|
|
|
|
|
lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax,
|
|
|
|
|
lastCachedTimeMin: lastCachedTimeMin,
|
|
|
|
|
lastCachedTimeMax: lastCachedTimeMax)
|
|
|
|
|
lastCachedTimeMin: lastCachedTimeMin, lastCachedTimeMax: lastCachedTimeMax))
|
|
|
|
|
.OrderBy(string.IsNullOrWhiteSpace(sorting) ? "name asc" : sorting).As<IMongoQueryable<Document>>()
|
|
|
|
|
.PageBy<Document, IMongoQueryable<Document>>(skipCount, maxResultCount)
|
|
|
|
|
.LongCountAsync(GetCancellationToken(cancellationToken));
|
|
|
|
|
@ -157,8 +169,8 @@ namespace Volo.Docs.Documents
|
|
|
|
|
{
|
|
|
|
|
return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.Id == id).SingleAsync(GetCancellationToken(cancellationToken));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual IMongoQueryable<DocumentWithoutContent> ApplyFilterForGetAll(
|
|
|
|
|
|
|
|
|
|
protected virtual async Task<IMongoQueryable<DocumentWithoutContent>> ApplyFilterForGetAll(
|
|
|
|
|
IMongoQueryable<Document> query,
|
|
|
|
|
Guid? projectId,
|
|
|
|
|
string name,
|
|
|
|
|
@ -200,6 +212,11 @@ namespace Volo.Docs.Documents
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(d => d.FileName != null && d.FileName.Contains(fileName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (format != null)
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(d => d.Format != null && d.Format == format);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (creationTimeMin.HasValue)
|
|
|
|
|
{
|
|
|
|
|
@ -240,20 +257,25 @@ namespace Volo.Docs.Documents
|
|
|
|
|
{
|
|
|
|
|
query = query.Where(d => d.LastCachedTime.Date <= lastCachedTimeMax.Value.Date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return query.Select(x => new DocumentWithoutContent
|
|
|
|
|
var join = query.Join(
|
|
|
|
|
(await GetDbContextAsync(cancellationToken)).Projects,
|
|
|
|
|
d => d.ProjectId,
|
|
|
|
|
p => p.Id,
|
|
|
|
|
(d, p) => new { Document = d, Project = p });
|
|
|
|
|
return join.Select(x => new DocumentWithoutContent
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
ProjectId = x.ProjectId,
|
|
|
|
|
Name = x.Name,
|
|
|
|
|
Version = x.Version,
|
|
|
|
|
LanguageCode = x.LanguageCode,
|
|
|
|
|
FileName = x.FileName,
|
|
|
|
|
Format = x.Format,
|
|
|
|
|
CreationTime = x.CreationTime,
|
|
|
|
|
LastUpdatedTime = x.LastUpdatedTime,
|
|
|
|
|
LastSignificantUpdateTime = x.LastSignificantUpdateTime,
|
|
|
|
|
LastCachedTime = x.LastCachedTime
|
|
|
|
|
Id = x.Document.Id,
|
|
|
|
|
ProjectId = x.Document.ProjectId,
|
|
|
|
|
ProjectName = x.Project.Name,
|
|
|
|
|
Name = x.Document.Name,
|
|
|
|
|
Version = x.Document.Version,
|
|
|
|
|
LanguageCode = x.Document.LanguageCode,
|
|
|
|
|
FileName = x.Document.FileName,
|
|
|
|
|
Format = x.Document.Format,
|
|
|
|
|
CreationTime = x.Document.CreationTime,
|
|
|
|
|
LastUpdatedTime = x.Document.LastUpdatedTime,
|
|
|
|
|
LastSignificantUpdateTime = x.Document.LastSignificantUpdateTime,
|
|
|
|
|
LastCachedTime = x.Document.LastCachedTime
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|