手动发送邮件修改
parent
1f82b6cecf
commit
70039bcedf
|
@ -409,6 +409,26 @@ public static class FileStoreHelper
|
|||
return (serverFilePath, relativePath, fileRealName);
|
||||
}
|
||||
|
||||
// 获取 入组确认 PD 进展发送邮件Word|PDF 存放路径
|
||||
|
||||
public static (string PhysicalPath, string RelativePath, string FileRealName) GetSubjectEnrollConfirmOrPDEmailPath(IWebHostEnvironment _hostEnvironment, string fileName, Guid trialId, Guid siteId, Guid subjectId)
|
||||
{
|
||||
var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment);
|
||||
|
||||
string uploadFolderPath = Path.Combine(rootPath, StaticData.Folder.TrialDataFolder, trialId.ToString(), siteId.ToString(), subjectId.ToString());
|
||||
|
||||
if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath);
|
||||
|
||||
var (trustedFileNameForFileStorage, fileRealName) = FileStoreHelper.GetStoreFileName(fileName);
|
||||
|
||||
|
||||
var relativePath = $"/{StaticData.Folder.IRaCISDataFolder}/{StaticData.Folder.TrialDataFolder}/{trialId}/{siteId}/{subjectId}/{trustedFileNameForFileStorage}";
|
||||
|
||||
var serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage);
|
||||
|
||||
return (serverFilePath, relativePath, fileRealName);
|
||||
}
|
||||
|
||||
|
||||
public static string GetSubjectVisitDicomFolderPhysicalPath(IWebHostEnvironment _hostEnvironment,Guid trialId, Guid siteId, Guid subjectId, Guid subjectVisitId)
|
||||
{
|
||||
|
|
|
@ -602,14 +602,32 @@
|
|||
<returns></returns>
|
||||
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.TrialEmailNoticeConfigService.BaseBusinessScenarioSendEmailAsync(System.Guid)">
|
||||
<member name="M:IRaCIS.Core.Application.Service.TrialEmailNoticeConfigService.BaseBusinessScenarioSendEmailAsync(System.Guid,System.Nullable{System.Boolean},IRaCIS.Core.Domain.Share.Common.EmailStoreSendMode,System.String)">
|
||||
<summary>
|
||||
测试邮件 带附件 填充word --前端不需要用
|
||||
</summary>
|
||||
<param name="visitTaskId"></param>
|
||||
<param name="isMedicalReviewAndSuggestApplyReReading"></param>
|
||||
<param name="emailStoreMode"></param>
|
||||
<param name="sendFileRelativePath"></param>
|
||||
<returns></returns>
|
||||
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.TrialEmailNoticeConfigService.ManualGenerateEmailFile(System.Guid)">
|
||||
<summary>
|
||||
手动生成入组确认 或者PD 进展的邮件 如果能发送,会返回文件的路径,否则会给出提示
|
||||
</summary>
|
||||
<param name="visitTaskId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.TrialEmailNoticeConfigService.ManualSendEmail(System.Guid,System.String)">
|
||||
<summary>
|
||||
手动发送邮件
|
||||
</summary>
|
||||
<param name="visitTaskId"></param>
|
||||
<param name="sendFileRelativePath"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.TrialEmailNoticeConfigService.GetTrialUserTypeSelectList(System.Guid)">
|
||||
<summary>
|
||||
选择人员下拉
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Domain.Share.Common;
|
||||
|
||||
namespace IRaCIS.Core.Application.Interfaces
|
||||
{
|
||||
|
@ -22,7 +23,14 @@ namespace IRaCIS.Core.Application.Interfaces
|
|||
|
||||
Task<IResponseOutput> DeleteTrialEmailNoticeConfig(Guid trialEmailNoticeConfigId);
|
||||
|
||||
Task BaseBusinessScenarioSendEmailAsync( Guid visitTaskId, bool? isMedicalReviewAndSuggestApplyReReading = null);
|
||||
Task<string> BaseBusinessScenarioSendEmailAsync(Guid visitTaskId, bool? isMedicalReviewAndSuggestApplyReReading = null, EmailStoreSendMode emailStoreMode = EmailStoreSendMode.StoreLocalSend, string sendFileRelativePath="");
|
||||
|
||||
}
|
||||
|
||||
public class EmailStoreSendDto
|
||||
{
|
||||
public EmailStoreSendMode EmailStoreSendMode { get; set; } = EmailStoreSendMode.StoreLocalSend;
|
||||
|
||||
public string SendFileRelativePath { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ using IRaCIS.Core.Application.Contracts;
|
|||
using IRaCIS.Core.Application.Filter;
|
||||
using MiniSoftware;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Domain.Share.Common;
|
||||
using System.IO;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
|
@ -165,7 +167,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
|
||||
private async Task<bool> DealMedicalReviewTasKGenerateAndIsSendAsync(Guid trialId, bool? isMedicalReviewAndSuggestApplyReReading,string pdAnswer, List<Guid> taskIdList, List<Guid> minUserIdList)
|
||||
private async Task<bool> DealMedicalReviewTasKGenerateAndIsSendAsync(Guid trialId, bool? isMedicalReviewAndSuggestApplyReReading, string pdAnswer, List<Guid> taskIdList, List<Guid> minUserIdList)
|
||||
{
|
||||
|
||||
var isNeedSend = true;
|
||||
|
@ -177,7 +179,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
//正常阅片为否的
|
||||
if (isMedicalReviewAndSuggestApplyReReading == null)
|
||||
{
|
||||
isNeedSend = false;
|
||||
|
@ -213,9 +215,11 @@ namespace IRaCIS.Core.Application.Service
|
|||
/// </summary>
|
||||
/// <param name="visitTaskId"></param>
|
||||
/// <param name="isMedicalReviewAndSuggestApplyReReading"></param>
|
||||
/// <param name="emailStoreMode"></param>
|
||||
/// <param name="sendFileRelativePath"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public async Task BaseBusinessScenarioSendEmailAsync(Guid visitTaskId, bool? isMedicalReviewAndSuggestApplyReReading)
|
||||
public async Task<string> BaseBusinessScenarioSendEmailAsync(Guid visitTaskId, bool? isMedicalReviewAndSuggestApplyReReading, EmailStoreSendMode emailStoreMode, string sendFileRelativePath)
|
||||
{
|
||||
|
||||
CommonDocumentBusinessScenario? businessScenarioEnum = null;
|
||||
|
@ -292,7 +296,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -317,7 +321,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
//throw new BusinessValidationFailedException("找不到该项目标准场景下邮件的配置");
|
||||
|
||||
return;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
@ -382,7 +386,6 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 确保 邮件Html存在
|
||||
|
||||
//邮件附件
|
||||
|
@ -403,6 +406,46 @@ namespace IRaCIS.Core.Application.Service
|
|||
#endregion
|
||||
|
||||
|
||||
#region 不同场景 Tile 设置
|
||||
|
||||
if (businessScenarioEnum == CommonDocumentBusinessScenario.EnrollConfirmed)
|
||||
{
|
||||
sendEmailConfig.TopicDescription = $"【入组确认报告】关于{taskInfo.ResearchProgramNo}项目{taskInfo.SubjectCode}受试者";
|
||||
|
||||
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
|
||||
{
|
||||
var templateInfo = SourceReader.ReadToEnd();
|
||||
|
||||
|
||||
sendEmailConfig.HtmlBodyStr = string.Format(templateInfo,
|
||||
$" 附件为入组确认报告,请查收 "
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (businessScenarioEnum == CommonDocumentBusinessScenario.PDConfirmed)
|
||||
{
|
||||
sendEmailConfig.TopicDescription = $"【疾病进展确认报告】关于{taskInfo.ResearchProgramNo}项目{taskInfo.SubjectCode}受试者";
|
||||
|
||||
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
|
||||
{
|
||||
var templateInfo = SourceReader.ReadToEnd();
|
||||
|
||||
|
||||
sendEmailConfig.HtmlBodyStr = string.Format(templateInfo,
|
||||
$" 附件为疾病进展确认报告,请查收 "
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 不同标准 不同项目配置 发送邮件的时机 处理具体逻辑
|
||||
|
||||
var answer = "否";
|
||||
var isNeedSend = true;
|
||||
var minUserIdList = _trialUserRepository.Where(t => t.User.UserTypeEnum == Domain.Share.UserTypeEnum.MIM && t.TrialId == taskInfo.TrialId).Select(t => t.UserId).ToList();
|
||||
|
@ -418,18 +461,6 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
else
|
||||
{
|
||||
sendEmailConfig.TopicDescription = $"【入组确认报告】关于{taskInfo.ResearchProgramNo}项目{taskInfo.SubjectCode}受试者";
|
||||
|
||||
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
|
||||
{
|
||||
var templateInfo = SourceReader.ReadToEnd();
|
||||
|
||||
|
||||
sendEmailConfig.HtmlBodyStr = string.Format(templateInfo,
|
||||
$" 附件为入组确认报告,请查收 "
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (await _repository.Where<ReadingTableQuestionAnswer>().AnyAsync(x => x.VisitTaskId == visitTaskId && x.Answer == TargetState.Exist.GetEnumInt() &&
|
||||
x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && x.ReadingQuestionTrial.LesionType == LesionType.TargetLesion))
|
||||
|
@ -455,17 +486,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
else if (businessScenarioEnum == CommonDocumentBusinessScenario.PDConfirmed)
|
||||
{
|
||||
sendEmailConfig.TopicDescription = $"【疾病进展确认报告】关于{taskInfo.ResearchProgramNo}项目{taskInfo.SubjectCode}受试者";
|
||||
|
||||
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
|
||||
{
|
||||
var templateInfo = SourceReader.ReadToEnd();
|
||||
|
||||
|
||||
sendEmailConfig.HtmlBodyStr = string.Format(templateInfo,
|
||||
$" 附件为疾病进展确认报告,请查收 "
|
||||
);
|
||||
}
|
||||
|
||||
//有序
|
||||
|
||||
|
@ -707,9 +728,29 @@ namespace IRaCIS.Core.Application.Service
|
|||
isNeedSend = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region MiniWord 组织字典 发送
|
||||
if (isNeedSend)
|
||||
|
||||
|
||||
if (emailStoreMode == EmailStoreSendMode.NotStoreLocalOnlySentEmail)
|
||||
{
|
||||
|
||||
var phyPath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, sendFileRelativePath);
|
||||
|
||||
//先预先生成了邮件,发送预先生成的邮件
|
||||
sendEmailConfig.EmailAttachMentConfigList.Add(new EmailAttachMentConfig()
|
||||
{
|
||||
FileName = emailConfig.FileName,
|
||||
|
||||
FileStream = File.OpenRead(phyPath),
|
||||
});
|
||||
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig);
|
||||
}
|
||||
|
||||
var value = new Dictionary<string, object>()
|
||||
{
|
||||
["SponsorName"] = taskInfo.SponsorName,
|
||||
|
@ -723,6 +764,27 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
};
|
||||
|
||||
var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetSubjectEnrollConfirmOrPDEmailPath(_hostEnvironment, Path.GetFileName(path), taskInfo.TrialId, taskInfo.SiteId, taskInfo.SubjectId);
|
||||
|
||||
if (emailStoreMode == EmailStoreSendMode.StoreLocalSend || emailStoreMode == EmailStoreSendMode.OnlyStoreLocalNotSentEmail)
|
||||
{
|
||||
MiniSoftware.MiniWord.SaveAsByTemplate(serverFilePath, path, value);
|
||||
|
||||
}
|
||||
//手动生成发送的邮件内容,但是并不发送
|
||||
if (emailStoreMode == EmailStoreSendMode.OnlyStoreLocalNotSentEmail)
|
||||
{
|
||||
isNeedSend = false;
|
||||
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
|
||||
//正常的即时生成邮件 并发送邮件
|
||||
if (isNeedSend)
|
||||
{
|
||||
|
||||
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
|
||||
MiniSoftware.MiniWord.SaveAsByTemplate(memoryStream, path, value);
|
||||
|
@ -740,6 +802,15 @@ namespace IRaCIS.Core.Application.Service
|
|||
await SendEmailHelper.SendEmailAsync(sendEmailConfig);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return string.Empty;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
@ -747,6 +818,37 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 手动生成入组确认 或者PD 进展的邮件 如果能发送,会返回文件的路径,否则会给出提示
|
||||
/// </summary>
|
||||
/// <param name="visitTaskId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> ManualGenerateEmailFile(Guid visitTaskId)
|
||||
{
|
||||
var filePath = await BaseBusinessScenarioSendEmailAsync(visitTaskId, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty);
|
||||
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return ResponseOutput.NotOk("该任务不符合发送邮件的条件");
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok(filePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动发送邮件
|
||||
/// </summary>
|
||||
/// <param name="visitTaskId"></param>
|
||||
/// <param name="sendFileRelativePath"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> ManualSendEmail(Guid visitTaskId, string sendFileRelativePath)
|
||||
{
|
||||
var filePath = await BaseBusinessScenarioSendEmailAsync(visitTaskId, true, EmailStoreSendMode.NotStoreLocalOnlySentEmail, sendFileRelativePath);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private async Task<string> TranslatePdStateAsync(Guid visitTaskId, ReadingCategory readingCategory, CriterionType criterionType)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Domain.Share.Common
|
||||
{
|
||||
|
||||
|
||||
public enum EmailStoreSendMode
|
||||
{
|
||||
//不存储本地 发送
|
||||
NotStoreLocalSend = 0,
|
||||
|
||||
//存储本地发送
|
||||
StoreLocalSend = 1,
|
||||
|
||||
//存储本地不发送
|
||||
OnlyStoreLocalNotSentEmail = 2,
|
||||
|
||||
//不存储本地 发送
|
||||
NotStoreLocalOnlySentEmail = 3,
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue