private void UploadAsync() { var message = "Uploading runs to OKB..."; IProgress progress = MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); double count = dataGridView.Rows.Count; int i = 0; foreach (DataGridViewRow row in dataGridView.Rows) { i++; if (!Convert.ToBoolean(row.Cells[UploadColumn.Name].Value)) { continue; } selectedAlgorithm = algorithms.FirstOrDefault(x => x.Name == row.Cells[OKBAlgorithmColumn.Name].Value.ToString()); selectedProblem = problems.FirstOrDefault(x => x.Name == row.Cells[OKBProblemColumn.Name].Value.ToString()); if (selectedAlgorithm == null || selectedProblem == null) { throw new ArgumentException("Can't retrieve the algorithm/problem to upload"); } OKBRun run = new OKBRun(selectedAlgorithm.Id, selectedProblem.Id, row.Tag as IRun, UserInformation.Instance.User.Id); run.Store(); progress.ProgressValue = ((double)i) / count; } MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); ClearRuns(); }
private void Algorithm_Runs_ItemsAdded(object sender, CollectionItemsChangedEventArgs <IRun> e) { OKBProblem problem = Problem as OKBProblem; foreach (IRun run in e.Items) { if (problem != null) { OKBRun okbRun = new OKBRun(AlgorithmId, problem.ProblemId, run, UserId); runs.Add(okbRun); if (StoreRunsAutomatically) { okbRun.Store(); } } else { runs.Add(run); } } }