修改邮件发送配置
parent
2d50037c03
commit
e333368528
|
@ -23,7 +23,8 @@ public static class CommonEmailHelper
|
||||||
|
|
||||||
if (configInfo == null)
|
if (configInfo == null)
|
||||||
{
|
{
|
||||||
throw new BusinessValidationFailedException("系统未找到当前场景邮件配置信息,请联系运维人员核查");
|
//"系统未找到当前场景邮件配置信息,请联系运维人员核查"
|
||||||
|
throw new BusinessValidationFailedException(I18n.T("CommonEmail_NotFoundConfig"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,8 +37,9 @@ public static class CommonEmailHelper
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
//"邮件模板内容有误,填充内容出现问题,请联系运维人员核查"
|
||||||
|
|
||||||
throw new BusinessValidationFailedException("邮件模板内容有误,填充内容出现问题,请联系运维人员核查");
|
throw new BusinessValidationFailedException(I18n.T("CommonEmail_ConfigError"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,6 +54,49 @@ public static class CommonEmailHelper
|
||||||
return configInfo;
|
return configInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<TrialEmailNoticeConfig> GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(IRepository<TrialEmailNoticeConfig> _trialEmailNoticeConfigrepository, 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 _trialEmailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario && t.IsAutoSend && t.IsEnable).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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static string ReplaceCompanyName(SystemEmailSendConfig _systemEmailConfig, string needDealtxt)
|
public static string ReplaceCompanyName(SystemEmailSendConfig _systemEmailConfig, string needDealtxt)
|
||||||
{
|
{
|
||||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||||
|
@ -74,7 +119,8 @@ public static class CommonEmailHelper
|
||||||
var enumValueList = inDto.DictionaryList.Select(x => x.EnumValue).ToList();
|
var enumValueList = inDto.DictionaryList.Select(x => x.EnumValue).ToList();
|
||||||
|
|
||||||
|
|
||||||
var dicList =await inDto.DictionaryRepository.Where(x => dictionaryCodelist.Contains(x.Parent.Code) && enumValueList.Contains(x.Code)).Select(x=>new DictionaryData() {
|
var dicList = await inDto.DictionaryRepository.Where(x => dictionaryCodelist.Contains(x.Parent.Code) && enumValueList.Contains(x.Code)).Select(x => new DictionaryData()
|
||||||
|
{
|
||||||
|
|
||||||
DictionaryCode = x.Parent.Code,
|
DictionaryCode = x.Parent.Code,
|
||||||
EnumValue = x.Code,
|
EnumValue = x.Code,
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class UserSiteSurveySubmitedEventConsumer(
|
||||||
IRepository<TrialSite> _trialSiteRepository,
|
IRepository<TrialSite> _trialSiteRepository,
|
||||||
IRepository<TrialUserRole> _trialUserRoleRepository,
|
IRepository<TrialUserRole> _trialUserRoleRepository,
|
||||||
IRepository<TrialSiteSurvey> _trialSiteSurveyRepository,
|
IRepository<TrialSiteSurvey> _trialSiteSurveyRepository,
|
||||||
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
IRepository<TrialEmailNoticeConfig> _trialEmailNoticeConfigrepository,
|
||||||
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig
|
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig
|
||||||
) : IConsumer<UserSiteSurveySubmitedEvent>
|
) : IConsumer<UserSiteSurveySubmitedEvent>
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,13 @@ public class UserSiteSurveySubmitedEventConsumer(
|
||||||
|
|
||||||
var trialId = siteSurveyInfo.TrialId;
|
var trialId = siteSurveyInfo.TrialId;
|
||||||
|
|
||||||
|
var scenario = _trialSiteSurveyRepository.Where(t => t.Id != trialSiteSurveyId && t.TrialId == siteSurveyInfo.TrialId && t.TrialSiteId == siteSurveyInfo.TrialSiteId).IgnoreQueryFilters().Any() ?
|
||||||
|
EmailBusinessScenario.Approval_UpdateSiteSurvey : EmailBusinessScenario.Approval_SubmitSiteSurvey;
|
||||||
|
|
||||||
|
|
||||||
|
if (_trialEmailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario && t.IsAutoSend && t.IsEnable).Any())
|
||||||
|
{
|
||||||
|
|
||||||
var trialUserList = await _trialUserRoleRepository.Where(t => t.TrialId == siteSurveyInfo.TrialId)
|
var trialUserList = await _trialUserRoleRepository.Where(t => t.TrialId == siteSurveyInfo.TrialId)
|
||||||
.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.SPM || t.UserRole.UserTypeEnum == UserTypeEnum.CPM || t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM)
|
.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.SPM || t.UserRole.UserTypeEnum == UserTypeEnum.CPM || t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM)
|
||||||
.Select(t => new { t.UserRole.FullName, t.UserRole.IdentityUser.EMail, t.UserRole.UserTypeEnum }).ToListAsync();
|
.Select(t => new { t.UserRole.FullName, t.UserRole.IdentityUser.EMail, t.UserRole.UserTypeEnum }).ToListAsync();
|
||||||
|
@ -110,12 +117,11 @@ public class UserSiteSurveySubmitedEventConsumer(
|
||||||
return (topicStr, htmlBodyStr);
|
return (topicStr, htmlBodyStr);
|
||||||
};
|
};
|
||||||
|
|
||||||
var scenario = _trialSiteSurveyRepository.Where(t => t.Id != trialSiteSurveyId && t.TrialId == siteSurveyInfo.TrialId && t.TrialSiteId == siteSurveyInfo.TrialSiteId).IgnoreQueryFilters().Any() ?
|
|
||||||
EmailBusinessScenario.Approval_UpdateSiteSurvey : EmailBusinessScenario.Approval_SubmitSiteSurvey;
|
|
||||||
|
|
||||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository, scenario, messageToSend, emailConfigFunc);
|
await CommonEmailHelper.GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(_trialEmailNoticeConfigrepository, scenario, messageToSend, emailConfigFunc);
|
||||||
|
|
||||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,6 +149,9 @@ public class SiteSurveySPMSubmitedEventConsumer(
|
||||||
|
|
||||||
var trialId = siteSurveyInfo.TrialId;
|
var trialId = siteSurveyInfo.TrialId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var messageToSend = new MimeMessage();
|
var messageToSend = new MimeMessage();
|
||||||
|
|
||||||
var trialUserList = _trialUserRoleRepository.Where(t => t.TrialId == trialId)
|
var trialUserList = _trialUserRoleRepository.Where(t => t.TrialId == trialId)
|
||||||
|
|
Loading…
Reference in New Issue