Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15642


Ignore:
Timestamp:
01/23/18 14:00:03 (6 years ago)
Author:
jzenisek
Message:

#2839

  • adapted handling of cascading revocations of project-user permissions and project-resource assignments: from deleting all AssignedJobResource (formerly) to deleting only entries which are effected by the previously mentioned revocations (now)
  • implemented job update (client side)
  • corrected & improved stateful project/resource selection dialog
  • corrected resource statistic calculation in project/resource selection dialog
Location:
branches/HiveProjectManagement
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectPermissionsView.cs

    r15580 r15642  
    9494    private async void inheritButton_Click(object sender, EventArgs e) {
    9595      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    96         action: () => SetGrantedProjectPermissions(Content.Id, newAssignedPermissions.Select(x => x.Id), false, true, true));
     96        action: () => SetGrantedProjectPermissions(Content.Id, newAssignedPermissions.Select(x => x.Id), false, true, false));
    9797      UpdatePermissionList();
    9898    }
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs

    r15627 r15642  
    100100      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    101101        action: () => {
    102           SetAssignedProjectResources(Content.Id, newAssignedResources.Select(x => x.Id), false, true);
     102          SetAssignedProjectResources(Content.Id, newAssignedResources.Select(x => x.Id), false, true, false);
    103103        });
    104104      UpdateResourceTree();
     
    108108      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    109109        action: () => {
    110           SetAssignedProjectResources(Content.Id, newAssignedResources.Select(x => x.Id), false, false);
     110          SetAssignedProjectResources(Content.Id, newAssignedResources.Select(x => x.Id), false, false, false);
    111111        });
    112112      UpdateResourceTree();
     
    156156    }
    157157
    158     private void SetAssignedProjectResources(Guid projectId, IEnumerable<Guid> resourceIds, bool reassign, bool cascading) {
     158    private void SetAssignedProjectResources(Guid projectId, IEnumerable<Guid> resourceIds, bool reassign, bool cascading, bool reassignCascading) {
    159159      if (projectId == null || resourceIds == null) return;
    160160      HiveServiceLocator.Instance.CallHiveService(s => {
    161        s.SaveProjectResourceAssignments(projectId, resourceIds.ToList(), reassign, cascading, true);
     161       s.SaveProjectResourceAssignments(projectId, resourceIds.ToList(), reassign, cascading, reassignCascading);
    162162      });
    163163    }
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r15627 r15642  
    7272    private string currentSearchString;
    7373
     74    private void resetHiveResourceSelector() {
     75      lastSelectedProject = null;
     76      selectedProject = null;
     77      projectId = null;
     78    }
     79
    7480    private Guid jobId;
    7581    public Guid JobId {
     
    7884        if (jobId == value) return;
    7985        jobId = value;
     86        resetHiveResourceSelector();
    8087      }
    8188    }
     
    99106    }
    100107
    101     public bool ChangedProject {
    102       get {
    103         return (selectedProject == null || selectedProject.Id == projectId) ? false : true;
     108    private IEnumerable<Guid> selectedResourceIds;
     109    public IEnumerable<Guid> SelectedResourceIds {
     110      get { return selectedResourceIds; }
     111      set {
     112        if (selectedResourceIds == value) return;
     113        selectedResourceIds = value;
    104114      }
    105115    }
     
    128138        selectedProject = value;
    129139        UpdateResourceTree();
     140        ExtractStatistics();
    130141        OnSelectedProjectChanged();
    131142      }
    132143    }
     144
    133145    public IEnumerable<Resource> AssignedResources {
    134146      get { return newAssignedResources; }
     
    142154    }
    143155
     156
    144157    public new IItemList<Project> Content {
    145158      get { return (IItemList<Project>)base.Content; }
     
    164177        UpdateResourceGenealogy();
    165178       
    166         if (SelectedProjectId.HasValue) {
     179        if (SelectedProjectId.HasValue && SelectedProjectId.Value != Guid.Empty) {
    167180          SelectedProject = GetSelectedProjectById(SelectedProjectId.Value);
    168181        } else {
    169182          SelectedProject = null;
    170183        }
     184        //ExtractStatistics();
    171185        UpdateProjectTree();
    172186
    173187      } else {
     188        lastSelectedProject = null;
     189        selectedProject = null;
     190        selectedProjectId = null;
    174191        projectsTreeView.Nodes.Clear();
    175192        resourcesTreeView.Nodes.Clear();
     
    183200      projectsTreeView.Nodes.Clear();
    184201      resourcesTreeView.Nodes.Clear();
    185       //SelectedProject = null;
    186202    }
    187203
     
    213229        }
    214230
    215         SelectedProject = node;
    216       }
    217 
    218       ExtractStatistics();
     231       
     232      }
     233      SelectedProject = node;
     234      //ExtractStatistics();
    219235    }
    220236
     
    243259
    244260      UpdateNewResourceTree();
     261      ExtractStatistics();
    245262      //ExtractStatistics((Resource)resourcesTreeView.SelectedNode?.Tag);
    246263      OnAssignedResourcesChanged();
     
    483500        }
    484501      }
    485       ExtractStatistics();
     502      //ExtractStatistics();
    486503      //OnAssignedResourcesChanged();
    487504    }
    488505
    489506    private void UpdateAssignedResources() {
    490 
    491       if (JobId == Guid.Empty && ChangedProjectSelection) { // new, unchanged jobs get all avaialable resources
     507      assignedResources.Clear();
     508      newAssignedResources.Clear();
     509
     510      if (JobId == Guid.Empty || JobId == null) { // new, unchanged jobs get all avaialable resources
    492511        // update new assigned resources
    493         assignedResources.Clear();
    494         newAssignedResources.Clear();
    495         foreach (var resource in availableResources
    496           .Where(x => !x.ParentResourceId.HasValue
    497           || !availableResources.Select(y => y.Id).Contains(x.ParentResourceId.Value))) {
    498           newAssignedResources.Add(resource);
    499         }
    500 
    501       } else if(JobId != Guid.Empty) { // existent, unchanged jobs get all assigned resources
     512        if(selectedResourceIds == null) {
     513          foreach (var resource in availableResources
     514            .Where(x => !x.ParentResourceId.HasValue
     515            || !availableResources.Select(y => y.Id).Contains(x.ParentResourceId.Value))) {
     516            newAssignedResources.Add(resource);
     517          }
     518        } else {
     519          foreach(var resource in availableResources.Where(x => selectedResourceIds.Contains(x.Id))) {
     520            newAssignedResources.Add(resource);
     521          }
     522        }
     523      } else { // existent, unchanged jobs get all assigned resources
    502524        // update assigned resources
    503525        var assignedJobResources = GetAssignedResourcesForJob(JobId);
    504526        foreach (var resource in assignedJobResources) {
    505527          assignedResources.Add(resource);
    506         }
    507 
    508         if(ChangedProjectSelection) {
    509           newAssignedResources.Clear();
    510           foreach (var resource in assignedJobResources) {
     528          if (selectedResourceIds == null) {
    511529            newAssignedResources.Add(resource);
    512530          }
    513531        }
    514       } else {
    515         var newAssignedResourceIds = newAssignedResources.Select(x => x.Id).ToList();
    516         newAssignedResources.Clear();
    517         foreach(var r in availableResources.Where(x => newAssignedResourceIds.Contains(x.Id))) {
    518           newAssignedResources.Add(r);
    519         }
    520       }
    521 
    522       ExtractStatistics();
     532
     533        if(selectedResourceIds != null) {
     534          foreach (var resource in availableResources.Where(x => selectedResourceIds.Contains(x.Id))) {
     535            newAssignedResources.Add(resource);
     536          }
     537        }
     538      }
     539
     540      //ExtractStatistics();
    523541      OnAssignedResourcesChanged();
    524542    }
     
    535553      includedResources.Clear();
    536554      newIncludedResources.Clear();
     555
    537556      if (JobId != Guid.Empty) {
    538557        foreach (var item in assignedResources) {
    539558          foreach (var descendant in resourceDescendants[item.Id]) {
    540559            includedResources.Add(descendant);
    541             newIncludedResources.Add(descendant);
    542           }
    543         }
    544       } else {
    545         foreach (var item in newAssignedResources) {
    546           foreach (var descendant in resourceDescendants[item.Id]) {
    547             newIncludedResources.Add(descendant);
    548           }
     560          }
     561        }
     562      }
     563
     564      foreach (var item in newAssignedResources) {
     565        foreach (var descendant in resourceDescendants[item.Id]) {
     566          newIncludedResources.Add(descendant);
    549567        }
    550568      }
     
    722740    }
    723741
    724     private void ExtractStatistics(Resource resource = null) {
    725       ISet<Slave> selectedSlaves = null;
     742    private void ExtractStatistics(Resource resource = null) {
     743      HashSet<Slave> newAssignedSlaves = new HashSet<Slave>(newAssignedResources.OfType<Slave>());
     744      foreach (var slaveGroup in newAssignedResources.OfType<SlaveGroup>()) {
     745        foreach(var slave in resourceDescendants[slaveGroup.Id].OfType<Slave>()) {
     746          newAssignedSlaves.Add(slave);
     747        }
     748      }
     749
     750      HashSet<Slave> selectedSlaves = null;
    726751
    727752      if (resource != null) {
    728 
    729 
    730753        var slaveGroup = resource as SlaveGroup;
    731754        if (slaveGroup != null) {
    732755          selectedSlaves = new HashSet<Slave>(resourceDescendants[slaveGroup.Id].OfType<Slave>());
    733           selectedSlaves.IntersectWith(newAssignedResources.OfType<Slave>());
     756          //selectedSlaves.IntersectWith(newAssignedSlaves);
    734757        } else {
    735758          selectedSlaves = new HashSet<Slave>(new[] { resource as Slave });
    736759        }
    737760      } else {
    738         selectedSlaves = new HashSet<Slave>(newAssignedResources.OfType<Slave>());
    739       }
    740 
    741       int sumCores = selectedSlaves.OfType<Slave>().Sum(x => x.Cores.GetValueOrDefault());
    742       int sumFreeCores = selectedSlaves.OfType<Slave>().Sum(x => x.FreeCores.GetValueOrDefault());
    743       double sumMemory = selectedSlaves.OfType<Slave>().Sum(x => x.Memory.GetValueOrDefault()) / 1024.0;
    744       double sumFreeMemory = selectedSlaves.OfType<Slave>().Sum(x => x.FreeMemory.GetValueOrDefault()) / 1024.0;
     761        selectedSlaves = newAssignedSlaves;
     762      }
     763
     764      int sumCores = selectedSlaves.Sum(x => x.Cores.GetValueOrDefault());
     765      int sumFreeCores = selectedSlaves.Sum(x => x.FreeCores.GetValueOrDefault());
     766      double sumMemory = selectedSlaves.Sum(x => x.Memory.GetValueOrDefault()) / 1024.0;
     767      double sumFreeMemory = selectedSlaves.Sum(x => x.FreeMemory.GetValueOrDefault()) / 1024.0;
    745768
    746769      coresSummaryLabel.Text = $"{sumCores} Total ({sumFreeCores} Free / {sumCores - sumFreeCores} Used)";
     
    760783    }
    761784
    762     private void ExtractStatistics_Old(Resource resource = null) {
    763       ISet<Slave> selectedSlaves = null;
    764 
    765       if (resource != null) {
    766         var slaveGroup = resource as SlaveGroup;
    767         if (slaveGroup != null) {
    768           var children = new HashSet<Resource>(availableResources.Where(x => x.ParentResourceId == slaveGroup.Id));
    769           int nrOfChildren = children.Count;
    770           do {
    771             var newChildren = availableResources.Where(x => children.Any(y => y.Id == x.ParentResourceId));
    772             foreach (var newChild in newChildren)
    773               children.Add(newChild);
    774           } while (children.Count > nrOfChildren);
    775           selectedSlaves = new HashSet<Slave>(children.OfType<Slave>());
    776           selectedSlaves.IntersectWith(assignedResources.OfType<Slave>());
    777         } else {
    778           selectedSlaves = new HashSet<Slave>(new[] { resource as Slave });
    779         }
    780       } else {
    781         selectedSlaves = new HashSet<Slave>(assignedResources.OfType<Slave>());
    782       }
    783 
    784       int sumCores = selectedSlaves.OfType<Slave>().Sum(x => x.Cores.GetValueOrDefault());
    785       int sumFreeCores = selectedSlaves.OfType<Slave>().Sum(x => x.FreeCores.GetValueOrDefault());
    786       double sumMemory = selectedSlaves.OfType<Slave>().Sum(x => x.Memory.GetValueOrDefault()) / 1024.0;
    787       double sumFreeMemory = selectedSlaves.OfType<Slave>().Sum(x => x.FreeMemory.GetValueOrDefault()) / 1024.0;
    788 
    789       coresSummaryLabel.Text = $"{sumCores} Total ({sumFreeCores} Free / {sumCores - sumFreeCores} Used)";
    790       memorySummaryLabel.Text = $"{sumMemory:0.00} GB Total ({sumFreeMemory:0.00} GB Free / {(sumMemory - sumFreeMemory):0.00} GB Used)";
    791     }
    792 
    793     private Resource BuildResourceTree_Old(IEnumerable<Resource> resources) {
    794       resourcesTreeView.Nodes.Clear();
    795       if (!resources.Any()) return null;
    796 
    797       var mainResources = new HashSet<Resource>(resources.Where(x => x.ParentResourceId == null));
    798       var subResources = new HashSet<Resource>(resources.Except(mainResources));
    799 
    800       var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name));
    801       var top = stack.Peek();
    802 
    803       TreeNode currentNode = null;
    804       Resource currentResource = null;
    805 
    806       while (stack.Any()) {
    807         var newResource = stack.Pop();
    808         var newNode = new TreeNode(newResource.Name) {
    809           Checked = true,
    810           ImageIndex = newResource is Slave ? slaveImageIndex : slaveGroupImageIndex,
    811           Tag = newResource
    812         };
    813 
    814         while (currentNode != null && newResource.ParentResourceId != currentResource.Id) {
    815           currentNode = currentNode.Parent;
    816           currentResource = currentNode == null ? null : (Resource)currentNode.Tag;
    817         }
    818 
    819         if (currentNode == null) {
    820           resourcesTreeView.Nodes.Add(newNode);
    821         } else {
    822           currentNode.Nodes.Add(newNode);
    823         }
    824 
    825         newNode.SelectedImageIndex = newNode.ImageIndex;
    826 
    827         var childResources = subResources.Where(x => x.ParentResourceId == newResource.Id);
    828         if (childResources.Any()) {
    829           foreach (var resource in childResources.OrderByDescending(x => x.Name)) {
    830             subResources.Remove(resource);
    831             stack.Push(resource);
    832           }
    833           currentNode = newNode;
    834           currentResource = newResource;
    835         }
    836       }
    837 
    838       resourcesTreeView.ExpandAll();
    839 
    840       return top;
    841     }
    842 
    843785    #endregion
    844786
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.cs

    r15627 r15642  
    5555    }
    5656
    57     // currently selected projectId (initially persisted projectId)
     57    // currently selected projectId (initially the persisted projectId)
    5858    private Guid? selectedProjectId;
    5959    public Guid? SelectedProjectId {
     
    6161      set { selectedProjectId = value; }
    6262    }
     63
     64    // currently selected resourceIds (if null, perform lookup in HiveResourceSelector)
     65    private IEnumerable<Guid> selectedResourceIds;
     66    public IEnumerable<Guid> SelectedResourceIds {
     67      get { return selectedResourceIds; }
     68      set { selectedResourceIds = value; }
     69    }
     70
    6371
    6472
     
    135143    private void hiveResourceSelector_ProjectsTreeViewDoubleClicked(object sender, EventArgs e) {
    136144      if (hiveResourceSelector.SelectedProject == null) return;
     145      if (!hiveResourceSelector.AssignedResources.Any()) return;
    137146
    138147      DialogResult = DialogResult.OK;
     
    147156      hiveResourceSelector.ProjectId = projectId;
    148157      hiveResourceSelector.SelectedProjectId = selectedProjectId;
     158      hiveResourceSelector.SelectedResourceIds = selectedResourceIds;
    149159      var projectList = new ItemList<Project>(HiveServiceLocator.Instance.CallHiveService(s => s.GetProjects()));
    150160      hiveResourceSelector.Content = projectList;
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs

    r15412 r15642  
    6868      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    6969      this.refreshButton = new System.Windows.Forms.Button();
     70      this.updateButton = new System.Windows.Forms.Button();
    7071      this.UnloadButton = new System.Windows.Forms.Button();
    7172      this.refreshAutomaticallyCheckBox = new System.Windows.Forms.CheckBox();
     
    337338      this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
    338339      //
     340      // updateButton
     341      //
     342      this.updateButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save;
     343      this.updateButton.Location = new System.Drawing.Point(30, 0);
     344      this.updateButton.Name = "updateButton";
     345      this.updateButton.Size = new System.Drawing.Size(24, 24);
     346      this.updateButton.TabIndex = 23;
     347      this.toolTip.SetToolTip(this.updateButton, "Update Job (Name, Project, Resources)");
     348      this.updateButton.UseVisualStyleBackColor = true;
     349      this.updateButton.Click += new System.EventHandler(this.updateButton_Click);
     350      //
    339351      // UnloadButton
    340352      //
    341353      this.UnloadButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Disconnect;
    342       this.UnloadButton.Location = new System.Drawing.Point(30, 0);
     354      this.UnloadButton.Location = new System.Drawing.Point(57, 0);
    343355      this.UnloadButton.Name = "UnloadButton";
    344356      this.UnloadButton.Size = new System.Drawing.Size(24, 24);
     
    351363      //
    352364      this.refreshAutomaticallyCheckBox.AutoSize = true;
    353       this.refreshAutomaticallyCheckBox.Location = new System.Drawing.Point(70, 3);
     365      this.refreshAutomaticallyCheckBox.Location = new System.Drawing.Point(100, 3);
    354366      this.refreshAutomaticallyCheckBox.Name = "refreshAutomaticallyCheckBox";
    355367      this.refreshAutomaticallyCheckBox.Size = new System.Drawing.Size(127, 17);
     
    457469      //
    458470      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    459       this.Controls.Add(this.UnloadButton);
    460471      this.Controls.Add(this.searchButton);
    461472      this.Controls.Add(this.infoGroupBox);
    462473      this.Controls.Add(this.refreshAutomaticallyCheckBox);
    463474      this.Controls.Add(this.refreshButton);
     475      this.Controls.Add(this.updateButton);
     476      this.Controls.Add(this.UnloadButton);
    464477      this.Controls.Add(this.nameTextBox);
    465478      this.Controls.Add(this.nameLabel);
     
    503516    private System.Windows.Forms.ToolTip toolTip;
    504517    private System.Windows.Forms.Button refreshButton;
     518    private System.Windows.Forms.Button updateButton;
     519    private System.Windows.Forms.Button UnloadButton;
    505520    private System.Windows.Forms.CheckBox refreshAutomaticallyCheckBox;
    506521    private System.Windows.Forms.GroupBox infoGroupBox;
     
    520535    private System.Windows.Forms.Button searchButton;
    521536    private MainForm.WindowsForms.DragOverTabControl tabControl;
    522     private System.Windows.Forms.Button UnloadButton;
    523 
    524537  }
    525538}
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r15627 r15642  
    4646    private object runCollectionViewLocker = new object();
    4747    private Project selectedProject;
     48    private Dictionary<Guid, Guid> originalJobProjectAssignment = new Dictionary<Guid, Guid>();
    4849
    4950    public new RefreshableJob Content {
    5051      get { return (RefreshableJob)base.Content; }
    51       set { base.Content = value; }
     52      set {
     53        base.Content = value;
     54      }
    5255    }
    5356
     
    129132          stateLogViewHost.Content = null;
    130133        } else {
     134          if(Content.Job != null
     135            && Content.Job.Id != Guid.Empty
     136            && !originalJobProjectAssignment.ContainsKey(Content.Job.Id)) {
     137            originalJobProjectAssignment.Add(Content.Job.Id, Content.Job.ProjectId);
     138          }
     139
    131140          nameTextBox.Text = Content.Job.Name;
    132141          executionTimeTextBox.Text = Content.ExecutionTime.ToString();
     
    135144          // project look up
    136145          if(Content.Job.ProjectId != null && Content.Job.ProjectId != Guid.Empty) {
    137             selectedProject = GetProject(Content.Job.ProjectId);
    138             if(selectedProject != null) {
    139               projectNameTextBox.Text = selectedProject.Name;
    140             } else {
    141               projectNameTextBox.Text = string.Empty;
     146            if(selectedProject == null || selectedProject.Id != Content.Job.ProjectId) {
     147              selectedProject = GetProject(Content.Job.ProjectId);
     148              if (selectedProject != null) {
     149                projectNameTextBox.Text = selectedProject.Name;
     150              } else {
     151                projectNameTextBox.Text = string.Empty;
     152              }
    142153            }
    143154          } else {
    144155            selectedProject = null;
    145156            projectNameTextBox.Text = string.Empty;
     157            Content.Job.ResourceIds = null;
    146158          }
    147159         
     
    195207          tabControl.Enabled = !Content.IsProgressing;
    196208
    197           this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    198           this.searchButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Prepared && !alreadyUploaded && !Content.IsProgressing;
     209          this.nameTextBox.ReadOnly = Content.IsProgressing;
     210          this.searchButton.Enabled = !Content.IsProgressing && Content.ExecutionState != ExecutionState.Stopped;
    199211          this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    200212
    201213          this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    202214          this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing;
     215          this.updateButton.Enabled = Content.ExecutionState != ExecutionState.Prepared && Content.ExecutionState != ExecutionState.Stopped && !Content.IsProgressing;
    203216
    204217          this.UnloadButton.Enabled = Content.HiveTasks != null && Content.HiveTasks.Count > 0 && alreadyUploaded && !Content.IsProgressing;
     
    347360      if (hiveResourceSelectorDialog == null) {
    348361        hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
    349       } else if(selectedProject != null) {
     362      } else if(hiveResourceSelectorDialog.JobId != Content.Job.Id) {
     363        hiveResourceSelectorDialog.JobId = Content.Job.Id;
    350364        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     365        hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     366
     367        if (originalJobProjectAssignment.ContainsKey(Content.Job.Id)) {
     368          hiveResourceSelectorDialog.ProjectId = originalJobProjectAssignment[Content.Job.Id];
     369        } else {
     370          hiveResourceSelectorDialog.ProjectId = Guid.Empty;
     371        }
     372      } else if(hiveResourceSelectorDialog.JobId == Guid.Empty && Content.Job.Id == Guid.Empty) {
     373        hiveResourceSelectorDialog.JobId = Content.Job.Id;
     374        hiveResourceSelectorDialog.ProjectId = Guid.Empty;
     375        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     376        hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
    351377      } else {
    352         hiveResourceSelectorDialog.SelectedProjectId = null;
     378        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     379        hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
    353380      }
    354381
     
    360387          Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
    361388        } else {
     389          selectedProject = null;
    362390          projectNameTextBox.Text = string.Empty;
    363391          Content.Job.ProjectId = Guid.Empty;
     
    447475    }
    448476
     477    private void updateButton_Click(object sender, EventArgs e) {
     478      HiveClient.UpdateJob(
     479        (Exception ex) => ErrorHandling.ShowErrorDialog(this, "Update failed.", ex),
     480        Content,
     481        new CancellationToken());
     482    }
     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    private void UnloadButton_Click(object sender, EventArgs e) {
     500      Content.Unload();
     501      runCollectionViewHost.Content = null;
     502      stateLogViewHost.Content = null;
     503      hiveExperimentPermissionListView.Content = null;
     504      jobsTreeView.Content = null;
     505
     506      SetEnabledStateOfControls();
     507    }
     508
    449509    private void refreshPermissionsButton_Click(object sender, EventArgs e) {
    450510      if (this.Content.Job.Id == Guid.Empty) {
     
    544604    }
    545605
    546     private void UnloadButton_Click(object sender, EventArgs e) {
    547       Content.Unload();
    548       runCollectionViewHost.Content = null;
    549       stateLogViewHost.Content = null;
    550       hiveExperimentPermissionListView.Content = null;
    551       jobsTreeView.Content = null;
    552 
    553       SetEnabledStateOfControls();
    554     }
    555606  }
    556607}
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r15630 r15642  
    249249    }
    250250
     251    public static void UpdateJob(Action<Exception> exceptionCallback, RefreshableJob refreshableJob, CancellationToken cancellationToken) {
     252      HiveServiceLocator.Instance.CallHiveService(service => {
     253        HiveClient.StoreAsync(
     254          new Action<Exception>((Exception ex) => {
     255            //refreshableJob.ExecutionState = ExecutionState.Prepared;
     256            exceptionCallback(ex);
     257          }), refreshableJob.Job, cancellationToken);
     258      });
     259    }
     260
    251261    #region Upload Job
    252262    private Semaphore taskUploadSemaphore = new Semaphore(Settings.Default.MaxParallelUploads, Settings.Default.MaxParallelUploads);
Note: See TracChangeset for help on using the changeset viewer.