diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj
index 18b317d53..e717885ba 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj
@@ -74,10 +74,9 @@
+
-
- true
-
+
true
diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs
index eb34d3eb7..6aa7b4ee9 100644
--- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs
+++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs
@@ -60,7 +60,7 @@ namespace IRaCIS.Core.Application.Services
var trialDocumentQueryable = _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == queryTrialDocument.TrialId)
.WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Name), t => t.Name.Contains(queryTrialDocument.Name))
.WhereIf(queryTrialDocument.FileTypeId != null, t => t.FileTypeId == queryTrialDocument.FileTypeId)
- .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, isEn_Us=_userInfo.IsEn_Us });
+ .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, isEn_Us = _userInfo.IsEn_Us });
return await trialDocumentQueryable.ToPagedListAsync(queryTrialDocument.PageIndex, queryTrialDocument.PageSize, queryTrialDocument.SortField, queryTrialDocument.Asc);
}
@@ -74,12 +74,12 @@ namespace IRaCIS.Core.Application.Services
[HttpPost]
public async Task GetNextUnSignDocument(GetNextUnSignDocumentInDto inDto)
{
- var result =await this.GetUserDocumentList(new TrialUserDocUnionQuery()
+ var result = await this.GetUserDocumentList(new TrialUserDocUnionQuery()
{
Asc = inDto.Asc,
IsSign = false,
SortField = inDto.SortField,
- TrialId= inDto.TrialId,
+ TrialId = inDto.TrialId,
PageIndex = 1,
PageSize = 1,
});
@@ -88,7 +88,8 @@ namespace IRaCIS.Core.Application.Services
{
return result.Data.CurrentPageData.First();
}
- else {
+ else
+ {
return null;
}
@@ -100,7 +101,7 @@ namespace IRaCIS.Core.Application.Services
///
///
[HttpPost]
- public async Task< IResponseOutput> > GetUserDocumentList(TrialUserDocUnionQuery querySystemDocument)
+ public async Task>> GetUserDocumentList(TrialUserDocUnionQuery querySystemDocument)
{
#region https://github.com/dotnet/efcore/issues/16243 操作不行
////系统文档查询
@@ -164,7 +165,7 @@ namespace IRaCIS.Core.Application.Services
var trialId = querySystemDocument.TrialId;
- var trialInfo = await (_repository.Where(t => t.Id == querySystemDocument.TrialId).Select(t => new { t.TrialFinishedTime,t.TrialStatusStr } ).FirstOrDefaultAsync());
+ var trialInfo = await (_repository.Where(t => t.Id == querySystemDocument.TrialId).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstOrDefaultAsync());
//系统文档查询
var systemDocumentQueryable = from needConfirmedUserType in _repository.Where(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)
@@ -187,10 +188,10 @@ namespace IRaCIS.Core.Application.Services
Name = needConfirmedUserType.SystemDocument.Name,
Path = needConfirmedUserType.SystemDocument.Path,
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,
- FullFilePath = needConfirmedUserType.SystemDocument.Path ,
+ FullFilePath = needConfirmedUserType.SystemDocument.Path,
ConfirmUserId = confirm.ConfirmUserId,
ConfirmTime = confirm.ConfirmTime,
@@ -214,12 +215,12 @@ namespace IRaCIS.Core.Application.Services
Id = trialDoc.Id,
IsSystemDoc = false,
CreateTime = trialDoc.CreateTime,
- FullFilePath = trialDoc.Path ,
+ FullFilePath = trialDoc.Path,
IsDeleted = trialDoc.IsDeleted,
Name = trialDoc.Name,
Path = trialDoc.Path,
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,
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);
+ .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 result = await unionQuery.ToPagedListAsync(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)
+ #region 临时方案
+
+ //var list1 = systemDocumentQueryable
+ // .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 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 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.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();
@@ -254,15 +281,12 @@ namespace IRaCIS.Core.Application.Services
var trialTaskConfig = _trialRepository.Where(t => t.Id == querySystemDocument.TrialId).ProjectTo(_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 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();
- 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
- &&t.TrialCriterionAdditionalAssessmentTypeList.Any(c=>/*c.AdditionalAssessmentType==Domain.Share.Reading.AdditionalAssessmentType.BrainMetastasis &&*/ c.IsSelected==true)).Any();
-
- return ResponseOutput.Ok>( result, new { NeedSignCount = needSignTrialDocCount + needSignSystemDocCount, NeedSignTrialDocCount = needSignTrialDocCount, NeedSignSystemDocCount = needSignSystemDocCount, IsAdditionalAssessment = isAdditionalAssessment && isManualGenerateTask, TrialStatusStr = trialInfo.TrialStatusStr,TrialConfig= trialTaskConfig });
+ return ResponseOutput.Ok>(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
///
///
[HttpPost]
- public async Task<(PageOutput,object)> GetDocumentConfirmList(DocumentTrialUnionQuery querySystemDocument)
+ public async Task<(PageOutput, object)> GetDocumentConfirmList(DocumentTrialUnionQuery querySystemDocument)
{
@@ -345,7 +369,7 @@ namespace IRaCIS.Core.Application.Services
UserTypeId = trialUser.User.UserTypeId,
UserTypeShortName = trialUser.User.UserTypeRole.UserTypeShortName,
- FullFilePath = trialDocumentNeedConfirmedUserType.TrialDocument.Path
+ FullFilePath = trialDocumentNeedConfirmedUserType.TrialDocument.Path
};
@@ -400,7 +424,7 @@ namespace IRaCIS.Core.Application.Services
.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,14 +450,14 @@ namespace IRaCIS.Core.Application.Services
[HttpGet("{trialId:guid}")]
public async Task 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 }))
.ToListAsync();
return ResponseOutput.Ok(result);
}
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
//[Authorize(Policy = IRaCISPolicy.PM)]
public async Task AddOrUpdateTrialDocument(AddOrEditTrialDocument addOrEditTrialDocument)
{
@@ -444,7 +468,7 @@ namespace IRaCIS.Core.Application.Services
if (await _trialDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditTrialDocument.FileTypeId && t.Name == addOrEditTrialDocument.Name && t.TrialId == addOrEditTrialDocument.TrialId, true))
{
- //---该项目中已经存在同类型的同名文件。
+ //---该项目中已经存在同类型的同名文件。
return ResponseOutput.NotOk(_localizer["TrialD_DuplicateFileInProject"]);
}
@@ -456,7 +480,7 @@ namespace IRaCIS.Core.Application.Services
{
if (await _trialDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditTrialDocument.FileTypeId && t.Name == addOrEditTrialDocument.Name && t.Id != addOrEditTrialDocument.Id && t.TrialId == addOrEditTrialDocument.TrialId, true))
{
- //---该项目中已经存在同类型的同名文件。
+ //---该项目中已经存在同类型的同名文件。
return ResponseOutput.NotOk(_localizer["TrialD_DuplicateFileInProject"]);
}
@@ -505,7 +529,7 @@ namespace IRaCIS.Core.Application.Services
///
[HttpDelete("{trialId:guid}/{trialDocumentId:guid}")]
//[Authorize(Policy = IRaCISPolicy.PM)]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
+ [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
public async Task DeleteTrialDocument(Guid trialDocumentId, Guid trialId)
{
if (await _trialDocumentRepository.AsQueryable(true).Where(t => t.Id == trialDocumentId).AnyAsync(t => t.TrialDocConfirmedUserList.Any()))
@@ -534,7 +558,7 @@ namespace IRaCIS.Core.Application.Services
var success = false;
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 });
@@ -598,17 +622,17 @@ namespace IRaCIS.Core.Application.Services
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"]);
}
if (sysDocConfirm.IsDeleted)
{
- //---文件已废除,签署失败!
+ //---文件已废除,签署失败!
return ResponseOutput.NotOk(_localizer["TrialD_ObsoleteFile"]);
}
@@ -629,13 +653,13 @@ namespace IRaCIS.Core.Application.Services
if (trialDocConfirm.ConfirmTime != null)
{
- //---该文件已经签名
+ //---该文件已经签名
return ResponseOutput.NotOk(_localizer["TrialD_FileAlreadySigned"]);
}
if (trialDocConfirm.IsDeleted)
{
- //---文件已废除,签署失败!
+ //---文件已废除,签署失败!
return ResponseOutput.NotOk(_localizer["TrialD_ObsoleteFile"]);
}
@@ -730,7 +754,7 @@ namespace IRaCIS.Core.Application.Services
Id = t.Id,
IsSystemDoc = true,
CreateTime = t.CreateTime,
- FullFilePath = t.Path ,
+ FullFilePath = t.Path,
IsDeleted = t.IsDeleted,
Name = t.Name,
Path = t.Path,
@@ -748,7 +772,7 @@ namespace IRaCIS.Core.Application.Services
Id = t.Id,
IsSystemDoc = false,
CreateTime = t.CreateTime,
- FullFilePath = t.Path ,
+ FullFilePath = t.Path,
IsDeleted = t.IsDeleted,
Name = t.Name,
Path = t.Path,
diff --git a/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj b/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj
index 85a1db3cc..1c168175c 100644
--- a/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj
+++ b/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj
@@ -8,8 +8,4 @@
..\bin
-
-
-
-
diff --git a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj
index db04254d7..53f18f1b4 100644
--- a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj
+++ b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj
@@ -14,10 +14,10 @@
-
-
-
+
+
+
diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs
index 946eb6683..32ae20058 100644
--- a/IRaCIS.Core.Domain/Management/User.cs
+++ b/IRaCIS.Core.Domain/Management/User.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using EntityFrameworkCore.Projectables;
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Domain.Models
@@ -92,7 +93,7 @@ namespace IRaCIS.Core.Domain.Models
///
public bool AutoCutNextTask { get; set; } = false;
- [NotMapped]
+ [Projectable]
public string FullName => LastName + " / " + FirstName;
//[Projectable] public string FullName => $"{LastName} / {FirstName}";
diff --git a/IRaCIS.Core.Domain.Share/AuthUser/IUserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs
similarity index 100%
rename from IRaCIS.Core.Domain.Share/AuthUser/IUserInfo.cs
rename to IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs
diff --git a/IRaCIS.Core.Domain.Share/AuthUser/UserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs
similarity index 100%
rename from IRaCIS.Core.Domain.Share/AuthUser/UserInfo.cs
rename to IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs
diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj
index c763a7435..926824848 100644
--- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj
+++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj
@@ -8,7 +8,9 @@
..\bin
-
+
+
+
@@ -17,13 +19,10 @@
-
-
+
+
-
-
-
diff --git a/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs b/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs
index 07246c223..4e58ccad4 100644
--- a/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs
+++ b/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs
@@ -257,11 +257,6 @@ namespace IRaCIS.Core.Infra.EFCore
#endregion
-
-
-
-
-
}
diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj
index 086de1dce..738f20c04 100644
--- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj
+++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj
@@ -11,8 +11,8 @@
-
-
+
+
diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs
index bb102cd7d..ee6aa1189 100644
--- a/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs
+++ b/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs
@@ -3,6 +3,8 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
+using System.Collections.Generic;
+using System;
namespace IRaCIS.Core.Infrastructure.Extention
{
@@ -23,7 +25,7 @@ namespace IRaCIS.Core.Infrastructure.Extention
if (count == 0)
{
- return new PageOutput() { CurrentPageData=new T[0] };
+ return new PageOutput() { CurrentPageData = new T[0] };
}
@@ -49,10 +51,10 @@ namespace IRaCIS.Core.Infrastructure.Extention
}
//单字段排序 异步
- public static async Task> ToPagedListAsync(this IQueryable source, int pageNumber, int pageSize, string defaultSortFiled = "Id", bool isAsc = true,bool isMultiSortFiled=false, string[] sortArray=default, CancellationToken cancellationToken = default)
+ public static async Task> ToPagedListAsync(this IQueryable 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");
}
@@ -83,7 +85,7 @@ namespace IRaCIS.Core.Infrastructure.Extention
{
var sortString = string.Join(',', sortArray);
- source= source.OrderBy(sortString);
+ source = source.OrderBy(sortString);
}
source = source.Skip((pageNumber - 1) * pageSize);
var items = await source
@@ -102,8 +104,47 @@ namespace IRaCIS.Core.Infrastructure.Extention
return pagedList;
}
+
+ public static PageOutput ToPagedList(this IList 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() { CurrentPageData = new List() };
+ }
+
+ var propName = string.IsNullOrWhiteSpace(defaultSortFiled) ? "Id" : defaultSortFiled;
+
+ IQueryable 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()
+ {
+ PageIndex = pageIndex,
+ PageSize = pageSize,
+ TotalCount = count,
+ CurrentPageData = items
+ };
+
+ return pagedList;
+ }
+
//多字段排序 ["a asc", "b desc", "c asc"]
- public static PageOutput ToPagedList(this IQueryable source, int pageIndex, int pageSize,string[] sortArray)
+ public static PageOutput ToPagedList(this IQueryable source, int pageIndex, int pageSize, string[] sortArray)
{
if (pageIndex <= 0)
{
@@ -180,5 +221,8 @@ namespace IRaCIS.Core.Infrastructure.Extention
return pagedList;
}
+
+
+
}
}
diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj
index 16b11378d..899f95036 100644
--- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj
+++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj
@@ -13,10 +13,10 @@
-
-
-
-
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive