|
|
|
@@ -21,6 +21,7 @@ using DocumentFormat.OpenXml.Vml;
|
|
|
|
|
using System.Net.Mail;
|
|
|
|
|
using IP2Region.Net.XDB;
|
|
|
|
|
using NPOI.SS.Formula.Eval;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace IRaCIS.Application.Services
|
|
|
|
|
{
|
|
|
|
@@ -97,7 +98,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task<MimeMessage> GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario scenario, MimeMessage messageToSend,
|
|
|
|
|
private async Task<EmailNoticeConfig> GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario scenario, MimeMessage messageToSend,
|
|
|
|
|
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailFunc)
|
|
|
|
|
{
|
|
|
|
|
var configInfo = await _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario).FirstOrDefaultAsync();
|
|
|
|
@@ -130,7 +131,19 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
|
|
|
|
|
messageToSend.Body = builder.ToMessageBody();
|
|
|
|
|
|
|
|
|
|
return messageToSend;
|
|
|
|
|
return configInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<EmailNoticeConfig> GetEmailConfigInfoAsync(EmailBusinessScenario scenario)
|
|
|
|
|
{
|
|
|
|
|
var configInfo = await _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario).Include(t=>t.EmailNoticeUserTypeList).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
if (configInfo == null)
|
|
|
|
|
{
|
|
|
|
|
throw new BusinessValidationFailedException("系统未找到当前场景邮件配置信息,请联系运维人员核查");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return configInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -188,7 +201,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(mfaType == UserMFAType.Login ? EmailBusinessScenario.MFALogin : EmailBusinessScenario.MFAUnlock, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(mfaType == UserMFAType.Login ? EmailBusinessScenario.MFALogin : EmailBusinessScenario.MFAUnlock, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sucessHandle = GetEmailSuccessHandle(userId, verificationCode, emailAddress);
|
|
|
|
@@ -226,7 +239,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.UserResetEmail, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.UserResetEmail, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sucessHandle = GetEmailSuccessHandle(userId, verificationCode, emailAddress);
|
|
|
|
@@ -265,7 +278,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.UnloginUseEmailResetPassword, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.UnloginUseEmailResetPassword, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
////此时不知道用户
|
|
|
|
|
var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode, emailAddress);
|
|
|
|
@@ -309,7 +322,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.UnloginUseEmailResetPassword, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.UnloginUseEmailResetPassword, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
//此时不知道用户
|
|
|
|
|
var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode, emailAddress);
|
|
|
|
@@ -351,7 +364,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SiteSurveyLogin, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SiteSurveyLogin, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
//此时不知道用户
|
|
|
|
|
var sucessHandle = GetEmailSuccessHandle(Guid.Empty, verificationCode, emailAddress);
|
|
|
|
@@ -397,7 +410,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SiteSurveyReject, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SiteSurveyReject, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -450,7 +463,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SysCreateUser, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SysCreateUser, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
|
|
|
@@ -487,7 +500,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SysResetPassword, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SysResetPassword, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
|
|
|
|
}
|
|
|
|
@@ -544,7 +557,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(sysUserInfo.IsFirstAdd ? EmailBusinessScenario.SiteUseOrExternalUserFirstrJoinTrial : EmailBusinessScenario.SiteUserOrExternalUserExistJoinTrial, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(sysUserInfo.IsFirstAdd ? EmailBusinessScenario.SiteUseOrExternalUserFirstrJoinTrial : EmailBusinessScenario.SiteUserOrExternalUserExistJoinTrial, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
|
|
|
@@ -604,7 +617,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(sysUserInfo.IsFirstAdd ? EmailBusinessScenario.SiteUseOrExternalUserFirstrJoinTrial : EmailBusinessScenario.SiteUserOrExternalUserExistJoinTrial, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(sysUserInfo.IsFirstAdd ? EmailBusinessScenario.SiteUseOrExternalUserFirstrJoinTrial : EmailBusinessScenario.SiteUserOrExternalUserExistJoinTrial, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, null);
|
|
|
|
@@ -722,7 +735,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(sysUserInfo.IsFirstAdd ? EmailBusinessScenario.DoctorUserFirstJoinTrial : EmailBusinessScenario.DoctorUserExistJoinTrial, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(sysUserInfo.IsFirstAdd ? EmailBusinessScenario.DoctorUserFirstJoinTrial : EmailBusinessScenario.DoctorUserExistJoinTrial, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, null);
|
|
|
|
@@ -745,9 +758,12 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
|
|
|
|
|
var companyName = _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
|
|
|
|
|
|
var emailConfigInfo = await GetEmailConfigInfoAsync(EmailBusinessScenario.IRImageError);
|
|
|
|
|
|
|
|
|
|
var emailList = await _repository.Where<User>(t => t.UserTypeEnum == UserTypeEnum.Admin || t.UserTypeEnum == UserTypeEnum.ZYSS ||
|
|
|
|
|
(isHaveTrialId ? t.UserTrials.Any(t => t.User.UserTypeEnum == UserTypeEnum.ProjectManager && t.TrialId == feedBack.TrialId) : true)).Select(t => new { t.EMail, t.UserTypeEnum, t.FullName }).ToListAsync();
|
|
|
|
|
var userTypeEnumList = emailConfigInfo.EmailNoticeUserTypeList.Where(t => t.EmailUserType == EmailUserType.To).Select(t => t.UserType).ToList();
|
|
|
|
|
|
|
|
|
|
var emailList = await _repository.Where<User>(t => userTypeEnumList.Contains(t.UserTypeEnum) &&
|
|
|
|
|
(isHaveTrialId ? t.UserTrials.Any(t => t.TrialId == feedBack.TrialId) : true)).Select(t => new { t.EMail, t.UserTypeEnum, t.FullName }).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//影像阅片反馈 pm
|
|
|
|
@@ -789,7 +805,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.IRImageError, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.IRImageError, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//项目相关的反馈 pm admin
|
|
|
|
@@ -819,7 +835,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
userNames,
|
|
|
|
|
info.TrialCode,
|
|
|
|
|
feedBack.CreateUser.UserTypeRole.UserTypeShortName,
|
|
|
|
|
feedBack.CreateUser.FullName,
|
|
|
|
|
feedBack.CreateUser.FullName,
|
|
|
|
|
emailType,
|
|
|
|
|
feedBack.QuestionDescription,
|
|
|
|
|
_systemEmailConfig.SiteUrl
|
|
|
|
@@ -829,7 +845,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.TrialFeedBack, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.TrialFeedBack, messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//项目无关的反馈 admin zyss
|
|
|
|
@@ -862,7 +878,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend = await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SysFeedBack, messageToSend, emailConfigFunc);
|
|
|
|
|
await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.SysFeedBack, messageToSend, emailConfigFunc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
|
|
|
|