@@ -11,7 +11,10 @@ namespace IRaCIS.Application.Contracts
|
||||
{
|
||||
|
||||
|
||||
public class TrialSiteCRCListDTO
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class UserTrialDTO : UserTrialCommand
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
[ApiExplorerSettings(GroupName = "Trial")]
|
||||
public class TrialMaintenanceService(IRepository<TrialUserRole> _trialUseRoleRepository, IRepository<TrialIdentityUser> _trialIdentityUserRepository,
|
||||
IRepository<UserRole> _userRoleRepository,
|
||||
IRepository<TrialSiteUser> _trialSiteUserRepository,
|
||||
IRepository<TrialSiteUserRole> _trialSiteUserRoleRepository,
|
||||
IRepository<SubjectVisit> _subjectVisitRepository,
|
||||
IRepository<Trial> _trialRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ITrialMaintenanceService
|
||||
{
|
||||
@@ -56,7 +56,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
if (updateTrialUserCommand.IsDeleted)
|
||||
{
|
||||
if (await _trialSiteUserRepository.AnyAsync(t => t.UserRole.IdentityUserId == trialUser.IdentityUserId && t.TrialId == trialUser.TrialId))
|
||||
if (await _trialSiteUserRoleRepository.AnyAsync(t => t.UserRole.IdentityUserId == trialUser.IdentityUserId && t.TrialId == trialUser.TrialId))
|
||||
{
|
||||
// ----人员已加入现场维护
|
||||
return ResponseOutput.NotOk(_localizer["TrialMaint_PersonnelJoined"]);
|
||||
@@ -145,17 +145,20 @@ namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
var currentUserRoleList = item.ToList();
|
||||
|
||||
var addArray = _mapper.Map<TrialIdentityUser[]>(currentUserRoleList);
|
||||
var first = currentUserRoleList.FirstOrDefault();
|
||||
|
||||
var trialUsers = await _trialIdentityUserRepository.AddRangeAsync(addArray);
|
||||
|
||||
foreach (var trialUser in trialUsers)
|
||||
var currentUser = new TrialIdentityUser()
|
||||
{
|
||||
trialUser.JoinTime = DateTime.Now;
|
||||
}
|
||||
TrialId = first.TrialId,
|
||||
IdentityUserId = item.Key,
|
||||
JoinTime = DateTime.Now,
|
||||
TrialUserRoleList = currentUserRoleList.Select(t => new TrialUserRole() { UserId = t.UserId, TrialId = t.TrialId }).ToList()
|
||||
};
|
||||
|
||||
|
||||
var success = await _trialUseRoleRepository.SaveChangesAsync();
|
||||
await _trialIdentityUserRepository.AddAsync(currentUser);
|
||||
|
||||
var success = await _trialIdentityUserRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
||||
@@ -207,7 +210,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
if (trialUser == null) return Null404NotFound(trialUser);
|
||||
|
||||
if (await _trialSiteUserRepository.AnyAsync(t => t.UserId == trialUser.UserId && t.TrialId == trialUser.TrialId))
|
||||
if (await _trialSiteUserRoleRepository.AnyAsync(t => t.UserId == trialUser.UserId && t.TrialId == trialUser.TrialId))
|
||||
{
|
||||
//---人员已加入现场维护
|
||||
return ResponseOutput.NotOk(_localizer["TrialMaint_PersonnelJoined"]);
|
||||
|
||||
@@ -551,7 +551,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
await _repository.BatchDeleteNoTrackingAsync<TrialSiteEquipmentSurvey>(t => t.TrialSiteSurvey.TrialId == trialId);
|
||||
|
||||
await _repository.BatchDeleteNoTrackingAsync<TrialUserRole>(t => t.TrialId == trialId);
|
||||
await _repository.BatchDeleteNoTrackingAsync<TrialSiteUser>(t => t.TrialId == trialId);
|
||||
await _repository.BatchDeleteNoTrackingAsync<TrialSiteUserRole>(t => t.TrialId == trialId);
|
||||
await _repository.BatchDeleteNoTrackingAsync<VisitStage>(t => t.TrialId == trialId);
|
||||
await _repository.BatchDeleteNoTrackingAsync<VisitPlanInfluenceStat>(t => t.TrialId == trialId);
|
||||
await _repository.BatchDeleteNoTrackingAsync<VisitPlanInfluenceStudy>(t => t.TrialId == trialId);
|
||||
|
||||
@@ -10,15 +10,30 @@ namespace IRaCIS.Core.Application.Services
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "Trial")]
|
||||
public class TrialMaintenanceService(IRepository<TrialSite> _trialSiteRepository,
|
||||
IRepository<TrialSiteUser> _trialSiteUserRepository,
|
||||
IRepository<TrialSiteUserRole> _trialSiteUserRoleRepository,
|
||||
IRepository<Site> _siteRepository,
|
||||
IRepository<Subject> _subjectRepository,
|
||||
IRepository<VisitTask> _visitTaskRepository,
|
||||
IRepository<Trial> _trialRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ITrialSiteService
|
||||
{
|
||||
|
||||
#region 账户修改已维护
|
||||
|
||||
|
||||
/// <summary>获取某一Site下面的负责的CRC列表</summary>
|
||||
[HttpGet, Route("{trialId:guid}/{siteId:guid}")]
|
||||
public async Task<List<UserTrialDTO>> GetTrialSiteCRCList(Guid trialId, Guid siteId)
|
||||
{
|
||||
var query = _trialSiteUserRoleRepository.Where(t => t.TrialId == trialId && t.TrialSiteId == siteId).IgnoreQueryFilters()
|
||||
.ProjectTo<UserTrialDTO>(_mapper.ConfigurationProvider);
|
||||
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>Pannel 进去 SiteTab </summary>
|
||||
[HttpPost]
|
||||
@@ -65,16 +80,6 @@ namespace IRaCIS.Core.Application.Services
|
||||
}
|
||||
|
||||
|
||||
/// <summary>获取某一Site下面的负责的CRC列表</summary>
|
||||
[HttpGet, Route("{trialId:guid}/{siteId:guid}")]
|
||||
public async Task<List<UserTrialDTO>> GetTrialSiteCRCList(Guid trialId, Guid siteId)
|
||||
{
|
||||
var query = _trialSiteUserRepository.Where(t => t.TrialId == trialId && t.TrialSiteId == siteId).IgnoreQueryFilters()
|
||||
.ProjectTo<UserTrialDTO>(_mapper.ConfigurationProvider);
|
||||
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>[new] Setting页面 Site勾选列表( </summary>
|
||||
[HttpPost]
|
||||
@@ -111,7 +116,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
//[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||
[TrialGlobalLimit( "AfterStopCannNotOpt" )]
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
public async Task<IResponseOutput> AddTrialSites(List<TrialSiteCommand> trialSites)
|
||||
{
|
||||
var addArray = _mapper.Map<List<TrialSite>>(trialSites);
|
||||
@@ -152,7 +157,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
if (editTrialSiteCommand.IsDeleted)
|
||||
{
|
||||
|
||||
if (await _trialSiteUserRepository.AnyAsync(t => t.TrialId == trialId && t.TrialSiteId == trialSiteId))
|
||||
if (await _trialSiteUserRoleRepository.AnyAsync(t => t.TrialId == trialId && t.TrialSiteId == trialSiteId))
|
||||
{
|
||||
//---The site has been associated with CRC, and couldn't be deleted.
|
||||
return ResponseOutput.NotOk(_localizer["TrialSite_CannotDeleteAssociatedCRC"]);
|
||||
@@ -205,36 +210,36 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
/// <summary> 批量添加Site下 CRC的负责人 </summary>
|
||||
[HttpPost]
|
||||
[TrialGlobalLimit( "AfterStopCannNotOpt" )]
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
//[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||
public async Task<IResponseOutput> AssignSiteCRC(List<AssginSiteCRCCommand> trialSiteCRCList)
|
||||
{
|
||||
var addArray = _mapper.Map<List<TrialSiteUser>>(trialSiteCRCList);
|
||||
var addArray = _mapper.Map<List<TrialSiteUserRole>>(trialSiteCRCList);
|
||||
|
||||
await _trialSiteUserRepository.AddRangeAsync(addArray);
|
||||
await _trialSiteUserRoleRepository.AddRangeAsync(addArray);
|
||||
|
||||
await _trialSiteUserRepository.SaveChangesAsync();
|
||||
await _trialSiteUserRoleRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Result(true);
|
||||
}
|
||||
|
||||
/// <summary> 删除CRC人员</summary>
|
||||
[HttpDelete, Route("{id:guid}/{trialId:guid}/{isDelete:bool}")]
|
||||
[TrialGlobalLimit( "AfterStopCannNotOpt" )]
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
//[Authorize(Policy = IRaCISPolicy.PM_APM)]
|
||||
public async Task<IResponseOutput> DeleteSiteCRC(Guid id, bool isDelete)
|
||||
{
|
||||
|
||||
|
||||
await _trialSiteUserRepository.UpdatePartialFromQueryAsync(t => t.Id == id, u => new TrialSiteUser() { IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null }, true, true);
|
||||
await _trialSiteUserRoleRepository.UpdatePartialFromQueryAsync(t => t.Id == id, u => new TrialSiteUserRole() { IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null }, true, true);
|
||||
|
||||
//删除又启用改授权时间
|
||||
if (isDelete == false)
|
||||
{
|
||||
await _trialSiteUserRepository.BatchUpdateNoTrackingAsync(t => t.Id == id, u => new TrialSiteUser() { CreateTime = DateTime.Now });
|
||||
await _trialSiteUserRoleRepository.BatchUpdateNoTrackingAsync(t => t.Id == id, u => new TrialSiteUserRole() { CreateTime = DateTime.Now });
|
||||
}
|
||||
|
||||
////不跟踪
|
||||
//await _trialSiteUserRepository.ExecuteUpdateAsync(t => t.Id == id, s=>s.SetProperty(t=>t.IsDeleted,u=>isDelete)
|
||||
//await _trialSiteUserRoleRepository.ExecuteUpdateAsync(t => t.Id == id, s=>s.SetProperty(t=>t.IsDeleted,u=>isDelete)
|
||||
// .SetProperty(t=>t.DeletedTime,u=> isDelete ? DateTime.Now : null)
|
||||
// .SetProperty(t=>t.CreateTime,u=>isDelete?u.CreateTime:DateTime.Now));
|
||||
|
||||
@@ -280,7 +285,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
/// <summary>删除 项目 下某一site </summary>
|
||||
[HttpDelete("{id:guid}/{trialId:guid}")]
|
||||
[TrialGlobalLimit( "AfterStopCannNotOpt" )]
|
||||
[TrialGlobalLimit("AfterStopCannNotOpt")]
|
||||
[Obsolete]
|
||||
public async Task<IResponseOutput> DeleteTrialSite(Guid id)
|
||||
{
|
||||
@@ -291,7 +296,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
var trialId = relation.TrialId;
|
||||
var trialSiteId = relation.Id;
|
||||
|
||||
if (await _trialSiteUserRepository.AnyAsync(t => t.TrialId == trialId && t.TrialSiteId == trialSiteId))
|
||||
if (await _trialSiteUserRoleRepository.AnyAsync(t => t.TrialId == trialId && t.TrialSiteId == trialSiteId))
|
||||
{
|
||||
//---The site has been associated with CRC, and couldn't be deleted.
|
||||
return ResponseOutput.NotOk(_localizer["TrialSite_CannotDeleteAssociatedCRC"]);
|
||||
@@ -305,7 +310,7 @@ namespace IRaCIS.Core.Application.Services
|
||||
|
||||
await _trialSiteRepository.DeleteAsync(relation);
|
||||
|
||||
return ResponseOutput.Result(await _trialSiteUserRepository.SaveChangesAsync());
|
||||
return ResponseOutput.Result(await _trialSiteUserRoleRepository.SaveChangesAsync());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
|
||||
|
||||
CreateMap<TrialSiteUser, UserTrialDTO>().IncludeMembers(t => t.UserRole)
|
||||
CreateMap<TrialSiteUserRole, UserTrialDTO>().IncludeMembers(t => t.UserRole)
|
||||
.ForMember(d => d.UserType, u => u.MapFrom(s => s.UserRole.UserTypeRole.UserTypeShortName))
|
||||
.ForMember(d => d.UserRealName, u => u.MapFrom(s => s.UserRole.FullName));
|
||||
CreateMap<UserRole, UserTrialDTO>();
|
||||
@@ -157,7 +157,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
|
||||
|
||||
CreateMap<AssginSiteCRCCommand, TrialSiteUser>();
|
||||
CreateMap<AssginSiteCRCCommand, TrialSiteUserRole>();
|
||||
|
||||
|
||||
CreateMap<Domain.Models.Trial, TrialConfigDTO>().ForMember(t => t.TrialId, u => u.MapFrom(c => c.Id))
|
||||
@@ -266,7 +266,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
CreateMap<Trial, TrialSiteUserExportDto>()
|
||||
.ForMember(t => t.TrialSiteUserList, u => u.Ignore());
|
||||
|
||||
CreateMap<TrialSiteUser, SiteUserExportDTO>().IncludeMembers(t => t.UserRole)
|
||||
CreateMap<TrialSiteUserRole, SiteUserExportDTO>().IncludeMembers(t => t.UserRole)
|
||||
.ForMember(t => t.TrialSiteCode, u => u.MapFrom(c => c.TrialSite.TrialSiteCode))
|
||||
.ForMember(t => t.TrialSiteAliasName, u => u.MapFrom(c => c.TrialSite.TrialSiteAliasName))
|
||||
.ForMember(t => t.UserRealName, u => u.MapFrom(c => c.UserRole.FullName))
|
||||
|
||||
@@ -59,7 +59,6 @@ namespace IRaCIS.Core.Application.Service
|
||||
CreateMap<TrialUserRole, TrialIdentityUserRoleDto>();
|
||||
|
||||
|
||||
CreateMap<TrialUserAddCommand, TrialIdentityUser>();
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user