附件邮件测试
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user