private void UpdateSelectorDialog() { if (hiveResourceSelectorDialog != null) { hiveResourceSelectorDialog = null; //hiveResourceSelectorDialog.JobId = Content.Job.Id; //hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; //hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; } }
private void searchButton_Click(object sender, EventArgs e) { if (hiveResourceSelectorDialog == null) { hiveResourceSelectorDialog = new HiveResourceSelectorDialog(); } if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) { StringBuilder sb = new StringBuilder(); foreach (Resource resource in hiveResourceSelectorDialog.GetSelectedResources()) { sb.Append(resource.Name); sb.Append(";"); } resourceNamesTextBox.Text = sb.ToString(); if (Content.Job.ResourceNames != resourceNamesTextBox.Text) { Content.Job.ResourceNames = resourceNamesTextBox.Text; } } }
private void searchButton_Click(object sender, EventArgs e) { if (hiveResourceSelectorDialog == null) hiveResourceSelectorDialog = new HiveResourceSelectorDialog(); if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) { StringBuilder sb = new StringBuilder(); foreach (Resource resource in hiveResourceSelectorDialog.GetSelectedResources()) { sb.Append(resource.Name); sb.Append(";"); } resourceNamesTextBox.Text = sb.ToString(); if (Content.Job.ResourceNames != resourceNamesTextBox.Text) Content.Job.ResourceNames = resourceNamesTextBox.Text; } }
private void searchButton_Click(object sender, EventArgs e) { if (hiveResourceSelectorDialog == null) { hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId); } else if (hiveResourceSelectorDialog.JobId != Content.Job.Id) { hiveResourceSelectorDialog.JobId = Content.Job.Id; hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; if (originalJobProjectAssignment.ContainsKey(Content.Job.Id)) { hiveResourceSelectorDialog.ProjectId = originalJobProjectAssignment[Content.Job.Id]; } else { hiveResourceSelectorDialog.ProjectId = Guid.Empty; } } else if (hiveResourceSelectorDialog.JobId == Guid.Empty && Content.Job.Id == Guid.Empty) { hiveResourceSelectorDialog.JobId = Content.Job.Id; hiveResourceSelectorDialog.ProjectId = Guid.Empty; hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; } else { hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; } if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) { selectedProject = hiveResourceSelectorDialog.SelectedProject; if (selectedProject != null) { Content.Job.ProjectId = selectedProject.Id; Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList(); var cores = hiveResourceSelectorDialog.SelectedResources .Union(hiveResourceSelectorDialog.SelectedResources .SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id))) .OfType <Slave>() .Distinct() .Sum(x => x.Cores); projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id) + ""; projectNameTextBox.Text += " (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)"; } else { selectedProject = null; projectNameTextBox.Text = string.Empty; Content.Job.ProjectId = Guid.Empty; Content.Job.ResourceIds = null; } SetEnabledStateOfExecutableButtons(); } }
protected override void OnContentChanged() { base.OnContentChanged(); SuppressEvents = true; try { if (Content == null) { nameTextBox.Text = string.Empty; descriptionTextBox.Text = string.Empty; executionTimeTextBox.Text = string.Empty; projectNameTextBox.Text = string.Empty; refreshAutomaticallyCheckBox.Checked = false; lock (runCollectionViewLocker) { runCollectionViewHost.Content = null; } logView.Content = null; jobsTreeView.Content = null; hiveExperimentPermissionListView.Content = null; stateLogViewHost.Content = null; } else { if (Content.Job != null && Content.Job.Id != Guid.Empty && !originalJobProjectAssignment.ContainsKey(Content.Job.Id)) { originalJobProjectAssignment.Add(Content.Job.Id, Content.Job.ProjectId); } // project look up if (Content.Job != null && Content.Job.ProjectId == Guid.Empty) { projectNameTextBox.Text = string.Empty; if (HiveClient.Instance != null && HiveClient.Instance.Projects != null && HiveClient.Instance.Projects.Count == 1) { var p = HiveClient.Instance.Projects.FirstOrDefault(); if (p != null && p.Id != Guid.Empty) { hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId); Content.Job.ProjectId = p.Id; var resources = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).ToList(); Content.Job.ResourceIds = resources.Select(x => x.Id).ToList(); hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; var cores = resources.Union(resources.SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id))) .OfType <Slave>() .Distinct() .Sum(x => x.Cores); projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(Content.Job.ProjectId); projectNameTextBox.Text += " (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)"; } } } else if (Content.Job != null && Content.Job.ProjectId != Guid.Empty) { if (selectedProject == null || selectedProject.Id != Content.Job.ProjectId) { selectedProject = GetProject(Content.Job.ProjectId); hiveResourceSelectorDialog = null; } if (hiveResourceSelectorDialog == null) { hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId); } if (selectedProject != null) { projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id); } else { projectNameTextBox.Text = string.Empty; } List <Resource> resources = null; if (Content.Job.ResourceIds == null) { resources = HiveClient.Instance.GetAssignedResourcesForJob(Content.Job.Id).ToList(); } else { resources = HiveClient.Instance.Resources.Where(x => Content.Job.ResourceIds.Contains(x.Id)).ToList(); } Content.Job.ResourceIds = resources.Select(x => x.Id).ToList(); hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; var cores = resources.Union(resources.SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id))) .OfType <Slave>() .Distinct() .Sum(x => x.Cores); projectNameTextBox.Text += " (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)"; } else { selectedProject = null; projectNameTextBox.Text = string.Empty; Content.Job.ResourceIds = null; } nameTextBox.Text = Content.Job.Name; descriptionTextBox.Text = Content.Job.Description; executionTimeTextBox.Text = Content.ExecutionTime.ToString(); refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically; logView.Content = Content.Log; lock (runCollectionViewLocker) { runCollectionViewHost.Content = GetAllRunsFromJob(Content); } } } finally { SuppressEvents = false; } hiveExperimentPermissionListView.Content = null; // has to be filled by refresh Content_JobStatisticsChanged(this, EventArgs.Empty); Content_HiveExperimentChanged(this, EventArgs.Empty); Content_HiveTasksChanged(this, EventArgs.Empty); Content_StateLogListChanged(this, EventArgs.Empty); HiveExperiment_PropertyChanged(this, new PropertyChangedEventArgs("Id")); SetEnabledStateOfControls(); }