优化分页排序和生成模板
continuous-integration/drone/push Build is passing

This commit is contained in:
hang
2024-08-17 20:33:21 +08:00
parent cd2166f11b
commit ff026f45fc
11 changed files with 300 additions and 186 deletions
@@ -0,0 +1,50 @@
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Application.BusinessFilter
{
/// <summary>
/// 不生效,不知道为啥
/// </summary>
public class GlobalExceptionHandler : IExceptionHandler
{
private readonly ILogger<GlobalExceptionHandler> _logger;
public GlobalExceptionHandler(ILogger<GlobalExceptionHandler> logger)
{
this._logger = logger;
}
public ValueTask<bool> TryHandleAsync(
HttpContext httpContext,
Exception exception,
CancellationToken cancellationToken)
{
httpContext.Response.ContentType = "application/json";
var ex = exception;
var errorInfo = $"Exception: {ex.Message}[{ex.StackTrace}]" + (ex.InnerException != null ? $" InnerException: {ex.InnerException.Message}[{ex.InnerException.StackTrace}]" : "");
httpContext.Response.WriteAsJsonAsync(ResponseOutput.NotOk($"{ex?.Message}"));
_logger.LogError(errorInfo);
// return true to signal that this exception is handled
return ValueTask.FromResult(false);
}
}
}
@@ -29,31 +29,16 @@
签名
</summary>
</member>
<member name="T:IRaCIS.Core.Application.BusinessFilter.GlobalExceptionHandler">
<summary>
不生效,不知道为啥
</summary>
</member>
<member name="T:IRaCIS.Core.Application.Filter.TrialResourceFilter">
<summary>
主要为了 处理项目结束 锁库,不允许操作
</summary>
</member>
<member name="M:IRaCIS.Core.Application.Helper.FileStoreHelper.GetSystemClinicalPathAsync(Microsoft.AspNetCore.Hosting.IWebHostEnvironment,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ClinicalDataSystemSet},System.Guid)">
<summary>
</summary>
<param name="_hostEnvironment"></param>
<param name="_clinicalDataTrialSetRepository"></param>
<param name="id"></param>
<returns></returns>
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
</member>
<member name="M:IRaCIS.Core.Application.Helper.FileStoreHelper.GetTrialClinicalPathAsync(Microsoft.AspNetCore.Hosting.IWebHostEnvironment,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.ClinicalDataTrialSet},System.Guid)">
<summary>
</summary>
<param name="_hostEnvironment"></param>
<param name="_clinicalDataTrialSetRepository"></param>
<param name="id"></param>
<returns></returns>
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
</member>
<member name="M:IRaCIS.Core.Application.Helper.FileStoreHelper.WriteFileAsync(System.IO.Stream,System.String)">
<summary>
写文件导到磁盘
@@ -62,28 +47,6 @@
<param name="path">文件保存路径</param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Helper.FileStoreHelper.GetUploadPrintscreenFilePath(Microsoft.AspNetCore.Hosting.IWebHostEnvironment,System.String,System.Guid,System.Guid,System.Guid)">
<summary>
上传截图
</summary>
<param name="_hostEnvironment"></param>
<param name="fileName"></param>
<param name="trialId"></param>
<param name="siteid"></param>
<param name="subjectId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Helper.FileStoreHelper.GetFilePath(Microsoft.AspNetCore.Hosting.IWebHostEnvironment,System.String,System.Guid,System.Guid,System.String)">
<summary>
通用获取文件路径
</summary>
<param name="_hostEnvironment"></param>
<param name="fileName"></param>
<param name="trialId"></param>
<param name="id"></param>
<param name="type"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Helper.OSSService.UploadToOSSAsync(System.IO.Stream,System.String,System.String,System.Boolean)">
<summary>
oosFolderPath 不要 "/ "开头 应该: TempFolder/ChildFolder
@@ -41,7 +41,7 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(string.IsNullOrEmpty(queryCommonDocument.Name), t => t.Name.Contains(queryCommonDocument.Name))
.ProjectTo<CommonDocumentView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, userId = _userInfo.Id });
return await commonDocumentQueryable.ToPagedListAsync(queryCommonDocument.PageIndex, queryCommonDocument.PageSize, String.IsNullOrEmpty(queryCommonDocument.SortField) ? nameof(CommonDocument.Code) : queryCommonDocument.SortField, queryCommonDocument.Asc); ;
return await commonDocumentQueryable.ToPagedListAsync(queryCommonDocument);
}
@@ -25,7 +25,7 @@ namespace IRaCIS.Core.Application.Contracts
Task<List<TrialUserDto>> GetTrialUserSelect(Guid trialId);
PageOutput<DocumentUnionWithUserStatView> GetTrialSystemDocumentList(DocumentTrialUnionQuery querySystemDocument);
Task<PageOutput<DocumentUnionWithUserStatView>> GetTrialSystemDocumentList(DocumentTrialUnionQuery querySystemDocument);
List<TrialUserUnionDocumentView> GetTrialUserDocumentList(Guid trialId);
}
}
@@ -26,8 +26,8 @@ namespace IRaCIS.Core.Application.Services
private readonly IRepository<TrialDocument> _trialDocumentRepository;
private readonly IRepository<TrialDocConfirmedUser> _trialDocUserTypeConfirmedUserRepository;
private readonly IRepository<Trial> _trialRepository;
private readonly ISystemDocumentService _systemDocumentService;
private readonly IRepository<SystemDocConfirmedUser> _systemDocConfirmedUserRepository;
private readonly ISystemDocumentService _systemDocumentService;
private readonly IRepository<SystemDocConfirmedUser> _systemDocConfirmedUserRepository;
private readonly IRepository<SystemDocument> _systemDocumentRepository;
private readonly IRepository<TrialCriterionAdditionalAssessmentType> _trialCriterionAdditionalAssessmentTypeRepository;
private readonly IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository;
@@ -36,8 +36,8 @@ namespace IRaCIS.Core.Application.Services
public TrialDocumentService(IRepository<TrialDocument> trialDocumentRepository,
IRepository<TrialDocConfirmedUser> trialDocUserTypeConfirmedUserRepository,
IRepository<Trial> trialRepository,
ISystemDocumentService systemDocumentService,
IRepository<SystemDocConfirmedUser> systemDocConfirmedUserRepository,
ISystemDocumentService systemDocumentService,
IRepository<SystemDocConfirmedUser> systemDocConfirmedUserRepository,
IRepository<TrialCriterionAdditionalAssessmentType> trialCriterionAdditionalAssessmentTypeRepository,
IRepository<ReadingQuestionCriterionTrial> readingQuestionCriterionTrialRepository
, IRepository<SystemDocument> systemDocumentRepository)
@@ -45,8 +45,8 @@ namespace IRaCIS.Core.Application.Services
_trialDocumentRepository = trialDocumentRepository;
this._trialDocUserTypeConfirmedUserRepository = trialDocUserTypeConfirmedUserRepository;
this._trialRepository = trialRepository;
this._systemDocumentService = systemDocumentService;
this._systemDocConfirmedUserRepository = systemDocConfirmedUserRepository;
this._systemDocumentService = systemDocumentService;
this._systemDocConfirmedUserRepository = systemDocConfirmedUserRepository;
_systemDocumentRepository = systemDocumentRepository;
_readingQuestionCriterionTrialRepository = readingQuestionCriterionTrialRepository;
_trialCriterionAdditionalAssessmentTypeRepository = trialCriterionAdditionalAssessmentTypeRepository;
@@ -64,7 +64,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)
.WhereIf(queryTrialDocument.UserTypeId != null, t => t.NeedConfirmedUserTypeList.Any(t=>t.NeedConfirmUserTypeId== queryTrialDocument.UserTypeId) )
.WhereIf(queryTrialDocument.UserTypeId != null, t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == queryTrialDocument.UserTypeId))
.WhereIf(queryTrialDocument.IsDeleted != null, t => t.IsDeleted == queryTrialDocument.IsDeleted)
.ProjectTo<TrialDocumentView>(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, isEn_Us = _userInfo.IsEn_Us });
@@ -75,17 +75,17 @@ namespace IRaCIS.Core.Application.Services
public async Task<PageOutput<TrialSignDocView>> GetTrialSignDocumentList(TrialDocQuery querySystemDocument)
{
var trialDocQueryable = from trialDoc in _trialDocumentRepository.AsQueryable(true)
.WhereIf(querySystemDocument.TrialId!=null,t=>t.TrialId==querySystemDocument.TrialId)
.Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId) )
.WhereIf(querySystemDocument.TrialId != null, t => t.TrialId == querySystemDocument.TrialId)
.Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
join trialUser in _repository.Where<TrialUser>(t=>t.UserId==_userInfo.Id) on trialDoc.TrialId equals trialUser.TrialId
join trialUser in _repository.Where<TrialUser>(t => t.UserId == _userInfo.Id) on trialDoc.TrialId equals trialUser.TrialId
join confirm in _repository.Where<TrialDocConfirmedUser>() on
new { trialUser.UserId, TrialDocumentId = trialDoc.Id } equals new { UserId = confirm.ConfirmUserId, confirm.TrialDocumentId } into cc
from confirm in cc.DefaultIfEmpty()
select new TrialSignDocView()
{
TrialCode=trialDoc.Trial.TrialCode,
TrialCode = trialDoc.Trial.TrialCode,
ResearchProgramNo = trialDoc.Trial.ResearchProgramNo,
ExperimentName = trialDoc.Trial.ExperimentName,
Id = trialDoc.Id,
@@ -116,7 +116,7 @@ namespace IRaCIS.Core.Application.Services
.WhereIf(querySystemDocument.IsSigned == false, t => t.ConfirmTime == null);
return await trialDocQueryable.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
return await trialDocQueryable.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
}
@@ -142,19 +142,19 @@ namespace IRaCIS.Core.Application.Services
PageSize = 1,
})).Data;
}
else
else
{
result = await _systemDocumentService.getWaitSignSysDocList(new SystemDocumentQuery()
{
PageIndex=1,
PageIndex = 1,
IsSigned = false,
PageSize=1,
Asc=false,
SortField="UpdateTime",
});
PageSize = 1,
Asc = false,
SortField = "UpdateTime",
});
}
}
if (result.CurrentPageData.Count > 0)
{
@@ -823,7 +823,7 @@ namespace IRaCIS.Core.Application.Services
/// <returns></returns>
[HttpPost]
[Obsolete]
public PageOutput<DocumentUnionWithUserStatView> GetTrialSystemDocumentList(DocumentTrialUnionQuery querySystemDocument)
public async Task<PageOutput<DocumentUnionWithUserStatView>> GetTrialSystemDocumentList(DocumentTrialUnionQuery querySystemDocument)
{
var systemDocumentQueryable = _repository
.WhereIf<SystemDocument>(!_userInfo.IsAdmin, t => t.IsDeleted == false)
@@ -867,7 +867,7 @@ namespace IRaCIS.Core.Application.Services
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
.WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId);
return unionQuery.ToPagedList(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
return await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
}
#endregion
@@ -103,8 +103,10 @@ namespace IRaCIS.Core.Application.Contracts
.OrderByDescending(x=>x.LanguageType)
.ThenBy(t=>t.ShowOrder)
.ProjectTo<QCQuestionConfigureView>(_mapper.ConfigurationProvider);
return await QCQuestionQueryable.ToPagedListAsync(queryQCQuestionConfigure.PageIndex, queryQCQuestionConfigure.PageSize, new string[2] { "LanguageType desc", "ShowOrder asc" });
var defalutSortArray = new string[] { nameof(QCQuestionConfigureView.LanguageType) + " desc", nameof(QCQuestionConfigureView.ShowOrder) };
return await QCQuestionQueryable.ToPagedListAsync(queryQCQuestionConfigure.PageIndex, queryQCQuestionConfigure.PageSize, new string[2] { "LanguageType desc", "ShowOrder asc" });
}
public async Task<IResponseOutput> AddOrUpdateQCQuestionConfigure(QCQuestionAddOrEdit addOrEditQCQuestionConfigure)
@@ -637,8 +637,9 @@ namespace IRaCIS.Core.Application.Service
ModuleName=x.ModuleName,
});
var defalutSortArray = new string[] { nameof(GetCRCConfirmListOutDto.SubjectCode) + " desc", nameof(GetCRCConfirmListOutDto.LatestScanDate) };
var result = await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, new string[2] { "SubjectCode asc", "LatestScanDate asc" });
var result = await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, new string[2] { "SubjectCode asc", "LatestScanDate asc" });
var formList = await _clinicalFormRepository.Where(x => x.TrialId == inDto.TrialId)
.Where(x => x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC)
@@ -65,7 +65,9 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inDto.LanguageType != null, x => x.LanguageType == inDto.LanguageType!.Value)
.ProjectTo<ReadingMedicineSystemQuestionView>(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder);
return await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, new string[2] { "LanguageType desc", "ShowOrder asc" });
var defalutSortArray = new string[] { nameof(ReadingMedicineSystemQuestionView.LanguageType) + " desc", nameof(ReadingMedicineSystemQuestionView.ShowOrder) };
return await query.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, new string[2] { "LanguageType desc", "ShowOrder asc" });
}
/// <summary>