|
|
|
@ -55,6 +55,20 @@ public class CRCSubmitedAndQCToAuditEventConsumer(
|
|
|
|
|
auditStateCode = "AuditStateRC";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DictionaryRepository = _dictionaryRepository,
|
|
|
|
|
IsEn_US = isEn_US,
|
|
|
|
|
DictionaryList = new List<DictionaryDto>()
|
|
|
|
|
{
|
|
|
|
|
new DictionaryDto (){DictionaryCode= auditStateCode,EnumValue=subjectVisit.AuditState.GetEnumInt(), }, //审核状态
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
foreach (var userinfo in userinfoList)
|
|
|
|
|
{
|
|
|
|
|
var messageToSend = new MimeMessage();
|
|
|
|
@ -66,17 +80,6 @@ public class CRCSubmitedAndQCToAuditEventConsumer(
|
|
|
|
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DictionaryRepository = _dictionaryRepository,
|
|
|
|
|
IsEn_US = isEn_US,
|
|
|
|
|
DictionaryList = new List<DictionaryDto>()
|
|
|
|
|
{
|
|
|
|
|
new DictionaryDto (){DictionaryCode= auditStateCode,EnumValue=subjectVisit.AuditState.GetEnumInt(), }, //审核状态
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
|
|
|
|
{
|
|
|
|
@ -197,25 +200,180 @@ public class CRCRepliedQCChallengeEventConsumer(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// QC回复 质控质疑,通知CRC
|
|
|
|
|
/// QC回复 质控质疑,通知CRC (014,015)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class QCRepliedQCChallengeEventConsumer : IConsumer<QCRepliedQCChallengeEvent>
|
|
|
|
|
public class QCRepliedQCChallengeEventConsumer(
|
|
|
|
|
IRepository<User> _userRepository,
|
|
|
|
|
IRepository<TrialUser> _trialUseRepository,
|
|
|
|
|
IRepository<SubjectVisit> _subjectVisitRepository,
|
|
|
|
|
IRepository<Trial> _trialRepository,
|
|
|
|
|
IRepository<QCChallenge> _qCChallengeRepository,
|
|
|
|
|
IRepository<QCChallengeDialog> _qCChallengeDialogRepository,
|
|
|
|
|
IRepository<Dictionary> _dictionaryRepository,
|
|
|
|
|
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
|
|
|
|
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig) : IConsumer<QCRepliedQCChallengeEvent>
|
|
|
|
|
{
|
|
|
|
|
public Task Consume(ConsumeContext<QCRepliedQCChallengeEvent> context)
|
|
|
|
|
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
|
|
|
|
|
public async Task Consume(ConsumeContext<QCRepliedQCChallengeEvent> context)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
Console.WriteLine("发送(014,015) 【 QC回复 质控质疑,通知CRC】邮件!!!");
|
|
|
|
|
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
|
|
|
|
|
|
|
|
|
var subjectVisitId = context.Message.SubjectVisitId;
|
|
|
|
|
|
|
|
|
|
var subjectVisit = await _subjectVisitRepository.Where(x => x.Id == subjectVisitId).Include(x => x.Subject).FirstNotNullAsync();
|
|
|
|
|
|
|
|
|
|
var trialUser = await _trialUseRepository.Where(x => x.TrialId == subjectVisit.TrialId).Include(x => x.User).Select(x => x.User).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var userinfoList = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.CRA || x.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == subjectVisit.TrialId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DictionaryRepository = _dictionaryRepository,
|
|
|
|
|
IsEn_US = isEn_US,
|
|
|
|
|
DictionaryList = new List<DictionaryDto>()
|
|
|
|
|
{
|
|
|
|
|
new DictionaryDto (){DictionaryCode= "CheckState",EnumValue=subjectVisit.CheckState.GetEnumInt(), }, //审核状态
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var userinfo in userinfoList)
|
|
|
|
|
{
|
|
|
|
|
var messageToSend = new MimeMessage();
|
|
|
|
|
//发件地址
|
|
|
|
|
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
|
|
|
|
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
|
|
|
|
{
|
|
|
|
|
var subjectCode = subjectVisit.Subject.Code;
|
|
|
|
|
var topicStr = string.Format(input.topicStr, trialInfo.ResearchProgramNo, subjectCode, subjectVisit.VisitName);
|
|
|
|
|
var htmlBodyStr = string.Format(
|
|
|
|
|
CommonEmailHelper.ReplaceCompanyName(_systemEmailConfig, input.htmlBodyStr),
|
|
|
|
|
trialInfo.ExperimentName, // 项目 {1}
|
|
|
|
|
userinfo.FullName, // 用户名 {1}
|
|
|
|
|
subjectCode, // 受试者 {2}
|
|
|
|
|
subjectVisit.VisitName, // 访视 {3}
|
|
|
|
|
dictionValue[0], // 核查状态 {4}
|
|
|
|
|
_systemEmailConfig.SiteUrl // 链接 {5}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (topicStr, htmlBodyStr);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository,
|
|
|
|
|
|
|
|
|
|
context.Message.IsPd ? EmailBusinessScenario.PDVerification_UnderDRForPMOrAPM : EmailBusinessScenario.EligibilityVerification_UnderDRForPMOrAPM,
|
|
|
|
|
|
|
|
|
|
messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CRC 回复一致性核查质疑 通知PM
|
|
|
|
|
/// CRC 回复一致性核查质疑 通知PM (019,020)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class CRCRepliedCheckChallengeEventConsumer : IConsumer<CRCRepliedCheckChallengeEvent>
|
|
|
|
|
public class CRCRepliedCheckChallengeEventConsumer(
|
|
|
|
|
IRepository<User> _userRepository,
|
|
|
|
|
IRepository<TrialUser> _trialUseRepository,
|
|
|
|
|
IRepository<SubjectVisit> _subjectVisitRepository,
|
|
|
|
|
IRepository<Trial> _trialRepository,
|
|
|
|
|
IRepository<QCChallenge> _qCChallengeRepository,
|
|
|
|
|
IRepository<QCChallengeDialog> _qCChallengeDialogRepository,
|
|
|
|
|
IRepository<Dictionary> _dictionaryRepository,
|
|
|
|
|
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
|
|
|
|
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig) : IConsumer<CRCRepliedCheckChallengeEvent>
|
|
|
|
|
{
|
|
|
|
|
public Task Consume(ConsumeContext<CRCRepliedCheckChallengeEvent> context)
|
|
|
|
|
|
|
|
|
|
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
|
|
|
|
|
public async Task Consume(ConsumeContext<CRCRepliedCheckChallengeEvent> context)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
Console.WriteLine("发送(019,020) 【 CRC 回复一致性核查质疑 通知PM】邮件!!!");
|
|
|
|
|
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
|
|
|
|
|
|
|
|
|
var subjectVisitId = context.Message.SubjectVisitId;
|
|
|
|
|
|
|
|
|
|
var subjectVisit = await _subjectVisitRepository.Where(x => x.Id == subjectVisitId).Include(x => x.Subject).FirstNotNullAsync();
|
|
|
|
|
|
|
|
|
|
var trialUser = await _trialUseRepository.Where(x => x.TrialId == subjectVisit.TrialId).Include(x => x.User).Select(x => x.User).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var userinfoList = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.APM || x.UserTypeEnum == UserTypeEnum.ProjectManager).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == subjectVisit.TrialId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DictionaryRepository = _dictionaryRepository,
|
|
|
|
|
IsEn_US = isEn_US,
|
|
|
|
|
DictionaryList = new List<DictionaryDto>()
|
|
|
|
|
{
|
|
|
|
|
new DictionaryDto (){DictionaryCode= "CheckState",EnumValue=subjectVisit.CheckState.GetEnumInt(), }, //审核状态
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var userinfo in userinfoList)
|
|
|
|
|
{
|
|
|
|
|
var messageToSend = new MimeMessage();
|
|
|
|
|
//发件地址
|
|
|
|
|
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
|
|
|
|
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
|
|
|
|
{
|
|
|
|
|
var subjectCode = subjectVisit.Subject.Code;
|
|
|
|
|
var topicStr = string.Format(input.topicStr, trialInfo.ResearchProgramNo, subjectCode, subjectVisit.VisitName);
|
|
|
|
|
var htmlBodyStr = string.Format(
|
|
|
|
|
CommonEmailHelper.ReplaceCompanyName(_systemEmailConfig, input.htmlBodyStr),
|
|
|
|
|
trialInfo.ExperimentName, // 项目 {1}
|
|
|
|
|
userinfo.FullName, // 用户名 {1}
|
|
|
|
|
subjectCode, // 受试者 {2}
|
|
|
|
|
subjectVisit.VisitName, // 访视 {3}
|
|
|
|
|
dictionValue[0], // 核查状态 {4}
|
|
|
|
|
_systemEmailConfig.SiteUrl // 链接 {5}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (topicStr, htmlBodyStr);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository,
|
|
|
|
|
|
|
|
|
|
context.Message.IsPd ? EmailBusinessScenario.PDVerification_UnderDRForPMOrAPM : EmailBusinessScenario.EligibilityVerification_UnderDRForPMOrAPM,
|
|
|
|
|
|
|
|
|
|
messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -234,13 +392,90 @@ public class PMRepliedCheckChallengeEventConsumer : IConsumer<PMRepliedCheckChal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通知PM 进行一致性核查
|
|
|
|
|
/// 通知PM 进行一致性核查 (018,030)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class CheckStateChangedToAuditEventConsumer : IConsumer<CheckStateChangedToAuditEvent>
|
|
|
|
|
public class CheckStateChangedToAuditEventConsumer(
|
|
|
|
|
IRepository<User> _userRepository,
|
|
|
|
|
IRepository<TrialUser> _trialUseRepository,
|
|
|
|
|
IRepository<SubjectVisit> _subjectVisitRepository,
|
|
|
|
|
IRepository<Trial> _trialRepository,
|
|
|
|
|
IRepository<QCChallenge> _qCChallengeRepository,
|
|
|
|
|
IRepository<QCChallengeDialog> _qCChallengeDialogRepository,
|
|
|
|
|
IRepository<Dictionary> _dictionaryRepository,
|
|
|
|
|
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
|
|
|
|
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig) : IConsumer<CheckStateChangedToAuditEvent>
|
|
|
|
|
{
|
|
|
|
|
public Task Consume(ConsumeContext<CheckStateChangedToAuditEvent> context)
|
|
|
|
|
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
|
|
|
|
|
public async Task Consume(ConsumeContext<CheckStateChangedToAuditEvent> context)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
Console.WriteLine("发送(018,030) 【通知PM 进行一致性核查】邮件!!!");
|
|
|
|
|
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
|
|
|
|
|
|
|
|
|
var subjectVisitId = context.Message.SubjectVisitId;
|
|
|
|
|
|
|
|
|
|
var subjectVisit = await _subjectVisitRepository.Where(x => x.Id == subjectVisitId).Include(x => x.Subject).FirstNotNullAsync();
|
|
|
|
|
|
|
|
|
|
var trialUser = await _trialUseRepository.Where(x => x.TrialId == subjectVisit.TrialId).Include(x => x.User).Select(x => x.User).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var userinfoList = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.APM || x.UserTypeEnum == UserTypeEnum.ProjectManager).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == subjectVisit.TrialId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DictionaryRepository = _dictionaryRepository,
|
|
|
|
|
IsEn_US = isEn_US,
|
|
|
|
|
DictionaryList = new List<DictionaryDto>()
|
|
|
|
|
{
|
|
|
|
|
new DictionaryDto (){DictionaryCode= "CheckState",EnumValue=subjectVisit.CheckState.GetEnumInt(), }, //审核状态
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var userinfo in userinfoList)
|
|
|
|
|
{
|
|
|
|
|
var messageToSend = new MimeMessage();
|
|
|
|
|
//发件地址
|
|
|
|
|
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
|
|
|
|
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
|
|
|
|
{
|
|
|
|
|
var subjectCode = subjectVisit.Subject.Code;
|
|
|
|
|
var topicStr = string.Format(input.topicStr, trialInfo.ResearchProgramNo, subjectCode, subjectVisit.VisitName);
|
|
|
|
|
var htmlBodyStr = string.Format(
|
|
|
|
|
CommonEmailHelper.ReplaceCompanyName(_systemEmailConfig, input.htmlBodyStr),
|
|
|
|
|
trialInfo.ExperimentName, // 项目 {1}
|
|
|
|
|
userinfo.FullName, // 用户名 {1}
|
|
|
|
|
subjectCode, // 受试者 {2}
|
|
|
|
|
subjectVisit.VisitName, // 访视 {3}
|
|
|
|
|
dictionValue[0], // 核查状态 {4}
|
|
|
|
|
_systemEmailConfig.SiteUrl // 链接 {5}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (topicStr, htmlBodyStr);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository,
|
|
|
|
|
|
|
|
|
|
context.Message.IsPd ? EmailBusinessScenario.PDVerification_DR : EmailBusinessScenario.EligibilityVerification_DR,
|
|
|
|
|
|
|
|
|
|
messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|