Changeset 15978
- Timestamp:
- 07/02/18 15:51:17 (6 years ago)
- Location:
- branches/2839_HiveProjectManagement
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectJobsView.cs
r15969 r15978 144 144 145 145 private StringMatrix CreateValueMatrix() { 146 if (Content == null || Content.Id == Guid.Empty) 147 return new StringMatrix(); 148 146 149 var jobs = HiveAdminClient.Instance.Jobs[Content.Id]; 147 150 var resources = HiveAdminClient.Instance.Resources; … … 172 175 if (InvokeRequired) Invoke((Action)UpdateJobs); 173 176 else { 174 StringMatrix matrix = null; 175 if(Content != null) { 176 matrix = CreateValueMatrix(); 177 if(Content != null && Content.Id != null && Content.Id != Guid.Empty) { 178 var matrix = CreateValueMatrix(); 179 matrixView.Content = matrix; 180 if(matrix != null) { 181 foreach (DataGridViewRow row in matrixView.DataGridView.Rows) { 182 string val = ((string)row.Cells[0].Value); 183 if (val == JobState.Online.ToString()) { 184 row.DefaultCellStyle.BackColor = onlineStatusColor; 185 } else if (val == JobState.StatisticsPending.ToString()) { 186 row.DefaultCellStyle.BackColor = statisticsPendingStatusColor; 187 } else if (val == JobState.DeletionPending.ToString()) { 188 row.DefaultCellStyle.BackColor = deletionPendingStatusColor; 189 } 190 } 191 192 matrixView.DataGridView.AutoResizeColumns(); 193 matrixView.DataGridView.Columns[0].MinimumWidth = 90; 194 matrixView.DataGridView.Columns[1].MinimumWidth = 108; 195 } 177 196 } else { 178 197 refreshButton.Enabled = false; 179 198 removeButton.Enabled = false; 180 } 181 matrixView.Content = matrix; 182 183 foreach(DataGridViewRow row in matrixView.DataGridView.Rows) { 184 string val = ((string)row.Cells[0].Value); 185 if (val == JobState.Online.ToString()) { 186 row.DefaultCellStyle.BackColor = onlineStatusColor; 187 } else if(val == JobState.StatisticsPending.ToString()) { 188 row.DefaultCellStyle.BackColor = statisticsPendingStatusColor; 189 } else if(val == JobState.DeletionPending.ToString()) { 190 row.DefaultCellStyle.BackColor = deletionPendingStatusColor; 191 } 192 } 193 194 matrixView.DataGridView.AutoResizeColumns(); 195 matrixView.DataGridView.Columns[0].MinimumWidth = 90; 196 matrixView.DataGridView.Columns[1].MinimumWidth = 108; 199 matrixView.Content = null; 200 } 197 201 } 198 202 } -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectPermissionsView.cs
r15955 r15978 143 143 #region Helpers 144 144 private void UpdatePermissionList() { 145 AccessClient.Instance.Refresh(); 146 145 147 UpdateUserGroupGenealogy(); 146 148 UpdateAssignedPermissions(); -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs
r15955 r15978 117 117 SetAssignedProjectResources(Content.Id, newAssignedResources.Select(x => x.Id), false, true, false); 118 118 }); 119 HiveAdminClient.Instance.Refresh(); 119 120 UpdateResourceTree(); 120 121 } -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs
r15953 r15978 198 198 this.viewHost.Caption = "View"; 199 199 this.viewHost.Content = null; 200 this.viewHost.Enabled = false;200 this.viewHost.Enabled = true; 201 201 this.viewHost.Location = new System.Drawing.Point(6, 6); 202 202 this.viewHost.Name = "viewHost"; -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r15953 r15978 123 123 btnRemoveGroup.Enabled = !locked; 124 124 btnSave.Enabled = !locked; 125 viewHost.Locked = locked; 125 viewHost.Enabled = true; 126 //viewHost.Locked = locked; 127 viewHost.Locked = false; 128 viewHost.ReadOnly = false; 126 129 scheduleView.Locked = locked; 127 scheduleView.SetEnabledStateOfSchedule(!scheduleLocked);130 //scheduleView.SetEnabledStateOfSchedule(!scheduleLocked); 128 131 } 129 132 #endregion -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs
r15956 r15978 234 234 } 235 235 236 public virtual void SetEnabledStateOfSchedule(bool state) {237 if (InvokeRequired) {238 Invoke(new Action(() => SetEnabledStateOfSchedule(state)));239 } else {240 if (Content == null || Locked || ReadOnly) state = false;241 //groupBox1.Enabled = state;242 btnClearCal.Enabled = state;243 btnSaveCal.Enabled = state;244 }245 }236 //public virtual void SetEnabledStateOfSchedule(bool state) { 237 // if (InvokeRequired) { 238 // Invoke(new Action(() => SetEnabledStateOfSchedule(state))); 239 // } else { 240 // if (Content == null || Locked || ReadOnly) state = false; 241 // //groupBox1.Enabled = state; 242 // btnClearCal.Enabled = state; 243 // btnSaveCal.Enabled = state; 244 // } 245 //} 246 246 247 247 private void btnClearCal_Click(object sender, System.EventArgs e) { -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs
r15422 r15978 60 60 protected override void SetEnabledStateOfControls() { 61 61 base.SetEnabledStateOfControls(); 62 disposableCheckBox.Enabled = Content != null; 62 bool enabled = Content != null && !Locked; 63 disposableCheckBox.Enabled = enabled; 63 64 } 64 65 #endregion -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.Designer.cs
r15956 r15978 147 147 this.projectsTreeView.TabIndex = 3; 148 148 this.projectsTreeView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.projectsTreeView_MouseDoubleClick); 149 this.projectsTreeView.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.projectsTreeView_BeforeSelect); 149 150 this.projectsTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.projectsTreeView_AfterSelect); 150 151 // -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r15966 r15978 227 227 } 228 228 229 private void projectsTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) { 230 var node = (Project)e.Node.Tag; 231 if (HiveClient.Instance.DisabledParentProjects.Contains(node)) { 232 e.Cancel = true; 233 } 234 } 235 229 236 private void projectsTreeView_AfterSelect(object sender, TreeViewEventArgs e) { 230 237 var node = (Project)e.Node.Tag; 231 238 232 239 if (node == null) { 233 240 projectsTreeView.SelectedNode = null; 241 } else if (HiveClient.Instance.DisabledParentProjects.Contains(node)) { 242 return; 234 243 } else { 235 244 ResetTreeNodes(projectsTreeView.Nodes); 236 245 e.Node.BackColor = selectedBackColor; 237 246 e.Node.ForeColor = selectedForeColor; 238 239 if (node.Id == projectId) {247 248 if (node.Id == projectId) { 240 249 e.Node.Text += CURRENT_SELECTION_TAG; 241 } else if (projectId == null || projectId == Guid.Empty) {250 } else if (projectId == null || projectId == Guid.Empty) { 242 251 e.Node.Text += NEW_SELECTION_TAG; 243 252 } else { … … 245 254 } 246 255 247 256 248 257 } 249 258 SelectedProject = node; … … 313 322 if (!projects.Any()) return; 314 323 324 var disabledParentProjects = HiveClient.Instance.DisabledParentProjects; 315 325 // select all top level projects (withouth parent, or without any ancestor within current project collection) 316 326 var mainProjects = new HashSet<Project>(projects.Where(x => x.ParentProjectId == null)); 317 var parentedMainProjects = new HashSet<Project>(projects 318 .Where(x => x.ParentProjectId.HasValue 319 && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value) 320 && !projects.SelectMany(y => HiveClient.Instance.ProjectAncestors[y.Id]).Contains(x.ParentProjectId.Value))); 321 mainProjects.UnionWith(parentedMainProjects); 322 var subProbjects = new HashSet<Project>(projects.Except(mainProjects)); 323 foreach(var p in subProbjects) { 324 p.ParentProjectId = HiveClient.Instance.ProjectAncestors[p.Id].Where(x => projects.Select(y => y.Id).Contains(x)).FirstOrDefault(); 325 } 327 //var parentedMainProjects = new HashSet<Project>(projects 328 // .Where(x => x.ParentProjectId.HasValue 329 // && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value) 330 // && !projects.SelectMany(y => HiveClient.Instance.ProjectAncestors[y.Id]).Contains(x.ParentProjectId.Value))); 331 //mainProjects.UnionWith(parentedMainProjects); 332 var mainDisabledParentProjects = new HashSet<Project>(disabledParentProjects.Where(x => x.ParentProjectId == null)); 333 mainProjects.UnionWith(mainDisabledParentProjects); 334 var subProbjects = new HashSet<Project>(projects.Union(disabledParentProjects).Except(mainProjects)); 335 //foreach (var p in subProbjects) { 336 // p.ParentProjectId = HiveClient.Instance.ProjectAncestors[p.Id].Where(x => projects.Select(y => y.Id).Contains(x)).FirstOrDefault(); 337 //} 326 338 327 339 var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name)); … … 349 361 newNode.SelectedImageIndex = newNode.ImageIndex; 350 362 351 if (SelectedProject != null && SelectedProject.Id.Equals(newProject.Id)) { 363 if(disabledParentProjects.Contains(newProject)) { 364 newNode.Checked = false; 365 newNode.ForeColor = grayTextColor; 366 } 367 else if (SelectedProject != null && SelectedProject.Id.Equals(newProject.Id)) { 352 368 newNode.BackColor = selectedBackColor; 353 369 newNode.ForeColor = selectedForeColor; … … 673 689 n.BackColor = Color.Transparent; 674 690 n.ForeColor = Color.Black; 691 692 if(n.Tag is Project) { 693 var p = (Project)n.Tag; 694 if(HiveClient.Instance.DisabledParentProjects.Select(x => x.Id).Contains(p.Id)) { 695 n.ForeColor = grayTextColor; 696 } 697 } 675 698 } 676 699 -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r15922 r15978 87 87 } 88 88 89 private Dictionary<Guid, string> projectNames; 90 public Dictionary<Guid, string> ProjectNames { 91 get { return projectNames; } 92 } 93 94 private HashSet<Project> disabledParentProjects; 95 public HashSet<Project> DisabledParentProjects { 96 get { return disabledParentProjects; } 97 } 89 98 90 99 private List<Plugin> onlinePlugins; … … 127 136 resources = new ItemList<Resource>(); 128 137 jobs = new HiveItemCollection<RefreshableJob>(); 138 projectNames = new Dictionary<Guid, string>(); 129 139 130 140 projectAncestors = new Dictionary<Guid, HashSet<Guid>>(); … … 138 148 service.GetSlaves().ForEach(s => resources.Add(s)); 139 149 service.GetJobs().ForEach(p => jobs.Add(new RefreshableJob(p))); 150 projectNames = service.GetProjectNames(); 140 151 }); 141 152 142 153 UpdateResourceGenealogy(); 143 154 UpdateProjectGenealogy(); 155 UpdateDisabledParentProjects(); 144 156 } 145 157 catch { … … 159 171 try { 160 172 projects = new ItemList<Project>(); 173 projectNames = new Dictionary<Guid, string>(); 161 174 resources = new ItemList<Resource>(); 162 175 … … 170 183 service.GetSlaveGroups().ForEach(g => resources.Add(g)); 171 184 service.GetSlaves().ForEach(s => resources.Add(s)); 185 projectNames = service.GetProjectNames(); 172 186 }); 173 187 174 188 UpdateResourceGenealogy(); 175 189 UpdateProjectGenealogy(); 190 UpdateDisabledParentProjects(); 176 191 } catch { 177 192 projects = null; … … 236 251 projectDescendants[ancestor].Add(pa.Key); 237 252 } 253 } 254 } 255 256 private void UpdateDisabledParentProjects() { 257 disabledParentProjects = new HashSet<Project>(); 258 259 foreach (var pid in projects 260 .Where(x => x.ParentProjectId.HasValue) 261 .SelectMany(x => projectAncestors[x.Id]).Distinct() 262 .Where(x => !projects.Select(y => y.Id).Contains(x))) { 263 var p = new Project(); 264 p.Id = pid; 265 p.ParentProjectId = projectAncestors[pid].FirstOrDefault(); 266 p.Name = projectNames[pid]; 267 disabledParentProjects.Add(p); 238 268 } 239 269 } -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs
r15969 r15978 75 75 76 76 public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; 77 78 77 } 79 78 … … 2461 2460 System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetProjectGenealogy(); 2462 2461 2462 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetProjectNames", ReplyAction="http://tempuri.org/IHiveService/GetProjectNamesResponse")] 2463 System.Collections.Generic.Dictionary<System.Guid, string> GetProjectNames(); 2464 2463 2465 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/SaveProjectPermissions", ReplyAction="http://tempuri.org/IHiveService/SaveProjectPermissionsResponse")] 2464 2466 void SaveProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds, bool reassign, bool cascading, bool reassignCascading); … … 2789 2791 } 2790 2792 2793 public System.Collections.Generic.Dictionary<System.Guid, string> GetProjectNames() 2794 { 2795 return base.Channel.GetProjectNames(); 2796 } 2797 2791 2798 public void SaveProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds, bool reassign, bool cascading, bool reassignCascading) 2792 2799 { -
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Prepare Hive Database.sql
r15737 r15978 104 104 REFERENCES [dbo].[Project] ([ProjectId]) 105 105 ON UPDATE CASCADE 106 ON DELETE CASCADE107 106 GO 108 107 -
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
r15969 r15978 43 43 private const string NOT_AUTHORIZED_PROJECTRESOURCE = "Selected project is not authorized to access the requested resource"; 44 44 private const string NOT_AUTHORIZED_USERPROJECT = "Current user is not authorized to access the requested project"; 45 private const string NO_JOB_UPDATE_POSSIBLE = "This job has already been flagged for deletion, thus, it can not be updated anymore."; 45 46 46 47 private static readonly DA.TaskState[] CompletedStates = { DA.TaskState.Finished, DA.TaskState.Aborted, DA.TaskState.Failed }; … … 465 466 exists = false; 466 467 job = new DA.Job(); 467 } 468 } else if(job.State != DA.JobState.Online) { 469 throw new InvalidOperationException(NO_JOB_UPDATE_POSSIBLE); 470 } 471 472 468 473 jobDto.CopyToEntity(job); 469 474 … … 539 544 540 545 var pm = PersistenceManager; 541 using (new PerformanceLogger("UpdateJob sState")) {546 using (new PerformanceLogger("UpdateJobStates")) { 542 547 var jobDao = pm.JobDao; 543 548 var projectDao = pm.ProjectDao; … … 802 807 pm.UseTransaction(() => { 803 808 var project = projectDao.GetById(projectDto.Id); 804 if (project != null) { // update existent 809 if (project != null) { // update existent project 805 810 var formerOwnerId = project.OwnerUserId; 806 811 projectDto.CopyToEntity(project); … … 808 813 // if owner has changed... 809 814 if(formerOwnerId != projectDto.OwnerUserId) { 810 var formerPermissionItem = project.ProjectPermissions.Where(x => x.GrantedUserId == formerOwnerId).FirstOrDefault(); 811 if (formerPermissionItem != null) { 812 // remove permissions 813 project.ProjectPermissions.Remove(formerPermissionItem); 814 // remove jobs if former owner is no member of a still permitted group 815 var ugt = GetUserGroupTree(); 816 var permittedGuids = new HashSet<Guid>(); // User- and Group-Guids 817 // get all member-Guids of all still permitted groups 818 foreach (var item in project.ProjectPermissions) { 819 permittedGuids.Add(item.GrantedUserId); 820 if(ugt.ContainsKey(item.GrantedUserId)) { 821 ugt[item.GrantedUserId].ToList().ForEach(x => permittedGuids.Add(x)); 822 } 823 824 // check if former owner Guid is in Member-Guids 825 // if yes: do nothing, if not do: 826 if (!permittedGuids.Contains(formerOwnerId)) { 827 assignedJobResourceDao.DeleteByProjectIdAndUserIds(project.ProjectId, new List<Guid> { formerOwnerId }); 828 } 829 } 815 // OBSOLETE: former owner looses permission and project-related jobs 816 //var formerPermissionItem = project.ProjectPermissions.Where(x => x.GrantedUserId == formerOwnerId).FirstOrDefault(); 817 //if (formerPermissionItem != null) { 818 // // remove permissions 819 // project.ProjectPermissions.Remove(formerPermissionItem); 820 // // remove jobs if former owner is no member of a still permitted group 821 // var ugt = GetUserGroupTree(); 822 // var permittedGuids = new HashSet<Guid>(); // User- and Group-Guids 823 // // get all member-Guids of all still permitted groups 824 // foreach (var item in project.ProjectPermissions) { 825 // permittedGuids.Add(item.GrantedUserId); 826 // if(ugt.ContainsKey(item.GrantedUserId)) { 827 // ugt[item.GrantedUserId].ToList().ForEach(x => permittedGuids.Add(x)); 828 // } 829 830 // // check if former owner Guid is in Member-Guids 831 // // if yes: do nothing, if not do: 832 // if (!permittedGuids.Contains(formerOwnerId)) { 833 // assignedJobResourceDao.DeleteByProjectIdAndUserIds(project.ProjectId, new List<Guid> { formerOwnerId }); 834 // } 835 // } 836 //} 837 // Add permission for new owner if not already done 838 if(!project.ProjectPermissions 839 .Select(pp => pp.GrantedUserId) 840 .Contains(projectDto.OwnerUserId)) { 841 project.ProjectPermissions.Add(new DA.ProjectPermission { 842 GrantedUserId = projectDto.OwnerUserId, 843 GrantedByUserId = UserManager.CurrentUserId 844 }); 830 845 } 831 project.ProjectPermissions.Add(new DA.ProjectPermission {832 GrantedUserId = projectDto.OwnerUserId,833 GrantedByUserId = UserManager.CurrentUserId834 });835 846 } 836 847 837 } else { // save new 848 } else { // save new project 838 849 var newProject = projectDao.Save(projectDto.ToEntity()); 839 850 newProject.ProjectPermissions.Clear(); … … 953 964 } 954 965 return projectAncestors; 966 }); 967 } 968 } 969 970 public IDictionary<Guid, string> GetProjectNames() { 971 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 972 var pm = PersistenceManager; 973 using (new PerformanceLogger("GetProjectNames")) { 974 var projectDao = pm.ProjectDao; 975 var projectNames = new Dictionary<Guid, string>(); 976 return pm.UseTransaction(() => { 977 projectDao 978 .GetAll().ToList() 979 .ForEach(p=> projectNames.Add(p.ProjectId, p.Name)); 980 return projectNames; 955 981 }); 956 982 } -
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs
r15969 r15978 166 166 [OperationContract] 167 167 IDictionary<Guid, HashSet<Guid>> GetProjectGenealogy(); 168 169 [OperationContract] 170 IDictionary<Guid, string> GetProjectNames(); 168 171 #endregion 169 172
Note: See TracChangeset
for help on using the changeset viewer.