Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 1892 was 1753, checked in by aleitner, 16 years ago

set used cores in testjob, logged in response involved (#600)

File size: 3.2 KB
RevLine 
[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
22using System;
[1018]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;
[1120]33using HeuristicLab.Hive.JobBase;
34using HeuristicLab.Core;
[1018]35
[1089]36namespace HeuristicLab.Hive.Server.ServerConsole {
[1164]37
38  public delegate void addDelegate();
39
[1018]40  public partial class AddJobForm : Form {
41
[1164]42    public event addDelegate addJobEvent;
43
[1018]44    ResponseList<Job> jobGroups = null;
45    IJobManager jobManager;
46
47    public AddJobForm() {
48      InitializeComponent();
[1037]49      AddJob();
[1018]50    }
51
[1037]52    private void AddJob() {
[1018]53      jobManager =
54        ServiceLocator.GetJobManager();
55      jobGroups = jobManager.GetAllJobs();
56      cbParJob.Items.Add("none");
57      cbParJob.SelectedIndex = 0;
58      foreach (Job job in jobGroups.List) {
59        cbParJob.Items.Add(job.Id);
60      }
61    }
62
[1037]63    private void BtnAdd_Click(object sender, EventArgs e) {
[1030]64      try {
65        lblError.Text = "";
66        int numJobs = Convert.ToInt32(tbNumJobs.Text);
67        if (numJobs > 0) {
68          for (int i = 0; i < numJobs; i++) {
69            if (cbParJob.SelectedIndex != 0) {
70              foreach (Job pjob in jobGroups.List) {
71                if (cbParJob.SelectedItem.ToString().Equals(pjob.Id.ToString())) {
[1753]72                  Job job = new Job { ParentJob = pjob, State = State.offline, CoresNeeded = 1 };
[1120]73                  job.SerializedJob = PersistenceManager.SaveToGZip(new TestJob());
[1030]74                  Response resp = jobManager.AddNewJob(job);
75                }
76              }
77            } else {
[1753]78              Job job = new Job { State = State.offline, CoresNeeded = 1 };
[1120]79              job.SerializedJob = PersistenceManager.SaveToGZip(new TestJob());
[1030]80              Response resp = jobManager.AddNewJob(job);
81            }
[1018]82          }
[1164]83          if (addJobEvent != null) {
84            addJobEvent();
85          }
[1030]86          this.Close();
87        } else {
88          lblError.Text = "Wrong number of Jobs";
[1018]89        }
[1030]90
[1018]91      }
[1030]92      catch {
93        lblError.Text = "There should be a number";
94      }
[1018]95    }
96
[1037]97    private void BtnClose_Click(object sender, EventArgs e) {
[1018]98      this.Close();
99    }
[1037]100
101
[1018]102  }
103}
Note: See TracBrowser for help on using the repository browser.