修改邮件发送配置

This commit is contained in:
2025-04-24 17:22:52 +08:00
parent 2d50037c03
commit e333368528
2 changed files with 130 additions and 75 deletions
@@ -23,7 +23,8 @@ public static class CommonEmailHelper
if (configInfo == null)
{
throw new BusinessValidationFailedException("系统未找到当前场景邮件配置信息,请联系运维人员核查");
//"系统未找到当前场景邮件配置信息,请联系运维人员核查"
throw new BusinessValidationFailedException(I18n.T("CommonEmail_NotFoundConfig"));
}
@@ -36,8 +37,9 @@ public static class CommonEmailHelper
}
catch (Exception ex)
{
//"邮件模板内容有误,填充内容出现问题,请联系运维人员核查"
throw new BusinessValidationFailedException("邮件模板内容有误,填充内容出现问题,请联系运维人员核查");
throw new BusinessValidationFailedException(I18n.T("CommonEmail_ConfigError"));
}
@@ -52,6 +54,49 @@ public static class CommonEmailHelper
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)
{
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
@@ -74,12 +119,13 @@ public static class CommonEmailHelper
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() {
DictionaryCode=x.Parent.Code,
EnumValue=x.Code,
Value=x.Value,
ValueCN=x.ValueCN
var dicList = await inDto.DictionaryRepository.Where(x => dictionaryCodelist.Contains(x.Parent.Code) && enumValueList.Contains(x.Code)).Select(x => new DictionaryData()
{
DictionaryCode = x.Parent.Code,
EnumValue = x.Code,
Value = x.Value,
ValueCN = x.ValueCN
}).ToListAsync();