diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index 9d2cb6003..7371c790a 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -37,6 +37,7 @@ using Microsoft.Net.Http.Headers; using MiniExcelLibs; using Newtonsoft.Json; using SharpCompress.Archives; +using SharpCompress.Common; using System; using System.Collections.Generic; using System.Data; @@ -437,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上传 支持三种格式 @@ -936,6 +939,7 @@ namespace IRaCIS.Core.API.Controllers return ResponseOutput.Ok(); } + } @@ -1031,104 +1035,214 @@ namespace IRaCIS.Core.API.Controllers _userInfo = userInfo; } - /// 缩略图 - [AllowAnonymous] - [HttpGet("Common/LocalFilePreview")] - public async Task LocalFilePreview(string relativePath) + + [HttpPost, Route("TrialSiteSurvey/UploadTrialSiteSurveyUser")] + [DisableFormValueModelBinding] + [UnitOfWork] + public async Task UploadTrialSiteSurveyUser(Guid trialId, string baseUrl, string routeUrl, + [FromServices] IRepository _trialSiteRepository, + [FromServices] IRepository _usertypeRepository, + [FromServices] ITrialSiteSurveyService _trialSiteSurveyService) { - - var _fileStorePath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, relativePath); - - var storePreviewPath = _fileStorePath + ".preview.jpeg"; - - if (!System.IO.File.Exists(storePreviewPath)) + var (serverFilePath, relativePath, fileName) = (string.Empty, string.Empty, string.Empty); + await FileUploadAsync(async (realFileName) => { - ImageHelper.ResizeSave(_fileStorePath, storePreviewPath); + fileName = realFileName; + + if (!fileName.EndsWith(".xlsx", StringComparison.OrdinalIgnoreCase)) + { + throw new BusinessValidationFailedException("请用提供格式的模板excel上传需要处理的数据"); + } + + (serverFilePath, relativePath) = FileStoreHelper.GetTrialSiteSurveyFilePath(_hostEnvironment, fileName, trialId); + + return serverFilePath; + }); + + //去掉空白行 + var excelList = MiniExcel.Query(serverFilePath).ToList() + .Where(t => !(string.IsNullOrWhiteSpace(t.TrialSiteCode) && string.IsNullOrWhiteSpace(t.FirstName) && string.IsNullOrWhiteSpace(t.LastName) && string.IsNullOrWhiteSpace(t.Email) + && string.IsNullOrWhiteSpace(t.Phone) && string.IsNullOrWhiteSpace(t.UserTypeStr) && string.IsNullOrWhiteSpace(t.OrganizationName))).ToList(); + + if (excelList.Any(t => string.IsNullOrWhiteSpace(t.TrialSiteCode) || string.IsNullOrWhiteSpace(t.FirstName) || string.IsNullOrWhiteSpace(t.LastName) || string.IsNullOrWhiteSpace(t.Email) || string.IsNullOrWhiteSpace(t.UserTypeStr))) + { + throw new BusinessValidationFailedException("请确保Excel中 每一行的 中心编号,姓名,邮箱,用户类型数据记录完整再进行上传"); } - return new FileContentResult(await System.IO.File.ReadAllBytesAsync(storePreviewPath), "image/jpeg"); + var siteCodeList = excelList.Select(t => t.TrialSiteCode.Trim().ToUpper()).Distinct().ToList(); + + if (_trialSiteRepository.Where(t => t.TrialId==trialId && siteCodeList.Contains(t.TrialSiteCode.ToUpper())).Count() != siteCodeList.Count) + { + throw new BusinessValidationFailedException("在项目中未找到该Excel中部分或全部中心"); + } + + if (excelList.GroupBy(t => new { t.UserTypeStr, t.Email }).Any(g => g.Count() > 1)) + { + throw new BusinessValidationFailedException("同一邮箱,同一用户类型,只能生成一个账户,请核查Excel数据"); + } + + if (excelList.Any(t => !t.Email.Contains("@"))) + { + throw new BusinessValidationFailedException("有邮箱不符合邮箱格式,请核查Excel数据"); + } + var generateUserTypeList = new List() { "CRC", "SR", "CRA" }; + + if (excelList.Any(t => !generateUserTypeList.Contains(t.UserTypeStr.ToUpper()))) + { + throw new BusinessValidationFailedException("用户类型仅能为 CRC,SR,CRA 请核查Excel数据"); + } + + //处理好 用户类型 和用户类型枚举 + var sysUserTypeList = _usertypeRepository.Where(t => t.UserTypeEnum == UserTypeEnum.CRA || t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator || t.UserTypeEnum == UserTypeEnum.SR).Select(t => new { UserTypeId = t.Id, t.UserTypeEnum }).ToList(); + var siteList = _trialSiteRepository.Where(t => t.TrialId == trialId && siteCodeList.Contains(t.TrialSiteCode)).Select(t => new { t.TrialSiteCode, t.SiteId }).ToList(); + + foreach (var item in excelList) + { + switch (item.UserTypeStr.ToUpper()) + { + case "CRC": + + item.UserTypeId = sysUserTypeList.FirstOrDefault(t => t.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).UserTypeId; + item.UserTypeEnum = UserTypeEnum.ClinicalResearchCoordinator; + break; + + case "CRA": + item.UserTypeId = sysUserTypeList.FirstOrDefault(t => t.UserTypeEnum == UserTypeEnum.CRA).UserTypeId; + item.UserTypeEnum = UserTypeEnum.CRA; + break; + + case "SR": + item.UserTypeId = sysUserTypeList.FirstOrDefault(t => t.UserTypeEnum == UserTypeEnum.SR).UserTypeId; + item.UserTypeEnum = UserTypeEnum.SR; + break; + + } + + item.SiteId = siteList.FirstOrDefault(t => t.TrialSiteCode.ToUpper() == item.TrialSiteCode.ToUpper()).SiteId; + } + + await _trialSiteSurveyService.ImportGenerateAccountAndJoinTrialAsync(trialId, baseUrl, routeUrl, excelList.ToList()); + + return ResponseOutput.Ok(); } - /// 通用文件下载 - [AllowAnonymous] - [HttpGet("CommonDocument/DownloadCommonDoc")] - public async Task DownloadCommonFile(string code, [FromServices] IRepository _commonDocumentRepository) - { - var (filePath, fileName) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code); + #region 废弃 - new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType); + ///// 缩略图 + //[AllowAnonymous] + //[HttpGet("Common/LocalFilePreview")] + //public async Task LocalFilePreview(string relativePath) + //{ - return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName); + // var _fileStorePath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, relativePath); - } + // var storePreviewPath = _fileStorePath + ".preview.jpeg"; - /// - /// 下载项目临床数据文件 - /// - /// - /// - /// - [AllowAnonymous] - [HttpGet("CommonDocument/DownloadTrialClinicalFile")] - public async Task DownloadTrialClinicalFile(Guid clinicalDataTrialSetId, [FromServices] IRepository _clinicalDataTrialSetRepository) - { - var (filePath, fileName) = await FileStoreHelper.GetTrialClinicalPathAsync(_hostEnvironment, _clinicalDataTrialSetRepository, clinicalDataTrialSetId); + // if (!System.IO.File.Exists(storePreviewPath)) + // { + // ImageHelper.ResizeSave(_fileStorePath, storePreviewPath); + // } - new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType); + // return new FileContentResult(await System.IO.File.ReadAllBytesAsync(storePreviewPath), "image/jpeg"); - 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/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); - } + //} - /// - ///上传项目签名文档 - /// - /// - /// - [HttpPost("TrialDocument/UploadTrialDoc/{trialId:guid}")] - [DisableRequestSizeLimit] - [DisableFormValueModelBinding] - public async Task UploadTrialDoc(Guid trialId) - { + ///// + ///// 下载项目临床数据文件 + ///// + ///// + ///// + ///// + //[AllowAnonymous] + //[HttpGet("CommonDocument/DownloadTrialClinicalFile")] + //public async Task DownloadTrialClinicalFile(Guid clinicalDataTrialSetId, [FromServices] IRepository _clinicalDataTrialSetRepository) + //{ + // var (filePath, fileName) = await FileStoreHelper.GetTrialClinicalPathAsync(_hostEnvironment, _clinicalDataTrialSetRepository, clinicalDataTrialSetId); - return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetTrialSignDocPath(_hostEnvironment, trialId, fileName)); + // new FileExtensionContentTypeProvider().Mappings.TryGetValue(Path.GetExtension(filePath), out var contentType); - } + // return File(System.IO.File.OpenRead(filePath), contentType ?? "application/octet-stream", fileName); - /// - /// 上传系统签名文档 - /// - /// - [HttpPost("TrialDocument/UploadSystemDoc")] - [DisableRequestSizeLimit] - [DisableFormValueModelBinding] - public async Task UploadSysTemDoc() - { + //} - return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetSystemSignDocPath(_hostEnvironment, fileName)); - } + ///// + ///// 下载系统临床数据文件 + ///// + ///// + ///// + ///// + //[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); + + // 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) + //{ + + // return await SingleFileUploadAsync((fileName) => FileStoreHelper.GetTrialSignDocPath(_hostEnvironment, trialId, fileName)); + + //} + + ///// + ///// 上传系统签名文档 + ///// + ///// + //[HttpPost("TrialDocument/UploadSystemDoc")] + //[DisableRequestSizeLimit] + //[DisableFormValueModelBinding] + //public async Task UploadSysTemDoc() + //{ + + // 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 + /// @@ -1140,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/Properties/launchSettings.json b/IRaCIS.Core.API/Properties/launchSettings.json index dbb6e2d78..a8d648f0a 100644 --- a/IRaCIS.Core.API/Properties/launchSettings.json +++ b/IRaCIS.Core.API/Properties/launchSettings.json @@ -30,31 +30,15 @@ "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", "publishAllPorts": true }, - "IRaCIS.Staging": { + "Uat_Study": { "commandName": "Project", "launchBrowser": true, "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Staging" + "ASPNETCORE_ENVIRONMENT": "Uat_Study" }, - "applicationUrl": "http://localhost:6200" + "applicationUrl": "http://localhost:6100" }, - "IRaCIS.Production": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Production" - }, - "applicationUrl": "http://localhost:6300" - }, - "IRaCIS.CertificateApply": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "CertificateApply" - }, - "applicationUrl": "http://localhost:6400" - }, - "IRaCIS.CenterImageDev": { + "Test_Study": { "commandName": "Project", "launchBrowser": true, "environmentVariables": { 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/Test.cs b/IRaCIS.Core.API/Test.cs deleted file mode 100644 index f7567c3ca..000000000 --- a/IRaCIS.Core.API/Test.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.EntityFrameworkCore; - -namespace EFSaving.Concurrency -{ - public class Sample - { - public static void Run() - { - // Ensure database is created and has a person in it - using (var setupContext = new PersonContext()) - { - setupContext.Database.EnsureDeleted(); - setupContext.Database.EnsureCreated(); - - setupContext.People.Add(new Person { FirstName = "John", LastName = "Doe" }); - setupContext.SaveChanges(); - } - - #region ConcurrencyHandlingCode - using var context = new PersonContext(); - // Fetch a person from database and change phone number - var person = context.People.Single(p => p.PersonId == 1); - person.PhoneNumber = "555-555-5555"; - - // Change the person's name in the database to simulate a concurrency conflict - context.Database.ExecuteSqlRaw( - "UPDATE dbo.People SET FirstName = 'Jane' WHERE PersonId = 1"); - - var saved = false; - while (!saved) - { - try - { - // Attempt to save changes to the database - context.SaveChanges(); - saved = true; - } - catch (DbUpdateConcurrencyException ex) - { - foreach (var entry in ex.Entries) - { - if (entry.Entity is Person) - { - var proposedValues = entry.CurrentValues; - var databaseValues = entry.GetDatabaseValues(); - - foreach (var property in proposedValues.Properties) - { - var proposedValue = proposedValues[property]; - var databaseValue = databaseValues[property]; - - // TODO: decide which value should be written to database - // proposedValues[property] = ; - } - - // Refresh original values to bypass next concurrency check - entry.OriginalValues.SetValues(databaseValues); - } - else - { - throw new NotSupportedException( - "Don't know how to handle concurrency conflicts for " - + entry.Metadata.Name); - } - } - } - } - #endregion - } - - public class PersonContext : DbContext - { - public DbSet People { get; set; } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - // Requires NuGet package Microsoft.EntityFrameworkCore.SqlServer - optionsBuilder.UseSqlServer( - @"Server=(localdb)\mssqllocaldb;Database=EFSaving.Concurrency;Trusted_Connection=True"); - } - } - - public class Person - { - public int PersonId { get; set; } - - [ConcurrencyCheck] - public string FirstName { get; set; } - - [ConcurrencyCheck] - public string LastName { get; set; } - - public string PhoneNumber { get; set; } - } - } -} \ No newline at end of file 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 8b87a0e23..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=CenterImage_Test;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": { @@ -28,9 +29,9 @@ "SystemEmailSendConfig": { "Port": 465, "Host": "smtp.qiye.aliyun.com", - "FromEmail": "test@extimaging.com", - "FromName": "Test_IRC", - "AuthorizationCode": "SHzyyl2021" + "FromEmail": "test-study@extimaging.com", + "FromName": "Test_Study", + "AuthorizationCode": "zhanying123" } } diff --git a/IRaCIS.Core.API/appsettings.Uat_Study.json b/IRaCIS.Core.API/appsettings.Uat_Study.json index 2f3ac31ff..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": { @@ -28,9 +29,9 @@ "SystemEmailSendConfig": { "Port": 465, "Host": "smtp.qiye.aliyun.com", - "FromEmail": "test@extimaging.com", - "FromName": "Test_IRC", - "AuthorizationCode": "SHzyyl2021" + "FromEmail": "uat-study@extimaging.com", + "FromName": "Uat_Study", + "AuthorizationCode": "zhanying123" } } diff --git a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs index dbdd13cd4..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) @@ -292,6 +314,28 @@ public static class FileStoreHelper return (serverFilePath, relativePath); } + //获取 中心调研用户路径 + + public static (string PhysicalPath, string RelativePath) GetTrialSiteSurveyFilePath(IWebHostEnvironment _hostEnvironment, string fileName, Guid trialId) + { + var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment); + + //上传根路径 + string uploadFolderPath = Path.Combine(rootPath, StaticData.Folder.TrialDataFolder, trialId.ToString(), StaticData.Folder.UploadSiteSurveyData); + + if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath); + + + var (trustedFileNameForFileStorage, realFileName) = FileStoreHelper.GetStoreFileName(fileName); + + + var relativePath = $"/{StaticData.Folder.IRaCISDataFolder}/{StaticData.Folder.TrialDataFolder}/{trialId}/{StaticData.Folder.UploadSiteSurveyData}/{trustedFileNameForFileStorage}"; + + var serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage); + + return (serverFilePath, relativePath); + } + public static (string PhysicalPath, string RelativePath, string FileRealName) GetClinicalTemplatePath(IWebHostEnvironment _hostEnvironment, string fileName,Guid trialId) { diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 5fd42050b..3ec98cf7f 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -7741,42 +7741,6 @@ - - - 勾选用户 批量发送邮件 - - - - - - 不带Token 访问 用户选择 参与 不参与 Id: TrialExternalUserId 加入发送邮件 - - - - - - - 不带Token 访问 Site调研用户 加入项目 Id: TrialSiteSurveyUserId - - - - - - - 不带Token 访问 页面获取项目基本信息 和参与情况 (已经确认了 就不允许再次确认) Id: TrialExternalUserId/TrialSiteSurveyUserId - - - - - - - - 加入项目 - - - - - TaskAllocationRuleView 列表视图模型 @@ -9460,11 +9424,11 @@ - - 发送验证码 - - - + + site 调研 发送验证码 + + + @@ -9520,14 +9484,6 @@ - - - 驳回 - - - - - 提交 后台自动识别是谁提交 diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index d5498f96f..548987b2b 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -55,7 +55,7 @@ namespace IRaCIS.Core.Application.Service public VisitTaskHelpeService(IRepository visitTaskRepository, IRepository trialRepository, IEasyCachingProvider provider, IRepository subjectVisitRepository, IRepository readModuleRepository, - IRepository readingTaskQuestionAnswerRepository, + IRepository readingTaskQuestionAnswerRepository, IRepository readingTableAnswerRowInfoRepository, IRepository readingTableQuestionAnswerRepository, IRepository readingTableQuestionTrialRepository, diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 9bbeef1b5..80167909a 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -255,6 +255,8 @@ namespace IRaCIS.Core.Application.Service.Allocation visitTask.LatestReplyUserId = _userInfo.Id; visitTask.LatestReplyTime = DateTime.Now; + visitTask.IsEnrollment = incommand.PIAuditState == PIAuditState.PINotAgree ? null : visitTask.IsEnrollment; + visitTask.IsPDConfirm = incommand.PIAuditState == PIAuditState.PINotAgree ? null : visitTask.IsPDConfirm; if (isFirstAudit) { diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 33cc8d6a6..abdba14f3 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -155,9 +155,7 @@ namespace IRaCIS.Core.Application.Service.Common .Where(t => groupSelectIdQuery.Contains(t.TrialSiteSurveyId)) .WhereIf(queryParam.UserTypeId != null, t => t.UserTypeId == queryParam.UserTypeId) .WhereIf(queryParam.IsGenerateAccount != null, t => t.IsGenerateAccount == queryParam.IsGenerateAccount) - .WhereIf(queryParam.TrialRoleNameId != null, t => t.TrialRoleNameId == queryParam.TrialRoleNameId) .WhereIf(queryParam.State != null && queryParam.State != TrialSiteUserStateEnum.OverTime, t => t.InviteState == queryParam.State) - .WhereIf(queryParam.State != null && queryParam.State == TrialSiteUserStateEnum.OverTime, t => t.InviteState == TrialSiteUserStateEnum.HasSend && t.ExpireTime < DateTime.Now) .WhereIf(!string.IsNullOrEmpty(queryParam.UserName), t => (t.LastName + " / " + t.FirstName).Contains(queryParam.UserName)) .WhereIf(!string.IsNullOrEmpty(queryParam.OrganizationName), t => t.OrganizationName.Contains(queryParam.OrganizationName)) .ProjectTo(_mapper.ConfigurationProvider); diff --git a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs index fc4b1efa1..4d3003ad9 100644 --- a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Contracts; using User = IRaCIS.Core.Domain.Models.User; +using DocumentFormat.OpenXml.Office2010.Word; namespace IRaCIS.Core.Application.Services { @@ -19,14 +20,16 @@ namespace IRaCIS.Core.Application.Services private readonly IRepository _systemDocumentRepository; private readonly IRepository _systemDocNeedConfirmedUserTypeRepository; + private readonly IRepository _systemDocConfirmedUserRepository; public SystemDocumentService( IRepository systemDocumentRepository, - IRepository systemDocNeedConfirmedUserTypeRepository - ) + IRepository systemDocNeedConfirmedUserTypeRepository, + IRepository systemDocConfirmedUserRepository) { _systemDocumentRepository = systemDocumentRepository; this._systemDocNeedConfirmedUserTypeRepository = systemDocNeedConfirmedUserTypeRepository; - } + _systemDocConfirmedUserRepository = systemDocConfirmedUserRepository; + } @@ -109,6 +112,22 @@ namespace IRaCIS.Core.Application.Services } + [HttpDelete("{systemDocumentId:guid}")] + public async Task AbandonSystemDocumentAsync(Guid systemDocumentId) + { + + await _systemDocumentRepository.UpdatePartialFromQueryAsync(systemDocumentId, u => new SystemDocument() { IsDeleted = true }); + + await _systemDocConfirmedUserRepository.UpdatePartialFromQueryAsync(x => x.SystemDocumentId == systemDocumentId, x => new SystemDocConfirmedUser() + { + IsDeleted = true + }); + + await _systemDocConfirmedUserRepository.SaveChangesAsync(); + return ResponseOutput.Result(true); + } + + [HttpDelete("{systemDocumentId:guid}")] public async Task DeleteSystemDocumentAsync(Guid systemDocumentId) diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index 9defbfcbb..64556463d 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -224,7 +224,7 @@ namespace IRaCIS.Core.Application.Services .Where(t => t.IsDeleted == false && !t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id && t.ConfirmTime != null) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .CountAsync(); - var trialTaskConfig = _trialRepository.Where(t => t.Id == querySystemDocument.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); + var trialTaskConfig = _trialRepository.Where(t => t.Id == querySystemDocument.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); //var trialCriterionAdditionalAssessmentTypeList = _trialCriterionAdditionalAssessmentTypeRepository diff --git a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs index c6aa10fd2..c6b5a168e 100644 --- a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs @@ -113,7 +113,15 @@ namespace IRaCIS.Core.Application.Contracts if (userTypeSelectEnum == UserTypeSelectEnum.ExternalUser) { - userTypeEnums = new List() { UserTypeEnum.PI, UserTypeEnum.MIM }; + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.TA) + { + userTypeEnums = new List() { UserTypeEnum.ProjectManager }; + } + else + { + userTypeEnums = new List() { UserTypeEnum.PI, UserTypeEnum.MIM }; + } + } if (userTypeSelectEnum == UserTypeSelectEnum.SiteSurvey) diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs index c6cecba91..bd658172b 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs @@ -84,7 +84,6 @@ namespace IRaCIS.Core.Application.Contracts public bool? IsGenerateAccount { get; set; } - public Guid? TrialRoleNameId { get; set; } public TrialSiteUserStateEnum? State { get; set; } @@ -168,6 +167,29 @@ namespace IRaCIS.Core.Application.Contracts + } + + public class TrialSiteSurveySelectView + { + public Guid Id { get; set; } + public TrialSiteSurveyEnum State { get; set; } + public DateTime CreateTime { get; set; } + public bool IsDeleted { get; set; } + + public string Phone { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + + public string UserName { get; set; } = string.Empty; + + } + + public class TrialSiteSurveySelectquery + { + public Guid TrialId { get; set; } + + public Guid SiteId { get; set; } + + public Guid TrialSiteSurveyId { get;set; } } ///TrialSiteSurveyQuery 列表查询参数模型 diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs index f3e868457..d272c3cba 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs @@ -5,7 +5,9 @@ //-------------------------------------------------------------------- using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Domain.Share; +using MiniExcelLibs.Attributes; using Newtonsoft.Json; +using System.ComponentModel.DataAnnotations; namespace IRaCIS.Core.Application.Contracts { @@ -48,14 +50,18 @@ namespace IRaCIS.Core.Application.Contracts } } - public string TrialRoleName { get; set; } - public string TrialRoleCode { get; set; } public UserTypeEnum? UserTypeEnum { get; set; } public Guid? SystemUserId { get; set; } + + + + public bool? IsHistoryUserOriginDeleted { get; set; } + + } @@ -98,11 +104,20 @@ namespace IRaCIS.Core.Application.Contracts [DictionaryTranslateAttribute("YesOrNo")] public bool IsGenerateAccount { get; set; } - public Guid TrialRoleNameId { get; set; } + public int TrialRoleCode { get; set; } public string OrganizationName { get; set; } = string.Empty; + + public bool IsHistoryUser { get; set; } + public bool? IsHistoryUserDeleted { get; set; } } + public class TrialSiteUserSurverQuery + { + public Guid TrialSiteSurveyId { get; set; } + + public bool? IsHistoryUser { get; set; } + } public class TrialSiteUserSurveyVerfyResult { @@ -111,6 +126,44 @@ namespace IRaCIS.Core.Application.Contracts public List ErroMsgList { get; set; } = new List(); } + public class SiteSurveyUserImportUploadDto + { + [NotDefault] + public Guid TrialId { get; set; } + + public string BaseUrl { get; set; } + public string RouteUrl { get; set; } + } + + public class SiteSurveyUserImportDto + { + public string TrialSiteCode { get;set; }=string.Empty; + public string FirstName { get; set; } = string.Empty; + public string LastName { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + public string Phone { get; set; } = string.Empty; + public string OrganizationName { get; set; } = string.Empty; + + [ExcelColumnName("UserType")] + public string UserTypeStr { get; set; } + + [JsonIgnore] + public Guid SiteId { get; set; } + + [JsonIgnore] + public UserTypeEnum UserTypeEnum { get; set; } = UserTypeEnum.Undefined; + + + [JsonIgnore] + public Guid UserTypeId{ get; set; } + + + [JsonIgnore] + public bool IsGeneratedAccount { get; set; } + [JsonIgnore] + public bool IsJoinedTrial { get; set; } + } + } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteSurveyService.cs index 6bc2fc3ec..52a6ba09a 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteSurveyService.cs @@ -20,5 +20,7 @@ namespace IRaCIS.Core.Application.Contracts //Task TrialSurveyLock(Guid trialSiteSurveyId, bool isLock); //IResponseOutput TrialSurveySubmmit(Guid trialId, Guid trialSiteSurveyId); Task VerifySendCode(LoginDto userInfo, [FromServices] ITokenService _tokenService); + + Task ImportGenerateAccountAndJoinTrialAsync(Guid trialId, string baseUrl,string rootUrl, List list); } } \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteUserSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteUserSurveyService.cs index 32942f1ac..10de23ac1 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteUserSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteUserSurveyService.cs @@ -10,6 +10,6 @@ namespace IRaCIS.Core.Application.Contracts { Task AddOrUpdateTrialSiteUserSurvey(TrialSiteUserSurveyAddOrEdit addOrEditTrialSiteUserSurvey); Task DeleteTrialSiteUserSurvey(Guid trialSiteUserSurveyId); - Task> GetTrialSiteUserSurveyList(Guid trialSiteSurveyId); + Task> GetTrialSiteUserSurveyList(TrialSiteUserSurverQuery inquery); } } \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs index 5a1de2dff..16486d477 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs @@ -17,10 +17,12 @@ namespace IRaCIS.Core.Application.Contracts public class TrialSiteEquipmentSurveyService : BaseService, ITrialSiteEquipmentSurveyService { private readonly IRepository _trialSiteEquipmentSurveyRepository; + private readonly IRepository _trialSiteSurveyRepository; - public TrialSiteEquipmentSurveyService(IRepository trialSiteEquipmentSurveyRepository) + public TrialSiteEquipmentSurveyService(IRepository trialSiteEquipmentSurveyRepository, IRepository trialSiteSurveyRepository) { _trialSiteEquipmentSurveyRepository = trialSiteEquipmentSurveyRepository; + _trialSiteSurveyRepository = trialSiteSurveyRepository; } @@ -38,17 +40,14 @@ namespace IRaCIS.Core.Application.Contracts [HttpPost("{trialId:guid}")] public async Task AddOrUpdateTrialSiteEquipmentSurvey(TrialSiteEquipmentSurveyAddOrEdit addOrEditTrialSiteEquipmentSurvey) { - - if (addOrEditTrialSiteEquipmentSurvey.Id != null) + + if (await _trialSiteSurveyRepository.AnyAsync(t => t.Id == addOrEditTrialSiteEquipmentSurvey.TrialSiteSurveyId && (t.IsDeleted == true ||t.State==TrialSiteSurveyEnum.PMCreatedAndLock), true)) { - if (await _trialSiteEquipmentSurveyRepository.Where(t => t.Id == addOrEditTrialSiteEquipmentSurvey.Id).AnyAsync(t => t.TrialSiteSurvey.State==TrialSiteSurveyEnum.PMCreatedAndLock)) - { - //---已锁定,不允许操作 - return ResponseOutput.NotOk(_localizer["TrialSiteEquipment_Locked"]); - } + return ResponseOutput.NotOk("当前调研表已废除,或者调研表状态已锁定,不允许操作"); } + var entity = await _trialSiteEquipmentSurveyRepository.InsertOrUpdateAsync(addOrEditTrialSiteEquipmentSurvey, true); return ResponseOutput.Ok(entity.Id.ToString()); diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index c6a07797d..e88eb19d6 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -15,6 +15,12 @@ using MailKit.Security; using MimeKit; using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.Filter; +using IRaCIS.Core.Infrastructure.Extention; +using Microsoft.VisualBasic; +using DocumentFormat.OpenXml.Spreadsheet; +using IRaCIS.Core.Domain.Models; +using IRaCIS.Core.Application.ViewModel; +using Dicom; namespace IRaCIS.Core.Application.Contracts { @@ -29,13 +35,14 @@ namespace IRaCIS.Core.Application.Contracts private readonly IRepository _userRepository; private readonly IRepository _trialSiteRepository; private readonly IRepository _trialUserRepository; + private readonly IRepository _trialSiteUserRepository; private readonly ITokenService _tokenService; private readonly IMailVerificationService _mailVerificationService; public TrialSiteSurveyService(IRepository trialSiteSurveyRepository, IRepository trialUserRepository, IRepository trialSiteUserSurveyRepository, IRepository userRepository, IRepository trialSiteRepository, ITokenService tokenService, - IMailVerificationService mailVerificationService) + IMailVerificationService mailVerificationService, IRepository trialSiteUserRepository) { _trialSiteSurveyRepository = trialSiteSurveyRepository; _trialSiteUserSurveyRepository = trialSiteUserSurveyRepository; @@ -44,6 +51,7 @@ namespace IRaCIS.Core.Application.Contracts _trialSiteRepository = trialSiteRepository; _tokenService = tokenService; _mailVerificationService = mailVerificationService; + _trialSiteUserRepository = trialSiteUserRepository; } private object lockObj { get; set; } = new object(); @@ -107,7 +115,7 @@ namespace IRaCIS.Core.Application.Contracts } /// - /// 发送验证码 + ///site 调研 发送验证码 /// /// /// @@ -150,225 +158,244 @@ namespace IRaCIS.Core.Application.Contracts public async Task VerifySendCode(LoginDto userInfo, [FromServices] ITokenService _tokenService) { - var isReplaceUser = !string.IsNullOrEmpty(userInfo.ReplaceUserEmailOrPhone); + + #region 历史版本 删除前 + + //var isReplaceUser = !string.IsNullOrEmpty(userInfo.ReplaceUserEmailOrPhone); - if (userInfo.IsUpdate && isReplaceUser && !await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.ReplaceUserEmailOrPhone || t.Phone == userInfo.ReplaceUserEmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId)) - { - //---该中心不存在该交接人的中心调研记录表,不允许选择更新。 - return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_NoRecordToUpdate"]); - } + //if (userInfo.IsUpdate && isReplaceUser && !await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.ReplaceUserEmailOrPhone || t.Phone == userInfo.ReplaceUserEmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId)) + //{ + // //---该中心不存在该交接人的中心调研记录表,不允许选择更新。 + // return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_NoRecordToUpdate"]); + //} - if (userInfo.IsUpdate && await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.EmailOrPhone || t.Phone == userInfo.EmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State != TrialSiteSurveyEnum.PMCreatedAndLock)) - { - //---您的中心调研记录正在审核中,不允许进行更新操作。若需要更新,请在驳回后进行操作。 - return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_RecordUnderReview"]); - } + //if (userInfo.IsUpdate && await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.EmailOrPhone || t.Phone == userInfo.EmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State != TrialSiteSurveyEnum.PMCreatedAndLock)) + //{ + // //---您的中心调研记录正在审核中,不允许进行更新操作。若需要更新,请在驳回后进行操作。 + // return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_RecordUnderReview"]); + //} - //自己的记录锁定了 只能更新自己的,不能更新别人的(但是别人能更新自己锁定的) - if (userInfo.IsUpdate && userInfo.ReplaceUserEmailOrPhone != userInfo.EmailOrPhone && await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.EmailOrPhone || t.Phone == userInfo.EmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock)) - { - //自己的锁了 想更新别人的 - //---当前中心中,您提交调研记录表已锁定,不允许更新其他人邮箱调研记录。 - return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_LockedByCurrentUser"]); - } + ////自己的记录锁定了 只能更新自己的,不能更新别人的(但是别人能更新自己锁定的) + //if (userInfo.IsUpdate && userInfo.ReplaceUserEmailOrPhone != userInfo.EmailOrPhone && await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.EmailOrPhone || t.Phone == userInfo.EmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock)) + //{ + // //自己的锁了 想更新别人的 + // //---当前中心中,您提交调研记录表已锁定,不允许更新其他人邮箱调研记录。 + // return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_LockedByCurrentUser"]); + //} - //自己的锁定了 如果有其他未锁定的,也不能更新自己的 - if (userInfo.IsUpdate && userInfo.ReplaceUserEmailOrPhone == userInfo.EmailOrPhone && - await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.EmailOrPhone || t.Phone == userInfo.EmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock) - && await _trialSiteSurveyRepository.AnyAsync(t => (t.Email != userInfo.EmailOrPhone && t.Phone != userInfo.EmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State != TrialSiteSurveyEnum.PMCreatedAndLock)) - { + ////自己的锁定了 如果有其他未锁定的,也不能更新自己的 + //if (userInfo.IsUpdate && userInfo.ReplaceUserEmailOrPhone == userInfo.EmailOrPhone && + // await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.EmailOrPhone || t.Phone == userInfo.EmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock) + // && await _trialSiteSurveyRepository.AnyAsync(t => (t.Email != userInfo.EmailOrPhone && t.Phone != userInfo.EmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State != TrialSiteSurveyEnum.PMCreatedAndLock)) + //{ - //---当前中心,您提交的调研记录表已锁定。当前存在其他人员提交的调研记录表未锁定,不允许更新您之前提交的调研记录。 - return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_LockedByOtherUsers"]); - } + // //---当前中心,您提交的调研记录表已锁定。当前存在其他人员提交的调研记录表未锁定,不允许更新您之前提交的调研记录。 + // return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_LockedByOtherUsers"]); + //} - ////存在未锁定的记录,却去更新已锁定的 - if (userInfo.IsUpdate && userInfo.ReplaceUserEmailOrPhone != userInfo.EmailOrPhone && await _trialSiteSurveyRepository.AnyAsync(t => t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State != TrialSiteSurveyEnum.PMCreatedAndLock) - && await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.ReplaceUserEmailOrPhone || t.Phone == userInfo.ReplaceUserEmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock) - && !await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.ReplaceUserEmailOrPhone || t.Phone == userInfo.ReplaceUserEmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State != TrialSiteSurveyEnum.PMCreatedAndLock) - ) - { - //---当前中心存在未锁定的调研记录,不允许更新已锁定的调研记录。 - return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_UnlockedRecordsExist"]); - } + //////存在未锁定的记录,却去更新已锁定的 + //if (userInfo.IsUpdate && userInfo.ReplaceUserEmailOrPhone != userInfo.EmailOrPhone && await _trialSiteSurveyRepository.AnyAsync(t => t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State != TrialSiteSurveyEnum.PMCreatedAndLock) + //&& await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.ReplaceUserEmailOrPhone || t.Phone == userInfo.ReplaceUserEmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock) + //&& !await _trialSiteSurveyRepository.AnyAsync(t => (t.Email == userInfo.ReplaceUserEmailOrPhone || t.Phone == userInfo.ReplaceUserEmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State != TrialSiteSurveyEnum.PMCreatedAndLock) + //) + //{ + // //---当前中心存在未锁定的调研记录,不允许更新已锁定的调研记录。 + // return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_UnlockedRecordsExist"]); + //} + #endregion - var verificationRecord = await _repository - .FirstOrDefaultAsync(t => (t.EmailOrPhone == userInfo.EmailOrPhone) && t.Code == userInfo.verificationCode && t.CodeType == userInfo.verificationType); + #region 20230804 修改调研表逻辑 + + var verifyRecord = await _repository.FirstOrDefaultAsync(t => (t.EmailOrPhone == userInfo.EmailOrPhone) && t.Code == userInfo.verificationCode && t.CodeType == userInfo.verificationType); //检查数据库是否存在该验证码 - if (verificationRecord == null) + if (verifyRecord == null) { //---验证码错误。 return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_WrongVerificationCode"]); } + else if (verifyRecord.ExpirationTime < DateTime.Now) + { + return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_WrongVerificationCode"]); + } else { - //检查验证码是否失效 - if (verificationRecord.ExpirationTime < DateTime.Now) + //验证码正确 不处理 + } + + TrialSiteSurvey? currentEntity = null; + + + var userList = await _trialSiteUserRepository.Where(t => t.TrialId == userInfo.TrialId && t.SiteId == userInfo.SiteId, false, true).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + + //普通登录 + if (userInfo.IsUpdate == false) + { + + var dbEntityList = await _trialSiteSurveyRepository.Where(t => t.TrialId == userInfo.TrialId && t.SiteId == userInfo.SiteId).ToListAsync(); + + + //没有记录 new一份 + if (dbEntityList.Count == 0) { - //---验证码已经过期。 - return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_ExpiredVerificationCode"]); + var addSurvey = _mapper.Map(userInfo); + + + //从项目site 中找到已存在的 加到历史人员中 + addSurvey.TrialSiteUserSurveyList = userList; + + currentEntity = await _repository.AddAsync(addSurvey); + } - else //验证码正确 并且 没有超时 + else { - TrialSiteSurvey? dbEntity = null; + //找到当前最新的调研表 + var currentLatest = dbEntityList.OrderByDescending(t => t.CreateTime).FirstOrDefault(); - //替换交接人 - if (isReplaceUser) + if (currentLatest.Email != userInfo.EmailOrPhone) { - //该交接人的记录 是否有未锁定的 有就用未锁定的,没有就用 锁定的最后一条 - - var noLockedLastSurvey = await _trialSiteSurveyRepository.Where(t => (t.Email == userInfo.ReplaceUserEmailOrPhone || t.Phone == userInfo.ReplaceUserEmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock == false, true) - .Include(u => u.TrialSiteEquipmentSurveyList).Include(u => u.TrialSiteUserSurveyList).OrderByDescending(t => t.CreateTime).FirstOrDefaultAsync(); - - //都是锁定的 - if (noLockedLastSurvey == null) - { - - var latestLock = await _trialSiteSurveyRepository.Where(t => t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId).OrderByDescending(t => t.CreateTime).FirstOrDefaultAsync(); - - if (latestLock!.Email != userInfo.ReplaceUserEmailOrPhone) - { - return ResponseOutput.NotOk($"该邮箱{userInfo.ReplaceUserEmailOrPhone}对应的调查表不是最新锁定的记录,不允许更新!"); - } - - var lockedLastSurvey = await _trialSiteSurveyRepository.Where(t => (t.Email == userInfo.ReplaceUserEmailOrPhone || t.Phone == userInfo.ReplaceUserEmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock == true) - .Include(u => u.TrialSiteEquipmentSurveyList).Include(u => u.TrialSiteUserSurveyList).OrderByDescending(t => t.CreateTime).FirstOrDefaultAsync().IfNullThrowException(); - - //Copy 一份 更换邮箱 - - var copy = lockedLastSurvey.Clone(); - - copy.State = TrialSiteSurveyEnum.ToSubmit; - - copy.Email = userInfo.EmailOrPhone; - - if (userInfo.ReplaceUserEmailOrPhone != userInfo.EmailOrPhone) - { - copy.UserName = String.Empty; - copy.Phone = String.Empty; - } - - - copy.Id = Guid.Empty; - copy.TrialSiteEquipmentSurveyList.ForEach(t => t.Id = Guid.Empty); - copy.TrialSiteUserSurveyList.ForEach(t => t.Id = Guid.Empty); - - dbEntity = await _repository.AddAsync(copy); - - } - else - { - //有未锁定的 更新下邮箱 - noLockedLastSurvey.Email = userInfo.EmailOrPhone; - noLockedLastSurvey.UserName = String.Empty; - noLockedLastSurvey.Phone = String.Empty; - - dbEntity = noLockedLastSurvey; - } - - - - ////邮箱相同的话 就是同一个人进来 copy一份 - //if (userInfo.EmailOrPhone == userInfo.ReplaceUserEmailOrPhone) - //{ - // dbEntity = await _repository.Where(t => (t.Email == userInfo.EmailOrPhone || t.Phone == userInfo.EmailOrPhone) && t.SiteId == userInfo.SiteId && t.TrialId == userInfo.TrialId).Include(u => u.TrialSiteEquipmentSurveyList).Include(u => u.TrialSiteUserSurveyList).FirstOrDefaultAsync().IfNullThrowConvertException(); - - // var clone = dbEntity.Clone(); - // clone.Id = Guid.Empty; - // clone.TrialSiteEquipmentSurveyList.ForEach(t => t.Id = Guid.Empty); - // clone.TrialSiteUserSurveyList.ForEach(t => t.Id = Guid.Empty); - // clone.State = TrialSiteSurveyEnum.ToSubmit; - - // dbEntity = await _repository.AddAsync(clone); - - //} - + //---该中心下已经有其他用户已填写的调研表,您不被允许继续填写 + return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_AlreadyFilledByOtherUsers"]); } - else + + currentEntity = currentLatest; + + if (currentEntity.State != TrialSiteSurveyEnum.PMCreatedAndLock) { - var dbEntityList = await _trialSiteSurveyRepository.Where(t => t.TrialId == userInfo.TrialId && t.SiteId == userInfo.SiteId).ToListAsync(); - - - //没有记录 new一份 - if (dbEntityList.Count == 0) - { - - dbEntity = await _repository.AddAsync(_mapper.Map(userInfo)); - - } - else - { - - - - //该site 下不存在该邮箱的记录 - if (!dbEntityList.Any(t => t.Email == userInfo.EmailOrPhone || t.Phone == userInfo.EmailOrPhone)) - { - //---该中心下已经有其他用户已填写的调研表,您不被允许继续填写 - return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_AlreadyFilledByOtherUsers"]); - } - - - //有没有该邮箱 未锁定的 - var nolockEntity = dbEntityList.Where(t => t.Email == userInfo.EmailOrPhone || t.Phone == userInfo.EmailOrPhone).FirstOrDefault(t => t.State != TrialSiteSurveyEnum.PMCreatedAndLock); - - // 未锁定的 为空 - if (nolockEntity == null) - { - //查看最新锁定的 - dbEntity = dbEntityList.Where(t => t.Email == userInfo.EmailOrPhone || t.Phone == userInfo.EmailOrPhone).OrderByDescending(t => t.CreateTime).FirstOrDefault(t => t.State == TrialSiteSurveyEnum.PMCreatedAndLock).IfNullThrowException(); - - } - else //有未锁定的 直接用未锁定的 - { - dbEntity = nolockEntity; - } - - } - //_mapper.Map(userInfo, dbEntity); - - - + await UnlockSyncSiteUserAsync(userInfo.TrialId, userInfo.SiteId, currentEntity.Id, userList); } + } - //删除验证码历史记录 - await _repository.BatchDeleteAsync(t => t.EmailOrPhone == userInfo.EmailOrPhone && t.Code == userInfo.verificationCode && t.CodeType == userInfo.verificationType); - await _repository.SaveChangesAsync(); - return ResponseOutput.Ok(new - { - TrialSiteSurveyId = dbEntity!.Id, - Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo() - { - Id = Guid.NewGuid(), - IsReviewer = false, - IsAdmin = false, - RealName = "SiteSurvey", - UserName = "SiteSurvey", - Sex = 0, - //UserType = "ShareType", - UserTypeEnum = UserTypeEnum.Undefined, - Code = "SiteSurvey", - })) - }); + } + //更新调研表 + else + { + //找到最新的调研表 + var currentLatest = await _trialSiteSurveyRepository.Where(t => t.TrialId == userInfo.TrialId && t.SiteId == userInfo.SiteId, true) + .Include(u => u.TrialSiteEquipmentSurveyList).Include(u => u.TrialSiteUserSurveyList).OrderByDescending(t => t.CreateTime).FirstOrDefaultAsync(); + + if (currentLatest == null) + { + return ResponseOutput.NotOk("当前site没有调研表可以更新,请确认"); + } + + if (currentLatest.Email != userInfo.ReplaceUserEmailOrPhone) + { + //---该中心不存在该交接人的中心调研记录表,不允许选择更新。 + return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_NoRecordToUpdate"]); + } + + + + //未锁定的状态 就改为废除 + if (currentLatest.State != TrialSiteSurveyEnum.PMCreatedAndLock) + { + currentLatest.IsDeleted = true; + } + //锁定的 需要改状态么? + else + { + + } + var copy = currentLatest.Clone(); + + copy.State = TrialSiteSurveyEnum.ToSubmit; + copy.IsDeleted = false; + + copy.Email = userInfo.EmailOrPhone; + copy.Id = Guid.Empty; + copy.CreateTime = DateAndTime.Now; + + if (userInfo.ReplaceUserEmailOrPhone != userInfo.EmailOrPhone) + { + copy.UserName = String.Empty; + copy.Phone = String.Empty; + } + + + + copy.TrialSiteEquipmentSurveyList = currentLatest.TrialSiteEquipmentSurveyList.Clone(); + copy.TrialSiteEquipmentSurveyList.ForEach(t => { t.Id = Guid.Empty; t.CreateTime = DateTime.Now; }); + + //锁定了的话,就不拷贝 + if (currentLatest.State != TrialSiteSurveyEnum.PMCreatedAndLock) + { + copy.TrialSiteUserSurveyList = currentLatest.TrialSiteUserSurveyList.Clone().Where(t => t.IsHistoryUser == false).ToList(); + copy.TrialSiteUserSurveyList.ForEach(t => { t.Id = Guid.Empty; t.IsGenerateSuccess = false; t.CreateTime = DateTime.Now; }); + } + + //从项目site 中找到已存在的 加到历史人员中 + + + copy.TrialSiteUserSurveyList.AddRange(userList); + + currentEntity = await _trialSiteSurveyRepository.AddAsync(copy); + + + + } + + + //删除验证码历史记录 + await _repository.BatchDeleteAsync(t => t.EmailOrPhone == userInfo.EmailOrPhone && t.Code == userInfo.verificationCode && t.CodeType == userInfo.verificationType); + + await _trialSiteSurveyRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(new + { + TrialSiteSurveyId = currentEntity!.Id, + Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo() + { + Id = Guid.NewGuid(), + IsReviewer = false, + IsAdmin = false, + RealName = "SiteSurvey", + UserName = "SiteSurvey", + Sex = 0, + //UserType = "ShareType", + UserTypeEnum = UserTypeEnum.Undefined, + Code = "SiteSurvey", + })) + }); + + #endregion + } + + private async Task UnlockSyncSiteUserAsync(Guid trialId, Guid siteId, Guid trialSiteSurveyId, List userList) + { + var existList = await _trialSiteUserSurveyRepository.Where(t => t.IsHistoryUser && t.TrialSiteSurvey.TrialId == trialId && t.TrialSiteSurvey.SiteId == siteId, true).ToListAsync(); + + foreach (var item in userList) + { + var find = existList.FirstOrDefault(t => t.SystemUserId == item.SystemUserId); + //不存在就加入 + if (find == null) + { + item.TrialSiteSurveyId = trialSiteSurveyId; + await _trialSiteUserSurveyRepository.AddAsync(item); + } + else + { + find.IsHistoryUserOriginDeleted = item.IsHistoryUserOriginDeleted; } } + await _trialSiteUserSurveyRepository.SaveChangesAsync(); } @@ -379,9 +406,24 @@ namespace IRaCIS.Core.Application.Contracts [HttpGet("{trialId:guid}/{trialSiteSurveyId:guid}")] public async Task GetSiteSurveyInfo(Guid trialSiteSurveyId, Guid trialId) { - var result = await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId && t.TrialId == trialId) - .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); + //有可能填表人提交了,但是此时PM手动对人员信息进行了更改,此时需要将数据同步下(选择在这里同步是因为 不想改动 中心人员哪里的两个接口的逻辑) + var find = await _trialSiteSurveyRepository.FirstOrDefaultAsync(t => t.Id == trialSiteSurveyId, true); + + + if (find.State != TrialSiteSurveyEnum.PMCreatedAndLock && find.IsDeleted != true) + { + var userList = await _trialSiteUserRepository.Where(t => t.TrialId == find.TrialId && t.SiteId == find.SiteId, false, true).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + + + await UnlockSyncSiteUserAsync(find.TrialId, find.SiteId, find.Id, userList); + } + + + + + var result = await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId && t.TrialId == trialId).IgnoreQueryFilters() + .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); return result; } @@ -464,6 +506,16 @@ namespace IRaCIS.Core.Application.Contracts return await trialSiteSurveyQueryable.ToPagedListAsync(surveyQueryDTO.PageIndex, surveyQueryDTO.PageSize, surveyQueryDTO.SortField, surveyQueryDTO.Asc); } + [HttpPost] + public async Task> GetTrialSiteSurveySelectList(TrialSiteSurveySelectquery inQuery) + { + var trialSiteSurveyQueryable = _trialSiteSurveyRepository + .Where(t => t.Id != inQuery.TrialSiteSurveyId) + .Where(t => t.TrialId == inQuery.TrialId && t.SiteId == inQuery.SiteId).IgnoreQueryFilters() + .ProjectTo(_mapper.ConfigurationProvider); + + return await trialSiteSurveyQueryable.ToListAsync(); + } /// /// 项目Site调研用户列表 所有site的调研用户 最新的调研表的记录的用户 new @@ -485,27 +537,12 @@ namespace IRaCIS.Core.Application.Contracts .Where(t => groupSelectIdQuery.Contains(t.TrialSiteSurveyId)) .WhereIf(queryParam.UserTypeId != null, t => t.UserTypeId == queryParam.UserTypeId) .WhereIf(queryParam.IsGenerateAccount != null, t => t.IsGenerateAccount == queryParam.IsGenerateAccount) - .WhereIf(queryParam.TrialRoleNameId != null, t => t.TrialRoleNameId == queryParam.TrialRoleNameId) .WhereIf(queryParam.State != null && queryParam.State != TrialSiteUserStateEnum.OverTime, t => t.InviteState == queryParam.State) - .WhereIf(queryParam.State != null && queryParam.State == TrialSiteUserStateEnum.OverTime, t => t.InviteState == TrialSiteUserStateEnum.HasSend && t.ExpireTime < DateTime.Now) .WhereIf(!string.IsNullOrEmpty(queryParam.UserName), t => (t.LastName + " / " + t.FirstName).Contains(queryParam.UserName)) .WhereIf(!string.IsNullOrEmpty(queryParam.OrganizationName), t => t.OrganizationName.Contains(queryParam.OrganizationName)) .ProjectTo(_mapper.ConfigurationProvider); - //var query = _trialSiteSurveyRepository.Where(t => t.TrialId == queryParam.TrialId && t.IsAbandon == false) - // .WhereIf(queryParam.SiteId != null, t => t.SiteId == queryParam.SiteId) - // .WhereIf(!string.IsNullOrEmpty(queryParam.FormWriterKeyInfo), t => (t.UserName).Contains(queryParam.FormWriterKeyInfo) || t.Email.Contains(queryParam.FormWriterKeyInfo) || t.Phone.Contains(queryParam.FormWriterKeyInfo)) - // .GroupBy(t => t.SiteId) - // .Select(g => g.OrderByDescending(u => u.CreateTime).FirstOrDefault()) - // .SelectMany(t => t.TrialSiteUserSurveyList) - //.WhereIf(queryParam.UserTypeId != null, t => t.UserTypeId == queryParam.UserTypeId) - //.WhereIf(queryParam.IsGenerateAccount != null, t => t.IsGenerateAccount == queryParam.IsGenerateAccount) - //.WhereIf(queryParam.TrialRoleNameId != null, t => t.TrialRoleNameId == queryParam.TrialRoleNameId) - //.WhereIf(queryParam.State != null && queryParam.State != TrialSiteUserStateEnum.OverTime, t => t.InviteState == queryParam.State) - //.WhereIf(queryParam.State != null && queryParam.State == TrialSiteUserStateEnum.OverTime, t => t.InviteState == TrialSiteUserStateEnum.HasSend && t.ExpireTime < DateTime.Now) - //.WhereIf(!string.IsNullOrEmpty(queryParam.UserKeyInfo), t => (t.LastName + " / " + t.FirstName).Contains(queryParam.UserKeyInfo) || t.Email.Contains(queryParam.UserKeyInfo) || t.Phone.Contains(queryParam.UserKeyInfo)) - //.ProjectTo(_mapper.ConfigurationProvider); return await query.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, queryParam.SortField, queryParam.Asc); @@ -556,18 +593,18 @@ namespace IRaCIS.Core.Application.Contracts //---中心调研已锁定,不允许操作。 return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_Locked"]); } - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager ) + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { - //没有SPM 给填表人发 - messageToSend.To.Add(new MailboxAddress(String.Empty, survey.Email)); + //没有SPM 给填表人发 + messageToSend.To.Add(new MailboxAddress(String.Empty, survey.Email)); - survey.State = TrialSiteSurveyEnum.ToSubmit; + survey.State = TrialSiteSurveyEnum.ToSubmit; - survey.PreliminaryUserId = null; - survey.ReviewerUserId = null; - survey.PreliminaryTime = null; - survey.ReviewerTime = null; + survey.PreliminaryUserId = null; + survey.ReviewerUserId = null; + survey.PreliminaryTime = null; + survey.ReviewerTime = null; } @@ -620,29 +657,8 @@ namespace IRaCIS.Core.Application.Contracts } - /// - /// 驳回 - /// - /// - /// - /// - [HttpPut("{trialId:guid}/{trialSiteSurveyId:guid}")] - [Obsolete] - public async Task SubmissionRejection(Guid trialId, Guid trialSiteSurveyId) - { - if (await _repository.AnyAsync(t => t.State == TrialSiteSurveyEnum.PMCreatedAndLock && t.Id == trialSiteSurveyId)) - { - //---中心调研已锁定,不允许操作。 - return ResponseOutput.NotOk(_localizer["TrialSiteSurvey_Locked"]); - } - await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.ToSubmit }); - - return ResponseOutput.Ok(); - - } - [HttpPut("{trialId:guid}/{trialSiteSurveyId:guid}")] [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] @@ -681,9 +697,20 @@ namespace IRaCIS.Core.Application.Contracts var trialId = siteSurvyeSubmit.TrialId; var trialSiteSurveyId = siteSurvyeSubmit.TrialSiteSurveyId; - var trialSiteSurvey = (await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId).FirstOrDefaultAsync()).IfNullThrowException(); + var trialSiteSurvey = (await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId, false, true).FirstOrDefaultAsync()).IfNullThrowException(); - var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurvey.TrialId == trialId && t.TrialSiteSurvey.SiteId == trialSiteSurvey.SiteId && t.TrialSiteSurvey.IsDeleted == false).Select(t => + + if (trialSiteSurvey.IsDeleted == true || trialSiteSurvey.State == TrialSiteSurveyEnum.PMCreatedAndLock) + { + throw new BusinessValidationFailedException("当前调研表已废除,或者调研表状态已锁定,不允许操作"); + } + + + + + var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId) + .Where(t => !(t.IsHistoryUser && t.IsHistoryUserDeleted == true)) + .Select(t => new { t.TrialSiteSurveyId, @@ -691,25 +718,29 @@ namespace IRaCIS.Core.Application.Contracts t.IsGenerateSuccess, t.UserTypeId, UserTypeEnum = (UserTypeEnum?)t.UserTypeRole.UserTypeEnum, - t.TrialRoleName.Code, - t.Email + t.TrialRoleCode, + 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) { - //是第一次 - if (!siteUserList.Any(t => t.IsGenerateSuccess)) - { - var currentUserList = siteUserList.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId).ToList(); - - if (!currentUserList.Any(t => t.Code == "1") || !currentUserList.Any(t => t.Code == "5")) - { - throw new BusinessValidationFailedException("本次提交,必须有CRC和影像阅片人信息"); - } - } await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved }); @@ -717,39 +748,26 @@ namespace IRaCIS.Core.Application.Contracts else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { - foreach (var group in (siteUserList.Where(t => t.IsGenerateAccount && t.TrialSiteSurveyId == trialSiteSurveyId) - .GroupBy(t => new { t.Email, t.IsGenerateAccount, t.UserTypeId }))) - { - if (group.Count() > 1) - { - throw new BusinessValidationFailedException("同一邮箱同一用户类型,生成账号的数据只允许存在一条!"); - } - } - - //是第一次 - if (!siteUserList.Any(t => t.IsGenerateSuccess)) - { - 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"); - } - } - + var allUserList = _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId).ProjectTo(_mapper.ConfigurationProvider).ToList(); //已生成的不管 管的只需要是 生成失败的并且需要生成账号的 - var needGenerateList = _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId && t.IsGenerateAccount && t.IsJoin != true).ProjectTo(_mapper.ConfigurationProvider).ToList(); - - - //await SendInviteEmail(new InviteEmailCommand() { TrialId = trialId, RouteUrl = siteSurvyeSubmit.RouteUrl, UserList = needGenerateList }); - + var needGenerateList = allUserList.Where(t => t.IsHistoryUser == false && t.IsGenerateAccount && t.IsJoin != true).ToList(); await GenerateAccountAsync(needGenerateList, trialId); - await SendSiteSurveyUserJoinEmail(new TrialSiteUserSurveyJoinCommand() { TrialId = trialId, TrialSiteSurveyId = trialSiteSurveyId, RouteUrl = siteSurvyeSubmit.RouteUrl, BaseUrl = siteSurvyeSubmit.BaseUrl, UserList = needGenerateList }); + //新加入的 或者历史人员退出改为加入的 + var needSendEmailList = allUserList.Where(t => (t.IsHistoryUser == false && t.IsGenerateAccount && t.IsJoin != true) || (t.IsHistoryUser == true && t.IsHistoryUserOriginDeleted == true && t.IsHistoryUserDeleted == false)).ToList(); + + await SendSiteSurveyUserJoinEmail(new TrialSiteUserSurveyJoinCommand() { TrialId = trialId, TrialSiteSurveyId = trialSiteSurveyId, RouteUrl = siteSurvyeSubmit.RouteUrl, BaseUrl = siteSurvyeSubmit.BaseUrl, UserList = needSendEmailList }); + + + var needQuitUserList = allUserList.Where(t => t.IsHistoryUser && t.IsHistoryUserOriginDeleted == false && t.IsHistoryUserDeleted == true).ToList(); + + await DealSiteUserQuitSiteAsync(trialId, trialSiteSurvey.SiteId, needQuitUserList); + + //将历史锁定的调研表废弃 + await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.SiteId == trialSiteSurvey.SiteId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock && t.Id != trialSiteSurveyId, z => new TrialSiteSurvey() { IsDeleted = true }); //将历史锁定的调研表废弃 await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.SiteId == trialSiteSurvey.SiteId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock, z => new TrialSiteSurvey() { IsDeleted = true }); @@ -763,13 +781,14 @@ namespace IRaCIS.Core.Application.Contracts private async Task GenerateAccountAsync(List needGenerateList, Guid trialId) { + var trialType = _repository.Where(t => t.Id == trialId).Select(t => t.TrialType).FirstOrDefault(); + foreach (var item in needGenerateList) { //找下系统中是否存在该用户类型的 并且邮箱 或者手机的账户 var sysUserInfo = await _userRepository.Where(t => t.UserTypeId == item.UserTypeId && t.EMail == item.Email).Include(t => t.UserTypeRole).FirstOrDefaultAsync(); - var trialType = _repository.Where(t => t.Id == trialId).Select(t => t.TrialType).FirstOrDefault(); if (sysUserInfo == null) { @@ -794,7 +813,6 @@ namespace IRaCIS.Core.Application.Contracts saveItem.UserTypeEnum = _repository.Where(t => t.Id == saveItem.UserTypeId).Select(t => t.UserTypeEnum).First(); - //saveItem.Password = MD5Helper.Md5(verificationCode.ToString()); var newUser = _userRepository.AddAsync(saveItem).Result; @@ -803,29 +821,24 @@ namespace IRaCIS.Core.Application.Contracts sysUserInfo = newUser; + } + await _trialSiteUserSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, SystemUserId = sysUserInfo.Id }); + } //发送邮件的时候需要用到该字段 item.SystemUserId = sysUserInfo.Id; - await _trialSiteUserSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, SystemUserId = sysUserInfo.Id }); - - - - } await _trialSiteUserSurveyRepository.SaveChangesAsync(); } - - - [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task SendSiteSurveyUserJoinEmail(TrialSiteUserSurveyJoinCommand joinCommand) + private async Task SendSiteSurveyUserJoinEmail(TrialSiteUserSurveyJoinCommand joinCommand) { var trialSiteSurvey = await _trialSiteSurveyRepository.FirstAsync(t => t.Id == joinCommand.TrialSiteSurveyId); @@ -846,24 +859,48 @@ namespace IRaCIS.Core.Application.Contracts //判断TrialUser中是否存在 不存在就插入 - if (!await _trialUserRepository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId, true)) + + var findTrialUser = await _trialUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId, true); + if (findTrialUser == null) { await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId, JoinTime = DateTime.Now }); + + await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl); + } - if (!await _repository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true)) + else if (findTrialUser.IsDeleted == true) + { + await _trialUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.UserId == userId, c => new TrialUser() + { + IsDeleted = false, + DeletedTime = null, + JoinTime = DateTime.Now, + }); + + await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl); + } + + var findTrialSiteUser = await _trialSiteUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true); + + if (findTrialSiteUser == null) { await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId }); + + } + else + { + findTrialSiteUser.IsDeleted = false; + findTrialSiteUser.DeletedTime = null; } await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); + await _trialSiteUserSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == userInfo.Id, u => new TrialSiteUserSurvey() { IsJoin = true }); - - await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl); - } await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurvey.Id && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); + await _userRepository.SaveChangesAsync(); return ResponseOutput.Ok(); @@ -872,39 +909,67 @@ namespace IRaCIS.Core.Application.Contracts } - - - - #region 废弃 - //Site 调研邀请 - public async Task SendInviteEmail(InviteEmailCommand inviteEmailCommand) + private async Task DealSiteUserQuitSiteAsync(Guid trialId, Guid siteId, List list) { - var trialInfo = await _repository.FirstOrDefaultAsync(t => t.Id == inviteEmailCommand.TrialId); + var userIdList = list.Select(t => t.SystemUserId).ToList(); - foreach (var item in inviteEmailCommand.UserList) + await _trialSiteUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.SiteId == siteId && userIdList.Contains(t.UserId), c => new TrialSiteUser() { + IsDeleted = true, + DeletedTime = DateTime.Now, + }); - var messageToSend = new MimeMessage(); - //发件地址 - messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com")); - //收件地址 - messageToSend.To.Add(new MailboxAddress(String.Empty, item.Email)); - //主题 - //$"[来自展影IRC] [{trialInfo.ResearchProgramNo}] 邀请信"; - messageToSend.Subject = _localizer["TrialSiteSurvey_IRCInvitation", trialInfo.ResearchProgramNo]; + //var siteUserList = await _repository.Where(t => t.TrialId == trialId && t.SiteId == siteId && userIdList.Contains(t.UserId), true,true).ToListAsync(); - var builder = new BodyBuilder(); + //foreach (var siteUser in siteUserList) + //{ + + // var find= list.FirstOrDefault(t => t.SystemUserId == siteUser.UserId); + // if(find != null) + // { + // siteUser.IsDeleted =(bool) find.IsHistoryUserDeleted; + // siteUser.DeletedTime = find.IsHistoryUserDeleted==true? DateTime.Now:null; + // } + //} + + + #region MyRegion + ////跟踪查询该site下的所有的用户 + //var siteUserList = await _repository.Where(t => t.TrialId == trialId && t.SiteId == siteId, true).ToListAsync(); + + //foreach (var siteUser in siteUserList) + //{ + // //当前中心用户 不在调研表存在,就将该人退出 + // if (!list.Any(t => t.SystemUserId == siteUser.UserId)) + // { + // siteUser.IsDeleted = true; + // siteUser.DeletedTime = DateTime.Now; + // } + + //} + #endregion + + + await _repository.SaveChangesAsync(); + } + + + + public async Task ImportGenerateAccountAndJoinTrialAsync(Guid trialId, string baseUrl, string routeUrl, List list) + { + + + var trialType = _repository.Where(t => t.Id == trialId).Select(t => t.TrialType).FirstOrDefault(); + + //判断是否有系统账号 + foreach (var item in list) + { //找下系统中是否存在该用户类型的 并且邮箱 或者手机的账户 var sysUserInfo = await _userRepository.Where(t => t.UserTypeId == item.UserTypeId && t.EMail == item.Email).Include(t => t.UserTypeRole).FirstOrDefaultAsync(); - //int verificationCode = new Random().Next(100000, 1000000); - - //var baseApiUrl = baseUrl.Remove(baseUrl.IndexOf("#")) + "api"; - - if (sysUserInfo == null) { @@ -912,83 +977,80 @@ namespace IRaCIS.Core.Application.Contracts { var saveItem = _mapper.Map(item); + + if (trialType == TrialType.NoneOfficial) + { + saveItem.IsTestUser = true; + } + + // 中心调研生成账号 都是外部的 + saveItem.IsZhiZhun = false; saveItem.Code = _userRepository.Select(t => t.Code).DefaultIfEmpty().Max() + 1; - saveItem.UserCode = AppSettings.GetCodeStr(saveItem.Code, nameof(User)); ; + saveItem.UserCode = AppSettings.GetCodeStr(saveItem.Code, nameof(User)); saveItem.UserName = saveItem.UserCode; - saveItem.UserTypeEnum = _repository.Where(t => t.Id == saveItem.UserTypeId).Select(t => t.UserTypeEnum).First(); + var newUser = _userRepository.AddAsync(saveItem).Result; - //saveItem.Password = MD5Helper.Md5(verificationCode.ToString()); + _ = _userRepository.SaveChangesAsync().Result; - _ = _repository.AddAsync(saveItem).Result; + sysUserInfo = newUser; - _ = _repository.SaveChangesAsync().Result; - - - sysUserInfo = saveItem; } + item.IsGeneratedAccount = true; + } + var userId = sysUserInfo.Id; + var siteId = item.SiteId; - - builder.HtmlBody = @$" -
-
-
- {sysUserInfo.LastName + "/" + sysUserInfo.FirstName}: -
-
- {_localizer["TrialSiteSurvey_IRCInvitationContent", trialInfo.ResearchProgramNo]} -
- - - 查看并确认 - -
-
- "; - - - - messageToSend.Body = builder.ToMessageBody(); - - using (var smtp = new MailKit.Net.Smtp.SmtpClient()) + //判断是否加入到项目 + var findTrialUser = await _trialUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId, true); + if (findTrialUser == null) { + await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId, JoinTime = DateTime.Now }); - smtp.ServerCertificateValidationCallback = (s, c, h, e) => true; + await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, baseUrl, routeUrl); - smtp.MessageSent += (sender, args) => - { - - _ = _trialSiteUserSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, InviteState = TrialSiteUserStateEnum.HasSend, ConfirmTime = null, RejectReason = String.Empty, SystemUserId = sysUserInfo.Id, ExpireTime = DateTime.Now.AddDays(7) }).Result; - - }; - - - await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls); - - - await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH"); - - - await smtp.SendAsync(messageToSend); - - - await smtp.DisconnectAsync(true); } + else if (findTrialUser.IsDeleted == true) + { + await _trialUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.UserId == userId, c => new TrialUser() + { + IsDeleted = false, + DeletedTime = null, + JoinTime = DateTime.Now, + }); + + await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, baseUrl, routeUrl); + } + + + var findTrialSiteUser = await _trialSiteUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true); + + if (findTrialSiteUser == null) + { + await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId }); + + } + else + { + findTrialSiteUser.IsDeleted = false; + findTrialSiteUser.DeletedTime = null; + } + + await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); + + await _trialSiteUserRepository.SaveChangesAsync(); } - return ResponseOutput.Ok(); + } - #endregion - - } } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs index 78a25359e..e11d4e531 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Application.Filter; using IRaCIS.Core.Infrastructure; +using IRaCIS.Application.Contracts; namespace IRaCIS.Core.Application.Contracts { @@ -17,57 +18,43 @@ namespace IRaCIS.Core.Application.Contracts public class TrialSiteUserSurveyService : BaseService, ITrialSiteUserSurveyService { private readonly IRepository _trialSiteUserSurveyRepository; + private readonly IRepository _trialSiteSurveyRepository; - public TrialSiteUserSurveyService(IRepository trialSiteUserSurveyRepository) + public TrialSiteUserSurveyService(IRepository trialSiteUserSurveyRepository, IRepository trialSiteSurveyRepository) { _trialSiteUserSurveyRepository = trialSiteUserSurveyRepository; + _trialSiteSurveyRepository = trialSiteSurveyRepository; } - [HttpGet("{trialSiteSurveyId:guid}")] - public async Task> GetTrialSiteUserSurveyList(Guid trialSiteSurveyId) + [HttpPost] + public async Task> GetTrialSiteUserSurveyList(TrialSiteUserSurverQuery inquery) { - var trialSiteUserSurveyQueryable = _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId) - //.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM, t => t.TrialSiteSurvey.State >= TrialSiteSurveyEnum.CRCSubmitted) - //.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM|| _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM, t => t.TrialSiteSurvey.State >= TrialSiteSurveyEnum.SPMApproved) + var trialSiteUserSurveyQueryable = _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == inquery.TrialSiteSurveyId) + .WhereIf(inquery.IsHistoryUser !=null, t => t.IsHistoryUser==inquery.IsHistoryUser) .ProjectTo(_mapper.ConfigurationProvider, new { isEn_Us = _userInfo.IsEn_Us }); return await trialSiteUserSurveyQueryable.ToListAsync(); } - [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] + + [TypeFilter(typeof(TrialResourceFilter),Arguments = new object[] { "AfterStopCannNotOpt" })] [HttpPost("{trialId:guid}")] public async Task AddOrUpdateTrialSiteUserSurvey(TrialSiteUserSurveyAddOrEdit addOrEditTrialSiteUserSurvey) { - if (await _trialSiteUserSurveyRepository.Where(t => t.Id == addOrEditTrialSiteUserSurvey.Id).AnyAsync(t => t.TrialSiteSurvey.State == TrialSiteSurveyEnum.PMCreatedAndLock)) + + + if (await _trialSiteSurveyRepository.AnyAsync(t => t.Id == addOrEditTrialSiteUserSurvey.TrialSiteSurveyId && (t.IsDeleted == true || t.State == TrialSiteSurveyEnum.PMCreatedAndLock), true)) { - //---已锁定,不允许操作 - return ResponseOutput.NotOk(_localizer["TrialSiteUser_Locked"]); + //当前调研表已废除,或者调研表状态已锁定,不允许操作 + return ResponseOutput.NotOk("当前调研表已废除,或者调研表状态已锁定,不允许操作"); } - - if (addOrEditTrialSiteUserSurvey.UserTypeId != null && ( _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM)) - { - var existSysUser = await _repository.Where(t => t.EMail == addOrEditTrialSiteUserSurvey.Email && t.UserTypeId == addOrEditTrialSiteUserSurvey.UserTypeId).Include(d=>d.UserTypeRole).FirstOrDefaultAsync(); - - - if (existSysUser != null) - { - if (existSysUser.LastName != addOrEditTrialSiteUserSurvey.LastName || existSysUser.FirstName != addOrEditTrialSiteUserSurvey.FirstName) - { - //$"该用户在系统中账户名为:{existSysUser.LastName + " / " + existSysUser.FirstName} ,与填写信息存在不一致项, 现将界面信息修改为与系统一致,可进行保存" - return ResponseOutput.NotOk(_localizer["TrialSiteUser_InconsistentInfo", existSysUser.UserTypeRole.UserTypeShortName, existSysUser.EMail, existSysUser.LastName + " / " + existSysUser.FirstName,existSysUser.Phone], - new { existSysUser.LastName, existSysUser.FirstName, existSysUser.Phone,existSysUser.IsTestUser,existSysUser.IsZhiZhun }, ApiResponseCodeEnum.NeedTips); - } - - } - - } - + if (addOrEditTrialSiteUserSurvey.IsGenerateAccount ) { - var trialId= _trialSiteUserSurveyRepository.Where(t=>t.TrialSiteSurveyId == addOrEditTrialSiteUserSurvey.TrialSiteSurveyId).Select(t=>t.TrialSiteSurvey.TrialId).FirstOrDefault(); + var trialId= _trialSiteSurveyRepository.Where(t=>t.Id == addOrEditTrialSiteUserSurvey.TrialSiteSurveyId,false,true).Select(t=>t.TrialId).FirstOrDefault(); var trialType = _repository.Where(t => t.Id == trialId).Select(t => t.TrialType).FirstOrDefault(); @@ -105,7 +92,40 @@ namespace IRaCIS.Core.Application.Contracts } - var entity = await _trialSiteUserSurveyRepository.InsertOrUpdateAsync(addOrEditTrialSiteUserSurvey, true); + var verifyExp1 = new EntityVerifyExp() + { + VerifyExp = u => u.UserTypeId == addOrEditTrialSiteUserSurvey.UserTypeId && u.Email == addOrEditTrialSiteUserSurvey.Email && u.TrialSiteSurveyId==addOrEditTrialSiteUserSurvey.TrialSiteSurveyId, + VerifyMsg = "同一邮箱同一用户类型,生成账号的数据只允许存在一条!", + IsVerify=addOrEditTrialSiteUserSurvey.IsGenerateAccount + + }; + + if (addOrEditTrialSiteUserSurvey.UserTypeId != null) + { + var existSysUser = await _repository.Where(t => t.EMail == addOrEditTrialSiteUserSurvey.Email && t.UserTypeId == addOrEditTrialSiteUserSurvey.UserTypeId).Include(d => d.UserTypeRole).FirstOrDefaultAsync(); + + + if (existSysUser != null) + { + if (existSysUser.LastName != addOrEditTrialSiteUserSurvey.LastName || existSysUser.FirstName != addOrEditTrialSiteUserSurvey.FirstName) + { + + + var optEntity = await _trialSiteUserSurveyRepository.InsertOrUpdateAsync(addOrEditTrialSiteUserSurvey, true, verifyExp1); + + //$"该用户在系统中账户名为:{existSysUser.LastName + " / " + existSysUser.FirstName} ,与填写信息存在不一致项, 现将界面信息修改为与系统一致,可进行保存" + return ResponseOutput.NotOk(_localizer["TrialSiteUser_InconsistentInfo", existSysUser.UserTypeRole.UserTypeShortName, existSysUser.EMail, existSysUser.LastName + " / " + existSysUser.FirstName, existSysUser.Phone], + new { Id= optEntity.Id, existSysUser.LastName, existSysUser.FirstName, existSysUser.Phone, existSysUser.IsTestUser, existSysUser.IsZhiZhun }, ApiResponseCodeEnum.NeedTips); + } + + } + } + + + var entity = await _trialSiteUserSurveyRepository.InsertOrUpdateAsync(addOrEditTrialSiteUserSurvey, true, verifyExp1); + + + return ResponseOutput.Ok(entity.Id.ToString()); diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs b/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs index 311a8fda6..ea2453623 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs @@ -21,6 +21,23 @@ namespace IRaCIS.Core.Application.AutoMapper CreateMap().ForMember(d => d.Email, t => t.MapFrom(t => t.EmailOrPhone)); + CreateMap() + .ForMember(d => d.Id, u => u.Ignore()) + .ForMember(d => d.Phone, u => u.MapFrom(c => c.User.Phone)) + .ForMember(d => d.Email, u => u.MapFrom(c => c.User.EMail)) + .ForMember(d => d.OrganizationName, u => u.MapFrom(c => c.User.OrganizationName)) + .ForMember(d => d.UserTypeId, u => u.MapFrom(c => c.User.UserTypeId)) + .ForMember(d => d.IsHistoryUser, u => u.MapFrom(c => true)) + .ForMember(d => d.IsHistoryUserOriginDeleted, u => u.MapFrom(c => c.IsDeleted)) + .ForMember(d => d.IsHistoryUserDeleted, u => u.MapFrom(c => c.IsDeleted)) + .ForMember(d => d.FirstName, u => u.MapFrom(c => c.User.FirstName)) + .ForMember(d => d.LastName, u => u.MapFrom(c => c.User.LastName)) + .ForMember(d => d.IsGenerateAccount, u => u.MapFrom(c => true)) + .ForMember(d => d.IsGenerateSuccess, u => u.MapFrom(c => true)) + .ForMember(d => d.SystemUserId, u => u.MapFrom(c => c.UserId)) + .ForMember(d => d.IsJoin, u => u.MapFrom(c => !c.IsDeleted)); + + //列表 CreateMap() @@ -33,11 +50,10 @@ namespace IRaCIS.Core.Application.AutoMapper .ForMember(d => d.SiteName, u => u.MapFrom(s => s.Site.SiteName)) .ForMember(d => d.TrialSiteCode, u => u.MapFrom(s => s.TrialSite.TrialSiteCode)); - + CreateMap(); + var isEn_Us = false; CreateMap() - .ForMember(t => t.TrialRoleName, u => u.MapFrom(d => isEn_Us? d.TrialRoleName.Value:d.TrialRoleName.ValueCN)) - .ForMember(t => t.TrialRoleCode, u => u.MapFrom(d => d.TrialRoleName.Code)) .ForMember(d => d.UserType, u => u.MapFrom(s => s.UserTypeRole.UserTypeShortName)) .ForMember(d => d.UserTypeEnum, u => u.MapFrom(s => s.UserTypeRole.UserTypeEnum)); @@ -61,6 +77,10 @@ namespace IRaCIS.Core.Application.AutoMapper CreateMap(); + CreateMap() + .ForMember(d => d.EMail, u => u.MapFrom(s => s.Email)); + + CreateMap(); @@ -70,7 +90,6 @@ namespace IRaCIS.Core.Application.AutoMapper CreateMap() .ForMember(t=>t.TrialSiteSurvey,u=>u.MapFrom(c=>c.TrialSiteSurvey)) - .ForMember(t => t.TrialRoleName, u => u.MapFrom(d => d.TrialRoleName.Value)) .ForMember(d => d.UserType, u => u.MapFrom(s => s.UserTypeRole.UserTypeShortName)) .ForMember(d => d.UserTypeEnum, u => u.MapFrom(s => s.UserTypeRole.UserTypeEnum)); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs index 9da0f6e88..ba9cedd59 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs @@ -214,6 +214,25 @@ namespace IRaCIS.Core.Application.Contracts } + public class TrialConfigTabDto + { + public TrialQCProcess QCProcessEnum { get; set; } = TrialQCProcess.DoubleAudit; + + public bool IsImageConsistencyVerification { get; set; } = true; + + public bool IsMedicalReview { get; set; } + + + public bool IsEnrollementQualificationConfirm { get; set; } = false; + + + public bool IsPDProgressView { get; set; } + + public UserTypeEnum? EnrollConfirmDefaultUserType { get; set; } + + public UserTypeEnum? PDProgressDefaultUserType { get; set; } + } + public class TrialProcessConfigDTO { /// diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs index ca5d4e631..69e0d5b83 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs @@ -50,7 +50,7 @@ namespace IRaCIS.Core.Application.ViewModel - + public UserTypeEnum? UserTypeEnum { get; set; } public DateTime? ExpireTime { get; set; } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialExternalUserService.cs index 065aeea98..b3e671035 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialExternalUserService.cs @@ -21,7 +21,6 @@ namespace IRaCIS.Core.Application.Interfaces Task DeleteTrialExternalUser(Guid trialExternalUserId, bool isSystemUser, Guid systemUserId); - Task UserConfirmJoinTrial(Guid trialId, Guid trialExternalUserId); } } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index 94bb318c3..6bf00a16e 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -281,535 +281,5 @@ namespace IRaCIS.Core.Application.Service - - - - #region 老版本流程 现在废弃 - - /// - /// 勾选用户 批量发送邮件 - /// - /// - [HttpPost] - public async Task SendInviteEmail(TrialExternalUserSendEmail sendEmail) - { - - var trialInfo = await _repository.FirstOrDefaultAsync(t => t.Id == sendEmail.TrialId); - - foreach (var userInfo in sendEmail.SendUsers) - { - var messageToSend = new MimeMessage(); - //发件地址 - messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com")); - //收件地址 - messageToSend.To.Add(new MailboxAddress(String.Empty, userInfo.Email)); - //主题 - messageToSend.Subject = $"[{trialInfo.ResearchProgramNo}] 邀请"; - - //var baseApiUrl = sendEmail.BaseUrl.Remove(sendEmail.BaseUrl.IndexOf("#")) + "api"; - - var builder = new BodyBuilder(); - - var sysUserInfo = (await _userRepository.Where(t => t.Id == userInfo.SystemUserId).FirstOrDefaultAsync()).IfNullThrowException(); - - - builder.HtmlBody = @$" -
-
-
- {sysUserInfo.LastName + "/" + sysUserInfo.FirstName}: -
-
- { - //您好,展影医疗作为 实验方案号:{trialInfo.ResearchProgramNo} 项目的IRC供应商,诚邀您参加该项目IRC相关工作,欢迎您提供指导和建议,非常感谢! - _localizer["TrialExternalUser_IRCInvitation", trialInfo.ResearchProgramNo] - } - -
- - - - - 查看并确认 - -
櫭 -
- "; - - - //< form action = '#' method = 'post' > - - // < button type = 'submit' style = 'margin-left:60px;font-size:14px;text-decoration: none;display: inline-block;height: 40px;width: 140px;background: #00D1B2;color:#fff;border-radius: 5px;line-height: 40px;text-align: center;border:none;margin-bottom: 100px;cursor: pointer' > 查看并确认 - - // - messageToSend.Body = builder.ToMessageBody(); - - using (var smtp = new MailKit.Net.Smtp.SmtpClient()) - { - smtp.MessageSent += (sender, args) => - { - - _ = _trialExternalUseRepository.BatchUpdateNoTrackingAsync(t => t.Id == userInfo.Id, u => new TrialExternalUser() { InviteState = TrialExternalUserStateEnum.HasSend, ConfirmTime = null, RejectReason = String.Empty, ExpireTime = DateTime.Now.AddDays(7) }).Result; - - }; - - smtp.ServerCertificateValidationCallback = (s, c, h, e) => true; - - await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls); - - await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH"); - - await smtp.SendAsync(messageToSend); - - await smtp.DisconnectAsync(true); - } - - - } - - return ResponseOutput.Ok(); - - } - - - - - /// - /// 不带Token 访问 用户选择 参与 不参与 Id: TrialExternalUserId 加入发送邮件 - /// - /// - /// - [AllowAnonymous] - public async Task TrialExternalUserJoinTrial(TrialExternalUserConfirm editTrialUserPreparation) - { - - var needUpdate = await _trialExternalUseRepository.FirstOrDefaultAsync(t => t.Id == editTrialUserPreparation.Id); - - if (DateTime.Now > needUpdate.ExpireTime) - { - //---邀请加入时间已过期,重新被邀请后才可以进行确认操作 - return ResponseOutput.NotOk(_localizer["TrialExternalUser_InvitationExpired"]); - } - - _mapper.Map(editTrialUserPreparation, needUpdate); - - needUpdate.InviteState = editTrialUserPreparation.IsJoin == true ? TrialExternalUserStateEnum.UserConfirmed : TrialExternalUserStateEnum.UserReject; - - - var trialId = needUpdate.TrialId; - var userId = needUpdate.SystemUserId; - - //判断TrialUser中是否存在 不存在就插入 - if (!await _trialUserRepository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId)) - { - - await _trialUserRepository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId, JoinTime = DateTime.Now }); - - } - - var success = await _trialExternalUseRepository.SaveChangesAsync(); - - - if (editTrialUserPreparation.IsJoin == true) - { - var trialInfo = await _repository.FirstOrDefaultAsync(t => t.Id == needUpdate.TrialId); - - var messageToSend = new MimeMessage(); - //发件地址 - messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com")); - //收件地址 - messageToSend.To.Add(new MailboxAddress(String.Empty, needUpdate.Email)); - //主题 - //$"[来自展影IRC] [{trialInfo.ResearchProgramNo}] 账户信息"; - messageToSend.Subject = _localizer["TrialExternalUser_AccountInfo", trialInfo.ResearchProgramNo]; - - var builder = new BodyBuilder(); - - - var sysUserInfo = (await _userRepository.Where(t => t.Id == needUpdate.SystemUserId).Include(t => t.UserTypeRole).FirstOrDefaultAsync()).IfNullThrowException(); - - int verificationCode = new Random().Next(100000, 1000000); - - if (sysUserInfo.IsFirstAdd) - { - await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, - u => new User() { Password = MD5Helper.Md5(verificationCode.ToString()) }); - } - - builder.HtmlBody = @$" -
-
-
- {sysUserInfo.LastName + "/" + sysUserInfo.FirstName}: -
-
-{ - // 您好,欢迎您参加项目 实验方案号:{trialInfo.ResearchProgramNo}IRC相关工作。该项目采用电子化工作流,系统及您的账号信息如下: - _localizer["TrialExternalUser_Welcome", trialInfo.ResearchProgramNo] - } - -
-
-
- -{ - // 项目编号: {trialInfo.TrialCode} - _localizer["TrialExternalUser_ProjectNumber", trialInfo.TrialCode] - } -
-
- -{ - // 试验方案号: {trialInfo.ResearchProgramNo} - _localizer["TrialExternalUser_ExperimentPlanNumber", trialInfo.ResearchProgramNo] - } -
-
- -{ - // 试验名称: {trialInfo.ExperimentName} - _localizer["TrialExternalUser_ExperimentName", trialInfo.ExperimentName] - } -
-
- -{ - // 用户名: {sysUserInfo.UserName} - _localizer["TrialExternalUser_Username", sysUserInfo.UserName] - } -
-
- - -{ - // 密码: {(sysUserInfo.IsFirstAdd ? verificationCode.ToString() + "(请在登录后进行修改)" : "***(您已有账号, 若忘记密码, 请通过邮箱找回)")} - _localizer["TrialExternalUser_Password", verificationCode.ToString()] - } -
-
- -{ - // 角色: {sysUserInfo.UserTypeRole.UserTypeShortName} - _localizer["TrialExternalUser_Role", sysUserInfo.UserTypeRole.UserTypeShortName] - } -
-
- 系统登录地址: {editTrialUserPreparation.BaseUrl} -{ - // 系统登录地址: {editTrialUserPreparation.BaseUrl} - _localizer["TrialExternalUser_LoginUrl", editTrialUserPreparation.BaseUrl] - } -
-
- -
-
- "; - - messageToSend.Body = builder.ToMessageBody(); - - using (var smtp = new MailKit.Net.Smtp.SmtpClient()) - { - - smtp.ServerCertificateValidationCallback = (s, c, h, e) => true; - - await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls); - - await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH"); - - await smtp.SendAsync(messageToSend); - - await smtp.DisconnectAsync(true); - } - - await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); - - - } - return ResponseOutput.Ok(); - - //else - //{ - // builder.HtmlBody = @$" - //
- //
- //
- // {sysUserInfo.LastName + "/" + sysUserInfo.FirstName}: - //
- //
- // 您好,您拒绝了参加 {trialInfo.ResearchProgramNo} 项目IRC相关工作的邀请。详细信息如下: - //
- //
- //
- // 项目编号: {trialInfo.TrialCode} - //
- //
- // 试验方案号: {trialInfo.ResearchProgramNo} - //
- //
- // 试验名称: {trialInfo.ExperimentName} - //
- //
- // 用户名: {sysUserInfo.UserName} - //
- //
- // 角色: {sysUserInfo.UserTypeRole.UserTypeShortName} - //
- //
- //
- //
- // "; - //} - - - - - - - } - - /// - /// 不带Token 访问 Site调研用户 加入项目 Id: TrialSiteSurveyUserId - /// - /// - /// - [AllowAnonymous] - public async Task TrialSiteSurveyUserJoinTrial(TrialExternalUserConfirm editInfo) - { - - var needUpdate = (await _trialSiteSurveyUserRepository.Where(t => t.Id == editInfo.Id, true).Include(t => t.TrialSiteSurvey).FirstOrDefaultAsync()).IfNullThrowException(); - - var revieweUser = await _userRepository.FirstOrDefaultAsync(t => t.Id == needUpdate.TrialSiteSurvey.ReviewerUserId); - - - if (DateTime.Now > needUpdate.ExpireTime) - { - //---邀请加入时间已过期,重新被邀请后才可以进行确认操作 - return ResponseOutput.NotOk(_localizer["TrialExternalUser_InvitationExpired"]); - } - - _mapper.Map(editInfo, needUpdate); - - needUpdate.InviteState = editInfo.IsJoin == true ? TrialSiteUserStateEnum.UserConfirmed : TrialSiteUserStateEnum.UserReject; - - - if (needUpdate.SystemUserId == null) - { - //---调研表系统用户Id 存储有问题 - return ResponseOutput.NotOk(_localizer["TrialExternalUser_UserIdStorageProblem"]); - } - - var trialId = needUpdate.TrialSiteSurvey.TrialId; - var siteId = needUpdate.TrialSiteSurvey.SiteId; - var userId = (Guid)needUpdate.SystemUserId; - - - if (!await _trialUserRepository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId)) - { - await _trialUserRepository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId, JoinTime = DateTime.Now }); - - await _trialSiteUserRepository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId }); - - await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == needUpdate.SystemUserId, u => new User() { Status = UserStateEnum.Enable }); - - - } - - var success = await _trialExternalUseRepository.SaveChangesAsync(); - - var trialInfo = await _repository.FirstOrDefaultAsync(t => t.Id == needUpdate.TrialSiteSurvey.TrialId); - - - var messageToSend = new MimeMessage(); - //发件地址 - messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com")); - //收件地址 - messageToSend.To.Add(new MailboxAddress(String.Empty, editInfo.IsJoin == true ? needUpdate.Email : revieweUser.EMail)); - //主题 - // $"[来自展影IRC] [{trialInfo.ResearchProgramNo}] 账户信息"; - messageToSend.Subject = _localizer["TrialExternalUser_IRCAccountInfo", trialInfo.ResearchProgramNo]; - - - var builder = new BodyBuilder(); - - - var sysUserInfo = await _userRepository.Where(t => t.Id == needUpdate.SystemUserId).Include(t => t.UserTypeRole).FirstOrDefaultAsync(); - - int verificationCode = new Random().Next(100000, 1000000); - - if (sysUserInfo.IsFirstAdd) - { - await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, - u => new User() { Password = MD5Helper.Md5(verificationCode.ToString()) }); - } - - if (editInfo.IsJoin == true) - { - builder.HtmlBody = @$" -
-
-
- {sysUserInfo.LastName + "/" + sysUserInfo.FirstName}: -
-
- 您好,欢迎您参加项目 实验方案号: {trialInfo.ResearchProgramNo} IRC相关工作。该项目采用电子化工作流,系统及您的账号信息如下: -
-
-
- 项目编号: {trialInfo.TrialCode} -
-
- 试验方案号: {trialInfo.ResearchProgramNo} -
-
- 试验名称: {trialInfo.ExperimentName} -
-
- 用户名: {sysUserInfo.UserName} -
-
- 密码: {(sysUserInfo.IsFirstAdd ? verificationCode.ToString() + "(请在登录后进行修改)" : "***(您已有账号, 若忘记密码, 请通过邮箱找回)")} -
-
- 角色: {sysUserInfo.UserTypeRole.UserTypeShortName} -
-
- 系统登录地址: {editInfo.BaseUrl} -
-
- -
-
- "; - - messageToSend.Body = builder.ToMessageBody(); - - using (var smtp = new MailKit.Net.Smtp.SmtpClient()) - { - - smtp.ServerCertificateValidationCallback = (s, c, h, e) => true; - - await smtp.ConnectAsync("smtp.163.com", 465, SecureSocketOptions.StartTls); - - await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH"); - - await smtp.SendAsync(messageToSend); - - await smtp.DisconnectAsync(true); - } - } - //else - //{ - - // builder.HtmlBody = @$" - //
- //
- //
- // {revieweUser.LastName + "/" + revieweUser.FirstName}: - //
- //
- // 您好,{sysUserInfo.LastName + "/" + sysUserInfo.FirstName} 拒绝了参加 {trialInfo.ResearchProgramNo} 项目IRC相关工作的邀请。详细信息如下: - //
- //
- //
- // 项目编号: {trialInfo.TrialCode} - //
- //
- // 试验方案号: {trialInfo.ResearchProgramNo} - //
- //
- // 试验名称: {trialInfo.ExperimentName} - //
- //
- // 用户名: {sysUserInfo.UserName} - //
- //
- // 角色: {sysUserInfo.UserTypeRole.UserTypeShortName} - //
- //
- // 拒绝原因: {editInfo.RejectReason} - //
- //
- //
- //
- // "; - - //} - - - - - - return ResponseOutput.Ok(); - - } - - - /// - /// 不带Token 访问 页面获取项目基本信息 和参与情况 (已经确认了 就不允许再次确认) Id: TrialExternalUserId/TrialSiteSurveyUserId - /// - /// - /// - /// - [AllowAnonymous] - public async Task JoinBasicInfo(Guid id, bool isExternalUser) - { - if (isExternalUser) - { - return (await _trialExternalUseRepository.Where(t => t.Id == id) - .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - } - else - { - return (await _trialSiteSurveyUserRepository.Where(t => t.Id == id) - .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - } - - } - - - - - - /// - /// 加入项目 - /// - /// - /// - /// - [HttpGet("{trialId:guid}/{trialExternalUserId:guid}")] - [NonDynamicMethod] - public async Task UserConfirmJoinTrial(Guid trialId, Guid trialExternalUserId) - { - - var externalUser = await _trialExternalUseRepository.FirstOrDefaultAsync(t => t.Id == trialExternalUserId); - - - //判断TrialUser中是否存在 不存在就插入 - if (!await _repository.AnyAsync(t => t.TrialId == trialId && t.UserId == externalUser.SystemUserId)) - { - await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = (Guid)externalUser.SystemUserId, JoinTime = DateTime.Now }); - - await _trialExternalUseRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialExternalUserId, - u => new TrialExternalUser() { InviteState = TrialExternalUserStateEnum.UserConfirmed }); - - await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == externalUser.SystemUserId, u => new User() { Status = UserStateEnum.Enable }); - - await _userRepository.SaveChangesAsync(); - } - - - - return ResponseOutput.Ok(); - - - } - - #endregion - - - - - } } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index 493e04861..0806cb981 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -280,52 +280,9 @@ namespace IRaCIS.Application.Services public async Task DeleteTrial(Guid trialId) { - - var trial = (await _trialRepository.FirstOrDefaultAsync(u => u.Id == trialId, true)).IfNullThrowException(); - - if (_verifyConfig.CurrentValue.OpenTrialRelationDelete) { - - #region 项目真删除废弃 - - //if (trial.VisitPlanConfirmed) - //{ - // return ResponseOutput.NotOk("Trial访视计划已经确认,无法删除"); - //} - - //if (await _repository.AnyAsync(u => u.TrialId == trialId)) - //{ - // return ResponseOutput.NotOk("该Trial有医生入组或在入组流程中,无法删除"); - //} - - //if (await _repository.AnyAsync(u => u.TrialId == trialId)) - //{ - // return ResponseOutput.NotOk("该Trial下面有Site,无法删除"); - //} - - ////PM 可以删除项目 仅仅在没有site 参与者只有他自己的时候 - //if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) - //{ - // //参与者仅有他自己时,可以删除 - // if (await _trialUserRepository.CountAsync(t => t.TrialId == trialId) == 1) - // { - - // var success1 = await _repository.BatchDeleteAsync(o => o.Id == trialId) || - // await _repository.BatchDeleteAsync(t => t.TrialId == trialId) || - // await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - - // return ResponseOutput.Result(success1); - // } - //} - - //if (await _repository.AnyAsync(u => u.TrialId == trialId)) - //{ - // return ResponseOutput.NotOk("该Trial下面有参与者,无法删除"); - //} - #endregion - - + await _repository.BatchDeleteAsync(o => o.SubjectVisit.TrialId == trialId); await _repository.BatchDeleteAsync(o => o.TrialId == trialId); @@ -344,9 +301,6 @@ namespace IRaCIS.Application.Services - - - await _repository.BatchDeleteAsync(t => t.SubjectVisit.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.SubjectVisit.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.SubjectVisit.TrialId == trialId); @@ -438,7 +392,6 @@ namespace IRaCIS.Application.Services await _repository.BatchDeleteAsync(t => t.OriginalReReadingTask.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - await _repository.BatchDeleteAsync(t => t.TrialId == trialId); await _repository.BatchDeleteAsync(t => t.TrialId == trialId) ; return ResponseOutput.Ok(); @@ -454,41 +407,6 @@ namespace IRaCIS.Application.Services } - [AllowAnonymous] - [HttpDelete, Route("{trialId:guid}")] - public async Task DeleteTrialTaskData(Guid trialId) - { - - //await _repository.BatchDeleteAsync(t => t.TrialId == trialId) || - // await _repository.BatchDeleteAsync(t => t.TrialId == trialId) || - // await _repository.BatchDeleteAsync(t => t.TrialId == trialId) || - - - - - //await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - // await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - - - // await _repository.BatchDeleteAsync(t => t.TaskMedicalReview.TrialId == trialId); - // await _repository.BatchDeleteAsync(t => t.TaskMedicalReview.TrialId == trialId); - - - // await _repository.BatchDeleteAsync(t => t.VisitTask.TrialId == trialId); - - // await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - - // await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - // await _repository.BatchDeleteAsync(t => t.TrialId == trialId) ; - - // await _repository.BatchDeleteAsync(t => t.VisitTask.TrialId == trialId); - // await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - - // await _repository.BatchDeleteAsync(t => t.OriginalReReadingTask.TrialId == trialId); - // await _repository.BatchDeleteAsync(t => t.TrialId == trialId); - - return ResponseOutput.Ok(); - } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs index 00a6a8be6..c8e56eebb 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs @@ -22,8 +22,8 @@ namespace IRaCIS.Core.Application.Service CreateMap(); + CreateMap(); - CreateMap () .ForMember(d => d.QCProcessEnum, u => u.MapFrom(s => s.Trial.QCProcessEnum)) .ForMember(d => d.IsImageConsistencyVerification, u => u.MapFrom(s => s.Trial.IsImageConsistencyVerification)) @@ -206,7 +206,8 @@ namespace IRaCIS.Core.Application.Service CreateMap().ReverseMap(); CreateMap(); - CreateMap(); + CreateMap() + .ForMember(t=>t.UserTypeEnum,u=>u.MapFrom(c=>c.SystemUser.UserTypeEnum)); CreateMap().ReverseMap(); @@ -285,7 +286,6 @@ namespace IRaCIS.Core.Application.Service .ForMember(t => t.TrialSiteUserList, u => u.Ignore()); CreateMap() - .ForMember(t => t.TrialRoleName, u => u.MapFrom(d => d.TrialRoleName.Value)) .ForMember(d => d.UserType, u => u.MapFrom(s => s.UserTypeRole.UserTypeShortName)) .ForMember(d => d.UserTypeEnum, u => u.MapFrom(s => s.UserTypeRole.UserTypeEnum)) .ForMember(t => t.TrialSiteCode, u => u.MapFrom(d => d.TrialSiteSurvey.TrialSite.TrialSiteCode)) diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index 54a486acc..fb175609a 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -2,6 +2,7 @@ using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infrastructure; +using MassTransit; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; @@ -64,90 +65,12 @@ namespace IRaCIS.Application.Services return ResponseOutput.Ok(); } - + [AllowAnonymous] [UnitOfWork] public async Task Get() { - - //Expression> visitTaskLambda = x => x.TrialId == Guid.Empty && x.SubjectId == Guid.Empty && x.TrialReadingCriterionId == Guid.Empty; - - //var visitTaskIdQueryable = _visitTaskRepositoryy.Where(visitTaskLambda).Where(t => t.Subject.SubjectVisitTaskList.AsQueryable().Where(visitTaskLambda).Any(c => c.IsNeedClinicalDataSign == true && c.IsClinicalDataSign == false && c.VisitTaskNum < t.VisitTaskNum)).Select(t => t.Id); - - //await _visitTaskRepositoryy.BatchUpdateNoTrackingAsync(t => visitTaskIdQueryable.Contains(t.Id), u => new VisitTask() - //{ - // IsFrontTaskNeedSignButNotSign = true - //}); - - - //var a = ((Decimal)1.00).ToString().TrimEnd(new char[] { '.', '0' }); - //var b = ((Decimal)1.01).ToString().TrimEnd(new char[] { '.', '0' }); - //var c = ((Decimal)100).ToString().TrimEnd(new char[] { '.', '0' }); - //var subject1 = Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391693"); - //var subject2 = Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391694"); - - // var subjectList = new List() { Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391693") , - // Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391694") , - // Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391695") - // }; - - //string[] citys = new string[] { "广州", "深圳", "上海", "北京" }; - //foreach (var item in subjectList) - //{ - // Console.WriteLine(await BNRFactory.Default.Create($"[CN:{item}][N:[CN:{item}]/0000000]")); - //} - //foreach (var item in subjectList) - //{ - // Console.WriteLine(await BNRFactory.Default.Create($"[N:[CN:{item}]/0000000]")); - //} - - //foreach (var item in subjectList) - //{ - // Console.WriteLine(await BNRFactory.Default.Create($"[CN:{item}][redis:city/0000000]")); - //} - - //var needAddVisitList = await _repository.Where(t => t.TrialId == Guid.Empty).DistinctBy(t => t.VisitTaskNum).ToListAsync(); - - - //await _repository.BatchUpdateAsync(t => t.Id == Guid.Empty, u => new VisitTask() - //{ - // SuggesteFinishedTime = u.IsUrgent ? DateTime.Now.AddDays(2) : DateTime.Now.AddDays(7), - - // Code = u.Code + 1 - //}); - - //var query = from item1 in _repository.Where() - // join item2 in _repository.Where() on item1.ValueType equals item2.ValueType - // select new - // { - // item1.ValueType, - // dd = item2.ValueType - // }; - - //var list2 = query.ToList(); - - //await Task.CompletedTask; - - //var list = await _repository.Where(t => t.TrialId == Guid.Parse("40400000-3e2c-0016-239b-08da581f0e74")).ToListAsync(); - - ////await _repository.BatchDeleteAsync(t => t.TrialId == Guid.Parse("40400000-3e2c-0016-239b-08da581f0e74")); - - //await _repository.AddRangeAsync(list, true); - - //await _repository.SaveChangesAsync(); - - //await _repository.BatchUpdateAsync(t => t.TrialId == Guid.Parse("40400000-3e2c-0016-239b-08da581f0e74") && t.EntityName== "ClinicalDataTrialSet", t => new DataInspection() { CreateTime= DateTime.Now.AddMonths(-2) } ); - - //await _visitTaskRepositoryy.UpdatePartialFromQueryAsync( Guid.Parse("78360000-3E2C-0016-9B53-08DA6A002040"), c => new VisitTask() { UpdateTime = DateTime.Now }); - - //await _visitTaskRepositoryy.UpdatePartialFromQueryAsync( Guid.Parse("78360000-3E2C-0016-9B53-08DA6A002040"), c => new VisitTask() { UpdateTime = DateTime.Now.AddMinutes(1) }); - - //var a = _userInfo.IsTestUser; - - //var list1 = await _repository.Where().Select(t => t.TranslateValue(t.Value, t.ValueCN, true)).ToListAsync(); - //var list2 = await _repository.Where().Select(t => t.TranslateValue(t.Value, t.ValueCN, false)).ToListAsync(); - - await _repository.SaveChangesAsync(); - return _userInfo.LocalIp; + + return "修改服务器时间自动发布测试--我又修改了"; } @@ -171,9 +94,19 @@ namespace IRaCIS.Application.Services [AllowAnonymous] - public async Task testwwwww([FromServices] IWebHostEnvironment env) + public async Task> testwwwww([FromServices] IWebHostEnvironment env) { - await Task.CompletedTask; + int count = 200; + + var list=new List(); + + for (int i = 0; i < count; i++) + { + Guid guid = NewId.NextGuid(); + list.Add(guid); + } + + return list; } diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs index 1135e0088..263ac8f46 100644 --- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs +++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs @@ -489,11 +489,11 @@ namespace IRaCIS.Core.Domain.Models /// /// PI不认同 /// - PIAgree = 1, + PINotAgree = 1, /// /// PI认同 /// - PINotAgree = 2 + PIAgree = 2 } } diff --git a/IRaCIS.Core.Domain/SQLFile/20220808.sql b/IRaCIS.Core.Domain/SQLFile/20220808.sql new file mode 100644 index 000000000..639ad02c0 --- /dev/null +++ b/IRaCIS.Core.Domain/SQLFile/20220808.sql @@ -0,0 +1,2 @@ + +update TrialSiteUserSurvey set TrialRoleCode= (select Code from Dictionary where Id=TrialSiteUserSurvey.TrialRoleNameId) \ No newline at end of file diff --git a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs index 69563657c..b82f4f698 100644 --- a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs +++ b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs @@ -28,11 +28,11 @@ namespace IRaCIS.Core.Domain.Models public Guid? UserTypeId { get; set; } - public Guid TrialRoleNameId { get; set; } - - public Dictionary TrialRoleName { get; set; } + //public Guid TrialRoleNameId { get; set; } + //public Dictionary TrialRoleName { get; set; } + public int? TrialRoleCode { get; set; } /// @@ -59,7 +59,6 @@ namespace IRaCIS.Core.Domain.Models [Required] public Guid UpdateUserId { get; set; } - public string UserName { get; set; } = string.Empty; /// /// Phone @@ -85,13 +84,6 @@ namespace IRaCIS.Core.Domain.Models public Guid? SystemUserId { get; set; } - public DateTime? ExpireTime { get; set; } - - public bool IsJoin { get; set; } - - public DateTime? ConfirmTime { get; set; } - - public string RejectReason { get; set; } = string.Empty; /// /// IsGenerateAccount @@ -104,7 +96,16 @@ namespace IRaCIS.Core.Domain.Models public TrialSiteUserStateEnum InviteState { get; set; } = TrialSiteUserStateEnum.WaitSent; - + public bool IsJoin { get; set; } + + + public bool IsHistoryUser { get; set; } + + public bool? IsHistoryUserDeleted { get; set; } + + public bool? IsHistoryUserOriginDeleted { get; set; } + + } diff --git a/IRaCIS.Core.Domain/TrialSiteUser/TrialExternalUser.cs b/IRaCIS.Core.Domain/TrialSiteUser/TrialExternalUser.cs index 297b37279..148c6e53c 100644 --- a/IRaCIS.Core.Domain/TrialSiteUser/TrialExternalUser.cs +++ b/IRaCIS.Core.Domain/TrialSiteUser/TrialExternalUser.cs @@ -92,7 +92,8 @@ namespace IRaCIS.Core.Domain.Models public Guid SystemUserId { get; set; } - + [JsonIgnore] + public User SystemUser { get; set; } public bool IsJoin { get; set; } diff --git a/IRaCIS.Core.Domain/_Config/_StaticData.cs b/IRaCIS.Core.Domain/_Config/_StaticData.cs index daf810d2b..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"; @@ -104,6 +106,8 @@ public static class StaticData public static readonly string UploadEDCData = "UploadEDCData"; + + public static readonly string UploadSiteSurveyData = "SiteSurveyData"; public static readonly string UploadFileFolder = "UploadFile"; } diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/Output/ApiResponseCodeEnum.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/Output/ApiResponseCodeEnum.cs index 0fb88dff2..73b9597ae 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/Output/ApiResponseCodeEnum.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/Output/ApiResponseCodeEnum.cs @@ -23,17 +23,10 @@ namespace IRaCIS.Core.Infrastructure.Extention //程序异常 相当于之前的 IsSuccess = false ProgramException = 4, - - - //需要提示 ,需要提示 从Result 取数据 ( 0 可以继续处理提交 ,1 不能进行继续处理提交 ,2 刷新列表 ) NeedTips = 5, - - - - //在其他地方登陆,被迫下线 LoginInOtherPlace = -1, diff --git a/irc_api.drone.yml b/irc_api.drone.yml new file mode 100644 index 000000000..5a9d7c9e7 --- /dev/null +++ b/irc_api.drone.yml @@ -0,0 +1,106 @@ +kind: pipeline +type: docker +name: irc-netcore-api + +steps: + - name: docker-build + image: docker + pull: if-not-exists + volumes: + - name: dockersock + path: /var/run/docker.sock + - name: cached_nuget_packages + path: /drone/nuget_packages + commands: + - date +%H:%M:%S + - pwd + - docker build -t Test.Study . + - date +%H:%M:%S + + - name: docker-deploy + image: docker + pull: if-not-exists + depends_on: + - docker-build + volumes: + - name: dockersock + path: /var/run/docker.sock + commands: + - date +%H:%M:%S + - docker rm -f test-study-container + - docker run -itd -e TZ=Asia/Shanghai -e ASPNETCORE_ENVIRONMENT=Test_Study --restart=always --name test-study-container -p 8030:80 Test.Study + - date +%H:%M:%S + +volumes: + - name: cached_nuget_packages + host: + path: /mnt/f/docker_publish/nuget_packages + - name: dockersock + host: + path: /var/run/docker.sock + +trigger: + branch: + - master + +--- + + +kind: pipeline +type: ssh +name: ssh-windows-test-study-publish + +platform: + os: windows + arch: amd64 + +clone: + disable: true #禁用默认克隆 + +server: + host: 123.56.94.154 + user: Administrator + password: WHxckj2019 + +steps: +- name: publish-test-study + commands: + #拉取代码 并停止服务 + - Start-Process "C:\CICD\Test.Study\netcore_Publish.bat" -Wait + - cd C:\CICD\Test.Study\netcore_repo + - dotnet restore .\IRaCIS.Core.API\IRaCIS.Core.API.csproj --packages C:\Users\Administrator\.nuget\packages + - dotnet publish .\IRaCIS.Core.API\IRaCIS.Core.API.csproj -c Release --no-restore --packages C:\Users\Administrator\.nuget\packages -o D:\Develop\Test_Study_PublishSite\IRaCIS.NetCore.API + - Start-Service -Name "Test_Study_API" + +trigger: + branch: + - Test.Study + + +--- + + +kind: pipeline +type: ssh +name: ssh-windows-test-irc-publish + +platform: + os: windows + arch: amd64 + +clone: + disable: true #禁用默认克隆 + +server: + host: 123.56.94.154 + user: Administrator + password: WHxckj2019 + +steps: +- name: publish-test-irc + commands: + - Start-Process "C:\CICD\Test.IRC\netcore_Publish.bat" -Wait + +trigger: + branch: + - Test.IRC \ No newline at end of file