- Timestamp:
- 12/07/17 14:41:47 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
r15497 r15500 75 75 var resourceDao = pm.ResourceDao; 76 76 var resourcePermissionDao = pm.ResourcePermissionDao; 77 78 77 var currentUserId = UserManager.CurrentUserId; 79 78 80 // V1 (without child check; with resourcePermission-oriented check for user grants) 81 // granted (parent) resources 82 var userGrantedResources = resourcePermissionDao.GetAll().ToList() 83 .Where(x => x.GrantedUserId == currentUserId 84 || UserManager.VerifyUser(currentUserId, new List<Guid> { x.GrantedUserId }) 85 ) 86 .Select(x => x.Resource) 87 .ToList(); 88 89 //// children 90 //var userGrantedResourceChildren = userGrantedResources 91 // .SelectMany(x => resourceDao.GetResourcesByParentId(x.ResourceId)); 92 //// join parent and child resources 93 //userGrantedResources.AddRange(userGrantedResourceChildren); 94 95 var userGrantedResourceIds = resourceIds 96 .Where(x => userGrantedResources 97 .Select(y => y.ResourceId) 98 .Contains(x)) 99 .Distinct().ToList(); 79 //// V1 user grant check 80 //// get granted (parent) resources 81 //var userGrantedResourceIds = pm.UseTransaction(() => { 82 // return resourcePermissionDao.GetAll().ToList() 83 // .Where(x => x.GrantedUserId == currentUserId 84 // || UserManager.VerifyUser(currentUserId, new List<Guid> { x.GrantedUserId })) 85 // .Select(y => y.ResourceId) 86 // .ToList(); 87 //}); 88 89 //// get children of granted parent resources 90 //var userGrantedChildResourceIds = pm.UseTransaction(() => { 91 // return userGrantedResourceIds 92 // .SelectMany(x => resourceDao.GetResourcesByParentId(x)) 93 // .Select(y => y.ResourceId); 94 //}); 95 96 //// join list of parent and child resources 97 //userGrantedResourceIds.AddRange(userGrantedChildResourceIds); 98 99 //// filter initial resourceId list with the list of the granted ones 100 //var allUserGrantedResourceIds = resourceIds 101 // .Where(x => userGrantedResourceIds.Contains(x)) 102 // .Distinct().ToList(); 103 104 // V2 user grant check 105 var allUserGrantedResourceIds = pm.UseTransaction(() => { 106 var groupAndGroupIds = new List<Guid> { currentUserId }; 107 groupAndGroupIds.AddRange(UserManager.GetUserGroupIdsOfUser(currentUserId)); 108 return resourcePermissionDao.GetByUserAndGroupIds(groupAndGroupIds); 109 }); 100 110 101 111 var newTask = task.ToEntity(); 102 112 newTask.JobData = taskData.ToEntity(); 103 113 newTask.JobData.LastUpdate = DateTime.Now; 104 newTask.AssignedTaskResources.AddRange( resourceIds.Select(114 newTask.AssignedTaskResources.AddRange(allUserGrantedResourceIds.Select( 105 115 x => new DA.AssignedTaskResource { 106 116 ResourceId = x
Note: See TracChangeset
for help on using the changeset viewer.