From 6e45be1f56821c1a0a097a398e4909fd59221a19 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 23 May 2022 16:33:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E5=BF=83=E8=B0=83=E7=A0=94=E6=8B=92?= =?UTF-8?q?=E7=BB=9D=E9=82=AE=E4=BB=B6=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/IRaCIS.Core.API.csproj | 3 + .../EmailTemplate/TrialSiteSurveyReject.html | 49 ++++++++++++ .../SiteSurvey/TrialSiteSurveyService.cs | 80 ++++++++----------- 3 files changed, 85 insertions(+), 47 deletions(-) create mode 100644 IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject.html diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index 61a21c492..998069f61 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -109,6 +109,9 @@ Always + + Always + Always diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject.html new file mode 100644 index 000000000..29b84eedc --- /dev/null +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/TrialSiteSurveyReject.html @@ -0,0 +1,49 @@ + + + + + Title + + +
+
+
+ 尊敬的 {0} ,您好: +
+
+ 您好, 您填写的中心调研表被驳回,详细信息如下: +
+ +
+
+ 项目编号: {1} +
+
+ 试验方案号: {2} +
+
+ 试验名称: {3} +
+
+ 中心编号: {4} +
+
+ 中心名称: {5} +
+
+ 驳回原因: {6} +
+ +
+ + 登陆并查看 + + +
+
祝您顺利!/Best Regards
+
上海展影医疗科技有限公司
+
+
+
+ + diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 85561117c..e7c61717d 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -31,7 +31,7 @@ namespace IRaCIS.Core.Application.Contracts private readonly IRepository _trialUserRepository; private readonly ITokenService _tokenService; - public TrialSiteSurveyService(IRepository trialSiteSurveyRepository, IRepository trialUserRepository,IRepository trialSiteUserSurveyRepository, + public TrialSiteSurveyService(IRepository trialSiteSurveyRepository, IRepository trialUserRepository, IRepository trialSiteUserSurveyRepository, IRepository userRepository, IRepository trialSiteRepository, ITokenService tokenService) { _trialSiteSurveyRepository = trialSiteSurveyRepository; @@ -363,7 +363,7 @@ namespace IRaCIS.Core.Application.Contracts } } - + if (addOrEditTrialSiteSurvey.Id == null) { var entity = _mapper.Map(addOrEditTrialSiteSurvey); @@ -373,7 +373,7 @@ namespace IRaCIS.Core.Application.Contracts else { - var entity = await _trialSiteSurveyRepository.Where(t => t.Id == addOrEditTrialSiteSurvey.Id, true).Include(x=>x.ReviewerUser).Include(x=>x.PreliminaryUser).FirstOrDefaultAsync(); + var entity = await _trialSiteSurveyRepository.Where(t => t.Id == addOrEditTrialSiteSurvey.Id, true).Include(x => x.ReviewerUser).Include(x => x.PreliminaryUser).FirstOrDefaultAsync(); _mapper.Map(addOrEditTrialSiteSurvey, entity); await _trialSiteSurveyRepository.SaveChangesAsync(); @@ -567,51 +567,37 @@ namespace IRaCIS.Core.Application.Contracts //主题 messageToSend.Subject = $"[来自展影IRC] [{trialInfo.ResearchProgramNo}] 关于中心调研审批的提醒"; - builder.HtmlBody = @$" -
-
-
- { (user == null ? survey.UserName : user.LastName + "/ " + user.FirstName)}: -
-
- 您好, 您填写的中心调研表被驳回,详细信息如下: -
-
-
- 项目编号: {trialInfo.TrialCode} -
-
- 试验方案号: {trialInfo.ResearchProgramNo} -
-
- 试验名称: {trialInfo.ExperimentName} -
-
- 中心编号: {siteInfo.TrialSiteCode} -
-
- 中心名称: {siteInfo.TrialSiteAliasName} -
-
- 驳回原因: {survey.LatestBackReason} -
-
+ var pathToFile = _hostEnvironment.WebRootPath + + Path.DirectorySeparatorChar.ToString() + + "EmailTemplate" + + Path.DirectorySeparatorChar.ToString() + + "TrialSiteSurveyReject.html"; - - 登陆并查看 - -
-
-
-
- "; + using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile)) + { + var templateInfo = SourceReader.ReadToEnd(); + + + builder.HtmlBody = string.Format(templateInfo, + (user == null ? survey.UserName : user.LastName + "/ " + user.FirstName), + trialInfo.TrialCode, + trialInfo.ResearchProgramNo, + trialInfo.ExperimentName, + siteInfo.TrialSiteCode, + siteInfo.TrialSiteAliasName, + survey.LatestBackReason, + trialSiteSubmitBackCommand.RouteUrl, + (survey.State == TrialSiteSurveyEnum.ToSubmit ? "inline - block" : "none") + + ); + } messageToSend.Body = builder.ToMessageBody(); await SendEmailHelper.SendEmailAsync(messageToSend, null); - + await _trialSiteSurveyRepository.SaveChangesAsync(); return ResponseOutput.Ok(); @@ -732,7 +718,7 @@ namespace IRaCIS.Core.Application.Contracts await GenerateAccountAsync(needGenerateList); - await SendSiteSurveyUserJoinEmail(new TrialSiteUserSurveyJoinCommand() { TrialId = trialId, TrialSiteSurveyId= trialSiteSurveyId, RouteUrl = siteSurvyeSubmit.RouteUrl, BaseUrl = siteSurvyeSubmit.BaseUrl, UserList = needGenerateList }); + await SendSiteSurveyUserJoinEmail(new TrialSiteUserSurveyJoinCommand() { TrialId = trialId, TrialSiteSurveyId = trialSiteSurveyId, RouteUrl = siteSurvyeSubmit.RouteUrl, BaseUrl = siteSurvyeSubmit.BaseUrl, UserList = needGenerateList }); await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); @@ -807,7 +793,7 @@ namespace IRaCIS.Core.Application.Contracts //主题 messageToSend.Subject = $"[来自展影IRC] [{ trialInfo.ResearchProgramNo}]邀请信"; - + var builder = new BodyBuilder(); @@ -835,7 +821,7 @@ namespace IRaCIS.Core.Application.Contracts trialInfo.TrialCode, sysUserInfo.UserName, sysUserInfo.UserTypeRole.UserTypeShortName, - sysUserInfo.IsFirstAdd ? routeUrl:joinCommand.BaseUrl + sysUserInfo.IsFirstAdd ? routeUrl : joinCommand.BaseUrl ); } @@ -843,7 +829,7 @@ namespace IRaCIS.Core.Application.Contracts await SendEmailHelper.SendEmailAsync(messageToSend, null); - + var trialId = joinCommand.TrialId; @@ -851,7 +837,7 @@ namespace IRaCIS.Core.Application.Contracts var siteId = trialSiteSurvey.SiteId; //判断TrialUser中是否存在 不存在就插入 - if (!await _trialUserRepository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId,true)) + if (!await _trialUserRepository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId, true)) { await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId }); @@ -986,7 +972,7 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.Ok(); } - + } }