修改字典表bug
This commit is contained in:
@@ -31,8 +31,53 @@ public static class SendEmailHelper
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task SendEmailAsync(MimeMessage messageToSend, SMTPEmailConfig sMTPEmailConfig, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||
public static async Task SendEmailAsync(SMTPEmailConfig sMTPEmailConfig, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||
{
|
||||
var messageToSend = new MimeMessage();
|
||||
|
||||
//主题
|
||||
messageToSend.Subject = sMTPEmailConfig.TopicDescription;
|
||||
|
||||
//发件地址
|
||||
messageToSend.From.Add(sMTPEmailConfig.FromEmailAddress);
|
||||
|
||||
//收件地址
|
||||
|
||||
if (sMTPEmailConfig.ToMailAddressList.Count == 0)
|
||||
{
|
||||
throw new ArgumentException("没有收件人");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in sMTPEmailConfig.ToMailAddressList)
|
||||
{
|
||||
messageToSend.To.Add(item);
|
||||
}
|
||||
|
||||
//抄送
|
||||
foreach (var copyToMailAddress in sMTPEmailConfig.CopyToMailAddressList)
|
||||
{
|
||||
messageToSend.Cc.Add(copyToMailAddress);
|
||||
}
|
||||
}
|
||||
|
||||
var builder = new BodyBuilder();
|
||||
|
||||
//html body
|
||||
|
||||
builder.HtmlBody = sMTPEmailConfig.HtmlBodyStr;
|
||||
|
||||
|
||||
//附件
|
||||
|
||||
foreach (var item in sMTPEmailConfig.EmailAttachMentConfigList)
|
||||
{
|
||||
await builder.Attachments.AddAsync(item.FileName, item.FileStream);
|
||||
}
|
||||
|
||||
|
||||
messageToSend.Body = builder.ToMessageBody();
|
||||
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
if (messageSentSuccess != null)
|
||||
@@ -61,12 +106,42 @@ public static class SendEmailHelper
|
||||
|
||||
public class SMTPEmailConfig
|
||||
{
|
||||
public int Port { get; set; }
|
||||
public int Port { get; set; } = 465;
|
||||
|
||||
public string Host { get; set; }
|
||||
public string Host { get; set; } = "smtp.163.com";
|
||||
|
||||
|
||||
public string UserName { get; set; }
|
||||
public string UserName { get; set; } = "iracis_grr@163.com";
|
||||
|
||||
public string AuthorizationCode { get; set; } = "XLWVQKZAEKLDWOAH";
|
||||
|
||||
|
||||
//邮件HtmlBody
|
||||
|
||||
public string HtmlBodyStr { get; set; } = string.Empty;
|
||||
|
||||
|
||||
//发
|
||||
public MailboxAddress FromEmailAddress { get; set; } = new MailboxAddress("GRR", "iracis_grr@163.com");
|
||||
|
||||
//收
|
||||
public List<MailboxAddress> ToMailAddressList { get; set; } = new List<MailboxAddress>();
|
||||
|
||||
//抄送
|
||||
public List<MailboxAddress> CopyToMailAddressList { get; set; } = new List<MailboxAddress>();
|
||||
|
||||
//邮件主题
|
||||
public string TopicDescription { get; set; } = string.Empty;
|
||||
|
||||
//邮件附件
|
||||
public List<EmailAttachMentConfig> EmailAttachMentConfigList { get; set; } = new List<EmailAttachMentConfig>() { };
|
||||
|
||||
public string AuthorizationCode { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class EmailAttachMentConfig
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
||||
public Stream FileStream { get; set; }
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="MimeKit" Version="3.4.1" />
|
||||
<PackageReference Include="MiniExcel" Version="1.28.0" />
|
||||
<PackageReference Include="MiniWord" Version="0.6.1" />
|
||||
<PackageReference Include="My.Extensions.Localization.Json" Version="3.0.0">
|
||||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
|
||||
@@ -398,6 +398,7 @@
|
||||
同步系统配置的文档到想项目中
|
||||
</summary>
|
||||
<param name="trialId"></param>
|
||||
<param name="criterionTypeEnum"></param>
|
||||
<returns></returns>
|
||||
|
||||
</member>
|
||||
@@ -7059,6 +7060,13 @@
|
||||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.TrialConfigService.AsyncTrialCriterionDictionary(IRaCIS.Core.Application.Contracts.AsyncTrialCriterionDictionaryInDto)">
|
||||
<summary>
|
||||
同步项目标准字典信息
|
||||
</summary>
|
||||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.TrialConfigService.SetGlobalReadingInfo(IRaCIS.Core.Application.Contracts.SetGlobalReadingInfoInDto)">
|
||||
<summary>
|
||||
修改全局阅片配置信息
|
||||
|
||||
@@ -123,9 +123,11 @@ namespace IRaCIS.Application.Services
|
||||
//}
|
||||
|
||||
|
||||
if (addOrEditBasic.Id != null && addOrEditBasic.ParentId!=null)
|
||||
if (addOrEditBasic.Id != null && addOrEditBasic.ParentId==null)
|
||||
{
|
||||
await _dicRepository.UpdatePartialFromQueryAsync(t => t.ParentId == addOrEditBasic.Id, c => new Dictionary() { DataTypeEnum = addOrEditBasic.DataTypeEnum });
|
||||
|
||||
//await _dicRepository.BatchUpdateNoTrackingAsync(t => t.ParentId == addOrEditBasic.Id, c => new Dictionary() { DataTypeEnum = addOrEditBasic.DataTypeEnum });
|
||||
}
|
||||
|
||||
var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true, verifyExp1);
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace IRaCIS.Application.Services
|
||||
messageToSend.To.Add(new MailboxAddress(userName, emailAddress));
|
||||
//主题
|
||||
messageToSend.Subject = "[来自展影IRC] 关于重置邮箱的提醒";
|
||||
|
||||
|
||||
var builder = new BodyBuilder();
|
||||
|
||||
|
||||
@@ -115,7 +115,6 @@ namespace IRaCIS.Application.Services
|
||||
}
|
||||
|
||||
|
||||
|
||||
messageToSend.Body = builder.ToMessageBody();
|
||||
|
||||
|
||||
@@ -495,7 +494,7 @@ namespace IRaCIS.Application.Services
|
||||
}
|
||||
|
||||
|
||||
|
||||
//医生生成账号加入 或者已存在账号加入到项目中
|
||||
public async Task<Guid> DoctorJoinTrialEmail(Guid trialId, Guid doctorId, string baseUrl, string rootUrl)
|
||||
{
|
||||
var doctor = await _doctorTypeRepository.FindAsync(doctorId);
|
||||
|
||||
@@ -9,6 +9,8 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Application.Helper;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
@@ -31,6 +33,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// 同步系统配置的文档到想项目中
|
||||
/// </summary>
|
||||
/// <param name="trialId"></param>
|
||||
/// <param name="criterionTypeEnum"></param>
|
||||
/// <returns></returns>
|
||||
///
|
||||
private async Task SyncSystemEmainCofigDocListAsync(Guid trialId, CriterionType? criterionTypeEnum)
|
||||
@@ -56,6 +59,91 @@ namespace IRaCIS.Core.Application.Service
|
||||
await _trialEmailNoticeConfigRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async Task FillWordTemplate(Guid trialId, CriterionType criterionTypeEnum, CommonDocumentBusinessScenario businessScenarioEnum)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private async Task <SMTPEmailConfig> FillWordTemplateAndEmailConfig(Guid trialId, Guid visitTaskId, Guid trialReadingCriterionId, CommonDocumentBusinessScenario businessScenarioEnum)
|
||||
{
|
||||
var criterionTypeEnum = await _repository.Where<ReadingQuestionCriterionTrial>(t => t.TrialId == trialId && t.Id == trialReadingCriterionId).Select(t => t.CriterionType).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
var emailConfig = await _trialEmailNoticeConfigRepository.Where(t => t.TrialId == trialId && t.CriterionTypeEnum == criterionTypeEnum && t.BusinessScenarioEnum == businessScenarioEnum).FirstOrDefaultAsync();
|
||||
|
||||
if (emailConfig == null)
|
||||
{
|
||||
throw new BusinessValidationFailedException("找不到该项目标准场景下邮件的配置");
|
||||
}
|
||||
|
||||
//填充邮件基本配置
|
||||
|
||||
var sendEmailConfig = new SMTPEmailConfig();
|
||||
|
||||
sendEmailConfig.TopicDescription = "入组确认测试";
|
||||
|
||||
foreach (var item in emailConfig.ReceiveEmailList)
|
||||
{
|
||||
sendEmailConfig.ToMailAddressList.Add(new MimeKit.MailboxAddress(string.Empty, item));
|
||||
}
|
||||
|
||||
foreach (var item in emailConfig.CopyEmailList)
|
||||
{
|
||||
sendEmailConfig.CopyToMailAddressList.Add(new MimeKit.MailboxAddress(string.Empty, item));
|
||||
}
|
||||
|
||||
|
||||
//邮件内容html
|
||||
var pathToFile = _hostEnvironment.WebRootPath
|
||||
+ Path.DirectorySeparatorChar.ToString()
|
||||
+ "EmailTemplate"
|
||||
+ Path.DirectorySeparatorChar.ToString()
|
||||
+ "SubjectEnrollConfirm.html";
|
||||
|
||||
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
|
||||
{
|
||||
var templateInfo = SourceReader.ReadToEnd();
|
||||
|
||||
|
||||
sendEmailConfig.HtmlBodyStr = string.Format(templateInfo,
|
||||
$" 附件为入组确认报告,请查收 "
|
||||
);
|
||||
}
|
||||
|
||||
//邮件附件
|
||||
|
||||
var path= FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, emailConfig.FilePath);
|
||||
|
||||
//sendEmailConfig.EmailAttachMentConfigList.Add(new EmailAttachMentConfig()
|
||||
//{
|
||||
// FileName = emailConfig.FileName,
|
||||
// FileStream =
|
||||
//});
|
||||
|
||||
|
||||
if (businessScenarioEnum == CommonDocumentBusinessScenario.EnrollConfirmed)
|
||||
{
|
||||
|
||||
}
|
||||
else if(businessScenarioEnum == CommonDocumentBusinessScenario.PDConfirmed)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return sendEmailConfig;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<List<TrialEmailNoticeConfigView>> GetTrialEmailNoticeConfigList(TrialEmailNoticeConfigQuery inQuery)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user