零时方案修改
parent
e6a909bba0
commit
be3dde7657
|
@ -60,7 +60,7 @@ namespace IRaCIS.Core.Application.Services
|
||||||
var trialDocumentQueryable = _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == queryTrialDocument.TrialId)
|
var trialDocumentQueryable = _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == queryTrialDocument.TrialId)
|
||||||
.WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Name), t => t.Name.Contains(queryTrialDocument.Name))
|
.WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Name), t => t.Name.Contains(queryTrialDocument.Name))
|
||||||
.WhereIf(queryTrialDocument.FileTypeId != null, t => t.FileTypeId == queryTrialDocument.FileTypeId)
|
.WhereIf(queryTrialDocument.FileTypeId != null, t => t.FileTypeId == queryTrialDocument.FileTypeId)
|
||||||
.ProjectTo<TrialDocumentView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, isEn_Us=_userInfo.IsEn_Us });
|
.ProjectTo<TrialDocumentView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, isEn_Us = _userInfo.IsEn_Us });
|
||||||
|
|
||||||
return await trialDocumentQueryable.ToPagedListAsync(queryTrialDocument.PageIndex, queryTrialDocument.PageSize, queryTrialDocument.SortField, queryTrialDocument.Asc);
|
return await trialDocumentQueryable.ToPagedListAsync(queryTrialDocument.PageIndex, queryTrialDocument.PageSize, queryTrialDocument.SortField, queryTrialDocument.Asc);
|
||||||
}
|
}
|
||||||
|
@ -74,12 +74,12 @@ namespace IRaCIS.Core.Application.Services
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<UnionDocumentWithConfirmInfoView?> GetNextUnSignDocument(GetNextUnSignDocumentInDto inDto)
|
public async Task<UnionDocumentWithConfirmInfoView?> GetNextUnSignDocument(GetNextUnSignDocumentInDto inDto)
|
||||||
{
|
{
|
||||||
var result =await this.GetUserDocumentList(new TrialUserDocUnionQuery()
|
var result = await this.GetUserDocumentList(new TrialUserDocUnionQuery()
|
||||||
{
|
{
|
||||||
Asc = inDto.Asc,
|
Asc = inDto.Asc,
|
||||||
IsSign = false,
|
IsSign = false,
|
||||||
SortField = inDto.SortField,
|
SortField = inDto.SortField,
|
||||||
TrialId= inDto.TrialId,
|
TrialId = inDto.TrialId,
|
||||||
PageIndex = 1,
|
PageIndex = 1,
|
||||||
PageSize = 1,
|
PageSize = 1,
|
||||||
});
|
});
|
||||||
|
@ -88,7 +88,8 @@ namespace IRaCIS.Core.Application.Services
|
||||||
{
|
{
|
||||||
return result.Data.CurrentPageData.First();
|
return result.Data.CurrentPageData.First();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ namespace IRaCIS.Core.Application.Services
|
||||||
/// <param name="querySystemDocument"></param>
|
/// <param name="querySystemDocument"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task< IResponseOutput<PageOutput<UnionDocumentWithConfirmInfoView>> > GetUserDocumentList(TrialUserDocUnionQuery querySystemDocument)
|
public async Task<IResponseOutput<PageOutput<UnionDocumentWithConfirmInfoView>>> GetUserDocumentList(TrialUserDocUnionQuery querySystemDocument)
|
||||||
{
|
{
|
||||||
#region https://github.com/dotnet/efcore/issues/16243 操作不行
|
#region https://github.com/dotnet/efcore/issues/16243 操作不行
|
||||||
////系统文档查询
|
////系统文档查询
|
||||||
|
@ -164,7 +165,7 @@ namespace IRaCIS.Core.Application.Services
|
||||||
|
|
||||||
var trialId = querySystemDocument.TrialId;
|
var trialId = querySystemDocument.TrialId;
|
||||||
|
|
||||||
var trialInfo = await (_repository.Where<Trial>(t => t.Id == querySystemDocument.TrialId).Select(t => new { t.TrialFinishedTime,t.TrialStatusStr } ).FirstOrDefaultAsync());
|
var trialInfo = await (_repository.Where<Trial>(t => t.Id == querySystemDocument.TrialId).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstOrDefaultAsync());
|
||||||
|
|
||||||
//系统文档查询
|
//系统文档查询
|
||||||
var systemDocumentQueryable = from needConfirmedUserType in _repository.Where<SystemDocNeedConfirmedUserType>(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)
|
var systemDocumentQueryable = from needConfirmedUserType in _repository.Where<SystemDocNeedConfirmedUserType>(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)
|
||||||
|
@ -187,10 +188,10 @@ namespace IRaCIS.Core.Application.Services
|
||||||
Name = needConfirmedUserType.SystemDocument.Name,
|
Name = needConfirmedUserType.SystemDocument.Name,
|
||||||
Path = needConfirmedUserType.SystemDocument.Path,
|
Path = needConfirmedUserType.SystemDocument.Path,
|
||||||
FileTypeId = needConfirmedUserType.SystemDocument.FileTypeId,
|
FileTypeId = needConfirmedUserType.SystemDocument.FileTypeId,
|
||||||
FileType = _userInfo.IsEn_Us? needConfirmedUserType.SystemDocument.FileType.Value: needConfirmedUserType.SystemDocument.FileType.ValueCN,
|
FileType = _userInfo.IsEn_Us ? needConfirmedUserType.SystemDocument.FileType.Value : needConfirmedUserType.SystemDocument.FileType.ValueCN,
|
||||||
UpdateTime = needConfirmedUserType.SystemDocument.UpdateTime,
|
UpdateTime = needConfirmedUserType.SystemDocument.UpdateTime,
|
||||||
|
|
||||||
FullFilePath = needConfirmedUserType.SystemDocument.Path ,
|
FullFilePath = needConfirmedUserType.SystemDocument.Path,
|
||||||
|
|
||||||
ConfirmUserId = confirm.ConfirmUserId,
|
ConfirmUserId = confirm.ConfirmUserId,
|
||||||
ConfirmTime = confirm.ConfirmTime,
|
ConfirmTime = confirm.ConfirmTime,
|
||||||
|
@ -214,12 +215,12 @@ namespace IRaCIS.Core.Application.Services
|
||||||
Id = trialDoc.Id,
|
Id = trialDoc.Id,
|
||||||
IsSystemDoc = false,
|
IsSystemDoc = false,
|
||||||
CreateTime = trialDoc.CreateTime,
|
CreateTime = trialDoc.CreateTime,
|
||||||
FullFilePath = trialDoc.Path ,
|
FullFilePath = trialDoc.Path,
|
||||||
IsDeleted = trialDoc.IsDeleted,
|
IsDeleted = trialDoc.IsDeleted,
|
||||||
Name = trialDoc.Name,
|
Name = trialDoc.Name,
|
||||||
Path = trialDoc.Path,
|
Path = trialDoc.Path,
|
||||||
FileTypeId = trialDoc.FileTypeId,
|
FileTypeId = trialDoc.FileTypeId,
|
||||||
FileType = _userInfo.IsEn_Us ? trialDoc.FileType.Value: trialDoc.FileType.ValueCN,
|
FileType = _userInfo.IsEn_Us ? trialDoc.FileType.Value : trialDoc.FileType.ValueCN,
|
||||||
UpdateTime = trialDoc.UpdateTime,
|
UpdateTime = trialDoc.UpdateTime,
|
||||||
SignViewMinimumMinutes = trialDoc.SignViewMinimumMinutes,
|
SignViewMinimumMinutes = trialDoc.SignViewMinimumMinutes,
|
||||||
|
|
||||||
|
@ -232,18 +233,44 @@ namespace IRaCIS.Core.Application.Services
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#region 报错 奇怪的bug
|
||||||
|
//var unionQuery = systemDocumentQueryable.Union(trialDocQueryable)
|
||||||
|
// .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
|
||||||
|
// .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId)
|
||||||
|
// .WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null)
|
||||||
|
// .WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null);
|
||||||
|
|
||||||
var unionQuery = systemDocumentQueryable.Union(trialDocQueryable)
|
|
||||||
|
|
||||||
|
//var result = await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 临时方案
|
||||||
|
|
||||||
|
var list1 = systemDocumentQueryable
|
||||||
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
|
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
|
||||||
.WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId)
|
.WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId)
|
||||||
.WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null)
|
.WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null)
|
||||||
.WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null);
|
.WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null).ToList();
|
||||||
|
|
||||||
var result = await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
|
var list2 = trialDocQueryable
|
||||||
|
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
|
||||||
|
.WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId)
|
||||||
|
.WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null)
|
||||||
|
.WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null).ToList();
|
||||||
|
|
||||||
var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId== querySystemDocument.TrialId && t.Trial.TrialStatusStr != StaticData.TrialState.TrialStopped)
|
var list3 = list1.Union(list2).ToList();
|
||||||
|
|
||||||
|
var result=list3.ToPagedList(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == querySystemDocument.TrialId && t.Trial.TrialStatusStr != StaticData.TrialState.TrialStopped)
|
||||||
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id))
|
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id))
|
||||||
.Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id && t.ConfirmTime!=null) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
.Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id && t.ConfirmTime != null) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||||
.CountAsync();
|
.CountAsync();
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,15 +281,12 @@ namespace IRaCIS.Core.Application.Services
|
||||||
var trialTaskConfig = _trialRepository.Where(t => t.Id == querySystemDocument.TrialId).ProjectTo<TrialProcessConfigDTO>(_mapper.ConfigurationProvider).FirstOrDefault();
|
var trialTaskConfig = _trialRepository.Where(t => t.Id == querySystemDocument.TrialId).ProjectTo<TrialProcessConfigDTO>(_mapper.ConfigurationProvider).FirstOrDefault();
|
||||||
|
|
||||||
|
|
||||||
//var trialCriterionAdditionalAssessmentTypeList = _trialCriterionAdditionalAssessmentTypeRepository
|
|
||||||
// .Where(t => t.TrialReadingCriterion.TrialId == trialId && t.IsSelected == true && t.TrialReadingCriterion.IsSigned).Select(t=>new { t.CriterionType,t.AdditionalAssessmentType}).ToList();
|
|
||||||
|
|
||||||
|
var isManualGenerateTask = _readingQuestionCriterionTrialRepository.Where(t => t.TrialId == trialId && t.IsSigned && t.IsAutoCreate == false).Any();
|
||||||
var isManualGenerateTask= _readingQuestionCriterionTrialRepository.Where(t=>t.TrialId==trialId && t.IsSigned && t.IsAutoCreate==false).Any();
|
|
||||||
var isAdditionalAssessment = _readingQuestionCriterionTrialRepository.Where(t => t.TrialId == trialId && t.IsSigned && t.IsAdditionalAssessment == true
|
var isAdditionalAssessment = _readingQuestionCriterionTrialRepository.Where(t => t.TrialId == trialId && t.IsSigned && t.IsAdditionalAssessment == true
|
||||||
&&t.TrialCriterionAdditionalAssessmentTypeList.Any(c=>/*c.AdditionalAssessmentType==Domain.Share.Reading.AdditionalAssessmentType.BrainMetastasis &&*/ c.IsSelected==true)).Any();
|
&& t.TrialCriterionAdditionalAssessmentTypeList.Any(c =>/*c.AdditionalAssessmentType==Domain.Share.Reading.AdditionalAssessmentType.BrainMetastasis &&*/ c.IsSelected == true)).Any();
|
||||||
|
|
||||||
return ResponseOutput.Ok<PageOutput<UnionDocumentWithConfirmInfoView>>( result, new { NeedSignCount = needSignTrialDocCount + needSignSystemDocCount, NeedSignTrialDocCount = needSignTrialDocCount, NeedSignSystemDocCount = needSignSystemDocCount, IsAdditionalAssessment = isAdditionalAssessment && isManualGenerateTask, TrialStatusStr = trialInfo.TrialStatusStr,TrialConfig= trialTaskConfig });
|
return ResponseOutput.Ok<PageOutput<UnionDocumentWithConfirmInfoView>>(result, new { NeedSignCount = needSignTrialDocCount + needSignSystemDocCount, NeedSignTrialDocCount = needSignTrialDocCount, NeedSignSystemDocCount = needSignSystemDocCount, IsAdditionalAssessment = isAdditionalAssessment && isManualGenerateTask, TrialStatusStr = trialInfo.TrialStatusStr, TrialConfig = trialTaskConfig });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,7 +298,7 @@ namespace IRaCIS.Core.Application.Services
|
||||||
/// <param name="querySystemDocument"></param>
|
/// <param name="querySystemDocument"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<(PageOutput<UnionDocumentWithConfirmInfoView>,object)> GetDocumentConfirmList(DocumentTrialUnionQuery querySystemDocument)
|
public async Task<(PageOutput<UnionDocumentWithConfirmInfoView>, object)> GetDocumentConfirmList(DocumentTrialUnionQuery querySystemDocument)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
@ -400,7 +424,7 @@ namespace IRaCIS.Core.Application.Services
|
||||||
.CountAsync();
|
.CountAsync();
|
||||||
|
|
||||||
|
|
||||||
return (result, new { NeedSignCount = needSignTrialDocCount + needSignSystemDocCount, NeedSignTrialDocCount = needSignTrialDocCount, NeedSignSystemDocCount = needSignSystemDocCount,TrialStatusStr = trialInfo.TrialStatusStr });
|
return (result, new { NeedSignCount = needSignTrialDocCount + needSignSystemDocCount, NeedSignTrialDocCount = needSignTrialDocCount, NeedSignSystemDocCount = needSignSystemDocCount, TrialStatusStr = trialInfo.TrialStatusStr });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -426,7 +450,7 @@ namespace IRaCIS.Core.Application.Services
|
||||||
[HttpGet("{trialId:guid}")]
|
[HttpGet("{trialId:guid}")]
|
||||||
public async Task<IResponseOutput> GetTrialDocAndSystemDocType(Guid trialId)
|
public async Task<IResponseOutput> GetTrialDocAndSystemDocType(Guid trialId)
|
||||||
{
|
{
|
||||||
var result = await _trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => new { FileType = _userInfo.IsEn_Us? t.FileType.Value :t.FileType.ValueCN, t.FileTypeId })
|
var result = await _trialDocumentRepository.Where(t => t.TrialId == trialId).Select(t => new { FileType = _userInfo.IsEn_Us ? t.FileType.Value : t.FileType.ValueCN, t.FileTypeId })
|
||||||
.Union(_systemDocumentRepository.Select(t => new { FileType = _userInfo.IsEn_Us ? t.FileType.Value : t.FileType.ValueCN, t.FileTypeId }))
|
.Union(_systemDocumentRepository.Select(t => new { FileType = _userInfo.IsEn_Us ? t.FileType.Value : t.FileType.ValueCN, t.FileTypeId }))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
@ -534,7 +558,7 @@ namespace IRaCIS.Core.Application.Services
|
||||||
var success = false;
|
var success = false;
|
||||||
if (isSystemDoc)
|
if (isSystemDoc)
|
||||||
{
|
{
|
||||||
if(!await _systemDocConfirmedUserRepository.AnyAsync(t=>t.SystemDocumentId==documentId && t.ConfirmUserId == _userInfo.Id))
|
if (!await _systemDocConfirmedUserRepository.AnyAsync(t => t.SystemDocumentId == documentId && t.ConfirmUserId == _userInfo.Id))
|
||||||
{
|
{
|
||||||
await _repository.AddAsync(new SystemDocConfirmedUser() { SystemDocumentId = documentId, ConfirmUserId = _userInfo.Id, SignFirstViewTime = DateTime.Now });
|
await _repository.AddAsync(new SystemDocConfirmedUser() { SystemDocumentId = documentId, ConfirmUserId = _userInfo.Id, SignFirstViewTime = DateTime.Now });
|
||||||
|
|
||||||
|
@ -598,9 +622,9 @@ namespace IRaCIS.Core.Application.Services
|
||||||
if (userConfirmCommand.isSystemDoc)
|
if (userConfirmCommand.isSystemDoc)
|
||||||
{
|
{
|
||||||
|
|
||||||
var sysDocConfirm = await _systemDocConfirmedUserRepository.FirstOrDefaultAsync(t => t.SystemDocumentId == userConfirmCommand.DocumentId && t.ConfirmUserId == _userInfo.Id,true);
|
var sysDocConfirm = await _systemDocConfirmedUserRepository.FirstOrDefaultAsync(t => t.SystemDocumentId == userConfirmCommand.DocumentId && t.ConfirmUserId == _userInfo.Id, true);
|
||||||
|
|
||||||
if(sysDocConfirm.ConfirmTime != null)
|
if (sysDocConfirm.ConfirmTime != null)
|
||||||
{
|
{
|
||||||
//---该文件已经签名
|
//---该文件已经签名
|
||||||
return ResponseOutput.NotOk(_localizer["TrialD_FileAlreadySigned"]);
|
return ResponseOutput.NotOk(_localizer["TrialD_FileAlreadySigned"]);
|
||||||
|
@ -730,7 +754,7 @@ namespace IRaCIS.Core.Application.Services
|
||||||
Id = t.Id,
|
Id = t.Id,
|
||||||
IsSystemDoc = true,
|
IsSystemDoc = true,
|
||||||
CreateTime = t.CreateTime,
|
CreateTime = t.CreateTime,
|
||||||
FullFilePath = t.Path ,
|
FullFilePath = t.Path,
|
||||||
IsDeleted = t.IsDeleted,
|
IsDeleted = t.IsDeleted,
|
||||||
Name = t.Name,
|
Name = t.Name,
|
||||||
Path = t.Path,
|
Path = t.Path,
|
||||||
|
@ -748,7 +772,7 @@ namespace IRaCIS.Core.Application.Services
|
||||||
Id = t.Id,
|
Id = t.Id,
|
||||||
IsSystemDoc = false,
|
IsSystemDoc = false,
|
||||||
CreateTime = t.CreateTime,
|
CreateTime = t.CreateTime,
|
||||||
FullFilePath = t.Path ,
|
FullFilePath = t.Path,
|
||||||
IsDeleted = t.IsDeleted,
|
IsDeleted = t.IsDeleted,
|
||||||
Name = t.Name,
|
Name = t.Name,
|
||||||
Path = t.Path,
|
Path = t.Path,
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
<PackageReference Include="EFCore.BulkExtensions" Version="6.5.6" />
|
<PackageReference Include="EFCore.BulkExtensions" Version="6.5.6" />
|
||||||
<PackageReference Include="EntityFrameworkCore.Triggered" Version="3.2.1" />
|
<PackageReference Include="EntityFrameworkCore.Triggered" Version="3.2.1" />
|
||||||
<PackageReference Include="EntityFrameworkCore.Projectables" Version="2.3.0" />
|
<PackageReference Include="EntityFrameworkCore.Projectables" Version="2.3.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.10" />
|
|
||||||
<PackageReference Include="EntityFrameworkCore.Exceptions.SqlServer" Version="6.0.3.2" />
|
<PackageReference Include="EntityFrameworkCore.Exceptions.SqlServer" Version="6.0.3.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||||
|
|
|
@ -257,11 +257,6 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Linq.Dynamic.Core;
|
using System.Linq.Dynamic.Core;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infrastructure.Extention
|
namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
{
|
{
|
||||||
|
@ -23,7 +25,7 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
return new PageOutput<T>() { CurrentPageData=new T[0] };
|
return new PageOutput<T>() { CurrentPageData = new T[0] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,10 +51,10 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
}
|
}
|
||||||
|
|
||||||
//单字段排序 异步
|
//单字段排序 异步
|
||||||
public static async Task<PageOutput<T>> ToPagedListAsync<T>(this IQueryable<T> source, int pageNumber, int pageSize, string defaultSortFiled = "Id", bool isAsc = true,bool isMultiSortFiled=false, string[] sortArray=default, CancellationToken cancellationToken = default)
|
public static async Task<PageOutput<T>> ToPagedListAsync<T>(this IQueryable<T> source, int pageNumber, int pageSize, string defaultSortFiled = "Id", bool isAsc = true, bool isMultiSortFiled = false, string[] sortArray = default, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (isMultiSortFiled&& sortArray==default)
|
if (isMultiSortFiled && sortArray == default)
|
||||||
{
|
{
|
||||||
throw new System.Exception("The sort field must be specified");
|
throw new System.Exception("The sort field must be specified");
|
||||||
}
|
}
|
||||||
|
@ -83,7 +85,7 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
{
|
{
|
||||||
var sortString = string.Join(',', sortArray);
|
var sortString = string.Join(',', sortArray);
|
||||||
|
|
||||||
source= source.OrderBy(sortString);
|
source = source.OrderBy(sortString);
|
||||||
}
|
}
|
||||||
source = source.Skip((pageNumber - 1) * pageSize);
|
source = source.Skip((pageNumber - 1) * pageSize);
|
||||||
var items = await source
|
var items = await source
|
||||||
|
@ -102,8 +104,47 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
return pagedList;
|
return pagedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static PageOutput<T> ToPagedList<T>(this IList<T> source, int pageIndex, int pageSize, string defaultSortFiled = "Id", bool isAsc = true)
|
||||||
|
{
|
||||||
|
if (pageIndex <= 0)
|
||||||
|
{
|
||||||
|
pageIndex = 1;
|
||||||
|
}
|
||||||
|
if (pageSize <= 0)
|
||||||
|
{
|
||||||
|
pageSize = 10;
|
||||||
|
}
|
||||||
|
var count = source.Count();
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
return new PageOutput<T>() { CurrentPageData = new List<T>() };
|
||||||
|
}
|
||||||
|
|
||||||
|
var propName = string.IsNullOrWhiteSpace(defaultSortFiled) ? "Id" : defaultSortFiled;
|
||||||
|
|
||||||
|
IQueryable<T> sourceQuery = isAsc ? source.AsQueryable().OrderBy(propName) : source.AsQueryable().OrderBy(propName + " desc");
|
||||||
|
|
||||||
|
sourceQuery = sourceQuery.Skip((pageIndex - 1) * pageSize);
|
||||||
|
|
||||||
|
var items = sourceQuery
|
||||||
|
.Take(pageSize)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
var pagedList = new PageOutput<T>()
|
||||||
|
{
|
||||||
|
PageIndex = pageIndex,
|
||||||
|
PageSize = pageSize,
|
||||||
|
TotalCount = count,
|
||||||
|
CurrentPageData = items
|
||||||
|
};
|
||||||
|
|
||||||
|
return pagedList;
|
||||||
|
}
|
||||||
|
|
||||||
//多字段排序 ["a asc", "b desc", "c asc"]
|
//多字段排序 ["a asc", "b desc", "c asc"]
|
||||||
public static PageOutput<T> ToPagedList<T>(this IQueryable<T> source, int pageIndex, int pageSize,string[] sortArray)
|
public static PageOutput<T> ToPagedList<T>(this IQueryable<T> source, int pageIndex, int pageSize, string[] sortArray)
|
||||||
{
|
{
|
||||||
if (pageIndex <= 0)
|
if (pageIndex <= 0)
|
||||||
{
|
{
|
||||||
|
@ -180,5 +221,8 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
|
|
||||||
return pagedList;
|
return pagedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue