- Timestamp:
- 07/04/19 14:47:01 (5 years ago)
- Location:
- stable
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
-
stable/HeuristicLab.Clients.Hive.Administrator
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Clients.Hive.Administrator merged: 16446
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/HiveAdministratorView.cs
r15584 r17063 37 37 } 38 38 39 #region Register Content Events40 protected override void DeregisterContentEvents() {41 base.DeregisterContentEvents();42 }43 protected override void RegisterContentEvents() {44 base.RegisterContentEvents();45 }46 #endregion47 48 39 protected override void OnContentChanged() { 49 40 base.OnContentChanged(); 50 } 51 52 protected override void SetEnabledStateOfControls() { 53 base.SetEnabledStateOfControls(); 41 if (Content != null) { 42 projectsView.Content = Content.Projects; 43 resourcesView.Content = Content.Resources; 44 } else { 45 projectsView.Content = null; 46 resourcesView.Content = null; 47 } 54 48 } 55 49 } -
stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.Designer.cs
r17059 r17063 171 171 this.Name = "ProjectResourcesView"; 172 172 this.Size = new System.Drawing.Size(830, 494); 173 this. Load += new System.EventHandler(this.ProjectResourcesView_Load);173 this.Disposed += new System.EventHandler(this.ProjectResourcesView_Disposed); 174 174 this.splitContainer.Panel1.ResumeLayout(false); 175 175 this.splitContainer.Panel2.ResumeLayout(false); -
stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs
r17059 r17063 29 29 using HeuristicLab.Core.Views; 30 30 using HeuristicLab.MainForm; 31 using System.Collections;32 using HeuristicLab.Common;33 31 34 32 namespace HeuristicLab.Clients.Hive.Administrator.Views { … … 79 77 80 78 #region Overrides 81 protected override void OnClosing(FormClosingEventArgs e) {82 HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;83 HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;84 base.OnClosing(e);85 }86 87 79 protected override void OnContentChanged() { 88 80 base.OnContentChanged(); … … 130 122 } 131 123 132 private void ProjectResourcesView_Load(object sender, EventArgs e) { 133 124 private void ProjectResourcesView_Disposed(object sender, EventArgs e) { 125 HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed; 126 HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing; 134 127 } 135 128 … … 165 158 166 159 var selectedResource = (Resource)e.Node.Tag; 167 if (HiveAdminClient.Instance.DisabledParentResources.Contains(selectedResource))160 if (HiveAdminClient.Instance.DisabledParentResources.Contains(selectedResource)) 168 161 e.Cancel = true; 169 162 } … … 179 172 return; 180 173 } 181 174 182 175 var checkedResource = (Resource)e.Node.Tag; 183 176 if (checkedResource == null 184 177 || checkedResource.Id == Guid.Empty 185 || HiveAdminClient.Instance.DisabledParentResources.Contains(checkedResource) 178 || HiveAdminClient.Instance.DisabledParentResources.Contains(checkedResource) 186 179 || newIncludedResources.Contains(checkedResource)) { 187 180 e.Cancel = true; 188 181 } else if (!IsAdmin()) { 189 if (!HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)190 || !HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any()191 192 193 182 if (!HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id) 183 || !HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any() 184 || projectExclusiveResources.Contains(checkedResource)) { 185 e.Cancel = true; 186 } 194 187 } 195 188 } … … 232 225 233 226 // get project specific assigned resources 234 var projectResources = resources.Where(x => 227 var projectResources = resources.Where(x => 235 228 HiveAdminClient.Instance.ProjectResourceAssignments 236 229 .Where(a => a.ProjectId == projectId) … … 242 235 HiveAdminClient.Instance.GetAvailableProjectAncestors(projectId).ToList().ForEach(x => projectIds.Add(x.Id)); 243 236 244 var ancestorProjectResources = resources.Where(x => 237 var ancestorProjectResources = resources.Where(x => 245 238 HiveAdminClient.Instance.ProjectResourceAssignments 246 239 .Where(a => projectIds.Contains(a.ProjectId)) … … 251 244 HashSet<Resource> availableResources = new HashSet<Resource>(ancestorProjectResources); 252 245 foreach (var r in ancestorProjectResources) { 253 foreach (var d in HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id)) {246 foreach (var d in HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id)) { 254 247 availableResources.Add(d); 255 248 } … … 267 260 foreach (var d in HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id)) { 268 261 projectExclusiveResources.Add(d); 269 } 262 } 270 263 } 271 264 } … … 286 279 if (projectId == null || resourceIds == null) return; 287 280 HiveServiceLocator.Instance.CallHiveService(s => { 288 s.SaveProjectResourceAssignments(projectId, resourceIds.ToList(), reassign, cascading, reassignCascading);281 s.SaveProjectResourceAssignments(projectId, resourceIds.ToList(), reassign, cascading, reassignCascading); 289 282 }); 290 283 } 291 284 292 285 private void UpdateNewAssignedResources() { 293 for (int i = newAssignedResources.Count -1; i >= 0; i--) {294 if (newAssignedResources.Intersect(HiveAdminClient.Instance.GetAvailableResourceAncestors(newAssignedResources.ElementAt(i).Id)).Any()) {286 for (int i = newAssignedResources.Count - 1; i >= 0; i--) { 287 if (newAssignedResources.Intersect(HiveAdminClient.Instance.GetAvailableResourceAncestors(newAssignedResources.ElementAt(i).Id)).Any()) { 295 288 newAssignedResources.Remove(newAssignedResources.ElementAt(i)); 296 289 } … … 345 338 346 339 var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name)); 347 340 348 341 Resource top = null; 349 342 //bool nodeSelected = false; … … 352 345 top = resources.Where(x => x.Id == resourceId).FirstOrDefault(); 353 346 } 354 347 355 348 356 349 TreeNode currentNode = null; … … 366 359 var newNode = new TreeNode(newResource.Name) { Tag = newResource }; 367 360 368 if (top == null && !disabledParentResources.Contains(newResource)) {361 if (top == null && !disabledParentResources.Contains(newResource)) { 369 362 top = newResource; 370 363 } … … 395 388 } else if (newAssignedResources.Contains(newResource)) { 396 389 newNode.Checked = true; 397 if (!HiveRoles.CheckAdminUserPermissions()) {398 if (!HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id) 399 || !HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any() 390 if (!HiveRoles.CheckAdminUserPermissions()) { 391 if (!HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id) 392 || !HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any() 400 393 || projectExclusiveResources.Contains(newResource)) { 401 394 newNode.ForeColor = SystemColors.GrayText; … … 452 445 bool expandUngroupedGroupNode = false; 453 446 var ungroupedSlaves = subResources.OfType<Slave>().OrderBy(x => x.Name); 454 if (ungroupedSlaves.Any()) {447 if (ungroupedSlaves.Any()) { 455 448 ungroupedGroupNode = new TreeNode(UNGROUPED_GROUP_NAME) { 456 449 ForeColor = SystemColors.GrayText, … … 486 479 } 487 480 488 if (expandUngroupedGroupNode) ungroupedGroupNode.Expand();481 if (expandUngroupedGroupNode) ungroupedGroupNode.Expand(); 489 482 treeView.Nodes.Add(ungroupedGroupNode); 490 483 } else if (ungroupedGroupNode != null) { … … 493 486 494 487 treeView.BeforeCheck += treeView_BeforeCheck; 495 treeView.AfterCheck += treeView_AfterCheck; 488 treeView.AfterCheck += treeView_AfterCheck; 496 489 497 490 return top; -
stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.Designer.cs
r17060 r17063 213 213 this.Size = new System.Drawing.Size(539, 271); 214 214 this.Load += new System.EventHandler(this.ProjectView_Load); 215 this.Disposed += new System.EventHandler(this.ProjectView_Disposed); 215 216 this.ResumeLayout(false); 216 217 this.PerformLayout(); -
stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs
r17062 r17063 35 35 private readonly object locker = new object(); 36 36 37 private Guid persistedOwnerUserId;38 39 37 public new Project Content { 40 38 get { return (Project)base.Content; } 41 set { base.Content = value; persistedOwnerUserId = Content != null ? Content.OwnerUserId : Guid.Empty;}39 set { base.Content = value; } 42 40 } 43 41 … … 50 48 51 49 #region Overrides 52 protected override void OnClosing(FormClosingEventArgs e) {53 AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed;54 AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing;55 base.OnClosing(e);56 }57 58 50 protected override void RegisterContentEvents() { 59 51 base.RegisterContentEvents(); … … 106 98 var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>(); 107 99 if (!Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator)); 108 ownerComboBox.DataSource = users.ToList(); 109 ownerComboBox.SelectedItem = users.FirstOrDefault(x => x.Id == Content.OwnerUserId); 100 var projectOwnerId = Content.OwnerUserId; 101 ownerComboBox.DataSource = users.OrderBy(x => x.UserName).ToList(); 102 ownerComboBox.SelectedItem = users.FirstOrDefault(x => x.Id == projectOwnerId); 110 103 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 111 104 … … 180 173 var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>(); 181 174 if (Content != null && !Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator)); 182 ownerComboBox.DataSource = users. ToList();175 ownerComboBox.DataSource = users.OrderBy(x => x.UserName).ToList(); 183 176 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 184 177 }); 178 } 179 180 private void ProjectView_Disposed(object sender, EventArgs e) { 181 AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed; 182 AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing; 185 183 } 186 184 -
stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.Designer.cs
r17060 r17063 260 260 this.Size = new System.Drawing.Size(853, 553); 261 261 this.Load += new System.EventHandler(this.ProjectsView_Load); 262 this.Disposed += new System.EventHandler(this.ProjectsView_Disposed); 262 263 this.splitContainer.Panel1.ResumeLayout(false); 263 264 this.splitContainer.Panel2.ResumeLayout(false); -
stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
r17062 r17063 56 56 57 57 private readonly object locker = new object(); 58 private bool refreshingInternal = false; 59 private bool refreshingExternal = false; 58 60 59 61 public new IItemList<Project> Content { … … 70 72 HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing; 71 73 HiveAdminClient.Instance.Refreshed += HiveAdminClient_Instance_Refreshed; 72 AccessClient.Instance.Refreshing += AccessClient_Instance_Refreshing;73 AccessClient.Instance.Refreshed += AccessClient_Instance_Refreshed;74 74 } 75 75 76 76 #region Overrides 77 protected override void OnClosing(FormClosingEventArgs e) {78 AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed;79 AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing;80 HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;81 HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;82 base.OnClosing(e);83 }84 85 77 protected override void RegisterContentEvents() { 86 78 base.RegisterContentEvents(); … … 183 175 if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e); 184 176 else { 177 lock (locker) { 178 if (refreshingExternal) return; 179 if (!refreshingInternal) refreshingExternal = true; 180 } 181 185 182 Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate); 186 183 SetEnabledStateOfControls(); … … 191 188 if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e); 192 189 else { 193 Progress.Hide(this); 194 SetEnabledStateOfControls(); 195 } 196 } 197 198 private void AccessClient_Instance_Refreshing(object sender, EventArgs e) { 199 if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e); 200 else { 201 Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate); 202 SetEnabledStateOfControls(); 203 } 204 } 205 206 private void AccessClient_Instance_Refreshed(object sender, EventArgs e) { 207 if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e); 208 else { 190 if (refreshingExternal) refreshingExternal = false; 191 Content = HiveAdminClient.Instance.Projects; 192 209 193 Progress.Hide(this); 210 194 SetEnabledStateOfControls(); … … 215 199 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 216 200 action: () => UpdateProjects()); 201 } 202 203 private void ProjectsView_Disposed(object sender, EventArgs e) { 204 HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed; 205 HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing; 217 206 } 218 207 … … 515 504 516 505 private void UpdateProjects() { 506 lock (locker) { 507 if (refreshingInternal || refreshingExternal) return; 508 refreshingInternal = true; 509 } 510 517 511 try { 518 512 HiveAdminClient.Instance.Refresh(); 519 Content = HiveAdminClient.Instance.Projects;520 513 } catch (AnonymousUserException) { 521 514 ShowHiveInformationDialog(); 515 } finally { 516 refreshingInternal = false; 522 517 } 523 518 } -
stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs
r17059 r17063 239 239 this.Size = new System.Drawing.Size(853, 553); 240 240 this.Load += new System.EventHandler(this.ResourcesView_Load); 241 this.Disposed += new System.EventHandler(this.ResourcesView_Disposed); 241 242 this.splitSlaves.Panel1.ResumeLayout(false); 242 243 this.splitSlaves.Panel2.ResumeLayout(false); -
stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r17062 r17063 54 54 55 55 56 57 56 private TreeNode ungroupedGroupNode; 58 57 … … 64 63 65 64 private readonly object locker = new object(); 65 private bool refreshingInternal = false; 66 private bool refreshingExternal = false; 66 67 67 68 public new IItemList<Resource> Content { … … 78 79 HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing; 79 80 HiveAdminClient.Instance.Refreshed += HiveAdminClient_Instance_Refreshed; 80 AccessClient.Instance.Refreshing += AccessClient_Instance_Refreshing;81 AccessClient.Instance.Refreshed += AccessClient_Instance_Refreshed;82 81 } 83 82 84 83 #region Overrides 85 protected override void OnClosing(FormClosingEventArgs e) {86 AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed;87 AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing;88 HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;89 HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;90 base.OnClosing(e);91 }92 93 84 protected override void RegisterContentEvents() { 94 85 base.RegisterContentEvents(); … … 185 176 if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e); 186 177 else { 178 lock (locker) { 179 if (refreshingExternal) return; 180 if (!refreshingInternal) refreshingExternal = true; 181 } 182 187 183 Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate); 188 184 SetEnabledStateOfControls(); … … 193 189 if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e); 194 190 else { 191 if (refreshingExternal) refreshingExternal = false; 192 Content = HiveAdminClient.Instance.Resources; 193 195 194 Progress.Hide(this); 196 195 SetEnabledStateOfControls(); … … 198 197 } 199 198 200 private void AccessClient_Instance_Refreshing(object sender, EventArgs e) {201 if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e);202 else {203 Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate);204 SetEnabledStateOfControls();205 }206 }207 208 private void AccessClient_Instance_Refreshed(object sender, EventArgs e) {209 if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e);210 else {211 Progress.Hide(this);212 SetEnabledStateOfControls();213 }214 }215 216 199 private async void ResourcesView_Load(object sender, EventArgs e) { 217 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 218 action: () => UpdateResources()); 200 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(() => UpdateResources()); 201 } 202 203 private void ResourcesView_Disposed(object sender, EventArgs e) { 204 HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed; 205 HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing; 219 206 } 220 207 … … 550 537 551 538 private void UpdateResources() { 539 lock (locker) { 540 if (refreshingInternal || refreshingExternal) return; 541 refreshingInternal = true; 542 } 543 552 544 try { 553 545 HiveAdminClient.Instance.Refresh(); 554 Content = HiveAdminClient.Instance.Resources;555 546 } catch (AnonymousUserException) { 556 547 ShowHiveInformationDialog(); 548 } finally { 549 refreshingInternal = false; 557 550 } 558 551 }
Note: See TracChangeset
for help on using the changeset viewer.