Changeset 15913 for branches/2839_HiveProjectManagement
- Timestamp:
- 04/20/18 11:52:33 (7 years ago)
- Location:
- branches/2839_HiveProjectManagement
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r15658 r15913 43 43 public const string additionalSlavesGroupDescription = "Contains additional slaves which are either ungrouped or the parenting slave group is not assigned to the selected project."; 44 44 45 private const string CURRENT_SELECTION_TAG = " [current selection]"; 46 private const string NEW_SELECTION_TAG = " [new selection]"; 47 private const string CHANGED_SELECTION_TAG = " [changed selection]"; 45 48 46 49 private readonly HashSet<TreeNode> mainTreeNodes = new HashSet<TreeNode>(); … … 54 57 private readonly HashSet<Resource> newIncludedResources = new HashSet<Resource>(); 55 58 56 private readonly Dictionary<Guid, HashSet<Project>> projectAncestors = new Dictionary<Guid, HashSet<Project>>();57 private readonly Dictionary<Guid, HashSet<Project>> projectDescendants = new Dictionary<Guid, HashSet<Project>>();58 private readonly Dictionary<Guid, HashSet<Resource>> resourceAncestors = new Dictionary<Guid, HashSet<Resource>>();59 private readonly Dictionary<Guid, HashSet<Resource>> resourceDescendants = new Dictionary<Guid, HashSet<Resource>>();60 61 59 private IEnumerable<Resource> addedResources; 62 60 private IEnumerable<Resource> removedResources; … … 68 66 private readonly Color addedIncludeColor = Color.FromArgb(25, 169, 221, 221); // #a9dddd 69 67 private readonly Color removedIncludeColor = Color.FromArgb(25, 249, 210, 145); // #f9d291 70 private readonly Color selectedColor = Color.FromArgb(255, 240, 194, 59); // #f0c23b 68 private readonly Color selectedBackColor = Color.DodgerBlue; 69 private readonly Color selectedForeColor = Color.White; 71 70 72 71 private string currentSearchString; … … 173 172 base.OnContentChanged(); 174 173 175 if (Content != null) { 176 UpdateProjectGenealogy(); 177 UpdateResourceGenealogy(); 178 174 if (Content != null) { 179 175 if (SelectedProjectId.HasValue && SelectedProjectId.Value != Guid.Empty) { 180 176 SelectedProject = GetSelectedProjectById(SelectedProjectId.Value); … … 218 214 projectsTreeView.SelectedNode = null; 219 215 } else { 220 ReColorTreeNodes(projectsTreeView.Nodes, selectedColor, Color.Transparent, true); 221 e.Node.BackColor = selectedColor; 216 ResetTreeNodes(projectsTreeView.Nodes); 217 e.Node.BackColor = selectedBackColor; 218 e.Node.ForeColor = selectedForeColor; 222 219 223 220 if(node.Id == projectId) { 224 e.Node.Text += " [current selection]";221 e.Node.Text += CURRENT_SELECTION_TAG; 225 222 } else if(projectId == null || projectId == Guid.Empty) { 226 e.Node.Text += " [new selection]";223 e.Node.Text += NEW_SELECTION_TAG; 227 224 } else { 228 e.Node.Text += " [changed selection]";225 e.Node.Text += CHANGED_SELECTION_TAG; 229 226 } 230 227 … … 270 267 271 268 #region Helpers 272 273 274 #region old275 private void UpdateMainTree() {276 mainTreeNodes.Clear();277 278 foreach (Project g in Content.OrderBy(x => x.Name)) {279 if (g.ParentProjectId == null) {280 TreeNode tn = new TreeNode();281 tn.ImageIndex = greenFlagImageIndex;282 tn.SelectedImageIndex = tn.ImageIndex;283 284 tn.Tag = g;285 tn.Text = g.Name;286 tn.Checked = assignedResources.Any(x => x.Id == g.Id);287 288 BuildMainTree(tn);289 mainTreeNodes.Add(tn);290 }291 }292 UpdateFilteredTree();293 }294 295 private void BuildMainTree(TreeNode tn) {296 foreach (Project r in Content.Where(s => s.ParentProjectId != null && s.ParentProjectId == ((Project)tn.Tag).Id).OrderBy(x => x.Name)) {297 TreeNode stn = new TreeNode(r.Name);298 stn.ImageIndex = redFlagImageIndex;299 stn.SelectedImageIndex = stn.ImageIndex;300 stn.Tag = r;301 stn.Checked = assignedResources.Any(x => x.Id == r.Id);302 tn.Nodes.Add(stn);303 mainTreeNodes.Add(stn);304 305 BuildMainTree(stn);306 }307 }308 309 private void UpdateFilteredTree() {310 filteredTreeNodes.Clear();311 foreach (TreeNode n in mainTreeNodes) {312 n.BackColor = SystemColors.Window;313 if (currentSearchString == null || ((Project)n.Tag).Name.ToLower().Contains(currentSearchString)) {314 n.BackColor = string.IsNullOrEmpty(currentSearchString) ? SystemColors.Window : Color.LightBlue;315 filteredTreeNodes.Add(n);316 TraverseParentNodes(n);317 }318 }319 UpdateProjectsTree();320 }321 322 private void UpdateProjectsTree() {323 projectsTreeView.Nodes.Clear();324 nodeStore.Clear();325 326 foreach (TreeNode node in filteredTreeNodes) {327 var clone = nodeStore.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)node.Tag).Id);328 if (clone == null) {329 clone = (TreeNode)node.Clone();330 nodeStore.Add(clone);331 clone.Nodes.Clear();332 }333 foreach (TreeNode child in node.Nodes)334 if (filteredTreeNodes.Any(x => ((Project)x.Tag).Id == ((Project)child.Tag).Id)) {335 var childClone = nodeStore.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)child.Tag).Id);336 if (childClone == null) {337 childClone = (TreeNode)child.Clone();338 nodeStore.Add(childClone);339 childClone.Nodes.Clear();340 }341 clone.Nodes.Add(childClone);342 }343 }344 projectsTreeView.Nodes.AddRange(nodeStore.Where(x => ((Project)x.Tag).ParentProjectId == null).ToArray());345 if (string.IsNullOrEmpty(currentSearchString)) ExpandSlaveGroupNodes();346 else projectsTreeView.ExpandAll();347 }348 349 private void TraverseParentNodes(TreeNode node) {350 if (node != null) {351 for (TreeNode parent = node.Parent; parent != null; parent = parent.Parent)352 filteredTreeNodes.Add(parent);353 }354 }355 #endregion356 269 357 270 private Project GetSelectedProjectById(Guid projectId) { … … 368 281 if(project.Name.ToLower().Contains(currentSearchString.ToLower())) { 369 282 filteredProjects.Add(project); 370 filteredProjects.UnionWith( projectAncestors[project.Id]);283 filteredProjects.UnionWith(Content.Where(p => HiveClient.Instance.ProjectAncestors[project.Id].Contains(p.Id))); 371 284 } 372 285 } … … 379 292 if (!projects.Any()) return; 380 293 381 // select all top level projects (withouth parent, or without parentwithin current project collection)294 // select all top level projects (withouth parent, or without any ancestor within current project collection) 382 295 var mainProjects = new HashSet<Project>(projects.Where(x => x.ParentProjectId == null)); 383 296 var parentedMainProjects = new HashSet<Project>(projects 384 297 .Where(x => x.ParentProjectId.HasValue 385 && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value))); 298 && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value) 299 && !projects.SelectMany(y => HiveClient.Instance.ProjectAncestors[y.Id]).Contains(x.ParentProjectId.Value))); 386 300 mainProjects.UnionWith(parentedMainProjects); 387 301 var subProbjects = new HashSet<Project>(projects.Except(mainProjects)); 302 foreach(var p in subProbjects) { 303 p.ParentProjectId = HiveClient.Instance.ProjectAncestors[p.Id].Where(x => projects.Select(y => y.Id).Contains(x)).FirstOrDefault(); 304 } 388 305 389 306 var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name)); … … 412 329 413 330 if (SelectedProject != null && SelectedProject.Id.Equals(newProject.Id)) { 414 newNode.BackColor = selectedColor; 331 newNode.BackColor = selectedBackColor; 332 newNode.ForeColor = selectedForeColor; 415 333 if(SelectedProject.Id == projectId) { 416 newNode.Text += " [current selection]";334 newNode.Text += CURRENT_SELECTION_TAG; 417 335 } else if (projectId == null || projectId == Guid.Empty) { 418 newNode.Text += " [new selection]";336 newNode.Text += NEW_SELECTION_TAG; 419 337 } else { 420 newNode.Text += " [changed selection]";338 newNode.Text += CHANGED_SELECTION_TAG; 421 339 } 422 340 } … … 439 357 projectsTreeView.ExpandAll(); 440 358 } 441 442 private void UpdateProjectGenealogy() {443 projectAncestors.Clear();444 projectDescendants.Clear();445 var projects = Content;446 447 foreach (var p in projects) {448 projectAncestors.Add(p.Id, new HashSet<Project>());449 projectDescendants.Add(p.Id, new HashSet<Project>());450 }451 452 foreach (var p in projects) {453 var parentProjectId = p.ParentProjectId;454 while (parentProjectId != null) {455 var parent = projects.SingleOrDefault(x => x.Id == parentProjectId);456 if (parent != null) {457 projectAncestors[p.Id].Add(parent);458 projectDescendants[parent.Id].Add(p);459 parentProjectId = parent.ParentProjectId;460 } else {461 parentProjectId = null;462 }463 }464 }465 }466 467 359 468 360 private static IEnumerable<Resource> GetAssignedResourcesForProject(Guid projectId) { … … 495 387 foreach (var resource in assignedProjectResources) { 496 388 availableResources.Add(resource); 497 foreach(var descendant in resourceDescendants[resource.Id]) {389 foreach(var descendant in HiveClient.Instance.Resources.Where(x => HiveClient.Instance.ResourceDescendants[resource.Id].Contains(x.Id))) { 498 390 availableResources.Add(descendant); 499 391 } … … 544 436 private void UpdateNewAssignedResources() { 545 437 for(int i = newAssignedResources.Count-1; i>=0; i--) { 546 if(newAssignedResources.Intersect( resourceAncestors[newAssignedResources.ElementAt(i).Id]).Any()) {438 if(newAssignedResources.Intersect(HiveClient.Instance.GetAvailableParentResources(newAssignedResources.ElementAt(i).Id)).Any()) { 547 439 newAssignedResources.Remove(newAssignedResources.ElementAt(i)); 548 440 } … … 556 448 if (JobId != Guid.Empty) { 557 449 foreach (var item in assignedResources) { 558 foreach (var descendant in resourceDescendants[item.Id]) {450 foreach (var descendant in HiveClient.Instance.GetAvailableChildResources(item.Id)) { 559 451 includedResources.Add(descendant); 560 452 } … … 563 455 564 456 foreach (var item in newAssignedResources) { 565 foreach (var descendant in resourceDescendants[item.Id]) {457 foreach (var descendant in HiveClient.Instance.GetAvailableChildResources(item.Id)) { 566 458 newIncludedResources.Add(descendant); 567 459 } … … 572 464 newIncludedResources.Clear(); 573 465 foreach (var item in newAssignedResources) { 574 foreach (var descendant in resourceDescendants[item.Id]) {466 foreach (var descendant in HiveClient.Instance.GetAvailableChildResources(item.Id)) { 575 467 newIncludedResources.Add(descendant); 576 }577 }578 }579 580 private void UpdateResourceGenealogy() {581 resourceAncestors.Clear();582 resourceDescendants.Clear();583 var resources = HiveClient.Instance.Resources;584 585 foreach (var r in resources) {586 resourceAncestors.Add(r.Id, new HashSet<Resource>());587 resourceDescendants.Add(r.Id, new HashSet<Resource>());588 }589 590 foreach (var r in resources) {591 var parentResourceId = r.ParentResourceId;592 while (parentResourceId != null) {593 var parent = resources.SingleOrDefault(x => x.Id == parentResourceId);594 if (parent != null) {595 resourceAncestors[r.Id].Add(parent);596 resourceDescendants[parent.Id].Add(r);597 parentResourceId = parent.ParentResourceId;598 } else {599 parentResourceId = null;600 }601 468 } 602 469 } … … 743 610 HashSet<Slave> newAssignedSlaves = new HashSet<Slave>(newAssignedResources.OfType<Slave>()); 744 611 foreach (var slaveGroup in newAssignedResources.OfType<SlaveGroup>()) { 745 foreach(var slave in resourceDescendants[slaveGroup.Id].OfType<Slave>()) {612 foreach(var slave in HiveClient.Instance.ResourceDescendants[slaveGroup.Id].OfType<Slave>()) { 746 613 newAssignedSlaves.Add(slave); 747 614 } … … 753 620 var slaveGroup = resource as SlaveGroup; 754 621 if (slaveGroup != null) { 755 selectedSlaves = new HashSet<Slave>( resourceDescendants[slaveGroup.Id].OfType<Slave>());622 selectedSlaves = new HashSet<Slave>(HiveClient.Instance.ResourceDescendants[slaveGroup.Id].OfType<Slave>()); 756 623 //selectedSlaves.IntersectWith(newAssignedSlaves); 757 624 } else { … … 771 638 } 772 639 773 private void ReColorTreeNodes(TreeNodeCollection nodes, Color c1, Color c2, bool resetText) { 640 private void StyleTreeNode(TreeNode n, string name) { 641 n.Text = name; 642 n.BackColor = Color.Transparent; 643 n.ForeColor = Color.Black; 644 } 645 646 private void ResetTreeNodes(TreeNodeCollection nodes) { 774 647 foreach (TreeNode n in nodes) { 775 if (n.BackColor.Equals(c1)) {776 n.BackColor = c2;777 if(resetText) n.Text = ((Project)n.Tag).Name;778 }648 string name = ""; 649 if (n.Tag is Project) name = ((Project)n.Tag).Name; 650 else if (n.Tag is Resource) name = ((Resource)n.Tag).Name; 651 StyleTreeNode(n, name); 779 652 if (n.Nodes.Count > 0) { 780 Re ColorTreeNodes(n.Nodes, c1, c2, resetText);653 ResetTreeNodes(n.Nodes); 781 654 } 782 655 } -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.cs
r15658 r15913 161 161 hiveResourceSelector.SelectedProjectId = selectedProjectId; 162 162 hiveResourceSelector.SelectedResourceIds = selectedResourceIds; 163 var projectList = new ItemList<Project>(HiveServiceLocator.Instance.CallHiveService(s => s.GetProjects())); 164 hiveResourceSelector.Content = projectList; 163 hiveResourceSelector.Content = HiveClient.Instance.Projects; 165 164 } 166 165 -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r15642 r15913 482 482 } 483 483 484 //private void updateButton_Click(object sender, EventArgs e) {485 // var task = System.Threading.Tasks.Task.Factory.StartNew(UpdateJobAsync, Content);486 // task.ContinueWith((t) => {487 // Content.Progress.Finish();488 // MessageBox.Show("An error occured updating the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);489 // Content.Log.LogException(t.Exception);490 // }, TaskContinuationOptions.OnlyOnFaulted);491 //}492 493 //private void UpdateJobAsync(object job) {494 // Content.Progress.Start("Updating job...");495 // HiveClient.UpdateJob((RefreshableJob)job);496 // Content.Progress.Finish();497 //}498 499 484 private void UnloadButton_Click(object sender, EventArgs e) { 500 485 Content.Unload(); -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/HiveTaskView.cs
r14185 r15913 211 211 } 212 212 } 213 214 private void coresNeededComboBox_SelectedIndexChanged(object sender, EventArgs e) { 215 if (int.TryParse(coresNeededComboBox.SelectedItem.ToString(), out int cores)) 216 Content.Task.CoresNeeded = cores; 217 } 213 218 } 214 219 } -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/HiveTaskView.designer.cs
r14185 r15913 292 292 "2", 293 293 "3", 294 "4"}); 294 "4", 295 "6", 296 "8", 297 "10", 298 "12"}); 295 299 this.coresNeededComboBox.Location = new System.Drawing.Point(134, 13); 296 300 this.coresNeededComboBox.Name = "coresNeededComboBox"; 297 301 this.coresNeededComboBox.Size = new System.Drawing.Size(134, 21); 298 302 this.coresNeededComboBox.TabIndex = 41; 303 this.coresNeededComboBox.SelectedIndexChanged += new System.EventHandler(this.coresNeededComboBox_SelectedIndexChanged); 299 304 // 300 305 // memoryNeededLabel -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r15742 r15913 67 67 } 68 68 69 private Dictionary<Guid, HashSet<Guid>> projectAncestors; 70 public Dictionary<Guid, HashSet<Guid>> ProjectAncestors { 71 get { return projectAncestors; } 72 } 73 74 private Dictionary<Guid, HashSet<Guid>> projectDescendants; 75 public Dictionary<Guid, HashSet<Guid>> ProjectDescendants { 76 get { return projectDescendants; } 77 } 78 79 private Dictionary<Guid, HashSet<Guid>> resourceAncestors; 80 public Dictionary<Guid, HashSet<Guid>> ResourceAncestors { 81 get { return resourceAncestors; } 82 } 83 84 private Dictionary<Guid, HashSet<Guid>> resourceDescendants; 85 public Dictionary<Guid, HashSet<Guid>> ResourceDescendants { 86 get { return resourceDescendants; } 87 } 88 69 89 70 90 private List<Plugin> onlinePlugins; … … 107 127 resources = new ItemList<Resource>(); 108 128 jobs = new HiveItemCollection<RefreshableJob>(); 129 130 projectAncestors = new Dictionary<Guid, HashSet<Guid>>(); 131 projectDescendants = new Dictionary<Guid, HashSet<Guid>>(); 132 resourceAncestors = new Dictionary<Guid, HashSet<Guid>>(); 133 resourceDescendants = new Dictionary<Guid, HashSet<Guid>>(); 109 134 110 135 HiveServiceLocator.Instance.CallHiveService(service => { … … 114 139 service.GetJobs().ForEach(p => jobs.Add(new RefreshableJob(p))); 115 140 }); 141 142 UpdateResourceGenealogy(); 143 UpdateProjectGenealogy(); 116 144 } 117 145 catch { … … 133 161 resources = new ItemList<Resource>(); 134 162 163 projectAncestors = new Dictionary<Guid, HashSet<Guid>>(); 164 projectDescendants = new Dictionary<Guid, HashSet<Guid>>(); 165 resourceAncestors = new Dictionary<Guid, HashSet<Guid>>(); 166 resourceDescendants = new Dictionary<Guid, HashSet<Guid>>(); 167 135 168 HiveServiceLocator.Instance.CallHiveService(service => { 136 169 service.GetProjects().ForEach(p => projects.Add(p)); … … 138 171 service.GetSlaves().ForEach(s => resources.Add(s)); 139 172 }); 173 174 UpdateResourceGenealogy(); 175 UpdateProjectGenealogy(); 140 176 } catch { 141 177 projects = null; … … 162 198 }, null); 163 199 } 164 200 201 private void UpdateResourceGenealogy() { 202 resourceAncestors.Clear(); 203 resourceDescendants.Clear(); 204 205 // fetch resource ancestor set 206 HiveServiceLocator.Instance.CallHiveService(service => { 207 var ra = service.GetResourceGenealogy(); 208 ra.Keys.ToList().ForEach(k => resourceAncestors.Add(k, new HashSet<Guid>())); 209 resourceAncestors.Keys.ToList().ForEach(k => resourceAncestors[k].UnionWith(ra[k])); 210 }); 211 212 // build resource descendant set 213 resourceAncestors.Keys.ToList().ForEach(k => resourceDescendants.Add(k, new HashSet<Guid>())); 214 foreach (var ra in resourceAncestors) { 215 foreach(var ancestor in ra.Value) { 216 resourceDescendants[ancestor].Add(ra.Key); 217 } 218 } 219 } 220 221 private void UpdateProjectGenealogy() { 222 projectAncestors.Clear(); 223 projectDescendants.Clear(); 224 225 // fetch project ancestor list 226 HiveServiceLocator.Instance.CallHiveService(service => { 227 var pa = service.GetProjectGenealogy(); 228 pa.Keys.ToList().ForEach(k => projectAncestors.Add(k, new HashSet<Guid>())); 229 projectAncestors.Keys.ToList().ForEach(k => projectAncestors[k].UnionWith(pa[k])); 230 }); 231 232 // build project descendant list 233 projectAncestors.Keys.ToList().ForEach(k => projectDescendants.Add(k, new HashSet<Guid>())); 234 foreach(var pa in projectAncestors) { 235 foreach(var ancestor in pa.Value) { 236 projectDescendants[ancestor].Add(pa.Key); 237 } 238 } 239 } 240 241 public IEnumerable<Project> GetAvailableParentProjects(Guid id) { 242 return projects.Where(x => projectAncestors[id].Contains(x.Id)); 243 } 244 245 public IEnumerable<Project> GetAvailableChildProjects(Guid id) { 246 return projects.Where(x => projectDescendants[id].Contains(x.Id)); 247 } 248 249 public IEnumerable<Resource> GetAvailableParentResources(Guid id) { 250 return resources.Where(x => resourceAncestors[id].Contains(x.Id)); 251 } 252 253 public IEnumerable<Resource> GetAvailableChildResources(Guid id) { 254 return resources.Where(x => resourceDescendants[id].Contains(x.Id)); 255 } 256 165 257 #endregion 166 258 … … 446 538 } 447 539 } 448 449 450 /// <summary>451 /// Uploads the given task and all its child-jobs while setting the proper parentJobId values for the childs452 /// </summary>453 /// <param name="parentHiveTask">shall be null if its the root task</param>454 //private void UploadTaskWithChildren_Old(IProgress progress, HiveTask hiveTask, HiveTask parentHiveTask, IEnumerable<Guid> groups, int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, CancellationToken cancellationToken) {455 // taskUploadSemaphore.WaitOne();456 // bool semaphoreReleased = false;457 // try {458 // cancellationToken.ThrowIfCancellationRequested();459 // lock (jobCountLocker) {460 // taskCount[0]++;461 // }462 // TaskData taskData;463 // List<IPluginDescription> plugins;464 465 // if (hiveTask.ItemTask.ComputeInParallel) {466 // hiveTask.Task.IsParentTask = true;467 // hiveTask.Task.FinishWhenChildJobsFinished = true;468 // taskData = hiveTask.GetAsTaskData(true, out plugins);469 // } else {470 // hiveTask.Task.IsParentTask = false;471 // hiveTask.Task.FinishWhenChildJobsFinished = false;472 // taskData = hiveTask.GetAsTaskData(false, out plugins);473 // }474 // cancellationToken.ThrowIfCancellationRequested();475 476 // TryAndRepeat(() => {477 // if (!cancellationToken.IsCancellationRequested) {478 // lock (pluginLocker) {479 // HiveServiceLocator.Instance.CallHiveService((s) => hiveTask.Task.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));480 // }481 // }482 // }, Settings.Default.MaxRepeatServiceCalls, "Failed to upload plugins");483 // cancellationToken.ThrowIfCancellationRequested();484 // hiveTask.Task.PluginsNeededIds.Add(configPluginId);485 // hiveTask.Task.JobId = jobId;486 487 // log.LogMessage(string.Format("Uploading task ({0} kb, {1} objects)", taskData.Data.Count() / 1024, hiveTask.ItemTask.GetObjectGraphObjects().Count()));488 // TryAndRepeat(() => {489 // if (!cancellationToken.IsCancellationRequested) {490 // if (parentHiveTask != null) {491 // hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddChildTask(parentHiveTask.Task.Id, hiveTask.Task, taskData));492 // } else {493 // hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData, groups.ToList()));494 // }495 // }496 // }, Settings.Default.MaxRepeatServiceCalls, "Failed to add task", log);497 // cancellationToken.ThrowIfCancellationRequested();498 499 // lock (jobCountLocker) {500 // progress.ProgressValue = (double)taskCount[0] / totalJobCount;501 // progress.Status = string.Format("Uploaded task ({0} of {1})", taskCount[0], totalJobCount);502 // }503 504 // var tasks = new List<TS.Task>();505 // foreach (HiveTask child in hiveTask.ChildHiveTasks) {506 // var task = TS.Task.Factory.StartNew((tuple) => {507 // var arguments = (Tuple<HiveTask, HiveTask>)tuple;508 // UploadTaskWithChildren_Old(progress, arguments.Item1, arguments.Item2, groups, taskCount, totalJobCount, configPluginId, jobId, log, cancellationToken);509 // }, new Tuple<HiveTask, HiveTask>(child, hiveTask));510 // task.ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted);511 // tasks.Add(task);512 // }513 // taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall!514 // TS.Task.WaitAll(tasks.ToArray());515 // }516 // finally {517 // if (!semaphoreReleased) taskUploadSemaphore.Release();518 // }519 //}520 521 540 #endregion 522 541 -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs
r15819 r15913 2449 2449 System.Collections.Generic.List<HeuristicLab.Clients.Hive.Project> GetProjectsForAdministration(); 2450 2450 2451 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetProjectGenealogy", ReplyAction="http://tempuri.org/IHiveService/GetProjectGenealogyResponse")] 2452 System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetProjectGenealogy(); 2453 2451 2454 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/SaveProjectPermissions", ReplyAction="http://tempuri.org/IHiveService/SaveProjectPermissionsResponse")] 2452 2455 void SaveProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds, bool reassign, bool cascading, bool reassignCascading); … … 2490 2493 System.Collections.Generic.List<HeuristicLab.Clients.Hive.SlaveGroup> GetSlaveGroupsForAdministration(); 2491 2494 2495 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetResourceGenealogy", ReplyAction="http://tempuri.org/IHiveService/GetResourceGenealogyResponse")] 2496 System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetResourceGenealogy(); 2497 2492 2498 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/UpdateSlave", ReplyAction="http://tempuri.org/IHiveService/UpdateSlaveResponse")] 2493 2499 void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave); … … 2754 2760 } 2755 2761 2762 public System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetProjectGenealogy() 2763 { 2764 return base.Channel.GetProjectGenealogy(); 2765 } 2766 2756 2767 public void SaveProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds, bool reassign, bool cascading, bool reassignCascading) 2757 2768 { … … 2819 2830 } 2820 2831 2832 public System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetResourceGenealogy() 2833 { 2834 return base.Channel.GetResourceGenealogy(); 2835 } 2836 2821 2837 public void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave) 2822 2838 { -
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
r15908 r15913 795 795 } 796 796 } 797 798 public IDictionary<Guid, HashSet<Guid>> GetProjectGenealogy() { 799 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 800 var pm = PersistenceManager; 801 using(new PerformanceLogger("GetProjectGenealogy")) { 802 var projectDao = pm.ProjectDao; 803 var projectAncestors = new Dictionary<Guid, HashSet<Guid>>(); 804 return pm.UseTransaction(() => { 805 var projects = projectDao.GetAll().ToList(); 806 projects.ForEach(p => projectAncestors.Add(p.ProjectId, new HashSet<Guid>())); 807 foreach (var p in projects) { 808 var parentProject = p.ParentProject; 809 while(parentProject != null) { 810 projectAncestors[p.ProjectId].Add(parentProject.ProjectId); 811 parentProject = parentProject.ParentProject; 812 } 813 } 814 return projectAncestors; 815 }); 816 } 817 } 797 818 #endregion 798 819 … … 1245 1266 } 1246 1267 1268 public IDictionary<Guid, HashSet<Guid>> GetResourceGenealogy() { 1269 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 1270 var pm = PersistenceManager; 1271 using (new PerformanceLogger("GetResourceGenealogy")) { 1272 var resourceDao = pm.ResourceDao; 1273 var resourceAncestors = new Dictionary<Guid, HashSet<Guid>>(); 1274 return pm.UseTransaction(() => { 1275 var resources = resourceDao.GetAll().ToList(); 1276 resources.ForEach(r => resourceAncestors.Add(r.ResourceId, new HashSet<Guid>())); 1277 1278 foreach(var r in resources) { 1279 var parentResource = r.ParentResource; 1280 while(parentResource != null) { 1281 resourceAncestors[r.ResourceId].Add(parentResource.ResourceId); 1282 parentResource = parentResource.ParentResource; 1283 } 1284 } 1285 return resourceAncestors; 1286 }); 1287 } 1288 } 1289 1247 1290 public void UpdateSlave(DT.Slave slaveDto) { 1248 1291 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); -
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs
r15819 r15913 154 154 [OperationContract] 155 155 IEnumerable<Project> GetProjectsForAdministration(); 156 157 [OperationContract] 158 IDictionary<Guid, HashSet<Guid>> GetProjectGenealogy(); 156 159 #endregion 157 160 … … 211 214 [OperationContract] 212 215 IEnumerable<SlaveGroup> GetSlaveGroupsForAdministration(); 216 217 [OperationContract] 218 IDictionary<Guid, HashSet<Guid>> GetResourceGenealogy(); 213 219 214 220 [OperationContract]
Note: See TracChangeset
for help on using the changeset viewer.