修改邮件配置
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
ce47776f19
commit
95f708da58
|
@ -14,45 +14,6 @@ namespace IRaCIS.Core.Application.MassTransit.Consumer;
|
||||||
|
|
||||||
public static class CommonEmailHelper
|
public static class CommonEmailHelper
|
||||||
{
|
{
|
||||||
public static async Task<EmailNoticeConfig> GetEmailSubejctAndHtmlInfoAndBuildAsync(IRepository<EmailNoticeConfig> _emailNoticeConfigrepository, EmailBusinessScenario scenario, MimeMessage messageToSend,
|
|
||||||
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailFunc)
|
|
||||||
{
|
|
||||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
|
||||||
|
|
||||||
var configInfo = await _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario).FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
if (configInfo == null)
|
|
||||||
{
|
|
||||||
//"系统未找到当前场景邮件配置信息,请联系运维人员核查"
|
|
||||||
throw new BusinessValidationFailedException(I18n.T("CommonEmail_NotFoundConfig"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var (topicStr, htmlBodyStr) = isEn_US ? (configInfo.EmailTopic, configInfo.EmailHtmlContent) : (configInfo.EmailTopicCN, configInfo.EmailHtmlContentCN);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//每个场景修改主题 和body的逻辑不一样
|
|
||||||
(topicStr, htmlBodyStr) = emailFunc((topicStr, htmlBodyStr));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//"邮件模板内容有误,填充内容出现问题,请联系运维人员核查"
|
|
||||||
|
|
||||||
throw new BusinessValidationFailedException(I18n.T("CommonEmail_ConfigError"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
messageToSend.Subject = topicStr;
|
|
||||||
|
|
||||||
var builder = new BodyBuilder();
|
|
||||||
|
|
||||||
builder.HtmlBody = htmlBodyStr;
|
|
||||||
|
|
||||||
messageToSend.Body = builder.ToMessageBody();
|
|
||||||
|
|
||||||
return configInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 系统默认邮件 + 项目默认邮件 (不用添加到项目邮件配置中,才发送)
|
/// 系统默认邮件 + 项目默认邮件 (不用添加到项目邮件配置中,才发送)
|
||||||
|
@ -67,8 +28,6 @@ Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr
|
||||||
{
|
{
|
||||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var (topicStr, htmlBodyStr) = isEn_US ? (configInfo.EmailTopic, configInfo.EmailHtmlContent) : (configInfo.EmailTopicCN, configInfo.EmailHtmlContentCN);
|
var (topicStr, htmlBodyStr) = isEn_US ? (configInfo.EmailTopic, configInfo.EmailHtmlContent) : (configInfo.EmailTopicCN, configInfo.EmailHtmlContentCN);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -99,13 +99,13 @@ public class ImageConsumer(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var trialEmailConfig = _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario && t.IsEnable).FirstOrDefault();
|
var emailConfig = _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario && t.IsEnable && t.IsAutoSend).FirstOrDefault();
|
||||||
|
|
||||||
if (trialEmailConfig != null)
|
if (emailConfig != null)
|
||||||
{
|
{
|
||||||
var inDto = new SendImageReuploadEmailInDto
|
var inDto = new SendImageReuploadEmailInDto
|
||||||
{
|
{
|
||||||
EmailNoticeConfig = trialEmailConfig,
|
EmailNoticeConfig = emailConfig,
|
||||||
Scenario = scenario,
|
Scenario = scenario,
|
||||||
SubjectVisit = subjectVisit,
|
SubjectVisit = subjectVisit,
|
||||||
TrialId = trialId,
|
TrialId = trialId,
|
||||||
|
@ -143,13 +143,13 @@ public class ImageConsumer(
|
||||||
return; // 其他状态不发送邮件
|
return; // 其他状态不发送邮件
|
||||||
}
|
}
|
||||||
|
|
||||||
var trialEmailConfig = _emailNoticeConfigrepository.Where(t =>t.BusinessScenarioEnum == scenario && t.IsEnable).FirstOrDefault();
|
var emailConfig = _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario && t.IsEnable && t.IsAutoSend).FirstOrDefault();
|
||||||
|
|
||||||
if (trialEmailConfig != null)
|
if (emailConfig != null)
|
||||||
{
|
{
|
||||||
var inDto = new SendImageReuploadEmailInDto
|
var inDto = new SendImageReuploadEmailInDto
|
||||||
{
|
{
|
||||||
EmailNoticeConfig = trialEmailConfig,
|
EmailNoticeConfig = emailConfig,
|
||||||
Scenario = scenario,
|
Scenario = scenario,
|
||||||
SubjectVisit = subjectVisit,
|
SubjectVisit = subjectVisit,
|
||||||
TrialId = trialId,
|
TrialId = trialId,
|
||||||
|
@ -185,13 +185,13 @@ public class ImageConsumer(
|
||||||
return; // 其他状态不发送邮件
|
return; // 其他状态不发送邮件
|
||||||
}
|
}
|
||||||
|
|
||||||
var trialEmailConfig = _emailNoticeConfigrepository.Where(t =>t.BusinessScenarioEnum == scenario && t.IsEnable).FirstOrDefault();
|
var emailConfig = _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario && t.IsEnable && t.IsAutoSend).FirstOrDefault();
|
||||||
|
|
||||||
if (trialEmailConfig != null)
|
if (emailConfig != null)
|
||||||
{
|
{
|
||||||
var inDto = new SendImageReuploadEmailInDto
|
var inDto = new SendImageReuploadEmailInDto
|
||||||
{
|
{
|
||||||
EmailNoticeConfig = trialEmailConfig,
|
EmailNoticeConfig = emailConfig,
|
||||||
Scenario = scenario,
|
Scenario = scenario,
|
||||||
SubjectVisit = subjectVisit,
|
SubjectVisit = subjectVisit,
|
||||||
TrialId = trialId
|
TrialId = trialId
|
||||||
|
@ -239,13 +239,13 @@ public class ImageConsumer(
|
||||||
return; // 其他状态不发送邮件
|
return; // 其他状态不发送邮件
|
||||||
}
|
}
|
||||||
|
|
||||||
var trialEmailConfig = _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario && t.IsEnable).FirstOrDefault();
|
var emailConfig = _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario && t.IsEnable && t.IsAutoSend).FirstOrDefault();
|
||||||
|
|
||||||
if (trialEmailConfig != null)
|
if (emailConfig != null)
|
||||||
{
|
{
|
||||||
var inDto = new SendImageReuploadEmailInDto
|
var inDto = new SendImageReuploadEmailInDto
|
||||||
{
|
{
|
||||||
EmailNoticeConfig = trialEmailConfig,
|
EmailNoticeConfig = emailConfig,
|
||||||
Scenario = scenario,
|
Scenario = scenario,
|
||||||
SubjectVisit = subjectVisit,
|
SubjectVisit = subjectVisit,
|
||||||
TrialId = trialId
|
TrialId = trialId
|
||||||
|
@ -375,7 +375,7 @@ public class ImageConsumer(
|
||||||
return (topicStr, htmlBodyStr);
|
return (topicStr, htmlBodyStr);
|
||||||
};
|
};
|
||||||
|
|
||||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository, inDto.Scenario, messageToSend, emailConfigFunc);
|
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(inDto.EmailNoticeConfig, messageToSend, emailConfigFunc);
|
||||||
|
|
||||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||||
}
|
}
|
||||||
|
@ -404,11 +404,11 @@ public class ImageConsumer(
|
||||||
// 设置邮件场景
|
// 设置邮件场景
|
||||||
var scenario = EmailBusinessScenario.ReviewerSelection_PMApplyApproving; // 69
|
var scenario = EmailBusinessScenario.ReviewerSelection_PMApplyApproving; // 69
|
||||||
|
|
||||||
var trialEmailConfig = _emailNoticeConfigrepository.Where(t =>t.BusinessScenarioEnum == scenario && t.IsEnable).FirstOrDefault();
|
var emailConfig = _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario && t.IsEnable && t.IsAutoSend).FirstOrDefault();
|
||||||
|
|
||||||
if (trialEmailConfig != null)
|
if (emailConfig != null)
|
||||||
{
|
{
|
||||||
await SendReviewerSelectionEmail(trialEmailConfig, scenario, trialId, enrollIdList);
|
await SendReviewerSelectionEmail(emailConfig, trialId, enrollIdList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,18 +435,18 @@ public class ImageConsumer(
|
||||||
// 设置邮件场景
|
// 设置邮件场景
|
||||||
var scenario = EmailBusinessScenario.ReviewerSelection_SPMCPMApproval; // 70
|
var scenario = EmailBusinessScenario.ReviewerSelection_SPMCPMApproval; // 70
|
||||||
|
|
||||||
var trialEmailConfig = _emailNoticeConfigrepository.Where(t =>t.BusinessScenarioEnum == scenario && t.IsEnable).FirstOrDefault();
|
var emailConfig = _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario && t.IsEnable && t.IsAutoSend).FirstOrDefault();
|
||||||
|
|
||||||
if (trialEmailConfig != null)
|
if (emailConfig != null)
|
||||||
{
|
{
|
||||||
await SendReviewerSelectionEmail(trialEmailConfig, scenario, trialId, enrollIdList);
|
await SendReviewerSelectionEmail(emailConfig, trialId, enrollIdList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送阅片人筛选相关邮件的通用方法
|
/// 发送阅片人筛选相关邮件的通用方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task SendReviewerSelectionEmail(EmailNoticeConfig emailNoticeConfig, EmailBusinessScenario scenario, Guid trialId, List<Guid> enrollIdList)
|
private async Task SendReviewerSelectionEmail(EmailNoticeConfig emailNoticeConfig, Guid trialId, List<Guid> enrollIdList)
|
||||||
{
|
{
|
||||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||||
|
|
||||||
|
@ -508,7 +508,7 @@ public class ImageConsumer(
|
||||||
return (topicStr, htmlBodyStr);
|
return (topicStr, htmlBodyStr);
|
||||||
};
|
};
|
||||||
|
|
||||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository, scenario, messageToSend, emailConfigFunc);
|
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(emailNoticeConfig, messageToSend, emailConfigFunc);
|
||||||
|
|
||||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue