From 96e1a2c39373710a0ecf4b004e82b1c3bda42f09 Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Fri, 18 Aug 2023 17:55:43 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=AD=E5=BF=83=E8=B0=83?=
=?UTF-8?q?=E7=A0=94=EF=BC=8C=E5=BC=95=E5=85=A5hangfire?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/UploadDownLoadController.cs | 798 ++++++++++--------
IRaCIS.Core.API/IRaCIS.Core.API.csproj | 3 +
IRaCIS.Core.API/IRaCIS.Core.API.xml | 100 +--
IRaCIS.Core.API/Startup.cs | 5 +-
.../LogDashBoardAuthFilter.cs | 0
.../Dashboard/hangfireAuthorizationFilter.cs | 17 +
.../_PipelineExtensions/HangfireConfig.cs | 60 ++
.../_ServiceExtensions/LogDashboardSetup.cs | 2 +
.../_ServiceExtensions/hangfireSetup.cs | 40 +
IRaCIS.Core.API/appsettings.Test_Study.json | 3 +-
IRaCIS.Core.API/appsettings.Uat_Study.json | 3 +-
.../Helper/FileStoreHelper.cs | 22 +
.../SiteSurvey/TrialSiteSurveyService.cs | 29 +-
IRaCIS.Core.Domain/_Config/_StaticData.cs | 2 +
14 files changed, 601 insertions(+), 483 deletions(-)
rename IRaCIS.Core.API/_PipelineExtensions/{LogDashboard => Dashboard}/LogDashBoardAuthFilter.cs (100%)
create mode 100644 IRaCIS.Core.API/_PipelineExtensions/Dashboard/hangfireAuthorizationFilter.cs
create mode 100644 IRaCIS.Core.API/_PipelineExtensions/HangfireConfig.cs
create mode 100644 IRaCIS.Core.API/_ServiceExtensions/hangfireSetup.cs
diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs
index 6117602a2..7371c790a 100644
--- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs
+++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs
@@ -438,312 +438,314 @@ namespace IRaCIS.Core.API.Controllers
+ #region 废弃
+
- ///
- /// 上传临床数据 多文件
- ///
- ///
- ///
- [HttpPost("ClinicalData/UploadVisitClinicalData/{trialId:guid}/{subjectVisitId:guid}")]
- [DisableRequestSizeLimit]
- //[Authorize(Policy = IRaCISPolicy.CRC)]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
-
- public async Task UploadVisitClinicalData(Guid subjectVisitId)
- {
- await _qCCommon.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId);
- var sv = _repository.Where(t => t.Id == subjectVisitId).Select(t => new { t.TrialId, t.SiteId, t.SubjectId }).FirstOrDefault().IfNullThrowException();
-
- await FileUploadAsync(async (fileName) =>
- {
- var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalDataPath(_hostEnvironment, fileName, sv.TrialId, sv.SiteId, sv.SubjectId, subjectVisitId);
- //插入临床pdf 路径
- await _repository.AddAsync(new PreviousPDF()
- {
- SubjectVisitId = subjectVisitId,
-
- IsVisist = true,
- DataType = ClinicalDataType.MedicalHistory,
- UploadType = ClinicalUploadType.PDF,
- SubjectId = sv.SubjectId,
- TrialId = sv.TrialId,
- ClinicalLevel = ClinicalLevel.Subject,
- Path = relativePath,
- FileName = fileRealName
- });
- return serverFilePath;
- });
- await _repository.SaveChangesAsync();
- return ResponseOutput.Ok();
-
- }
-
- ///
- /// 上传临床数据模板
- ///
- ///
- ///
- [HttpPost("ClinicalData/UploadClinicalTemplate")]
- [DisableRequestSizeLimit]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
-
-
- public async Task>> UploadClinicalTemplate(Guid? trialId)
- {
- if (trialId == null)
- trialId = default(Guid);
-
- var filerelativePath = string.Empty;
- List fileDtos = new List();
- await FileUploadAsync(async (fileName) =>
- {
- var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalTemplatePath(_hostEnvironment, fileName, trialId.Value);
- //插入临床pdf 路径
- filerelativePath = relativePath;
-
- fileDtos.Add(new FileDto()
- {
- FileName = fileName,
- Path = relativePath
-
- });
- await Task.CompletedTask;
- return serverFilePath;
- });
-
- return ResponseOutput.Ok(fileDtos);
- }
-
-
-
- ///
- /// 上传阅片临床数据
- ///
- ///
- ///
- ///
- ///
- [HttpPost("ClinicalData/UploadClinicalData/{trialId:guid}/{subjectId:guid}/{readingId:guid}")]
- [DisableRequestSizeLimit]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
-
- public async Task>> UploadReadClinicalData(Guid trialId, Guid subjectId, Guid readingId)
- {
- var filerelativePath = string.Empty;
- List fileDtos = new List();
-
- var siteid = await _repository.Where(x => x.Id == subjectId).Select(x => x.SiteId).FirstOrDefaultAsync();
-
- await FileUploadAsync(async (fileName) =>
- {
- var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetReadClinicalDataPath(_hostEnvironment, fileName, trialId, siteid, subjectId, readingId);
- //插入临床pdf 路径
- filerelativePath = relativePath;
-
- fileDtos.Add(new FileDto()
- {
- FileName = fileName,
- Path = relativePath
-
- });
- await Task.CompletedTask;
- return serverFilePath;
- });
-
- return ResponseOutput.Ok(fileDtos);
-
- }
-
-
- ///
- /// 上传截图
- ///
- ///
- ///
- [HttpPost("Printscreen/UploadPrintscreen/{subjectId:guid}")]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- public async Task> UploadPrintscreen(Guid subjectId)
- {
-
- var subjectInfo = await this._repository.Where(x => x.Id == subjectId).FirstNotNullAsync();
-
- FileDto fileDto = new FileDto();
- await FileUploadAsync(async (fileName) =>
- {
- var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetUploadPrintscreenFilePath(_hostEnvironment, fileName, subjectInfo.TrialId, subjectInfo.SiteId, subjectInfo.Id);
- fileDto.Path = relativePath;
- fileDto.FileName = fileName;
- await Task.CompletedTask;
- return serverFilePath;
- });
-
-
- return ResponseOutput.Ok(fileDto);
- }
-
-
- ///
- /// 上传Reading问题的图像
- ///
- ///
- ///
- ///
- [HttpPost("VisitTask/UploadReadingAnswerImage/{trialId:guid}/{visitTaskId:guid}")]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- public async Task> UploadReadingAnswerImage(Guid trialId, Guid visitTaskId)
- {
-
- FileDto fileDto = new FileDto();
- await FileUploadAsync(async (fileName) =>
- {
- var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetFilePath(_hostEnvironment, fileName, trialId, visitTaskId, StaticData.Folder.JudgeTask);
- fileDto.Path = relativePath;
- fileDto.FileName = fileName;
- await Task.CompletedTask;
- return serverFilePath;
- });
-
-
- return ResponseOutput.Ok(fileDto);
- }
-
- ///
- /// 上传裁判任务的图像
- ///
- ///
- ///
- ///
- [HttpPost("VisitTask/UploadJudgeTaskImage/{trialId:guid}/{visitTaskId:guid}")]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- public async Task> UploadJudgeTaskImage(Guid trialId, Guid visitTaskId)
- {
-
- FileDto fileDto = new FileDto();
- await FileUploadAsync(async (fileName) =>
- {
- var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetFilePath(_hostEnvironment, fileName, trialId, visitTaskId, StaticData.Folder.JudgeTask);
- fileDto.Path = relativePath;
- fileDto.FileName = fileName;
-
- await Task.CompletedTask;
-
- return serverFilePath;
- });
-
- return ResponseOutput.Ok(fileDto);
- }
-
-
-
- ///
- /// 上传医学审核图片
- ///
- ///
- ///
- ///
- [HttpPost("TaskMedicalReview/UploadMedicalReviewImage/{trialId:guid}/{taskMedicalReviewId:guid}")]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- public async Task> UploadMedicalReviewImage(Guid trialId, Guid taskMedicalReviewId)
- {
- string path = string.Empty;
- FileDto fileDto = new FileDto();
- await FileUploadAsync(async (fileName) =>
- {
-
- var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetMedicalReviewImage(_hostEnvironment, fileName, trialId, taskMedicalReviewId);
-
-
- //await _repository.UpdatePartialFromQueryAsync(x => x.Id == taskMedicalReviewId, x => new TaskMedicalReview()
- //{
- // ImagePath = relativePath,
- // FileName = fileName,
- //});
-
- path = relativePath;
- fileDto.Path = relativePath;
- fileDto.FileName = fileName;
- return serverFilePath;
- });
-
- await _repository.SaveChangesAsync();
- return ResponseOutput.Ok(fileDto);
- }
-
-
-
- public class UploadNoneDicomFileCommand
- {
- public Guid TrialId { get; set; }
- public Guid SubjectVisitId { get; set; }
- public Guid NoneDicomStudyId { get; set; }
- public Guid StudyMonitorId { get; set; }
-
-
- public List UploadedFileList { get; set; } = new List();
-
-
- public class OSSFileDTO
- {
- public string FilePath { get; set; }
- public string FileName { get; set; }
- public int FileFize { get; set; }
- }
- }
-
- ///
- /// 上传非Dicom 文件 支持压缩包 多文件上传
- ///
- ///
- ///
+ /////
+ ///// 上传临床数据 多文件
+ /////
+ /////
+ /////
+ //[HttpPost("ClinicalData/UploadVisitClinicalData/{trialId:guid}/{subjectVisitId:guid}")]
//[DisableRequestSizeLimit]
- [HttpPost("NoneDicomStudy/UploadNoneDicomFile")]
- [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- //[Authorize(Policy = IRaCISPolicy.CRC)]
- public async Task UploadNoneDicomFile(UploadNoneDicomFileCommand incommand,
- [FromServices] IRepository _noneDicomStudyRepository, [FromServices] IRepository _studyMonitorRepository)
- {
+ ////[Authorize(Policy = IRaCISPolicy.CRC)]
+ //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
- var subjectVisitId = incommand.SubjectVisitId;
- var studyMonitorId = incommand.StudyMonitorId;
- var noneDicomStudyId = incommand.NoneDicomStudyId;
+ //public async Task UploadVisitClinicalData(Guid subjectVisitId)
+ //{
+ // await _qCCommon.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId);
+ // var sv = _repository.Where(t => t.Id == subjectVisitId).Select(t => new { t.TrialId, t.SiteId, t.SubjectId }).FirstOrDefault().IfNullThrowException();
+
+ // await FileUploadAsync(async (fileName) =>
+ // {
+ // var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalDataPath(_hostEnvironment, fileName, sv.TrialId, sv.SiteId, sv.SubjectId, subjectVisitId);
+ // //插入临床pdf 路径
+ // await _repository.AddAsync(new PreviousPDF()
+ // {
+ // SubjectVisitId = subjectVisitId,
+
+ // IsVisist = true,
+ // DataType = ClinicalDataType.MedicalHistory,
+ // UploadType = ClinicalUploadType.PDF,
+ // SubjectId = sv.SubjectId,
+ // TrialId = sv.TrialId,
+ // ClinicalLevel = ClinicalLevel.Subject,
+ // Path = relativePath,
+ // FileName = fileRealName
+ // });
+ // return serverFilePath;
+ // });
+ // await _repository.SaveChangesAsync();
+ // return ResponseOutput.Ok();
+
+ //}
+
+ /////
+ ///// 上传临床数据模板
+ /////
+ /////
+ /////
+ //[HttpPost("ClinicalData/UploadClinicalTemplate")]
+ //[DisableRequestSizeLimit]
+ //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "BeforeOngoingCantOpt", "AfterStopCannNotOpt" })]
- await _qCCommon.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId);
+ //public async Task>> UploadClinicalTemplate(Guid? trialId)
+ //{
+ // if (trialId == null)
+ // trialId = default(Guid);
- var sv = (await _repository.Where(t => t.Id == subjectVisitId).Select(t => new { t.TrialId, t.SiteId, t.SubjectId }).FirstOrDefaultAsync()).IfNullThrowConvertException();
+ // var filerelativePath = string.Empty;
+ // List fileDtos = new List();
+ // await FileUploadAsync(async (fileName) =>
+ // {
+ // var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetClinicalTemplatePath(_hostEnvironment, fileName, trialId.Value);
+ // //插入临床pdf 路径
+ // filerelativePath = relativePath;
- var studyMonitor = await _studyMonitorRepository.FirstOrDefaultAsync(t => t.Id == studyMonitorId);
+ // fileDtos.Add(new FileDto()
+ // {
+ // FileName = fileName,
+ // Path = relativePath
- studyMonitor.UploadFinishedTime = DateTime.Now;
+ // });
+ // await Task.CompletedTask;
+ // return serverFilePath;
+ // });
- foreach (var item in incommand.UploadedFileList)
- {
- await _repository.AddAsync(new NoneDicomStudyFile() { FileName = item.FileName, Path = item.FilePath, NoneDicomStudyId = noneDicomStudyId });
-
- }
- var uploadFinishedTime = DateTime.Now;
-
- var noneDicomStudy = await _noneDicomStudyRepository.FirstOrDefaultAsync((t => t.Id == noneDicomStudyId));
-
- noneDicomStudy.FileCount = noneDicomStudy.FileCount + incommand.UploadedFileList.Count;
-
- studyMonitor.FileCount = incommand.UploadedFileList.Count;
- studyMonitor.FileSize = incommand.UploadedFileList.Sum(t => t.FileFize);
- studyMonitor.IsDicom = false;
- studyMonitor.IsDicomReUpload = false;
- studyMonitor.StudyId = noneDicomStudyId;
- studyMonitor.StudyCode = noneDicomStudy.StudyCode;
- studyMonitor.ArchiveFinishedTime = DateTime.Now;
- studyMonitor.IP = _userInfo.IP;
-
- await _repository.SaveChangesAsync();
-
- return ResponseOutput.Ok();
- }
+ // return ResponseOutput.Ok(fileDtos);
+ //}
+ /////
+ ///// 上传阅片临床数据
+ /////
+ /////
+ /////
+ /////
+ /////
+ //[HttpPost("ClinicalData/UploadClinicalData/{trialId:guid}/{subjectId:guid}/{readingId:guid}")]
+ //[DisableRequestSizeLimit]
+ //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+
+ //public async Task>> UploadReadClinicalData(Guid trialId, Guid subjectId, Guid readingId)
+ //{
+ // var filerelativePath = string.Empty;
+ // List fileDtos = new List();
+
+ // var siteid = await _repository.Where(x => x.Id == subjectId).Select(x => x.SiteId).FirstOrDefaultAsync();
+
+ // await FileUploadAsync(async (fileName) =>
+ // {
+ // var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetReadClinicalDataPath(_hostEnvironment, fileName, trialId, siteid, subjectId, readingId);
+ // //插入临床pdf 路径
+ // filerelativePath = relativePath;
+
+ // fileDtos.Add(new FileDto()
+ // {
+ // FileName = fileName,
+ // Path = relativePath
+
+ // });
+ // await Task.CompletedTask;
+ // return serverFilePath;
+ // });
+
+ // return ResponseOutput.Ok(fileDtos);
+
+ //}
+
+
+ /////
+ ///// 上传截图
+ /////
+ /////
+ /////
+ //[HttpPost("Printscreen/UploadPrintscreen/{subjectId:guid}")]
+ //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ //public async Task> UploadPrintscreen(Guid subjectId)
+ //{
+
+ // var subjectInfo = await this._repository.Where(x => x.Id == subjectId).FirstNotNullAsync();
+
+ // FileDto fileDto = new FileDto();
+ // await FileUploadAsync(async (fileName) =>
+ // {
+ // var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetUploadPrintscreenFilePath(_hostEnvironment, fileName, subjectInfo.TrialId, subjectInfo.SiteId, subjectInfo.Id);
+ // fileDto.Path = relativePath;
+ // fileDto.FileName = fileName;
+ // await Task.CompletedTask;
+ // return serverFilePath;
+ // });
+
+
+ // return ResponseOutput.Ok(fileDto);
+ //}
+
+
+ /////
+ ///// 上传Reading问题的图像
+ /////
+ /////
+ /////
+ /////
+ //[HttpPost("VisitTask/UploadReadingAnswerImage/{trialId:guid}/{visitTaskId:guid}")]
+ //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ //public async Task> UploadReadingAnswerImage(Guid trialId, Guid visitTaskId)
+ //{
+
+ // FileDto fileDto = new FileDto();
+ // await FileUploadAsync(async (fileName) =>
+ // {
+ // var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetFilePath(_hostEnvironment, fileName, trialId, visitTaskId, StaticData.Folder.JudgeTask);
+ // fileDto.Path = relativePath;
+ // fileDto.FileName = fileName;
+ // await Task.CompletedTask;
+ // return serverFilePath;
+ // });
+
+
+ // return ResponseOutput.Ok(fileDto);
+ //}
+
+ /////
+ ///// 上传裁判任务的图像
+ /////
+ /////
+ /////
+ /////
+ //[HttpPost("VisitTask/UploadJudgeTaskImage/{trialId:guid}/{visitTaskId:guid}")]
+ //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ //public async Task> UploadJudgeTaskImage(Guid trialId, Guid visitTaskId)
+ //{
+
+ // FileDto fileDto = new FileDto();
+ // await FileUploadAsync(async (fileName) =>
+ // {
+ // var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetFilePath(_hostEnvironment, fileName, trialId, visitTaskId, StaticData.Folder.JudgeTask);
+ // fileDto.Path = relativePath;
+ // fileDto.FileName = fileName;
+
+ // await Task.CompletedTask;
+
+ // return serverFilePath;
+ // });
+
+ // return ResponseOutput.Ok(fileDto);
+ //}
+
+
+
+ /////
+ ///// 上传医学审核图片
+ /////
+ /////
+ /////
+ /////
+ //[HttpPost("TaskMedicalReview/UploadMedicalReviewImage/{trialId:guid}/{taskMedicalReviewId:guid}")]
+ //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ //public async Task> UploadMedicalReviewImage(Guid trialId, Guid taskMedicalReviewId)
+ //{
+ // string path = string.Empty;
+ // FileDto fileDto = new FileDto();
+ // await FileUploadAsync(async (fileName) =>
+ // {
+
+ // var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetMedicalReviewImage(_hostEnvironment, fileName, trialId, taskMedicalReviewId);
+
+
+ // //await _repository.UpdatePartialFromQueryAsync(x => x.Id == taskMedicalReviewId, x => new TaskMedicalReview()
+ // //{
+ // // ImagePath = relativePath,
+ // // FileName = fileName,
+ // //});
+
+ // path = relativePath;
+ // fileDto.Path = relativePath;
+ // fileDto.FileName = fileName;
+ // return serverFilePath;
+ // });
+
+ // await _repository.SaveChangesAsync();
+ // return ResponseOutput.Ok(fileDto);
+ //}
+
+
+
+ //public class UploadNoneDicomFileCommand
+ //{
+ // public Guid TrialId { get; set; }
+ // public Guid SubjectVisitId { get; set; }
+ // public Guid NoneDicomStudyId { get; set; }
+ // public Guid StudyMonitorId { get; set; }
+
+
+ // public List UploadedFileList { get; set; } = new List();
+
+
+ // public class OSSFileDTO
+ // {
+ // public string FilePath { get; set; }
+ // public string FileName { get; set; }
+ // public int FileFize { get; set; }
+ // }
+ //}
+
+ /////
+ ///// 上传非Dicom 文件 支持压缩包 多文件上传
+ /////
+ /////
+ /////
+ ////[DisableRequestSizeLimit]
+ //[HttpPost("NoneDicomStudy/UploadNoneDicomFile")]
+ //[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
+ ////[Authorize(Policy = IRaCISPolicy.CRC)]
+ //public async Task UploadNoneDicomFile(UploadNoneDicomFileCommand incommand,
+ // [FromServices] IRepository _noneDicomStudyRepository, [FromServices] IRepository _studyMonitorRepository)
+ //{
+
+ // var subjectVisitId = incommand.SubjectVisitId;
+ // var studyMonitorId = incommand.StudyMonitorId;
+ // var noneDicomStudyId = incommand.NoneDicomStudyId;
+
+
+ // await _qCCommon.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId);
+
+ // var sv = (await _repository.Where(t => t.Id == subjectVisitId).Select(t => new { t.TrialId, t.SiteId, t.SubjectId }).FirstOrDefaultAsync()).IfNullThrowConvertException();
+
+ // var studyMonitor = await _studyMonitorRepository.FirstOrDefaultAsync(t => t.Id == studyMonitorId);
+
+ // studyMonitor.UploadFinishedTime = DateTime.Now;
+
+ // foreach (var item in incommand.UploadedFileList)
+ // {
+ // await _repository.AddAsync(new NoneDicomStudyFile() { FileName = item.FileName, Path = item.FilePath, NoneDicomStudyId = noneDicomStudyId });
+
+ // }
+ // var uploadFinishedTime = DateTime.Now;
+
+ // var noneDicomStudy = await _noneDicomStudyRepository.FirstOrDefaultAsync((t => t.Id == noneDicomStudyId));
+
+ // noneDicomStudy.FileCount = noneDicomStudy.FileCount + incommand.UploadedFileList.Count;
+
+ // studyMonitor.FileCount = incommand.UploadedFileList.Count;
+ // studyMonitor.FileSize = incommand.UploadedFileList.Sum(t => t.FileFize);
+ // studyMonitor.IsDicom = false;
+ // studyMonitor.IsDicomReUpload = false;
+ // studyMonitor.StudyId = noneDicomStudyId;
+ // studyMonitor.StudyCode = noneDicomStudy.StudyCode;
+ // studyMonitor.ArchiveFinishedTime = DateTime.Now;
+ // studyMonitor.IP = _userInfo.IP;
+
+ // await _repository.SaveChangesAsync();
+
+ // return ResponseOutput.Ok();
+ //}
+
+ #endregion
+
///
/// 一致性核查 excel上传 支持三种格式
@@ -1126,105 +1128,121 @@ namespace IRaCIS.Core.API.Controllers
}
+ #region 废弃
- /// 缩略图
- [AllowAnonymous]
- [HttpGet("Common/LocalFilePreview")]
- public async Task LocalFilePreview(string relativePath)
- {
+ ///// 缩略图
+ //[AllowAnonymous]
+ //[HttpGet("Common/LocalFilePreview")]
+ //public async Task LocalFilePreview(string relativePath)
+ //{
- var _fileStorePath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, relativePath);
+ // var _fileStorePath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, relativePath);
- var storePreviewPath = _fileStorePath + ".preview.jpeg";
+ // var storePreviewPath = _fileStorePath + ".preview.jpeg";
- if (!System.IO.File.Exists(storePreviewPath))
- {
- ImageHelper.ResizeSave(_fileStorePath, storePreviewPath);
- }
+ // if (!System.IO.File.Exists(storePreviewPath))
+ // {
+ // ImageHelper.ResizeSave(_fileStorePath, storePreviewPath);
+ // }
- return new FileContentResult(await System.IO.File.ReadAllBytesAsync(storePreviewPath), "image/jpeg");
+ // return new FileContentResult(await System.IO.File.ReadAllBytesAsync(storePreviewPath), "image/jpeg");
- }
+ //}
- /// 通用文件下载
- [AllowAnonymous]
- [HttpGet("CommonDocument/DownloadCommonDoc")]
- public async Task DownloadCommonFile(string code, [FromServices] IRepository _commonDocumentRepository)
- {
- var (filePath, fileName) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code);
+ ///// 通用文件下载
+ //[AllowAnonymous]
+ //[HttpGet("CommonDocument/DownloadCommonDoc")]
+ //public async Task DownloadCommonFile(string code, [FromServices] IRepository _commonDocumentRepository)
+ //{
+ // var (filePath, fileName) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code);
- new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType);
+ // new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType);
- return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName);
+ // return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName);
- }
+ //}
- ///
- /// 下载项目临床数据文件
- ///
- ///
- ///
- ///
- [AllowAnonymous]
- [HttpGet("CommonDocument/DownloadTrialClinicalFile")]
- public async Task DownloadTrialClinicalFile(Guid clinicalDataTrialSetId, [FromServices] IRepository _clinicalDataTrialSetRepository)
- {
- var (filePath, fileName) = await FileStoreHelper.GetTrialClinicalPathAsync(_hostEnvironment, _clinicalDataTrialSetRepository, clinicalDataTrialSetId);
+ /////
+ ///// 下载项目临床数据文件
+ /////
+ /////
+ /////
+ /////
+ //[AllowAnonymous]
+ //[HttpGet("CommonDocument/DownloadTrialClinicalFile")]
+ //public async Task DownloadTrialClinicalFile(Guid clinicalDataTrialSetId, [FromServices] IRepository _clinicalDataTrialSetRepository)
+ //{
+ // var (filePath, fileName) = await FileStoreHelper.GetTrialClinicalPathAsync(_hostEnvironment, _clinicalDataTrialSetRepository, clinicalDataTrialSetId);
- new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType);
+ // new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType);
- return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName);
+ // return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName);
- }
+ //}
- ///
- /// 下载系统临床数据文件
- ///
- ///
- ///
- ///
- [AllowAnonymous]
- [HttpGet("CommonDocument/DownloadSystemClinicalFile")]
- public async Task DownloadSystemClinicalFile(Guid clinicalDataSystemSetId, [FromServices] IRepository _clinicalDataSystemSetRepository)
- {
- var (filePath, fileName) = await FileStoreHelper.GetSystemClinicalPathAsync(_hostEnvironment, _clinicalDataSystemSetRepository, clinicalDataSystemSetId);
+ /////
+ ///// 下载系统临床数据文件
+ /////
+ /////
+ /////
+ /////
+ //[AllowAnonymous]
+ //[HttpGet("CommonDocument/DownloadSystemClinicalFile")]
+ //public async Task DownloadSystemClinicalFile(Guid clinicalDataSystemSetId, [FromServices] IRepository _clinicalDataSystemSetRepository)
+ //{
+ // var (filePath, fileName) = await FileStoreHelper.GetSystemClinicalPathAsync(_hostEnvironment, _clinicalDataSystemSetRepository, clinicalDataSystemSetId);
- new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType);
+ // new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType);
- return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName);
+ // return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName);
- }
+ //}
- ///
- ///上传项目签名文档
- ///
- ///
- ///
- [HttpPost("TrialDocument/UploadTrialDoc/{trialId:guid}")]
- [DisableRequestSizeLimit]
- [DisableFormValueModelBinding]
- public async Task UploadTrialDoc(Guid trialId)
- {
+ /////
+ /////上传项目签名文档
+ /////
+ /////
+ /////
+ //[HttpPost("TrialDocument/UploadTrialDoc/{trialId:guid}")]
+ //[DisableRequestSizeLimit]
+ //[DisableFormValueModelBinding]
+ //public async Task UploadTrialDoc(Guid trialId)
+ //{
- return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetTrialSignDocPath(_hostEnvironment, trialId, fileName));
+ // return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetTrialSignDocPath(_hostEnvironment, trialId, fileName));
- }
+ //}
- ///
- /// 上传系统签名文档
- ///
- ///
- [HttpPost("TrialDocument/UploadSystemDoc")]
- [DisableRequestSizeLimit]
- [DisableFormValueModelBinding]
- public async Task UploadSysTemDoc()
- {
+ /////
+ ///// 上传系统签名文档
+ /////
+ /////
+ //[HttpPost("TrialDocument/UploadSystemDoc")]
+ //[DisableRequestSizeLimit]
+ //[DisableFormValueModelBinding]
+ //public async Task UploadSysTemDoc()
+ //{
- return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemSignDocPath(_hostEnvironment, fileName));
+ // return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemSignDocPath(_hostEnvironment, fileName));
+
+ //}
+ /////
+ ///// 上传系统通知文档
+ /////
+ /////
+ //[HttpPost("SystemNotice/UploadSystemNoticeDoc")]
+ //[DisableRequestSizeLimit]
+ //[DisableFormValueModelBinding]
+ //public async Task UploadSystemNoticeDoc()
+ //{
+
+ // return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemNoticePath(_hostEnvironment, fileName));
+
+ //}
+ #endregion
- }
///
@@ -1236,25 +1254,63 @@ namespace IRaCIS.Core.API.Controllers
[DisableFormValueModelBinding]
public async Task UploadCommonDoc()
{
-
return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetCommonDocPath(_hostEnvironment, fileName));
}
+
+
+ public enum UploadFileType
+ {
+ DataUpload=1,
+
+ DataDownload=2,
+
+ EmailAttachment=3,
+
+ EmailBodyHtml=4,
+ }
+
///
- /// 上传系统通知文档
+ /// 数据上传、导出、 邮件附件 、邮件Html 通过 ----new
///
///
- [HttpPost("SystemNotice/UploadSystemNoticeDoc")]
+ [HttpPost("SystemFile/Upload")]
[DisableRequestSizeLimit]
[DisableFormValueModelBinding]
- public async Task UploadSystemNoticeDoc()
+ public async Task Upload(UploadFileType fileType)
{
+ IResponseOutput result = null;
- return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemNoticePath(_hostEnvironment, fileName));
+ switch (fileType)
+ {
+ case UploadFileType.DataUpload:
+ result= await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemFileUploadPath(_hostEnvironment, StaticData.Folder.DataTemplate,fileName));
+
+ break;
+ case UploadFileType.DataDownload:
+ result= await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemFileUploadPath(_hostEnvironment, StaticData.Folder.DataTemplate,fileName));
+
+ break;
+ case UploadFileType.EmailAttachment:
+ result = await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemFileUploadPath(_hostEnvironment, StaticData.Folder.DataTemplate, fileName));
+
+ break;
+
+ case UploadFileType.EmailBodyHtml:
+ result = await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemFileUploadPath(_hostEnvironment, StaticData.Folder.EmailHtmlTemplate, fileName));
+ break;
+
+ default:
+ break;
+ }
+
+ return result;
}
+
+
}
#endregion
diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj
index 171f527da..74b76b158 100644
--- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj
+++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj
@@ -72,6 +72,9 @@
+
+
+
diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml
index 430c4af5f..e5067df29 100644
--- a/IRaCIS.Core.API/IRaCIS.Core.API.xml
+++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml
@@ -212,67 +212,6 @@
Dicom 归档
-
-
- 上传临床数据 多文件
-
-
-
-
-
-
- 上传临床数据模板
-
-
-
-
-
-
- 上传阅片临床数据
-
-
-
-
-
-
-
-
- 上传截图
-
-
-
-
-
-
- 上传Reading问题的图像
-
-
-
-
-
-
-
- 上传裁判任务的图像
-
-
-
-
-
-
-
- 上传医学审核图片
-
-
-
-
-
-
-
- 上传非Dicom 文件 支持压缩包 多文件上传
-
-
-
-
一致性核查 excel上传 支持三种格式
@@ -299,50 +238,15 @@
文件类型
-
- 缩略图
-
-
- 通用文件下载
-
-
-
- 下载项目临床数据文件
-
-
-
-
-
-
-
- 下载系统临床数据文件
-
-
-
-
-
-
-
- 上传项目签名文档
-
-
-
-
-
-
- 上传系统签名文档
-
-
-
上传通用文档 比如一致性核查的 比如导出的excel 模板
-
+
- 上传系统通知文档
+ 数据上传、导出、 邮件附件 、邮件Html 通过 ----new
diff --git a/IRaCIS.Core.API/Startup.cs b/IRaCIS.Core.API/Startup.cs
index 886e443fc..3300796eb 100644
--- a/IRaCIS.Core.API/Startup.cs
+++ b/IRaCIS.Core.API/Startup.cs
@@ -114,7 +114,8 @@ namespace IRaCIS.Core.API
//services.AddDistributedMemoryCache();
// hangfire ʱ н棬Ѻ~
- //services.AddhangfireSetup(_configuration);
+ services.AddhangfireSetup(_configuration);
+
// QuartZ ʱ ʹhangfire ʱãҪԴѾ
services.AddQuartZSetup(_configuration);
@@ -181,7 +182,7 @@ namespace IRaCIS.Core.API
app.UseLogDashboard("/LogDashboard");
//hangfire
- //app.UseHangfireConfig(env);
+ app.UseHangfireConfig(env);
////ʱ
//app.UseHttpReports();
diff --git a/IRaCIS.Core.API/_PipelineExtensions/LogDashboard/LogDashBoardAuthFilter.cs b/IRaCIS.Core.API/_PipelineExtensions/Dashboard/LogDashBoardAuthFilter.cs
similarity index 100%
rename from IRaCIS.Core.API/_PipelineExtensions/LogDashboard/LogDashBoardAuthFilter.cs
rename to IRaCIS.Core.API/_PipelineExtensions/Dashboard/LogDashBoardAuthFilter.cs
diff --git a/IRaCIS.Core.API/_PipelineExtensions/Dashboard/hangfireAuthorizationFilter.cs b/IRaCIS.Core.API/_PipelineExtensions/Dashboard/hangfireAuthorizationFilter.cs
new file mode 100644
index 000000000..3dc3a3bb1
--- /dev/null
+++ b/IRaCIS.Core.API/_PipelineExtensions/Dashboard/hangfireAuthorizationFilter.cs
@@ -0,0 +1,17 @@
+using Hangfire.Dashboard;
+
+namespace IRaCIS.Core.API.Filter
+{
+ public class hangfireAuthorizationFilter : IDashboardAuthorizationFilter
+ {
+ public bool Authorize(DashboardContext context)
+ {
+ var httpContext = context.GetHttpContext();
+
+ // Allow all authenticated users to see the Dashboard (potentially dangerous).
+ //return httpContext.User.Identity.IsAuthenticated;
+
+ return true;
+ }
+ }
+}
diff --git a/IRaCIS.Core.API/_PipelineExtensions/HangfireConfig.cs b/IRaCIS.Core.API/_PipelineExtensions/HangfireConfig.cs
new file mode 100644
index 000000000..f0834570d
--- /dev/null
+++ b/IRaCIS.Core.API/_PipelineExtensions/HangfireConfig.cs
@@ -0,0 +1,60 @@
+using Hangfire;
+using Hangfire.Dashboard;
+using Hangfire.Dashboard.BasicAuthorization;
+using IRaCIS.Application.Services.BackGroundJob;
+using IRaCIS.Core.API.Filter;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+
+namespace IRaCIS.Core.API
+{
+
+
+ public static class HangfireConfig
+ {
+
+ public static void UseHangfireConfig(this IApplicationBuilder app, IWebHostEnvironment env)
+ {
+
+
+ app.UseHangfireDashboard("/api/hangfire", new DashboardOptions()
+ {
+ //直接访问,没有带token 获取不到用户身份信息,所以这种自定义授权暂时没法使用
+ //Authorization = new[] { new hangfireAuthorizationFilter() }
+
+ //本地请求 才能看
+ //Authorization = new[] { new LocalRequestsOnlyAuthorizationFilter() }
+
+ Authorization = new BasicAuthAuthorizationFilter[] {
+ new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions(){
+ SslRedirect=false,
+ RequireSsl=false,
+ Users=new BasicAuthAuthorizationUser[]{
+ new BasicAuthAuthorizationUser(){
+ Login="admin",
+ PasswordClear="test",
+
+ }
+ }
+
+ })
+ }
+
+ });
+
+ #region hangfire
+
+ //// 延迟任务执行 1秒之后执行 有时启动没运行 换成添加到队列中
+ //BackgroundJob.Schedule(t => t.MemoryCacheTrialStatus(), TimeSpan.FromSeconds(1));
+ ////添加到后台任务队列,
+ //BackgroundJob.Enqueue(t => t.MemoryCacheTrialStatus());
+
+ //周期性任务,1天执行一次
+
+ //RecurringJob.AddOrUpdate(t => t.ProjectStartCache(), Cron.Daily);
+
+ #endregion
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/IRaCIS.Core.API/_ServiceExtensions/LogDashboardSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/LogDashboardSetup.cs
index 4042dfefe..cf067db5f 100644
--- a/IRaCIS.Core.API/_ServiceExtensions/LogDashboardSetup.cs
+++ b/IRaCIS.Core.API/_ServiceExtensions/LogDashboardSetup.cs
@@ -19,6 +19,8 @@ namespace IRaCIS.Core.API
//opt.AddAuthorizationFilter(new LogDashBoardAuthFilter());
+
+
});
}
diff --git a/IRaCIS.Core.API/_ServiceExtensions/hangfireSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/hangfireSetup.cs
new file mode 100644
index 000000000..b3b02c3f9
--- /dev/null
+++ b/IRaCIS.Core.API/_ServiceExtensions/hangfireSetup.cs
@@ -0,0 +1,40 @@
+using Hangfire;
+using Hangfire.SqlServer;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+
+namespace IRaCIS.Core.API
+{
+ public static class hangfireSetup
+ {
+ public static void AddhangfireSetup(this IServiceCollection services, IConfiguration configuration)
+ {
+ var hangFireConnStr = configuration.GetSection("ConnectionStrings:Hangfire").Value;
+
+ services.AddHangfire(hangFireConfig =>
+ {
+
+ //hangFireConfig.UseInMemoryStorage();
+
+ //指定存储介质
+ hangFireConfig.UseSqlServerStorage(hangFireConnStr, new SqlServerStorageOptions()
+ {
+ SchemaName = "hangfire",
+ CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
+ SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
+ QueuePollInterval = TimeSpan.Zero,
+ UseRecommendedIsolationLevel = true,
+ DisableGlobalLocks = true
+ });
+
+ //hangFireConfig.UseTagsWithSql(); //nuget引入Hangfire.Tags.SqlServer
+ //.UseHangfireHttpJob();
+
+ });
+
+ services.AddHangfireServer();
+
+ }
+ }
+}
diff --git a/IRaCIS.Core.API/appsettings.Test_Study.json b/IRaCIS.Core.API/appsettings.Test_Study.json
index 9e82384b7..0e06899ff 100644
--- a/IRaCIS.Core.API/appsettings.Test_Study.json
+++ b/IRaCIS.Core.API/appsettings.Test_Study.json
@@ -7,7 +7,8 @@
}
},
"ConnectionStrings": {
- "RemoteNew": "Server=123.56.94.154,1433\\MSSQLSERVER;Database=Test.Study;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"
+ "RemoteNew": "Server=123.56.94.154,1433\\MSSQLSERVER;Database=Test.Study;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true",
+ "Hangfire": "Server=123.56.94.154,1433\\MSSQLSERVER;Database=Test.Study.hangfire;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"
},
"BasicSystemConfig": {
diff --git a/IRaCIS.Core.API/appsettings.Uat_Study.json b/IRaCIS.Core.API/appsettings.Uat_Study.json
index ba0d344bc..e3d31bacb 100644
--- a/IRaCIS.Core.API/appsettings.Uat_Study.json
+++ b/IRaCIS.Core.API/appsettings.Uat_Study.json
@@ -7,7 +7,8 @@
}
},
"ConnectionStrings": {
- "RemoteNew": "Server=123.56.94.154,1433\\MSSQLSERVER;Database=Uat.Study;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"
+ "RemoteNew": "Server=123.56.94.154,1433\\MSSQLSERVER;Database=Uat.Study;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true",
+ "Hangfire": "Server=123.56.94.154,1433\\MSSQLSERVER;Database=Uat.Study.hangfire;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"
},
"BasicSystemConfig": {
diff --git a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs
index cd9090ffb..68bb2b970 100644
--- a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs
+++ b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs
@@ -227,6 +227,28 @@ public static class FileStoreHelper
return (serverFilePath, relativePath);
}
+
+ public static (string PhysicalPath, string RelativePath) GetSystemFileUploadPath(IWebHostEnvironment _hostEnvironment, string templateFolderName, string fileName)
+ {
+ var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment);
+
+ //文件类型路径处理
+ var uploadFolderPath = Path.Combine(rootPath, StaticData.Folder.SystemDataFolder, templateFolderName);
+ if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath);
+
+
+ var (trustedFileNameForFileStorage, fileRealName) = FileStoreHelper.GetStoreFileName(fileName);
+
+
+ var relativePath = $"/{StaticData.Folder.IRaCISDataFolder}/{StaticData.Folder.SystemDataFolder}/{templateFolderName}/{trustedFileNameForFileStorage}";
+
+ var serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage);
+
+ return (serverFilePath, relativePath);
+ }
+
+
+
// 获取通用文档存放路径(excel模板 )
public static (string PhysicalPath, string RelativePath) GetCommonDocPath(IWebHostEnvironment _hostEnvironment, string fileName)
diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs
index 84dde1322..83a311319 100644
--- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs
+++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs
@@ -705,6 +705,9 @@ namespace IRaCIS.Core.Application.Contracts
throw new BusinessValidationFailedException("当前调研表已废除,或者调研表状态已锁定,不允许操作");
}
+
+
+
var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId)
.Where(t => !(t.IsHistoryUser && t.IsHistoryUserDeleted == true))
.Select(t =>
@@ -719,19 +722,25 @@ namespace IRaCIS.Core.Application.Contracts
t.Email,
}).ToListAsync();
+ var currentUserList = siteUserList.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId).ToList();
+
+
+ if (!currentUserList.Any(t => t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator) ||
+ !currentUserList.Any(t => t.UserTypeEnum == UserTypeEnum.SR))
+ {
+ throw new BusinessValidationFailedException("本次提交,生成账号必须要有CRC和SR");
+ }
+
+ if(currentUserList.GroupBy(t=>new {t.UserTypeId,t.Email})
+ .Any(g => g.Count() > 1))
+ {
+ throw new BusinessValidationFailedException("同一邮箱同一用户类型,生成账号的数据只允许存在一条!");
+ }
+
+
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined)
{
- var currentUserList = siteUserList.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId).ToList();
-
-
-
- if (!currentUserList.Any(t => t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator) ||
- !currentUserList.Any(t => t.UserTypeEnum == UserTypeEnum.SR))
- {
- throw new BusinessValidationFailedException("本次提交,生成账号必须要有CRC和SR");
- }
-
await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved });
diff --git a/IRaCIS.Core.Domain/_Config/_StaticData.cs b/IRaCIS.Core.Domain/_Config/_StaticData.cs
index 68298ec64..b95189eae 100644
--- a/IRaCIS.Core.Domain/_Config/_StaticData.cs
+++ b/IRaCIS.Core.Domain/_Config/_StaticData.cs
@@ -88,6 +88,8 @@ public static class StaticData
public static readonly string DataTemplate = "DataTemplate";
+ public static readonly string EmailHtmlTemplate = "EmailHtml";
+
public static readonly string NoticeAttachment = "NoticeAttachment";
public static readonly string DicomFolder = "Dicom";