Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/18/18 14:07:32 (6 years ago)
Author:
ddorfmei
Message:

#2931: Merged [16168-16232/trunk] into branch

Location:
branches/2931_OR-Tools_LP_MIP
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2931_OR-Tools_LP_MIP

  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Clients.Hive.JobManager

  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r16139 r16235  
    139139          }
    140140
     141          // project look up
    141142          if (Content.Job != null && Content.Job.ProjectId == Guid.Empty) {
     143            projectNameTextBox.Text = string.Empty;
    142144            if (HiveClient.Instance != null && HiveClient.Instance.Projects != null && HiveClient.Instance.Projects.Count == 1) {
    143145              var p = HiveClient.Instance.Projects.FirstOrDefault();
     
    145147                hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
    146148                Content.Job.ProjectId = p.Id;
    147                 Content.Job.ResourceIds = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).Select(x => x.Id).ToList();
     149                var resources = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).ToList();
     150                Content.Job.ResourceIds = resources.Select(x => x.Id).ToList();
    148151                hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
    149152                hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     153
     154                var cores = resources.Union(resources.SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     155                  .OfType<Slave>()
     156                  .Distinct()
     157                  .Sum(x => x.Cores);
     158
     159                projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(Content.Job.ProjectId);
     160                projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
    150161              }               
    151162            }
    152           }
    153 
    154 
    155           nameTextBox.Text = Content.Job.Name;
    156           descriptionTextBox.Text = Content.Job.Description;
    157           executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    158           refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
    159 
    160           // project look up
    161           if(Content.Job.ProjectId != null && Content.Job.ProjectId != Guid.Empty) {
    162             if(selectedProject == null || selectedProject.Id != Content.Job.ProjectId) {
     163          } else if (Content.Job != null && Content.Job.ProjectId != Guid.Empty) {
     164            if (selectedProject == null || selectedProject.Id != Content.Job.ProjectId) {
    163165              selectedProject = GetProject(Content.Job.ProjectId);
    164               if (selectedProject != null) {
    165                 projectNameTextBox.Text = selectedProject.Name;
    166               } else {
    167                 projectNameTextBox.Text = string.Empty;
    168               }
     166              hiveResourceSelectorDialog = null;
    169167            }
     168
     169            if(hiveResourceSelectorDialog == null)
     170              hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
     171
     172            if (selectedProject != null) {
     173              projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id);
     174            } else {
     175              projectNameTextBox.Text = string.Empty;
     176            }
     177
     178            List<Resource> resources = null;
     179            if (Content.Job.ResourceIds == null)
     180              resources = HiveClient.Instance.GetAssignedResourcesForJob(Content.Job.Id).ToList();
     181            else
     182              resources = HiveClient.Instance.Resources.Where(x => Content.Job.ResourceIds.Contains(x.Id)).ToList();
     183
     184            Content.Job.ResourceIds = resources.Select(x => x.Id).ToList();
     185            hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     186
     187            var cores = resources.Union(resources.SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     188              .OfType<Slave>()
     189              .Distinct()
     190              .Sum(x => x.Cores);
     191
     192            projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
     193
    170194          } else {
    171195            selectedProject = null;
     
    173197            Content.Job.ResourceIds = null;
    174198          }
     199
     200
     201          nameTextBox.Text = Content.Job.Name;
     202          descriptionTextBox.Text = Content.Job.Description;
     203          executionTimeTextBox.Text = Content.ExecutionTime.ToString();
     204          refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
    175205         
    176206          logView.Content = Content.Log;
     
    182212        SuppressEvents = false;
    183213      }
    184       hiveExperimentPermissionListView.Content = null; // has to be filled by refresh button
     214      hiveExperimentPermissionListView.Content = null; // has to be filled by refresh
    185215      Content_JobStatisticsChanged(this, EventArgs.Empty);
    186216      Content_HiveExperimentChanged(this, EventArgs.Empty);
     
    400430      if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    401431        selectedProject = hiveResourceSelectorDialog.SelectedProject;
    402         if(selectedProject != null) {
    403           projectNameTextBox.Text = selectedProject.Name;
     432        if(selectedProject != null) {       
    404433          Content.Job.ProjectId = selectedProject.Id;
    405434          Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
     435
     436          var cores = hiveResourceSelectorDialog.SelectedResources
     437            .Union(hiveResourceSelectorDialog.SelectedResources
     438              .SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     439            .OfType<Slave>()
     440            .Distinct()
     441            .Sum(x => x.Cores);
     442
     443          projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id) + "";
     444          projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
     445
    406446        } else {
    407447          selectedProject = null;
     
    501541    }
    502542
    503     private void updateButton_Click2(object sender, EventArgs e) {
    504       if (Content.ExecutionState == ExecutionState.Stopped) {
    505         MessageBox.Show("Job cannot be updated once it stopped.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
    506         return;
    507       }
    508 
    509       HiveClient.UpdateJob(
    510         (Exception ex) => ErrorHandling.ShowErrorDialog(this, "Update failed.", ex),
    511         Content,
    512         new CancellationToken());
    513       UpdateSelectorDialog();
    514     }
    515 
    516543    private void updateButton_Click(object sender, EventArgs e) {
    517544      if (Content.ExecutionState == ExecutionState.Stopped) {
     
    556583      } else {
    557584        startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0
    558           && Content.Job.ProjectId != null && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null  && Content.Job.ResourceIds.Any()
     585          && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null  && Content.Job.ResourceIds.Any()
    559586          && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    560587        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
Note: See TracChangeset for help on using the changeset viewer.