修改接口
parent
b76969ad20
commit
15fd8109c3
|
@ -22,8 +22,39 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||||
public DateTime CreateTime { get; set; }
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
public Guid CreateUserId { get; set; }
|
public Guid CreateUserId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public List<EmailUserInfoDto> TrialEmailNoticeUserList { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public new Guid FromUserId => TrialEmailNoticeUserList.Where(t => t.EmailUserType == EmailUserType.From).Select(t => t.UserId).FirstOrDefault();
|
||||||
|
public new List<Guid> ToUserIdList => TrialEmailNoticeUserList.Where(t => t.EmailUserType == EmailUserType.To).Select(t => t.UserId).ToList();
|
||||||
|
public new List<Guid> CopyUserIdList => TrialEmailNoticeUserList.Where(t => t.EmailUserType == EmailUserType.Copy).Select(t => t.UserId).ToList();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class EmailUserInfoDto
|
||||||
|
{
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
public Guid TrialEmailNoticeConfigId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public EmailUserType EmailUserType { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public string Email { get; set; }
|
||||||
|
|
||||||
|
public string UserName { get; set; }
|
||||||
|
|
||||||
|
public string RealName { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///<summary>TrialEmailNoticeConfigQuery 列表查询参数模型</summary>
|
///<summary>TrialEmailNoticeConfigQuery 列表查询参数模型</summary>
|
||||||
public class TrialEmailNoticeConfigQuery
|
public class TrialEmailNoticeConfigQuery
|
||||||
{
|
{
|
||||||
|
@ -51,14 +82,21 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||||
|
|
||||||
public CriterionType CriterionTypeEnum { get; set; }
|
public CriterionType CriterionTypeEnum { get; set; }
|
||||||
|
|
||||||
public List<string> ReceiveEmailList { get; set; }
|
|
||||||
public List<string> CopyEmailList { get; set; }
|
|
||||||
|
|
||||||
[JsonIgnore]
|
public Guid FromUserId { get; set; }
|
||||||
public string ReceiveEmailsStr { get; set; } = string.Empty;
|
public List<Guid> ToUserIdList { get; set; }
|
||||||
|
public List<Guid> CopyUserIdList { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public string CopyEmailsStr { get; set; } = string.Empty;
|
|
||||||
|
//public List<string> ReceiveEmailList { get; set; }
|
||||||
|
//public List<string> CopyEmailList { get; set; }
|
||||||
|
|
||||||
|
//[JsonIgnore]
|
||||||
|
//public string ReceiveEmailsStr { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
//[JsonIgnore]
|
||||||
|
//public string CopyEmailsStr { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
public string FromEmail { get; set; } = string.Empty;
|
public string FromEmail { get; set; } = string.Empty;
|
||||||
|
|
|
@ -23,9 +23,14 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
private readonly IRepository<TrialEmailNoticeConfig> _trialEmailNoticeConfigRepository;
|
private readonly IRepository<TrialEmailNoticeConfig> _trialEmailNoticeConfigRepository;
|
||||||
|
|
||||||
public TrialEmailNoticeConfigService(IRepository<TrialEmailNoticeConfig> trialEmailNoticeConfigRepository)
|
public IRepository<VisitTask> _visitTaskRepository { get; }
|
||||||
|
public IRepository<TrialUser> _trialUserRepository { get; }
|
||||||
|
|
||||||
|
public TrialEmailNoticeConfigService(IRepository<TrialEmailNoticeConfig> trialEmailNoticeConfigRepository, IRepository<VisitTask> visitTaskRepository,IRepository<TrialUser> trialUserRepository)
|
||||||
{
|
{
|
||||||
_trialEmailNoticeConfigRepository = trialEmailNoticeConfigRepository;
|
_trialEmailNoticeConfigRepository = trialEmailNoticeConfigRepository;
|
||||||
|
_visitTaskRepository = visitTaskRepository;
|
||||||
|
_trialUserRepository = trialUserRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,22 +91,22 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
var sendEmailConfig = new SMTPEmailConfig();
|
var sendEmailConfig = new SMTPEmailConfig();
|
||||||
|
|
||||||
foreach (var item in emailConfig.ReceiveEmailList)
|
//foreach (var item in emailConfig.ReceiveEmailList)
|
||||||
{
|
//{
|
||||||
sendEmailConfig.ToMailAddressList.Add(new MimeKit.MailboxAddress(item, item));
|
// sendEmailConfig.ToMailAddressList.Add(new MimeKit.MailboxAddress(item, item));
|
||||||
}
|
//}
|
||||||
|
|
||||||
foreach (var item in emailConfig.CopyEmailList)
|
//foreach (var item in emailConfig.CopyEmailList)
|
||||||
{
|
//{
|
||||||
if (item.Contains("@") && !string.IsNullOrEmpty(item))
|
// if (item.Contains("@") && !string.IsNullOrEmpty(item))
|
||||||
{
|
// {
|
||||||
sendEmailConfig.CopyToMailAddressList.Add(new MimeKit.MailboxAddress(item.Trim(), item.Trim()));
|
// sendEmailConfig.CopyToMailAddressList.Add(new MimeKit.MailboxAddress(item.Trim(), item.Trim()));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
//邮件内容html
|
//邮件内容html
|
||||||
await FillWordTemplateAndSetEmailAsync(sendEmailConfig, businessScenarioEnum, criterionTypeEnum!);
|
await FillWordTemplateAndSetEmailAsync(visitTaskId, sendEmailConfig, businessScenarioEnum, criterionTypeEnum!);
|
||||||
|
|
||||||
//邮件附件
|
//邮件附件
|
||||||
var path = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, emailConfig.FilePath);
|
var path = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, emailConfig.FilePath);
|
||||||
|
@ -126,7 +131,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async Task FillWordTemplateAndSetEmailAsync(SMTPEmailConfig sendEmailConfig, CommonDocumentBusinessScenario businessScenarioEnum, CriterionType criterionType)
|
private async Task FillWordTemplateAndSetEmailAsync(Guid visitTaskId, SMTPEmailConfig sendEmailConfig, CommonDocumentBusinessScenario businessScenarioEnum, CriterionType criterionType)
|
||||||
{
|
{
|
||||||
var pathToFile = _hostEnvironment.WebRootPath
|
var pathToFile = _hostEnvironment.WebRootPath
|
||||||
+ Path.DirectorySeparatorChar.ToString()
|
+ Path.DirectorySeparatorChar.ToString()
|
||||||
|
@ -157,6 +162,10 @@ namespace IRaCIS.Core.Application.Service
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CriterionType.RECIST1Pointt1:
|
case CriterionType.RECIST1Pointt1:
|
||||||
|
|
||||||
|
|
||||||
|
//_visitTaskRepository.Where(t => t.Id == visitTaskId).Select(t => new { t.Trial.ResearchProgramNo, t.Subject.TrialSite.TrialSiteCode, SubjectCode = t.Subject.Code, VisitEarliestScanDate = t.SourceSubjectVisit.EarliestScanDate, t.sou })
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CriterionType.PCWG3:
|
case CriterionType.PCWG3:
|
||||||
|
@ -220,6 +229,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
case CriterionType.SelfDefine:
|
case CriterionType.SelfDefine:
|
||||||
break;
|
break;
|
||||||
case CriterionType.RECIST1Pointt1:
|
case CriterionType.RECIST1Pointt1:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CriterionType.PCWG3:
|
case CriterionType.PCWG3:
|
||||||
break;
|
break;
|
||||||
|
@ -258,6 +268,8 @@ namespace IRaCIS.Core.Application.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<List<TrialEmailNoticeConfigView>> GetTrialEmailNoticeConfigList(TrialEmailNoticeConfigQuery inQuery)
|
public async Task<List<TrialEmailNoticeConfigView>> GetTrialEmailNoticeConfigList(TrialEmailNoticeConfigQuery inQuery)
|
||||||
{
|
{
|
||||||
|
@ -276,12 +288,57 @@ namespace IRaCIS.Core.Application.Service
|
||||||
public async Task<IResponseOutput> AddOrUpdateTrialEmailNoticeConfig(TrialEmailNoticeConfigAddOrEdit addOrEditTrialEmailNoticeConfig)
|
public async Task<IResponseOutput> AddOrUpdateTrialEmailNoticeConfig(TrialEmailNoticeConfigAddOrEdit addOrEditTrialEmailNoticeConfig)
|
||||||
{
|
{
|
||||||
|
|
||||||
addOrEditTrialEmailNoticeConfig.ReceiveEmailsStr = String.Join('|', addOrEditTrialEmailNoticeConfig.ReceiveEmailList);
|
List<TrialEmailNoticeUser> trialEmailNoticeUsers = new List<TrialEmailNoticeUser>();
|
||||||
addOrEditTrialEmailNoticeConfig.CopyEmailsStr = String.Join('|', addOrEditTrialEmailNoticeConfig.CopyEmailList);
|
|
||||||
|
|
||||||
var entity = await _trialEmailNoticeConfigRepository.InsertOrUpdateAsync(addOrEditTrialEmailNoticeConfig, true);
|
|
||||||
|
|
||||||
return ResponseOutput.Ok(entity.Id.ToString());
|
|
||||||
|
trialEmailNoticeUsers.Add(new TrialEmailNoticeUser() { EmailUserType = EmailUserType.From, UserId = addOrEditTrialEmailNoticeConfig.FromUserId });
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var item in addOrEditTrialEmailNoticeConfig.ToUserIdList)
|
||||||
|
{
|
||||||
|
trialEmailNoticeUsers.Add(new TrialEmailNoticeUser() { EmailUserType = EmailUserType.To, UserId = item });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in addOrEditTrialEmailNoticeConfig.CopyUserIdList)
|
||||||
|
{
|
||||||
|
trialEmailNoticeUsers.Add(new TrialEmailNoticeUser() { EmailUserType = EmailUserType.Copy, UserId = item });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//var entity = await _trialEmailNoticeConfigRepository.InsertOrUpdateAsync(addOrEditTrialEmailNoticeConfig);
|
||||||
|
|
||||||
|
if (addOrEditTrialEmailNoticeConfig.Id == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
var entity = _mapper.Map<TrialEmailNoticeConfig>(addOrEditTrialEmailNoticeConfig);
|
||||||
|
|
||||||
|
|
||||||
|
entity.TrialEmailNoticeUserList = trialEmailNoticeUsers;
|
||||||
|
|
||||||
|
|
||||||
|
await _trialEmailNoticeConfigRepository.AddAsync(entity, true);
|
||||||
|
|
||||||
|
return ResponseOutput.Ok(entity.Id.ToString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _repository.BatchDeleteAsync<TrialEmailNoticeUser>(t => t.TrialEmailNoticeConfigId == addOrEditTrialEmailNoticeConfig.Id);
|
||||||
|
|
||||||
|
|
||||||
|
var entity = (await _trialEmailNoticeConfigRepository.Where(t => t.Id == addOrEditTrialEmailNoticeConfig.Id, true, true).Include(t => t.TrialEmailNoticeUserList).FirstOrDefaultAsync()).IfNullThrowException();
|
||||||
|
|
||||||
|
await _repository.AddRangeAsync(trialEmailNoticeUsers);
|
||||||
|
|
||||||
|
await _trialEmailNoticeConfigRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
return ResponseOutput.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,17 @@ namespace IRaCIS.Core.Application.Service
|
||||||
.ForMember(d => d.SystemDocumentId, c => c.Ignore());
|
.ForMember(d => d.SystemDocumentId, c => c.Ignore());
|
||||||
|
|
||||||
|
|
||||||
CreateMap<TrialEmailNoticeConfig, TrialEmailNoticeConfigView>();
|
CreateMap<TrialEmailNoticeConfig, TrialEmailNoticeConfigView>()
|
||||||
|
.ForMember(d => d.TrialEmailNoticeUserList, c => c.MapFrom(t => t.TrialEmailNoticeUserList));
|
||||||
|
|
||||||
CreateMap<TrialEmailNoticeConfigAddOrEdit, TrialEmailNoticeConfig>();
|
CreateMap<TrialEmailNoticeConfigAddOrEdit, TrialEmailNoticeConfig>();
|
||||||
|
|
||||||
|
|
||||||
|
CreateMap<TrialEmailNoticeUser, EmailUserInfoDto>()
|
||||||
|
.ForMember(d => d.Email, c => c.MapFrom(t => t.User.EMail))
|
||||||
|
.ForMember(d => d.RealName, c => c.MapFrom(t => t.User.FullName))
|
||||||
|
.ForMember(d => d.UserName, c => c.MapFrom(t => t.User.UserName));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,15 @@ namespace IRaCIS.Core.Domain.Share
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum EmailUserType
|
||||||
|
{
|
||||||
|
From =1,
|
||||||
|
|
||||||
|
To=2,
|
||||||
|
|
||||||
|
Copy=3
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public enum BasicDataTypeEnum
|
public enum BasicDataTypeEnum
|
||||||
|
|
|
@ -215,6 +215,11 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
|
||||||
|
public Trial Trial { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<ReadingTaskQuestionAnswer> ReadingTaskQuestionAnswerList { get; set; } = new List<ReadingTaskQuestionAnswer>();
|
public List<ReadingTaskQuestionAnswer> ReadingTaskQuestionAnswerList { get; set; } = new List<ReadingTaskQuestionAnswer>();
|
||||||
|
|
||||||
|
|
|
@ -26,15 +26,22 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
public string AuthorizationCode { get; set; } = string.Empty;
|
public string AuthorizationCode { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
public string ReceiveEmailsStr { get; set; } = string.Empty;
|
|
||||||
public string CopyEmailsStr { get; set; } = string.Empty;
|
public List<TrialEmailNoticeUser> TrialEmailNoticeUserList { get; set; } = new List<TrialEmailNoticeUser>();
|
||||||
|
|
||||||
|
|
||||||
[NotMapped]
|
//[Required]
|
||||||
public List<string> ReceiveEmailList => ReceiveEmailsStr.Split('|', StringSplitOptions.RemoveEmptyEntries).Where(t => !string.IsNullOrEmpty(t)).Select(t=>t.Trim()).ToList();
|
//public string FromEmail { get; set; }
|
||||||
|
//public string ReceiveEmailsStr { get; set; } = string.Empty;
|
||||||
|
//public string CopyEmailsStr { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
//[NotMapped]
|
||||||
|
//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).Where(t=> !string.IsNullOrEmpty(t)).Select(t => t.Trim()).ToList();
|
||||||
|
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public List<string> CopyEmailList => CopyEmailsStr.Split('|', StringSplitOptions.RemoveEmptyEntries).Where(t=> !string.IsNullOrEmpty(t)).Select(t => t.Trim()).ToList();
|
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public bool IsUrgent { get; set; }
|
public bool IsUrgent { get; set; }
|
||||||
|
@ -48,8 +55,7 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
[Required]
|
[Required]
|
||||||
public bool IsReturnRequired { get; set; }
|
public bool IsReturnRequired { get; set; }
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string FromEmail { get; set; }
|
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public bool IsAutoSend { get; set; }
|
public bool IsAutoSend { get; set; }
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// 此代码由T4模板自动生成 byzhouhang 20210918
|
||||||
|
// 生成时间 2022-10-21 16:06:20
|
||||||
|
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||||
|
using System;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
namespace IRaCIS.Core.Domain.Models
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
///TrialEmailNoticeUser
|
||||||
|
///</summary>
|
||||||
|
[Table("TrialEmailNoticeUser")]
|
||||||
|
public class TrialEmailNoticeUser : Entity
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public User User { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public TrialEmailNoticeConfig TrialEmailNoticeConfig { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public Guid TrialEmailNoticeConfigId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public EmailUserType EmailUserType { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -665,6 +665,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
|
|
||||||
public virtual DbSet<TrialEmailNoticeConfig> TrialEmailNoticeConfig { get; set; }
|
public virtual DbSet<TrialEmailNoticeConfig> TrialEmailNoticeConfig { get; set; }
|
||||||
|
|
||||||
|
public virtual DbSet<TrialEmailNoticeUser> TrialEmailNoticeUser { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
public static readonly string ConnectionString = "Server=123.56.94.154,1433\\MSSQLSERVER;Database=IRaCIS_New_Tet;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true";
|
public static readonly string ConnectionString = "Server=123.56.94.154,1433\\MSSQLSERVER;Database=IRaCIS_New_Tet;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true";
|
||||||
public static readonly string DbDatabase = "IRaCIS_New_Tet";
|
public static readonly string DbDatabase = "IRaCIS_New_Tet";
|
||||||
//表名称用字符串,拼接
|
//表名称用字符串,拼接
|
||||||
public static readonly string TableName = "TrialEmailNoticeConfig";
|
public static readonly string TableName = "TrialEmailNoticeUser";
|
||||||
//具体文件里面 例如service 可以配置是否分页
|
//具体文件里面 例如service 可以配置是否分页
|
||||||
}
|
}
|
||||||
#>
|
#>
|
||||||
|
|
Loading…
Reference in New Issue