private void startButton_Click(object sender, EventArgs e) { if (nameTextBox.Text.Trim() == string.Empty) { MessageBox.Show("Please enter a name for the job before uploading it!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Content.Job.ProjectId == null || Content.Job.ProjectId == Guid.Empty) { MessageBox.Show("Please select a project before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Content.Job.ResourceIds == null || !Content.Job.ResourceIds.Any()) { MessageBox.Show("Please select resources before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Content.ExecutionState == ExecutionState.Paused) { var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content); task.ContinueWith((t) => { Content.Progress.Finish(); MessageBox.Show("An error occured resuming the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); Content.Log.LogException(t.Exception); }, TaskContinuationOptions.OnlyOnFaulted); } else { HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken()); UpdateSelectorDialog(); } }
public override void Execute() { IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; content = activeView.Content as IItem; //IOptimizer and IExecutables need some special care if (content is IOptimizer) { ((IOptimizer)content).Runs.Clear(); } if (content is IExecutable) { IExecutable exec = content as IExecutable; if (exec.ExecutionState != ExecutionState.Prepared) { exec.Prepare(); } } HiveClient.Instance.Refresh(); ItemTask hiveTask = ItemTask.GetItemTaskForItem(content); HiveTask task = hiveTask.CreateHiveTask(); RefreshableJob rJob = new RefreshableJob(); rJob.Job.Name = content.ToString(); rJob.HiveTasks.Add(task); task.ItemTask.ComputeInParallel = content is Experiment || content is BatchRun; var hiveResourceSelectorDialog = new HiveResourceSelectorDialog(rJob.Job.Id, rJob.Job.ProjectId); if (HiveClient.Instance.Projects.Count == 1) { var project = HiveClient.Instance.Projects.FirstOrDefault(); if (project != null && project.Id != Guid.Empty) { hiveResourceSelectorDialog.SelectedProjectId = project.Id; } } if (hiveResourceSelectorDialog.ShowDialog((UserControl)activeView) == DialogResult.OK) { var selectedProject = hiveResourceSelectorDialog.SelectedProject; if (selectedProject != null) { rJob.Job.ProjectId = selectedProject.Id; rJob.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList(); progress = Progress.Show(this.content, "Uploading to Hive...", ProgressMode.Indeterminate); rJob.Progress = progress; progress.ProgressStateChanged += progress_ProgressStateChanged; HiveClient.StartJob(new Action <Exception>(HandleEx), rJob, new CancellationToken()); } } }
public override void Execute() { IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; content = activeView.Content as IItem; //IOptimizer and IExecutables need some special care if (content is IOptimizer) { ((IOptimizer)content).Runs.Clear(); } if (content is IExecutable) { IExecutable exec = content as IExecutable; if (exec.ExecutionState != ExecutionState.Prepared) { exec.Prepare(); } } HiveClient.Instance.Refresh(); ItemTask hiveTask = ItemTask.GetItemTaskForItem(content); HiveTask task = hiveTask.CreateHiveTask(); RefreshableJob rJob = new RefreshableJob(); rJob.Job.Name = content.ToString(); rJob.HiveTasks.Add(task); task.ItemTask.ComputeInParallel = content is Experiment || content is BatchRun; progress = MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().AddOperationProgressToContent(this.content, "Uploading to Hive..."); rJob.Progress = progress; progress.ProgressStateChanged += progress_ProgressStateChanged; HiveClient.StartJob(new Action <Exception>(HandleEx), rJob, new CancellationToken()); }