Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.Console/AddJobForm.cs @ 1099

Last change on this file since 1099 was 1089, checked in by aleitner, 16 years ago

panel for details which shows an image and a close button if details should be closed (#452)

File size: 2.8 KB
Line 
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
22using System;
23using System.Collections.Generic;
24using System.ComponentModel;
25using System.Data;
26using System.Drawing;
27using System.Linq;
28using System.Text;
29using System.Windows.Forms;
30using HeuristicLab.Hive.Contracts.Interfaces;
31using HeuristicLab.Hive.Contracts.BusinessObjects;
32using HeuristicLab.Hive.Contracts;
33
34namespace HeuristicLab.Hive.Server.ServerConsole {
35  public partial class AddJobForm : Form {
36
37    ResponseList<Job> jobGroups = null;
38    IJobManager jobManager;
39
40    public AddJobForm() {
41      InitializeComponent();
42      AddJob();
43    }
44
45    private void AddJob() {
46      jobManager =
47        ServiceLocator.GetJobManager();
48      jobGroups = jobManager.GetAllJobs();
49      cbParJob.Items.Add("none");
50      cbParJob.SelectedIndex = 0;
51      foreach (Job job in jobGroups.List) {
52        cbParJob.Items.Add(job.Id);
53      }
54    }
55
56
57    private void BtnAdd_Click(object sender, EventArgs e) {
58      try {
59        lblError.Text = "";
60        int numJobs = Convert.ToInt32(tbNumJobs.Text);
61        if (numJobs > 0) {
62          for (int i = 0; i < numJobs; i++) {
63            if (cbParJob.SelectedIndex != 0) {
64              foreach (Job pjob in jobGroups.List) {
65                if (cbParJob.SelectedItem.ToString().Equals(pjob.Id.ToString())) {
66                  Job job = new Job { ParentJob = pjob, State = State.offline };
67                  Response resp = jobManager.AddNewJob(job);
68                }
69              }
70            } else {
71              Job job = new Job { State = State.offline };
72              Response resp = jobManager.AddNewJob(job);
73            }
74          }
75          this.Close();
76        } else {
77          lblError.Text = "Wrong number of Jobs";
78        }
79
80      }
81      catch {
82        lblError.Text = "There should be a number";
83      }
84    }
85
86    private void BtnClose_Click(object sender, EventArgs e) {
87      this.Close();
88    }
89
90
91  }
92}
Note: See TracBrowser for help on using the repository browser.