修改退出改为加入
parent
8c5cca7ba5
commit
b6403580de
|
@ -286,7 +286,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
{
|
{
|
||||||
//找到最新的调研表
|
//找到最新的调研表
|
||||||
|
|
||||||
var currentLatest = await _trialSiteSurveyRepository.Where(t => t.TrialId == userInfo.TrialId && t.SiteId == userInfo.SiteId,true)
|
var currentLatest = await _trialSiteSurveyRepository.Where(t => t.TrialId == userInfo.TrialId && t.SiteId == userInfo.SiteId, true)
|
||||||
.Include(u => u.TrialSiteEquipmentSurveyList).Include(u => u.TrialSiteUserSurveyList).OrderByDescending(t => t.CreateTime).FirstOrDefaultAsync();
|
.Include(u => u.TrialSiteEquipmentSurveyList).Include(u => u.TrialSiteUserSurveyList).OrderByDescending(t => t.CreateTime).FirstOrDefaultAsync();
|
||||||
|
|
||||||
if (currentLatest == null)
|
if (currentLatest == null)
|
||||||
|
@ -333,12 +333,12 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
copy.TrialSiteEquipmentSurveyList.ForEach(t => { t.Id = Guid.Empty; t.CreateTime = DateTime.Now; });
|
copy.TrialSiteEquipmentSurveyList.ForEach(t => { t.Id = Guid.Empty; t.CreateTime = DateTime.Now; });
|
||||||
|
|
||||||
//锁定了的话,就不拷贝
|
//锁定了的话,就不拷贝
|
||||||
if(currentLatest.State!= TrialSiteSurveyEnum.PMCreatedAndLock)
|
if (currentLatest.State != TrialSiteSurveyEnum.PMCreatedAndLock)
|
||||||
{
|
{
|
||||||
copy.TrialSiteUserSurveyList = currentLatest.TrialSiteUserSurveyList.Clone().Where(t => t.IsHistoryUser == false).ToList();
|
copy.TrialSiteUserSurveyList = currentLatest.TrialSiteUserSurveyList.Clone().Where(t => t.IsHistoryUser == false).ToList();
|
||||||
copy.TrialSiteUserSurveyList.ForEach(t => { t.Id = Guid.Empty; t.IsGenerateSuccess = false; t.CreateTime = DateTime.Now; });
|
copy.TrialSiteUserSurveyList.ForEach(t => { t.Id = Guid.Empty; t.IsGenerateSuccess = false; t.CreateTime = DateTime.Now; });
|
||||||
}
|
}
|
||||||
|
|
||||||
//从项目site 中找到已存在的 加到历史人员中
|
//从项目site 中找到已存在的 加到历史人员中
|
||||||
|
|
||||||
|
|
||||||
|
@ -408,9 +408,9 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
{
|
{
|
||||||
|
|
||||||
//有可能填表人提交了,但是此时PM手动对人员信息进行了更改,此时需要将数据同步下(选择在这里同步是因为 不想改动 中心人员哪里的两个接口的逻辑)
|
//有可能填表人提交了,但是此时PM手动对人员信息进行了更改,此时需要将数据同步下(选择在这里同步是因为 不想改动 中心人员哪里的两个接口的逻辑)
|
||||||
var find = await _trialSiteSurveyRepository.FirstOrDefaultAsync(t => t.Id == trialSiteSurveyId,true);
|
var find = await _trialSiteSurveyRepository.FirstOrDefaultAsync(t => t.Id == trialSiteSurveyId, true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (find.State != TrialSiteSurveyEnum.PMCreatedAndLock && find.IsDeleted != true)
|
if (find.State != TrialSiteSurveyEnum.PMCreatedAndLock && find.IsDeleted != true)
|
||||||
{
|
{
|
||||||
var userList = await _trialSiteUserRepository.Where(t => t.TrialId == find.TrialId && t.SiteId == find.SiteId, false, true).ProjectTo<TrialSiteUserSurvey>(_mapper.ConfigurationProvider).ToListAsync();
|
var userList = await _trialSiteUserRepository.Where(t => t.TrialId == find.TrialId && t.SiteId == find.SiteId, false, true).ProjectTo<TrialSiteUserSurvey>(_mapper.ConfigurationProvider).ToListAsync();
|
||||||
|
@ -419,7 +419,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
await UnlockSyncSiteUserAsync(find.TrialId, find.SiteId, find.Id, userList);
|
await UnlockSyncSiteUserAsync(find.TrialId, find.SiteId, find.Id, userList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var result = await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId && t.TrialId == trialId).IgnoreQueryFilters()
|
var result = await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId && t.TrialId == trialId).IgnoreQueryFilters()
|
||||||
|
@ -697,16 +697,16 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
var trialId = siteSurvyeSubmit.TrialId;
|
var trialId = siteSurvyeSubmit.TrialId;
|
||||||
var trialSiteSurveyId = siteSurvyeSubmit.TrialSiteSurveyId;
|
var trialSiteSurveyId = siteSurvyeSubmit.TrialSiteSurveyId;
|
||||||
|
|
||||||
var trialSiteSurvey = (await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId,false,true).FirstOrDefaultAsync()).IfNullThrowException();
|
var trialSiteSurvey = (await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId, false, true).FirstOrDefaultAsync()).IfNullThrowException();
|
||||||
|
|
||||||
|
|
||||||
if (trialSiteSurvey.IsDeleted == true || trialSiteSurvey.State==TrialSiteSurveyEnum.PMCreatedAndLock)
|
if (trialSiteSurvey.IsDeleted == true || trialSiteSurvey.State == TrialSiteSurveyEnum.PMCreatedAndLock)
|
||||||
{
|
{
|
||||||
throw new BusinessValidationFailedException("当前调研表已废除,或者调研表状态已锁定,不允许操作");
|
throw new BusinessValidationFailedException("当前调研表已废除,或者调研表状态已锁定,不允许操作");
|
||||||
}
|
}
|
||||||
|
|
||||||
var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId)
|
var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId)
|
||||||
.Where(t=>!(t.IsHistoryUser && t.IsHistoryUserDeleted==true))
|
.Where(t => !(t.IsHistoryUser && t.IsHistoryUserDeleted == true))
|
||||||
.Select(t =>
|
.Select(t =>
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
|
@ -717,7 +717,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
UserTypeEnum = (UserTypeEnum?)t.UserTypeRole.UserTypeEnum,
|
UserTypeEnum = (UserTypeEnum?)t.UserTypeRole.UserTypeEnum,
|
||||||
t.TrialRoleCode,
|
t.TrialRoleCode,
|
||||||
t.Email,
|
t.Email,
|
||||||
}). ToListAsync();
|
}).ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined)
|
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined)
|
||||||
|
@ -849,14 +849,14 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
//判断TrialUser中是否存在 不存在就插入
|
//判断TrialUser中是否存在 不存在就插入
|
||||||
|
|
||||||
var findTrialUser = await _trialUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId, true);
|
var findTrialUser = await _trialUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId, true);
|
||||||
if (findTrialUser==null)
|
if (findTrialUser == null)
|
||||||
{
|
{
|
||||||
await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId, JoinTime = DateTime.Now });
|
await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId, JoinTime = DateTime.Now });
|
||||||
|
|
||||||
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl);
|
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(findTrialUser.IsDeleted==true)
|
else if (findTrialUser.IsDeleted == true)
|
||||||
{
|
{
|
||||||
await _trialUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.UserId == userId, c => new TrialUser()
|
await _trialUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.UserId == userId, c => new TrialUser()
|
||||||
{
|
{
|
||||||
|
@ -868,18 +868,17 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl);
|
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!await _repository.AnyAsync<TrialSiteUser>(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true))
|
var findTrialSiteUser = await _trialSiteUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true);
|
||||||
|
|
||||||
|
if (findTrialSiteUser == null)
|
||||||
{
|
{
|
||||||
await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId });
|
await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId });
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _trialSiteUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, c => new TrialSiteUser()
|
findTrialSiteUser.IsDeleted = false;
|
||||||
{
|
findTrialSiteUser.DeletedTime = null;
|
||||||
IsDeleted = false,
|
|
||||||
DeletedTime = null,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable });
|
await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable });
|
||||||
|
@ -989,7 +988,7 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
}
|
}
|
||||||
|
|
||||||
item.IsGeneratedAccount = true;
|
item.IsGeneratedAccount = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var userId = sysUserInfo.Id;
|
var userId = sysUserInfo.Id;
|
||||||
|
@ -1017,18 +1016,17 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!await _repository.AnyAsync<TrialSiteUser>(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true))
|
var findTrialSiteUser = await _trialSiteUserRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, true);
|
||||||
|
|
||||||
|
if (findTrialSiteUser == null)
|
||||||
{
|
{
|
||||||
await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId });
|
await _repository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId });
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _trialSiteUserRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.UserId == userId && t.SiteId == siteId, c => new TrialSiteUser()
|
findTrialSiteUser.IsDeleted = false;
|
||||||
{
|
findTrialSiteUser.DeletedTime = null;
|
||||||
IsDeleted = false,
|
|
||||||
DeletedTime = null,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable });
|
await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable });
|
||||||
|
|
Loading…
Reference in New Issue