diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 8d57b1160..6a130b053 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -30,7 +30,7 @@ namespace IRaCIS.Core.Application.Service Task AdminResetPwdSendEmailAsync(Guid userId, string pwdNotMd5 = "123456"); - Task SiteSurveyUserJoinEmail(Guid trialId, Guid userId, string baseUrl, string rootUrl); + Task SiteSurveyUserJoinEmail(Guid trialId, Guid userId, string userTypes, string baseUrl, string rootUrl); Task ExternalUserJoinEmail(Guid trialId, Guid userId, string userTypes, string baseUrl, string rootUrl); @@ -301,8 +301,8 @@ namespace IRaCIS.Core.Application.Service var htmlBodyStr = string.Format(ReplaceCompanyName(input.htmlBodyStr), sysUserInfo.FullName, - sysUserInfo.UserName, - string.Join(',', sysUserInfo.UserRoleList.Select(t => t.UserTypeRole.UserTypeShortName)), + sysUserInfo.EMail, + //string.Join(',', sysUserInfo.UserRoleList.Select(t => t.UserTypeRole.UserTypeShortName)), redirectUrl ); @@ -339,7 +339,7 @@ namespace IRaCIS.Core.Application.Service sysUserInfo.FullName, sysUserInfo.UserName, - string.Join(',', sysUserInfo.UserRoleList.Select(t => t.UserTypeRole.UserTypeShortName)), + //string.Join(',', sysUserInfo.UserRoleList.Select(t => t.UserTypeRole.UserTypeShortName)), pwdNotMd5 ); @@ -470,7 +470,7 @@ namespace IRaCIS.Core.Application.Service trialInfo.ExperimentName, trialInfo.ResearchProgramNo, trialInfo.TrialCode, - sysUserInfo.UserName, + sysUserInfo.EMail, userTypes, sysUserInfo.IsFirstAdd ? redirectUrl : baseUrl ); @@ -487,12 +487,11 @@ namespace IRaCIS.Core.Application.Service } //Site调研 用户加入项目 - public async Task SiteSurveyUserJoinEmail(Guid trialId, Guid userId, string baseUrl, string rootUrl) + public async Task SiteSurveyUserJoinEmail(Guid trialId, Guid userId, string userTypes, string baseUrl, string rootUrl) { var sysUserInfo = (await _identityUserRepository.Where(t => t.Id == userId).FirstOrDefaultAsync()).IfNullThrowException(); - var userTypes = await _userRoleRepository.Where(t => t.IdentityUserId == sysUserInfo.Id).Select(t => t.UserTypeRole.UserTypeShortName).ToListAsync(); var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialId); @@ -531,8 +530,8 @@ namespace IRaCIS.Core.Application.Service trialInfo.ExperimentName, trialInfo.ResearchProgramNo, trialInfo.TrialCode, - sysUserInfo.UserName, - string.Join(',', userTypes), + sysUserInfo.EMail, + userTypes, sysUserInfo.IsFirstAdd ? redirectUrl : baseUrl ); @@ -646,7 +645,7 @@ namespace IRaCIS.Core.Application.Service trialInfo.ResearchProgramNo, trialInfo.TrialCode, sysUserInfo.UserName, - userType.UserTypeShortName, + $"{userType.UserTypeShortName} ({userType.UserTypeName})", sysUserInfo.IsFirstAdd ? redirectUrl : baseUrl ); diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 03a1a5fbf..8ded0154e 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -30,6 +30,7 @@ using IdentityModel; using Microsoft.AspNetCore.Components.Routing; using IRaCIS.Core.Application.ViewModel; using Microsoft.AspNetCore.Identity; +using NPOI.SS.Formula.Functions; namespace IRaCIS.Core.Application.Contracts { @@ -991,7 +992,12 @@ namespace IRaCIS.Core.Application.Contracts if (isNeedSendEmail) { - await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, identityUserId, baseUrl, routeUrl); + + var dbUserType = _userTypeRepository.Where(t => userTypeIdList.Contains(t.Id)).ToList(); + + var usertyps = string.Join(',', dbUserType.Select(t => $"{t.UserTypeShortName} ({t.UserTypeName})")); + + await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, identityUserId, usertyps, baseUrl, routeUrl); } var userJoinIdList = item.Select(t => t.Id).ToList(); @@ -1179,7 +1185,9 @@ namespace IRaCIS.Core.Application.Contracts if (isNeedSendEmail) { - await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, identityUserId, baseUrl, routeUrl); + var dbUserType = _userTypeRepository.Where(t => userTypeIdList.Contains(t.Id)).ToList(); + var usertyps = string.Join(',', dbUserType.Select(t => $"{t.UserTypeShortName} ({t.UserTypeName})")); + await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, identityUserId, usertyps, baseUrl, routeUrl); } await _trialSiteUserRoleRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index e49658fbd..7e25fdaf9 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -314,7 +314,7 @@ namespace IRaCIS.Core.Application.Service var identityUserId = existSysUser.Id; - var userTypeList = await _identityUserRepository.Where(t => t.Id == identityUserId).SelectMany(t => t.UserRoleList).Select(t => new { t.UserTypeId, t.UserTypeRole.UserTypeShortName }).ToListAsync(); + var userTypeList = await _identityUserRepository.Where(t => t.Id == identityUserId).SelectMany(t => t.UserRoleList).Select(t => new { t.UserTypeId, t.UserTypeRole.UserTypeName, t.UserTypeRole.UserTypeShortName }).ToListAsync(); var userHaveUserTypeIdList = userTypeList.Select(t => t.UserTypeId).ToList(); @@ -374,7 +374,7 @@ namespace IRaCIS.Core.Application.Service await _trialIdentityUserRepository.SaveChangesAsync(); - var usertyps = string.Join(',', userTypeList.Where(t => userTypeIdList.Contains(t.UserTypeId)).Select(t => t.UserTypeShortName)); + var usertyps = string.Join(',', userTypeList.Where(t => userTypeIdList.Contains(t.UserTypeId)).Select(t => $"{t.UserTypeShortName} ({t.UserTypeName})")); await _mailVerificationService.ExternalUserJoinEmail(trialId, identityUserId, usertyps, sendEmail.BaseUrl, sendEmail.RouteUrl);