diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 8450b3e8c..65eab2306 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -378,6 +378,12 @@ + + + 驳回 New + + + 驳回 @@ -393,6 +399,12 @@ + + + 项目Site调研用户列表 所有site的调研用户 会有重复 + + + TrialSiteUserSurveyService diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs index 62e71f2ce..278f99a95 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs @@ -22,7 +22,7 @@ namespace IRaCIS.Core.Application.Contracts public string TrialCode { get; set; } = string.Empty; - public Guid IndicationTypeId { get; set; } + public Guid IndicationTypeId { get; set; } public string IndicationType { get; set; } = string.Empty; @@ -30,13 +30,13 @@ namespace IRaCIS.Core.Application.Contracts public string TrialSiteSurveyEquipmentType { get; set; } = string.Empty; - public List TrialSiteSelectList { get; set; }=new List(); + public List TrialSiteSelectList { get; set; } = new List(); } public class TrialSiteForSelect { - public Guid Id { get; set; } + public Guid Id { get; set; } public Guid TrialId { get; set; } public Guid SiteId { get; set; } @@ -57,6 +57,26 @@ namespace IRaCIS.Core.Application.Contracts public List TrialSiteUserSurveyList { get; set; } = new List(); } + public class TrialSiteUserSurveyAllDTO : TrialSiteUserSurveyView + { + public TrialSiteSurveyView TrialSiteSurvey { get; set; } + } + + public class TrialSiteUserSurveyAllQuery : PageInput + { + [NotDefault] + public Guid TrialId { get; set; } + public Guid? SiteId { get; set; } + + + + public string FormWriterKeyInfo { get; set; } = string.Empty; + + public string UserKeyInfo { get; set; } = string.Empty; + + + } + /// TrialSiteSurveyView 列表视图模型 public class TrialSiteSurveyView @@ -86,7 +106,20 @@ namespace IRaCIS.Core.Application.Contracts public TrialSiteSurveyEnum State { get; set; } - public string LatestBackReason { get; set; } = string.Empty; + public string LatestBackReason { get; set; } = string.Empty; + + public UserInfoBasic ReviewerUser { get; set; } + public UserInfoBasic PreliminaryUser { get; set; } + + public Guid? PreliminaryUserId { get; set; } + + public Guid? ReviewerUserId { get; set; } + + + public DateTime? PreliminaryTime { get; set; } + + public DateTime? ReviewerTime { get; set; } + @@ -121,7 +154,7 @@ namespace IRaCIS.Core.Application.Contracts public class SiteSurveySendVerifyCode { public VerifyType verificationType { get; set; } - public string EmailOrPhone { get; set; } = string.Empty; + public string EmailOrPhone { get; set; } = string.Empty; } @@ -163,12 +196,25 @@ namespace IRaCIS.Core.Application.Contracts } - public class TrialSiteSurvyeSubmitDTO + + public class TrialSiteSubmitBackCommand { [NotDefault] - public Guid TrialId { get; set; } + public Guid TrialId { get; set; } [NotDefault] - public Guid TrialSiteSurveyId { get; set; } + public Guid TrialSiteSurveyId { get; set; } + + public string LatestBackReason { get; set; } + + public string RouteUrl { get; set; } + } + + public class TrialSiteSurvyeSubmitDTO + { + [NotDefault] + public Guid TrialId { get; set; } + [NotDefault] + public Guid TrialSiteSurveyId { get; set; } public string? LoginUrl { get; set; } @@ -186,7 +232,7 @@ namespace IRaCIS.Core.Application.Contracts public class CopyTrialSiteSurveyDTO { - public Guid TrialSiteSurveyId { get; set; } + public Guid TrialSiteSurveyId { get; set; } public string UserName { get; set; } = string.Empty; public string Phone { get; set; } = string.Empty; public string Email { get; set; } = string.Empty; diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs index d8476e64e..5106d1e72 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs @@ -50,8 +50,7 @@ namespace IRaCIS.Core.Application.Contracts public Guid? SystemUserId { get; set; } - public UserInfoBasic ReviewerUser { get; set; } - public UserInfoBasic PreliminaryUser { get; set; } + } @@ -92,7 +91,6 @@ namespace IRaCIS.Core.Application.Contracts public string LastName { get; set; } = string.Empty; public string Phone { get; set; } = string.Empty; public string Email { get; set; } = string.Empty; - public bool IsCorrect { get; set; } public bool IsGenerateAccount { get; set; } public string OrganizationName { get; set; } = string.Empty; diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 8b2ba63b7..bb9e46fc7 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -27,12 +27,14 @@ namespace IRaCIS.Core.Application.Contracts private readonly IRepository _trialSiteSurveyRepository; private readonly IRepository _trialSiteUserSurveyRepository; private readonly IRepository _userRepository; + private readonly IRepository _trialSiteRepository; - public TrialSiteSurveyService(IRepository trialSiteSurveyRepository,IRepository trialSiteUserSurveyRepository,IRepository userRepository) + public TrialSiteSurveyService(IRepository trialSiteSurveyRepository, IRepository trialSiteUserSurveyRepository, IRepository userRepository,IRepository trialSiteRepository) { _trialSiteSurveyRepository = trialSiteSurveyRepository; _trialSiteUserSurveyRepository = trialSiteUserSurveyRepository; _userRepository = userRepository; + _trialSiteRepository = trialSiteRepository; } private object lockObj { get; set; } = new object(); @@ -344,7 +346,6 @@ namespace IRaCIS.Core.Application.Contracts public async Task DeleteTrialSiteSurvey(Guid trialSiteSurveyId) { - if (await _trialSiteSurveyRepository.AnyAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.PMCreatedAndLock)) { return ResponseOutput.NotOk("已锁定,不允许操作"); @@ -376,27 +377,7 @@ namespace IRaCIS.Core.Application.Contracts return await trialSiteSurveyQueryable.ToListAsync(); } - //[HttpPut("{trialId:guid}/{isReplaceUser:bool}")] - //public async Task CopyTrialSurveyInitInfo(CopyTrialSiteSurveyDTO copyDto, bool isReplaceUser) - //{ - // var survey = await _repository.Where(t => t.Id == copyDto.TrialSiteSurveyId).FirstOrDefaultAsync(); - // if (survey == null) return Null404NotFound(survey); - - // survey.Id = Guid.Empty; - // if (isReplaceUser) - // { - // survey.UserName = copyDto.UserName; - // survey.Email = copyDto.Email; - // survey.Phone = copyDto.Phone; - // } - // else - // { - - // } - - // return ResponseOutput.Ok(); - //} @@ -415,6 +396,146 @@ namespace IRaCIS.Core.Application.Contracts } + /// + /// 驳回 New + /// + /// + public async Task SubmissionRejection(TrialSiteSubmitBackCommand trialSiteSubmitBackCommand) + { + var trialSiteSurveyId = trialSiteSubmitBackCommand.TrialSiteSurveyId; + + var survey = await _trialSiteSurveyRepository.FirstOrDefaultAsync(t => t.Id == trialSiteSurveyId); + + survey.LatestBackReason = trialSiteSubmitBackCommand.LatestBackReason; + + User user = null; + + var messageToSend = new MimeMessage(); + //发件地址 + messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com")); + + //主题 + messageToSend.Subject = "GRR Site survey ( Rejection )"; + + + if (await _repository.AnyAsync(t => t.State == TrialSiteSurveyEnum.PMCreatedAndLock && t.Id == trialSiteSurveyId)) + { + return ResponseOutput.NotOk("已锁定,不允许操作"); + } + + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) + { + + //SPM 给填表人发 + messageToSend.To.Add(new MailboxAddress(String.Empty, survey.Email)); + + survey.State = TrialSiteSurveyEnum.ToSubmit; + } + else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM) + { + var hasSPMOrCPM = await _trialSiteSurveyRepository.AnyAsync(t => t.TrialId == trialSiteSubmitBackCommand.TrialId && t.Trial.TrialUserList.Any(u => u.User.UserTypeEnum == UserTypeEnum.SPM || u.User.UserTypeEnum == UserTypeEnum.CPM)); + + if (hasSPMOrCPM) + { + + //PM 给SPM发 (初审人) + user = await _userRepository.FirstOrDefaultAsync(t => t.Id == survey.PreliminaryUserId); + + messageToSend.To.Add(new MailboxAddress(String.Empty, survey.PreliminaryUserId==null? survey.Email: user.EMail)); + + survey.State = TrialSiteSurveyEnum.CRCSubmitted; + + survey.ReviewerUserId = null; + survey.ReviewerTime = null; + } + else + { + //没有SPM 给填表人发 + messageToSend.To.Add(new MailboxAddress(String.Empty, survey.Email)); + + survey.State = TrialSiteSurveyEnum.ToSubmit; + + survey.PreliminaryUserId = null; + survey.ReviewerUserId = null; + survey.PreliminaryTime = null; + survey.ReviewerTime = null; + + + } + } + + + var builder = new BodyBuilder(); + + var trialInfo = await _repository.FirstOrDefaultAsync(t => t.Id == trialSiteSubmitBackCommand.TrialId); + + var siteInfo = await _trialSiteRepository.FirstOrDefaultAsync(t => t.TrialId == trialSiteSubmitBackCommand.TrialId&& t.SiteId== survey.SiteId,true); + + builder.HtmlBody = @$" +
+
+
+ { (user==null? survey.UserName: user.LastName + "/ " + user.FirstName)}: +
+
+ 您好, 您填写的中心调研表被驳回,详细信息如下: +
+
+
+ 项目编号: {trialInfo.TrialCode} +
+
+ 试验方案号: {trialInfo.ResearchProgramNo} +
+
+ 试验名称: {trialInfo.ExperimentName} +
+
+ 中心编号: {siteInfo.TrialSiteCode} +
+
+ 中心名称: {siteInfo.TrialSiteAliasName} +
+
+ 驳回原因: {survey.LatestBackReason} +
+ +
+
+
+ "; + + messageToSend.Body = builder.ToMessageBody(); + + using (var smtp = new MailKit.Net.Smtp.SmtpClient()) + { + + smtp.ServerCertificateValidationCallback = (s, c, h, e) => true; + + + await smtp.ConnectAsync("smtp.163.com", 25, SecureSocketOptions.StartTls); + + + await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH"); + + + await smtp.SendAsync(messageToSend); + + + await smtp.DisconnectAsync(true); + } + + await _trialSiteSurveyRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(); + } + + /// /// 驳回 @@ -423,6 +544,7 @@ namespace IRaCIS.Core.Application.Contracts /// /// [HttpPut("{trialId:guid}/{trialSiteSurveyId:guid}")] + [Obsolete] public async Task SubmissionRejection(Guid trialId, Guid trialSiteSurveyId) { if (await _repository.AnyAsync(t => t.State == TrialSiteSurveyEnum.PMCreatedAndLock && t.Id == trialSiteSurveyId)) @@ -479,10 +601,10 @@ namespace IRaCIS.Core.Application.Contracts /// //[TypeFilter(typeof(TrialResourceFilter))] [HttpPost] - public async Task TrialSurveySubmit(TrialSiteSurvyeSubmitDTO siteSurvyeSubmit) + public async Task TrialSurveySubmit(TrialSiteSurvyeSubmitDTO siteSurvyeSubmit) { - var trialId= siteSurvyeSubmit.TrialId; + var trialId = siteSurvyeSubmit.TrialId; var trialSiteSurveyId = siteSurvyeSubmit.TrialSiteSurveyId; if (_userInfo.IsAdmin) @@ -493,11 +615,11 @@ namespace IRaCIS.Core.Application.Contracts if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined) { - var hasSPMOrCPM = await _trialSiteSurveyRepository.AnyAsync(t => t.TrialId == trialId && t.Trial.TrialUserList.Any(u => u.User.UserTypeEnum == UserTypeEnum.SPM || u.User.UserTypeEnum == UserTypeEnum.CPM)); + var hasSPMOrCPM = await _trialSiteSurveyRepository.AnyAsync(t => t.TrialId == trialId && t.Trial.TrialUserList.Any(u => u.User.UserTypeEnum == UserTypeEnum.SPM || u.User.UserTypeEnum == UserTypeEnum.CPM)); if (hasSPMOrCPM) { - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); + await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); } else @@ -509,8 +631,8 @@ namespace IRaCIS.Core.Application.Contracts } else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) { - - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.CRCSubmitted, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved }); + + await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.CRCSubmitted, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved, PreliminaryUserId = _userInfo.Id,PreliminaryTime=DateTime.Now }); } else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) @@ -519,13 +641,13 @@ namespace IRaCIS.Core.Application.Contracts var trialSiteSurvey = _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId).FirstOrDefault(); if (trialSiteSurvey == null) return Null404NotFound(trialSiteSurvey); - + //已生成的不管 管的只需要是 生成失败的并且需要生成账号的 var needGenerateList = _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId && t.IsGenerateAccount && t.IsGenerateSuccess == false).ToList(); - var trialInfo = await _repository.FirstOrDefaultAsync(t => t.Id == trialId); + var trialInfo = await _repository.FirstOrDefaultAsync(t => t.Id == trialId); foreach (var item in needGenerateList) { @@ -541,14 +663,14 @@ namespace IRaCIS.Core.Application.Contracts var builder = new BodyBuilder(); //找下系统中是否存在该用户类型的 并且邮箱 或者手机的账户 - var sysUserInfo = await _userRepository.Where(t => t.UserTypeId == item.UserTypeId && t.EMail == item.Email ).Include(t=>t.UserTypeRole).FirstOrDefaultAsync(); + var sysUserInfo = await _userRepository.Where(t => t.UserTypeId == item.UserTypeId && t.EMail == item.Email).Include(t => t.UserTypeRole).FirstOrDefaultAsync(); //int verificationCode = new Random().Next(100000, 1000000); //var baseApiUrl = baseUrl.Remove(baseUrl.IndexOf("#")) + "api"; - if (sysUserInfo==null) + if (sysUserInfo == null) { lock (lockObj) @@ -592,7 +714,7 @@ namespace IRaCIS.Core.Application.Contracts 您好,展影医疗作为 实验方案号:{trialInfo.ResearchProgramNo} 项目的IRC供应商,诚邀您参加该项目IRC相关工作,欢迎您提供指导和建议,非常感谢! - + 查看并确认 @@ -649,7 +771,7 @@ namespace IRaCIS.Core.Application.Contracts smtp.MessageSent += (sender, args) => { - _= _trialSiteUserSurveyRepository.UpdateFromQueryAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, SystemUserId = sysUserInfo.Id , ExpireTime = DateTime.Now.AddDays(7) }).Result; + _ = _trialSiteUserSurveyRepository.UpdateFromQueryAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, SystemUserId = sysUserInfo.Id, ExpireTime = DateTime.Now.AddDays(7) }).Result; }; @@ -663,12 +785,12 @@ namespace IRaCIS.Core.Application.Contracts await smtp.SendAsync(messageToSend); - await smtp.DisconnectAsync(true); + await smtp.DisconnectAsync(true); } } - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock }); + await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime=DateTime.Now}); } @@ -676,6 +798,23 @@ namespace IRaCIS.Core.Application.Contracts } + /// + /// 项目Site调研用户列表 所有site的调研用户 会有重复 + /// + /// + public async Task> TrialSiteSurveyUserList(TrialSiteUserSurveyAllQuery queryParam) + { + var query = _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurvey.TrialId == queryParam.TrialId&&t.TrialSiteSurvey.IsAbandon==false) + .WhereIf(queryParam.SiteId!=null, t => t.TrialSiteSurvey.SiteId == queryParam.SiteId) + .WhereIf(! string.IsNullOrEmpty(queryParam.UserKeyInfo ), t => (t.LastName + " / " + t.FirstName).Contains(queryParam.UserKeyInfo)||t.Email.Contains(queryParam.UserKeyInfo) ||t.Phone.Contains(queryParam.UserKeyInfo)) + .WhereIf(!string.IsNullOrEmpty(queryParam.FormWriterKeyInfo), t => (t.TrialSiteSurvey.UserName).Contains(queryParam.FormWriterKeyInfo) || t.TrialSiteSurvey.Email.Contains(queryParam.FormWriterKeyInfo) || t.TrialSiteSurvey.Phone.Contains(queryParam.FormWriterKeyInfo)) + + .ProjectTo(_mapper.ConfigurationProvider); + + return await query.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, queryParam.SortField, queryParam.Asc); + } + + } } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs b/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs index 173d7b915..18baa2f37 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/_MapConfig.cs @@ -58,7 +58,13 @@ namespace IRaCIS.Core.Application.AutoMapper CreateMap().ForMember(d => d.RealName, u => u.MapFrom(s => s.LastName + " / " + s.FirstName)); - + + + + CreateMap().ForMember(t=>t.TrialSiteSurvey,u=>u.MapFrom(c=>c.TrialSiteSurvey)); + + + } } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs index 5f65baaf9..ffebce3a8 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialExternalUserViewModel.cs @@ -26,9 +26,6 @@ namespace IRaCIS.Core.Application.ViewModel public Guid SystemUserId { get; set; } - - - [JsonIgnore] public TrialExternalUserStateEnum InviteState { get; set; } @@ -86,6 +83,13 @@ namespace IRaCIS.Core.Application.ViewModel public string OrganizationName { get; set; } = String.Empty; + + public bool IsSendEmail { get; set; } + + + public string RouteUrl { get; set; } = string.Empty; + + } public class TrialExternalUserConfirm { @@ -133,8 +137,6 @@ namespace IRaCIS.Core.Application.ViewModel [NotDefault] public Guid TrialId { get; set; } - public string BaseUrl { get; set; } = string.Empty; - public string RouteUrl { get; set; } = string.Empty; public List SendUsers { get; set; } = new List(); @@ -161,7 +163,6 @@ namespace IRaCIS.Core.Application.ViewModel public string Email { get; set; } = string.Empty; - public string Phone { get; set; } = string.Empty; public string FirstName { get; set; } = string.Empty; diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs index f8c960a67..b42a37f27 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs @@ -20,6 +20,8 @@ namespace IRaCIS.Application.Contracts public string UserType { get; set; } = String.Empty; public string UserRealName { get; set; } = String.Empty; + public string OrganizationName { get; set; } = String.Empty; + } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index 339a12a5e..96d968371 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -64,12 +64,6 @@ namespace IRaCIS.Core.Application.Service public async Task AddOrUpdateTrialExternalUser(TrialExternalUserAddOrEdit addOrEditTrialExternalUser) { - //var verifyExp1 = new EntityVerifyExp() - //{ - // VerifyExp = t => t.Email == addOrEditTrialExternalUser.Email && t.UserTypeId == addOrEditTrialExternalUser.UserTypeId, - // VerifyMsg = "" - //}; - //var entity = await _trialExternalUseRepository.InsertOrUpdateAsync(addOrEditTrialExternalUser, false, verifyExp1); if (addOrEditTrialExternalUser.Id == null) @@ -136,6 +130,27 @@ namespace IRaCIS.Core.Application.Service } + + if (addOrEditTrialExternalUser.IsSendEmail) + { + await SendInviteEmail(new TrialExternalUserSendEmail() + { + //BaseUrl = addOrEditTrialExternalUser.BaseUrl, + RouteUrl = addOrEditTrialExternalUser.RouteUrl, + TrialId = addOrEditTrialExternalUser.TrialId, + SendUsers = new List() + { + new UserEmail() + { + Id = addEntity.Id, + Email=addEntity.Email, + IsSystemUser=addEntity.IsSystemUser, + SystemUserId=addEntity.SystemUserId + } + } + }); + } + await _trialExternalUseRepository.SaveChangesAsync(); return ResponseOutput.Ok(addEntity.Id.ToString()); @@ -213,7 +228,7 @@ namespace IRaCIS.Core.Application.Service //主题 messageToSend.Subject = "GRR External User survey (Invite)"; - var baseApiUrl = sendEmail.BaseUrl.Remove(sendEmail.BaseUrl.IndexOf("#")) + "api"; + //var baseApiUrl = sendEmail.BaseUrl.Remove(sendEmail.BaseUrl.IndexOf("#")) + "api"; var builder = new BodyBuilder(); @@ -323,14 +338,16 @@ namespace IRaCIS.Core.Application.Service u => new User() { Password = MD5Helper.Md5(verificationCode.ToString()) }); } - builder.HtmlBody = @$" + if (editTrialUserPreparation.IsJoin == true) + { + builder.HtmlBody = @$"
{sysUserInfo.LastName + "/" + sysUserInfo.FirstName}:
-
- 您好,欢迎您参加项目 实验方案号: {trialInfo.ResearchProgramNo} IRC相关工作。该项目采用电子化工作流,系统及您的账号信息如下: +
+ 您好,欢迎您参加项目 实验方案号:{trialInfo.ResearchProgramNo}IRC相关工作。该项目采用电子化工作流,系统及您的账号信息如下:
@@ -359,6 +376,43 @@ namespace IRaCIS.Core.Application.Service
"; + } + + else + { + builder.HtmlBody = @$" +
+
+
+ {sysUserInfo.LastName + "/" + sysUserInfo.FirstName}: +
+
+ 您好,您拒绝了参加 {trialInfo.ResearchProgramNo} 项目IRC相关工作的邀请。详细信息如下: +
+
+
+ 项目编号: {trialInfo.TrialCode} +
+
+ 试验方案号: {trialInfo.ResearchProgramNo} +
+
+ 试验名称: {trialInfo.ExperimentName} +
+
+ 用户名: {sysUserInfo.UserName} +
+
+ 角色: {sysUserInfo.UserTypeRole.UserTypeShortName} +
+
+
+
+ "; + } + + + messageToSend.Body = builder.ToMessageBody(); @@ -418,7 +472,7 @@ namespace IRaCIS.Core.Application.Service var userId = (Guid)needUpdate.SystemUserId; - if (! await _trialUserRepository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId)) + if (!await _trialUserRepository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId)) { await _trialUserRepository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId }); @@ -447,7 +501,9 @@ namespace IRaCIS.Core.Application.Service u => new User() { Password = MD5Helper.Md5(verificationCode.ToString()) }); } - builder.HtmlBody = @$" + if (editInfo.IsJoin == true) + { + builder.HtmlBody = @$"
@@ -483,6 +539,42 @@ namespace IRaCIS.Core.Application.Service
"; + } + else + { + + builder.HtmlBody = @$" +
+
+
+ {sysUserInfo.LastName + "/" + sysUserInfo.FirstName}: +
+
+ 您好,您拒绝了参加 {trialInfo.ResearchProgramNo} 项目IRC相关工作的邀请。详细信息如下: +
+
+
+ 项目编号: {trialInfo.TrialCode} +
+
+ 试验方案号: {trialInfo.ResearchProgramNo} +
+
+ 试验名称: {trialInfo.ExperimentName} +
+
+ 用户名: {sysUserInfo.UserName} +
+
+ 角色: {sysUserInfo.UserTypeRole.UserTypeShortName} +
+
+
+
+ "; + + } + messageToSend.Body = builder.ToMessageBody(); diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs index 0dff11de3..17c65816f 100644 --- a/IRaCIS.Core.Domain/Management/User.cs +++ b/IRaCIS.Core.Domain/Management/User.cs @@ -20,14 +20,14 @@ namespace IRaCIS.Core.Domain.Models [StringLength(255)] - public string UserName { get; set; } + public string UserName { get; set; } = String.Empty; [StringLength(255)] - public string Password { get; set; } + public string Password { get; set; } = String.Empty; [StringLength(255)] - public string LastName { get; set; } - public string FirstName { get; set; } + public string LastName { get; set; } = String.Empty; + public string FirstName { get; set; } = String.Empty; public string Phone { get; set; } = string.Empty; public string EMail { get; set; } = string.Empty; diff --git a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteSurvey.cs b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteSurvey.cs index 8130e0648..b8d66a39b 100644 --- a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteSurvey.cs +++ b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteSurvey.cs @@ -128,6 +128,20 @@ namespace IRaCIS.Core.Domain.Models public string LatestBackReason { get; set; } = string.Empty; + + public Guid? PreliminaryUserId { get; set; } + + public Guid? ReviewerUserId { get; set; } + + public DateTime? PreliminaryTime { get; set; } + + public DateTime? ReviewerTime { get; set; } + + public User ReviewerUser { get; set; } + + public User PreliminaryUser { get; set; } + + } } diff --git a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs index f083de668..bba98c9e0 100644 --- a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs +++ b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs @@ -106,13 +106,7 @@ namespace IRaCIS.Core.Domain.Models public TrialSiteUserStateEnum InviteState { get; set; } = TrialSiteUserStateEnum.WaitSent; - public Guid? PreliminaryUserId { get; set; } - - public Guid? ReviewerUserId { get; set; } - - public User ReviewerUser { get; set; } - - public User PreliminaryUser { get; set; } + }