IRC_NewDev
parent
c9a6f8b99b
commit
a88ef53104
|
@ -1,4 +1,5 @@
|
||||||
using DocumentFormat.OpenXml;
|
using Amazon.Runtime.Internal.Util;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
|
@ -65,11 +66,36 @@ public static class CommonEmailHelper
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inDto"></param>
|
/// <param name="inDto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string TranslationDictionary(TranslationDictionaryDto inDto)
|
public static async Task<List<string>> TranslationDictionary(TranslationDictionaryDto inDto)
|
||||||
{
|
{
|
||||||
var dic = inDto.DictionaryRepository.Where(x => x.Parent.Code == inDto.DictionaryCode && x.Code == inDto.EnumValue).FirstOrDefault();
|
|
||||||
|
|
||||||
return dic == null ? string.Empty : (inDto.IsEn_US ? dic.Value : dic.ValueCN);
|
var dictionaryCodelist = inDto.DictionaryList.Select(x => x.DictionaryCode).ToList();
|
||||||
|
|
||||||
|
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
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
|
List<string> result = new List<string>();
|
||||||
|
|
||||||
|
inDto.DictionaryList.ForEach(x =>
|
||||||
|
{
|
||||||
|
|
||||||
|
var dic = dicList.Where(y => y.EnumValue == x.EnumValue && y.DictionaryCode == x.DictionaryCode).FirstOrDefault();
|
||||||
|
result.Add(dic == null ? string.Empty : (inDto.IsEn_US ? dic.Value : dic.ValueCN));
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +110,39 @@ public class TranslationDictionaryDto
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IRepository<Dictionary> DictionaryRepository { get; set; }
|
public IRepository<Dictionary> DictionaryRepository { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否是英文
|
||||||
|
/// </summary>
|
||||||
|
public bool IsEn_US { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字典
|
||||||
|
/// </summary>
|
||||||
|
public List<DictionaryDto> DictionaryList { get; set; } = new List<DictionaryDto>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字典对象
|
||||||
|
/// </summary>
|
||||||
|
public class DictionaryDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 字典Code
|
||||||
|
/// </summary>
|
||||||
|
public string DictionaryCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 枚举值
|
||||||
|
/// </summary>
|
||||||
|
public string EnumValue { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class DictionaryData
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 字典Code
|
/// 字典Code
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -95,8 +154,13 @@ public class TranslationDictionaryDto
|
||||||
public string EnumValue { get; set; }
|
public string EnumValue { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否是英文
|
/// 值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsEn_US { get; set; }
|
public string Value { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回
|
||||||
|
/// </summary>
|
||||||
|
public string ValueCN { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ using IRaCIS.Core.Domain;
|
||||||
using IRaCIS.Core.Domain.BaseModel;
|
using IRaCIS.Core.Domain.BaseModel;
|
||||||
using IRaCIS.Core.Domain.Models;
|
using IRaCIS.Core.Domain.Models;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
|
@ -24,7 +25,8 @@ public class UrgentMedicalReviewAddedEventConsumer(
|
||||||
IRepository<TaskMedicalReview> _taskMedicalReviewRepository,
|
IRepository<TaskMedicalReview> _taskMedicalReviewRepository,
|
||||||
IRepository<Trial> _trialRepository,
|
IRepository<Trial> _trialRepository,
|
||||||
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
|
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
|
||||||
IRepository<TrialSiteSurvey> _trialSiteSurveyRepository,
|
IRepository<VisitTask> _visitTaskRepository,
|
||||||
|
IRepository<Dictionary> _dictionaryRepository,
|
||||||
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
||||||
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig
|
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig
|
||||||
) : IConsumer<UrgentMedicalReviewAddedEvent>
|
) : IConsumer<UrgentMedicalReviewAddedEvent>
|
||||||
|
@ -39,6 +41,7 @@ public class UrgentMedicalReviewAddedEventConsumer(
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
public async Task Consume(ConsumeContext<UrgentMedicalReviewAddedEvent> context)
|
public async Task Consume(ConsumeContext<UrgentMedicalReviewAddedEvent> context)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("发送【加急的医学反馈任务 通知MIM】邮件!!!");
|
||||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||||
|
|
||||||
var medicalReviewId = context.Message.MedicalReviewId;
|
var medicalReviewId = context.Message.MedicalReviewId;
|
||||||
|
@ -55,6 +58,7 @@ public class UrgentMedicalReviewAddedEventConsumer(
|
||||||
var criterion = await _readingQuestionCriterionTrialRepository.FirstOrDefaultAsync(x => x.Id == medicalReview.VisitTask.TrialReadingCriterionId);
|
var criterion = await _readingQuestionCriterionTrialRepository.FirstOrDefaultAsync(x => x.Id == medicalReview.VisitTask.TrialReadingCriterionId);
|
||||||
var userinfo = await _userRepository.Where(x => x.Id == medicalReview.MedicalManagerUserId).FirstOrDefaultAsync();
|
var userinfo = await _userRepository.Where(x => x.Id == medicalReview.MedicalManagerUserId).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
var taskInfo = await _visitTaskRepository.Where(x => x.Id == medicalReview.VisitTaskId).Include(x=>x.SourceSubjectVisit).Include(x => x.ReadModule).Include(x => x.Subject).FirstNotNullAsync();
|
||||||
|
|
||||||
|
|
||||||
var messageToSend = new MimeMessage();
|
var messageToSend = new MimeMessage();
|
||||||
|
@ -62,29 +66,44 @@ public class UrgentMedicalReviewAddedEventConsumer(
|
||||||
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
||||||
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == medicalReview.TrialId);
|
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == medicalReview.TrialId);
|
||||||
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
||||||
|
|
||||||
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
|
||||||
|
var dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto()
|
||||||
{
|
{
|
||||||
var topicStr = string.Format(input.topicStr, companyName, trialInfo.ResearchProgramNo);
|
|
||||||
var htmlBodyStr = string.Format(CommonEmailHelper.ReplaceCompanyName(_systemEmailConfig, input.htmlBodyStr),
|
|
||||||
userinfo.FullName, // 用户名
|
|
||||||
trialInfo.ExperimentName , // 项目
|
|
||||||
criterion.CriterionName // 阅片标准
|
|
||||||
// 受试者
|
|
||||||
// 访视
|
|
||||||
// 任务类型
|
|
||||||
// 阅片人是否同意
|
|
||||||
// 审核状态
|
|
||||||
// 是否加急
|
|
||||||
|
|
||||||
);
|
DictionaryRepository = _dictionaryRepository,
|
||||||
|
IsEn_US = isEn_US,
|
||||||
|
|
||||||
return (topicStr, htmlBodyStr);
|
|
||||||
};
|
DictionaryList = new List<DictionaryDto>()
|
||||||
|
{
|
||||||
|
new DictionaryDto (){DictionaryCode= "ReadingCategory",EnumValue=taskInfo.ReadingCategory.GetEnumInt(), },
|
||||||
|
new DictionaryDto (){DictionaryCode= "MedicalReviewDoctorUserIdea",EnumValue=medicalReview.DoctorUserIdeaEnum.GetEnumInt(), },
|
||||||
|
new DictionaryDto (){DictionaryCode= "MedicalReviewAuditState",EnumValue=medicalReview.AuditState.GetEnumInt(), },
|
||||||
|
new DictionaryDto (){DictionaryCode= "YesOrNo",EnumValue=taskInfo.IsUrgent.ToString(), }
|
||||||
|
}
|
||||||
|
}) ;
|
||||||
|
|
||||||
|
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
||||||
|
{
|
||||||
|
var topicStr = string.Format(input.topicStr, companyName, trialInfo.ResearchProgramNo);
|
||||||
|
var htmlBodyStr = string.Format(
|
||||||
|
CommonEmailHelper.ReplaceCompanyName(_systemEmailConfig, input.htmlBodyStr),
|
||||||
|
userinfo.FullName, // 用户名
|
||||||
|
trialInfo.ExperimentName, // 项目
|
||||||
|
criterion.CriterionName, // 阅片标准
|
||||||
|
taskInfo.BlindSubjectCode.IsNullOrEmpty() ? taskInfo.Subject.Code : taskInfo.BlindSubjectCode, // 受试者
|
||||||
|
taskInfo.TaskBlindName, // 访视
|
||||||
|
dictionValue[0], // 任务类型
|
||||||
|
dictionValue[1], // 阅片人是否同意
|
||||||
|
dictionValue[2], // 审核状态
|
||||||
|
dictionValue[3] // 是否加急
|
||||||
|
);
|
||||||
|
|
||||||
|
return (topicStr, htmlBodyStr);
|
||||||
|
};
|
||||||
|
|
||||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository, EmailBusinessScenario.SiteSurveyReject, messageToSend, emailConfigFunc);
|
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository, EmailBusinessScenario.SiteSurveyReject, messageToSend, emailConfigFunc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue