附件邮件测试
parent
f916f0801b
commit
2569ef3828
|
@ -53,11 +53,10 @@ public static class SendEmailHelper
|
|||
{
|
||||
messageToSend.To.Add(item);
|
||||
}
|
||||
|
||||
//抄送
|
||||
foreach (var copyToMailAddress in sMTPEmailConfig.CopyToMailAddressList)
|
||||
{
|
||||
messageToSend.Cc.Add(copyToMailAddress);
|
||||
//messageToSend.Cc.Add(copyToMailAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +71,9 @@ public static class SendEmailHelper
|
|||
|
||||
foreach (var item in sMTPEmailConfig.EmailAttachMentConfigList)
|
||||
{
|
||||
builder.Attachments.Add(item.FileName, item.FileData);
|
||||
//builder.Attachments.Add(item.FileName, item.FileData);
|
||||
|
||||
builder.Attachments.Add(item.FileName, item.FileStream);
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,6 +98,7 @@ public static class SendEmailHelper
|
|||
await smtp.DisconnectAsync(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4461,6 +4461,13 @@
|
|||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.RC.ReadingQuestionService.ResetTrialCriterionAsyncState(System.Guid)">
|
||||
<summary>
|
||||
重置项目标准的重置状态
|
||||
</summary>
|
||||
<param name="trialReadingCriterionId">项目标准Id</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.RC.ReadingQuestionService.GetSystemOncologyInfo(IRaCIS.Core.Application.Service.Reading.Dto.GetSystemOncologyInfoInDto)">
|
||||
<summary>
|
||||
获取系统肿瘤信息
|
||||
|
|
|
@ -7,6 +7,7 @@ using System;
|
|||
using IRaCIS.Core.Domain.Share;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IRaCIS.Core.Application.ViewModel
|
||||
{
|
||||
|
@ -42,23 +43,25 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public CommonDocumentBusinessScenario BusinessScenarioEnum { get; set; }
|
||||
|
||||
public string Code { get; set; }
|
||||
public string Code { get; set; } = string.Empty;
|
||||
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public string AuthorizationCode { get; set; }
|
||||
public string AuthorizationCode { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
|
||||
public List<string> ReceiveEmailList { get; set; }
|
||||
public List<string> CopyEmailList { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string ReceiveEmailsStr { get; set; } = string.Empty;
|
||||
|
||||
public string ReceiveEmailsStr { get; set; }
|
||||
public string CopyEmailsStr { get; set; }
|
||||
[JsonIgnore]
|
||||
public string CopyEmailsStr { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public string FromEmail { get; set; }
|
||||
public string FromEmail { get; set; } = string.Empty;
|
||||
|
||||
public bool IsUrgent { get; set; }
|
||||
|
||||
|
@ -68,8 +71,8 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public bool IsReturnRequired { get; set; }
|
||||
|
||||
public string FilePath { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string FilePath { get; set; } = string.Empty;
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -61,17 +61,16 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
|
||||
private async Task FillWordTemplate(Guid trialId, CriterionType criterionTypeEnum, CommonDocumentBusinessScenario businessScenarioEnum)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task <SMTPEmailConfig> FillWordTemplateAndEmailConfig(Guid trialId, Guid visitTaskId, Guid trialReadingCriterionId, CommonDocumentBusinessScenario businessScenarioEnum)
|
||||
/// <summary>
|
||||
/// 测试邮件 带附件 填充word --前端不需要用
|
||||
/// </summary>
|
||||
/// <param name="trialId"></param>
|
||||
/// <param name="visitTaskId"></param>
|
||||
/// <param name="trialReadingCriterionId"></param>
|
||||
/// <param name="businessScenarioEnum"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public async Task 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();
|
||||
|
||||
|
@ -87,8 +86,6 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
var sendEmailConfig = new SMTPEmailConfig();
|
||||
|
||||
sendEmailConfig.TopicDescription = "入组确认测试";
|
||||
|
||||
foreach (var item in emailConfig.ReceiveEmailList)
|
||||
{
|
||||
sendEmailConfig.ToMailAddressList.Add(new MimeKit.MailboxAddress(item, item));
|
||||
|
@ -96,7 +93,10 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
foreach (var item in emailConfig.CopyEmailList)
|
||||
{
|
||||
sendEmailConfig.CopyToMailAddressList.Add(new MimeKit.MailboxAddress(item, item));
|
||||
if (item.Contains("@") && !string.IsNullOrEmpty(item))
|
||||
{
|
||||
sendEmailConfig.CopyToMailAddressList.Add(new MimeKit.MailboxAddress(item.Trim(), item.Trim()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,40 +107,56 @@ namespace IRaCIS.Core.Application.Service
|
|||
+ Path.DirectorySeparatorChar.ToString()
|
||||
+ "SubjectEnrollConfirmOrPDProgress.html";
|
||||
|
||||
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
|
||||
|
||||
if (businessScenarioEnum == CommonDocumentBusinessScenario.EnrollConfirmed)
|
||||
{
|
||||
var templateInfo = SourceReader.ReadToEnd();
|
||||
|
||||
sendEmailConfig.TopicDescription = "入组确认测试";
|
||||
|
||||
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
|
||||
{
|
||||
var templateInfo = SourceReader.ReadToEnd();
|
||||
|
||||
|
||||
sendEmailConfig.HtmlBodyStr = string.Format(templateInfo,
|
||||
$" 附件为入组确认报告,请查收 "
|
||||
);
|
||||
sendEmailConfig.HtmlBodyStr = string.Format(templateInfo,
|
||||
$" 附件为入组确认报告,请查收 "
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (businessScenarioEnum == CommonDocumentBusinessScenario.PDConfirmed)
|
||||
{
|
||||
|
||||
sendEmailConfig.TopicDescription = "疾病进展测试";
|
||||
|
||||
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
|
||||
{
|
||||
var templateInfo = SourceReader.ReadToEnd();
|
||||
|
||||
|
||||
sendEmailConfig.HtmlBodyStr = string.Format(templateInfo,
|
||||
$" 附件为疾病进展确认报告,请查收 "
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//邮件附件
|
||||
var path = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, emailConfig.FilePath);
|
||||
|
||||
var path= FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, emailConfig.FilePath);
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
throw new BusinessValidationFailedException("找不到该项目标准场景下邮件模板");
|
||||
}
|
||||
|
||||
sendEmailConfig.EmailAttachMentConfigList.Add(new EmailAttachMentConfig()
|
||||
{
|
||||
FileName = emailConfig.FileName,
|
||||
|
||||
FileData= File.ReadAllBytes(path)
|
||||
FileStream = System.IO.File.OpenRead(path)
|
||||
});
|
||||
|
||||
|
||||
if (businessScenarioEnum == CommonDocumentBusinessScenario.EnrollConfirmed)
|
||||
{
|
||||
|
||||
}
|
||||
else if(businessScenarioEnum == CommonDocumentBusinessScenario.PDConfirmed)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig);
|
||||
|
||||
return sendEmailConfig;
|
||||
await SendEmailHelper.SendEmailAsync(sendEmailConfig);
|
||||
|
||||
}
|
||||
|
||||
|
@ -178,6 +194,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
public async Task<IResponseOutput> DeleteTrialEmailNoticeConfig(Guid trialEmailNoticeConfigId)
|
||||
{
|
||||
var success = await _trialEmailNoticeConfigRepository.DeleteFromQueryAsync(t => t.Id == trialEmailNoticeConfigId, true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ namespace IRaCIS.Core.Domain.Models
|
|||
|
||||
|
||||
[NotMapped]
|
||||
public List<string> ReceiveEmailList => ReceiveEmailsStr.Split('|', StringSplitOptions.RemoveEmptyEntries).Select(t=>t.Trim()).ToList();
|
||||
public List<string> ReceiveEmailList => ReceiveEmailsStr.Split('|', StringSplitOptions.RemoveEmptyEntries).Where(t => !string.IsNullOrEmpty(t)).Select(t=>t.Trim()).ToList();
|
||||
|
||||
[NotMapped]
|
||||
public List<string> CopyEmailList => CopyEmailsStr.Split('|', StringSplitOptions.RemoveEmptyEntries).Select(t => t.Trim()).ToList();
|
||||
public List<string> CopyEmailList => CopyEmailsStr.Split('|', StringSplitOptions.RemoveEmptyEntries).Where(t=> !string.IsNullOrEmpty(t)).Select(t => t.Trim()).ToList();
|
||||
|
||||
[Required]
|
||||
public bool IsUrgent { get; set; }
|
||||
|
|
Loading…
Reference in New Issue