[1030] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
[1018] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.ComponentModel;
|
---|
| 25 | using System.Data;
|
---|
| 26 | using System.Drawing;
|
---|
| 27 | using System.Linq;
|
---|
| 28 | using System.Text;
|
---|
| 29 | using System.Windows.Forms;
|
---|
| 30 | using HeuristicLab.Hive.Contracts.Interfaces;
|
---|
| 31 | using HeuristicLab.Hive.Contracts.BusinessObjects;
|
---|
| 32 | using HeuristicLab.Hive.Contracts;
|
---|
[1120] | 33 | using HeuristicLab.Hive.JobBase;
|
---|
| 34 | using HeuristicLab.Core;
|
---|
[1018] | 35 |
|
---|
[1089] | 36 | namespace HeuristicLab.Hive.Server.ServerConsole {
|
---|
[1018] | 37 | public partial class AddJobForm : Form {
|
---|
| 38 |
|
---|
| 39 | ResponseList<Job> jobGroups = null;
|
---|
| 40 | IJobManager jobManager;
|
---|
| 41 |
|
---|
| 42 | public AddJobForm() {
|
---|
| 43 | InitializeComponent();
|
---|
[1037] | 44 | AddJob();
|
---|
[1018] | 45 | }
|
---|
| 46 |
|
---|
[1037] | 47 | private void AddJob() {
|
---|
[1018] | 48 | jobManager =
|
---|
| 49 | ServiceLocator.GetJobManager();
|
---|
| 50 | jobGroups = jobManager.GetAllJobs();
|
---|
| 51 | cbParJob.Items.Add("none");
|
---|
| 52 | cbParJob.SelectedIndex = 0;
|
---|
| 53 | foreach (Job job in jobGroups.List) {
|
---|
| 54 | cbParJob.Items.Add(job.Id);
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 |
|
---|
[1037] | 58 | private void BtnAdd_Click(object sender, EventArgs e) {
|
---|
[1030] | 59 | try {
|
---|
| 60 | lblError.Text = "";
|
---|
| 61 | int numJobs = Convert.ToInt32(tbNumJobs.Text);
|
---|
| 62 | if (numJobs > 0) {
|
---|
| 63 | for (int i = 0; i < numJobs; i++) {
|
---|
| 64 | if (cbParJob.SelectedIndex != 0) {
|
---|
| 65 | foreach (Job pjob in jobGroups.List) {
|
---|
| 66 | if (cbParJob.SelectedItem.ToString().Equals(pjob.Id.ToString())) {
|
---|
| 67 | Job job = new Job { ParentJob = pjob, State = State.offline };
|
---|
[1120] | 68 | job.SerializedJob = PersistenceManager.SaveToGZip(new TestJob());
|
---|
[1030] | 69 | Response resp = jobManager.AddNewJob(job);
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 | } else {
|
---|
| 73 | Job job = new Job { State = State.offline };
|
---|
[1120] | 74 | job.SerializedJob = PersistenceManager.SaveToGZip(new TestJob());
|
---|
[1030] | 75 | Response resp = jobManager.AddNewJob(job);
|
---|
| 76 | }
|
---|
[1018] | 77 | }
|
---|
[1030] | 78 | this.Close();
|
---|
| 79 | } else {
|
---|
| 80 | lblError.Text = "Wrong number of Jobs";
|
---|
[1018] | 81 | }
|
---|
[1030] | 82 |
|
---|
[1018] | 83 | }
|
---|
[1030] | 84 | catch {
|
---|
| 85 | lblError.Text = "There should be a number";
|
---|
| 86 | }
|
---|
[1018] | 87 | }
|
---|
| 88 |
|
---|
[1037] | 89 | private void BtnClose_Click(object sender, EventArgs e) {
|
---|
[1018] | 90 | this.Close();
|
---|
| 91 | }
|
---|
[1037] | 92 |
|
---|
| 93 |
|
---|
[1018] | 94 | }
|
---|
| 95 | }
|
---|