Changeset 15760
- Timestamp:
- 02/12/18 18:10:42 (7 years ago)
- Location:
- branches/HiveProjectManagement
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectPermissionsView.cs
r15642 r15760 81 81 } 82 82 } 83 84 protected override void SetEnabledStateOfControls() { 85 base.SetEnabledStateOfControls(); 86 bool enabled = Content != null && !Locked && !ReadOnly; 87 88 inheritButton.Enabled = enabled; 89 saveButton.Enabled = enabled; 90 treeView.Enabled = enabled; 91 } 83 92 #endregion 84 93 -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs
r15658 r15760 50 50 private readonly Dictionary<Guid, HashSet<Resource>> resourceDescendants = new Dictionary<Guid, HashSet<Resource>>(); 51 51 52 //private readonly Color addedAssignmentColor = Color.FromArgb(255, 0, 174, 179); // #00aeb353 52 private readonly Color addedAssignmentColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1 54 53 private readonly Color removedAssignmentColor = Color.FromArgb(255, 236, 159, 72); // #ec9f48 … … 84 83 var top = BuildResourceTree(HiveAdminClient.Instance.Resources); 85 84 detailsViewHost.Content = top; 86 detailsViewHost.ActiveView.Locked = true; 87 } 88 } 89 85 } 86 } 87 88 protected override void SetEnabledStateOfControls() { 89 base.SetEnabledStateOfControls(); 90 bool enabled = Content != null && !Locked && !ReadOnly; 91 92 inheritButton.Enabled = enabled; 93 saveButton.Enabled = enabled; 94 treeView.Enabled = enabled; 95 } 90 96 #endregion 91 97 … … 208 214 var resources = HiveAdminClient.Instance.Resources; 209 215 210 foreach(var r in resources ) {216 foreach(var r in resources.Where(x => x.Id != Guid.Empty)) { 211 217 resourceAncestors.Add(r.Id, new HashSet<Resource>()); 212 218 resourceDescendants.Add(r.Id, new HashSet<Resource>()); 213 219 } 214 220 215 foreach(var r in resources ) {221 foreach(var r in resources.Where(x => x.Id != Guid.Empty)) { 216 222 var parentResourceId = r.ParentResourceId; 217 223 while(parentResourceId != null) { … … 253 259 treeView.AfterCheck -= treeView_AfterCheck; 254 260 261 resources = resources.Where(x => x.Id != Guid.Empty); 255 262 var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null)); 256 263 var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() … … 379 386 var projects = HiveAdminClient.Instance.Projects; 380 387 381 foreach(var p in projects ) {388 foreach(var p in projects.Where(x => x.Id != Guid.Empty)) { 382 389 projectAncestors.Add(p.Id, new HashSet<Project>()); 383 390 projectDescendants.Add(p.Id, new HashSet<Project>()); 384 391 } 385 392 386 foreach (var p in projects ) {393 foreach (var p in projects.Where(x => x.Id != Guid.Empty)) { 387 394 var parentProjectId = p.ParentProjectId; 388 395 while (parentProjectId != null) { -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs
r15576 r15760 92 92 protected override void SetEnabledStateOfControls() { 93 93 base.SetEnabledStateOfControls(); 94 bool enabled = Content != null && ! ReadOnly;94 bool enabled = Content != null && !Locked && !ReadOnly; 95 95 nameTextBox.Enabled = enabled; 96 96 descriptionTextBox.Enabled = enabled; -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
r15742 r15760 97 97 projectPermissionsView.Content = top; 98 98 projectResourcesView.Content = top; 99 100 if(top != null && top.Id == Guid.Empty) { 101 projectPermissionsView.Locked = true; 102 projectResourcesView.Locked = true; 103 } 99 104 } 100 105 } … … 390 395 var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name)); 391 396 if (selectedProject != null) selectedProject = projects.Where(x => x.Id == selectedProject.Id).FirstOrDefault(); 397 bool nodeSelected = false; 392 398 393 399 TreeNode currentNode = null; … … 406 412 selectedProject = newProject; 407 413 } 408 if (newProject.Id == selectedProject.Id ) {414 if (newProject.Id == selectedProject.Id && !nodeSelected) { 409 415 newNode.BackColor = selectedColor; 410 416 newNode.Text += " [selected]"; 417 nodeSelected = true; 411 418 } 412 419 -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r15742 r15760 95 95 } else { 96 96 var top = BuildResourceTree(Content); 97 SetEnabledStateOfControlsForSelectedResource(); 98 97 99 viewHost.Content = top; 100 bool locked = !IsAdmin(); 101 viewHost.Locked = locked; 102 scheduleView.Locked = locked; 103 104 if (top != null && top.Id == Guid.Empty) { 105 scheduleView.SetEnabledStateOfSchedule(false); 106 } 98 107 } 99 108 } … … 105 114 btnRemoveGroup.Enabled = enabled; 106 115 btnSave.Enabled = enabled; 107 scheduleView.SetEnabledStateOfSchedule(enabled && IsAdmin()); // IsAuthorized((Resource)viewHost.Content));116 scheduleView.SetEnabledStateOfSchedule(enabled && IsAdmin()); 108 117 } 109 118 #endregion … … 415 424 var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name)); 416 425 if (selectedResource != null) selectedResource = resources.Where(x => x.Id == selectedResource.Id).FirstOrDefault(); 417 //bool nodeSelected = false;426 bool nodeSelected = false; 418 427 419 428 TreeNode currentNode = null; … … 432 441 selectedResource = newResource; 433 442 } 434 if (newResource.Id == selectedResource.Id ) {443 if (newResource.Id == selectedResource.Id && !nodeSelected) { 435 444 newNode.BackColor = selectedColor; 436 445 newNode.Text += " [selected]"; 446 nodeSelected = true; 437 447 } 438 448 … … 490 500 slaveNode.Text += " [changes not stored]"; 491 501 } 492 if (slave.Id == selectedResource.Id ) {502 if (slave.Id == selectedResource.Id && !nodeSelected) { 493 503 slaveNode.BackColor = selectedColor; 494 504 slaveNode.Text += " [selected]"; 505 nodeSelected = true; 495 506 } 496 507 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs
r15742 r15760 234 234 Invoke(new Action(() => SetEnabledStateOfSchedule(state))); 235 235 } else { 236 if (Content == null ) state = false;236 if (Content == null || Locked || ReadOnly) state = false; 237 237 groupBox1.Enabled = state; 238 238 btnClearCal.Enabled = state; -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/AssignedJobResourceDao.cs
r15737 r15760 105 105 SELECT j.JobId 106 106 FROM [Job] j 107 WHERE j.ProjectId = {0}107 WHERE j.ProjectId = '{0}' 108 108 AND j.OwnerUserId IN ({1}) 109 109 ) -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectPermissionDao.cs
r15628 r15760 74 74 private const string DeleteByProjectIdAndGrantedUserIdsQueryString = @" 75 75 DELETE FROM [ProjectPermission] 76 WHERE ProjectId = {0}76 WHERE ProjectId = '{0}' 77 77 AND GrantedUserId IN ({1}); 78 78 "; -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs
r15671 r15760 401 401 } 402 402 403 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, Delete Rule="CASCADE")]403 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedProjectResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteOnNull=true)] 404 404 public Resource Resource 405 405 { … … 435 435 } 436 436 437 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, Delete Rule="CASCADE")]437 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_AssignedProjectResource", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, DeleteOnNull=true)] 438 438 public Project Project 439 439 { … … 2850 2850 } 2851 2851 2852 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Task_TaskData", Storage="_Job", ThisKey="TaskId", OtherKey="TaskId", IsForeignKey=true )]2852 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Task_TaskData", Storage="_Job", ThisKey="TaskId", OtherKey="TaskId", IsForeignKey=true, DeleteOnNull=true)] 2853 2853 public Task Task 2854 2854 { … … 3488 3488 } 3489 3489 3490 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperiment", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true )]3490 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_JobPermission", Storage="_HiveExperiment", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true, DeleteOnNull=true)] 3491 3491 public Job Job 3492 3492 { … … 6108 6108 } 6109 6109 6110 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true )]6110 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Project_ProjectPermission", Storage="_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true, DeleteOnNull=true)] 6111 6111 public Project Project 6112 6112 { … … 6242 6242 } 6243 6243 6244 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true )]6244 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedJobResource", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true, DeleteOnNull=true)] 6245 6245 public Resource Resource 6246 6246 { … … 6276 6276 } 6277 6277 6278 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_Job", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true )]6278 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Job_AssignedJobResource", Storage="_Job", ThisKey="JobId", OtherKey="JobId", IsForeignKey=true, DeleteOnNull=true)] 6279 6279 public Job Job 6280 6280 { -
branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
r15737 r15760 880 880 } 881 881 882 private void GrantProjectPermissions(Guid projectId, List<Guid> grantedUserIds, bool cascading) {883 throw new NotImplementedException();884 }885 886 private void RevokeProjectPermissions(Guid projectId, List<Guid> grantedUserIds, bool cascading) {887 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);888 if (projectId == null || grantedUserIds == null || !grantedUserIds.Any()) return;889 AuthorizationManager.AuthorizeForProjectAdministration(projectId, false);890 var pm = PersistenceManager;891 using (new PerformanceLogger("RevokeProjectPermissions")) {892 var projectPermissionDao = pm.ProjectPermissionDao;893 var projectDao = pm.ProjectDao;894 var assignedJobResourceDao = pm.AssignedJobResourceDao;895 pm.UseTransaction(() => {896 if (cascading) {897 var childProjectIds = projectDao.GetChildProjectIdsById(projectId).ToList();898 projectPermissionDao.DeleteByProjectIdsAndGrantedUserIds(childProjectIds, grantedUserIds);899 assignedJobResourceDao.DeleteByProjectIdsAndUserIds(childProjectIds, grantedUserIds);900 }901 projectPermissionDao.DeleteByProjectIdAndGrantedUserIds(projectId, grantedUserIds);902 assignedJobResourceDao.DeleteByProjectIdAndUserIds(projectId, grantedUserIds);903 pm.SubmitChanges();904 });905 }906 }882 //private void GrantProjectPermissions(Guid projectId, List<Guid> grantedUserIds, bool cascading) { 883 // throw new NotImplementedException(); 884 //} 885 886 //private void RevokeProjectPermissions(Guid projectId, List<Guid> grantedUserIds, bool cascading) { 887 // RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 888 // if (projectId == null || grantedUserIds == null || !grantedUserIds.Any()) return; 889 // AuthorizationManager.AuthorizeForProjectAdministration(projectId, false); 890 // var pm = PersistenceManager; 891 // using (new PerformanceLogger("RevokeProjectPermissions")) { 892 // var projectPermissionDao = pm.ProjectPermissionDao; 893 // var projectDao = pm.ProjectDao; 894 // var assignedJobResourceDao = pm.AssignedJobResourceDao; 895 // pm.UseTransaction(() => { 896 // if (cascading) { 897 // var childProjectIds = projectDao.GetChildProjectIdsById(projectId).ToList(); 898 // projectPermissionDao.DeleteByProjectIdsAndGrantedUserIds(childProjectIds, grantedUserIds); 899 // assignedJobResourceDao.DeleteByProjectIdsAndUserIds(childProjectIds, grantedUserIds); 900 // } 901 // projectPermissionDao.DeleteByProjectIdAndGrantedUserIds(projectId, grantedUserIds); 902 // assignedJobResourceDao.DeleteByProjectIdAndUserIds(projectId, grantedUserIds); 903 // pm.SubmitChanges(); 904 // }); 905 // } 906 //} 907 907 908 908 public IEnumerable<DT.ProjectPermission> GetProjectPermissions(Guid projectId) { … … 1001 1001 } 1002 1002 1003 private void AssignProjectResources(Guid projectId, List<Guid> resourceIds, bool cascading) { 1004 throw new NotImplementedException(); 1005 } 1006 1007 // basic: unassign resourceIds from project and depending jobs 1008 // cascading: unassign resourceIds from all child-projects and their depending jobs 1009 private void UnassignProjectResources(Guid projectId, List<Guid> resourceIds, bool cascading) { 1010 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 1011 if (projectId == null || resourceIds == null || !resourceIds.Any()) return; 1012 AuthorizationManager.AuthorizeForProjectResourceAdministration(projectId, resourceIds); 1013 var pm = PersistenceManager; 1014 using (new PerformanceLogger("UnassignProjectResources")) { 1015 var assignedProjectResourceDao = pm.AssignedProjectResourceDao; 1016 var assignedJobResourceDao = pm.AssignedJobResourceDao; 1017 var projectDao = pm.ProjectDao; 1018 pm.UseTransaction(() => { 1019 if (cascading) { 1020 var childProjectIds = projectDao.GetChildProjectIdsById(projectId).ToList(); 1021 assignedProjectResourceDao.DeleteByProjectIdsAndResourceIds(childProjectIds, resourceIds); 1022 assignedJobResourceDao.DeleteByProjectIdsAndResourceIds(childProjectIds, resourceIds); 1023 } 1024 assignedProjectResourceDao.DeleteByProjectIdAndResourceIds(projectId, resourceIds); 1025 assignedJobResourceDao.DeleteByProjectIdAndResourceIds(projectId, resourceIds); 1026 pm.SubmitChanges(); 1027 }); 1028 } 1029 } 1003 //private void AssignProjectResources(Guid projectId, List<Guid> resourceIds, bool cascading) { 1004 // throw new NotImplementedException(); 1005 //} 1006 1007 //private void UnassignProjectResources(Guid projectId, List<Guid> resourceIds, bool cascading) { 1008 // RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 1009 // if (projectId == null || resourceIds == null || !resourceIds.Any()) return; 1010 // AuthorizationManager.AuthorizeForProjectResourceAdministration(projectId, resourceIds); 1011 // var pm = PersistenceManager; 1012 // using (new PerformanceLogger("UnassignProjectResources")) { 1013 // var assignedProjectResourceDao = pm.AssignedProjectResourceDao; 1014 // var assignedJobResourceDao = pm.AssignedJobResourceDao; 1015 // var projectDao = pm.ProjectDao; 1016 // pm.UseTransaction(() => { 1017 // if (cascading) { 1018 // var childProjectIds = projectDao.GetChildProjectIdsById(projectId).ToList(); 1019 // assignedProjectResourceDao.DeleteByProjectIdsAndResourceIds(childProjectIds, resourceIds); 1020 // assignedJobResourceDao.DeleteByProjectIdsAndResourceIds(childProjectIds, resourceIds); 1021 // } 1022 // assignedProjectResourceDao.DeleteByProjectIdAndResourceIds(projectId, resourceIds); 1023 // assignedJobResourceDao.DeleteByProjectIdAndResourceIds(projectId, resourceIds); 1024 // pm.SubmitChanges(); 1025 // }); 1026 // } 1027 //} 1030 1028 1031 1029 public IEnumerable<DT.AssignedProjectResource> GetAssignedResourcesForProject(Guid projectId) {
Note: See TracChangeset
for help on using the changeset viewer.