Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 1943 was 1937, checked in by aleitner, 16 years ago

contextmenu is on place where clicked
Add project form
expand add job form
(#626)

File size: 4.1 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;
33using HeuristicLab.Hive.JobBase;
34using HeuristicLab.Core;
35
36namespace HeuristicLab.Hive.Server.ServerConsole {
37
38  public delegate void addDelegate();
39
40  public partial class AddJobForm : Form {
41
42    public event addDelegate addJobEvent;
43
44    ResponseList<Project> projects = null;
45    IJobManager jobManager;
46    IClientManager clientManager;
47    ResponseList<ClientGroup> clientGroups;
48
49    Dictionary<Guid, string> clients = null;
50
51    public AddJobForm() {
52      InitializeComponent();
53
54      clients = new Dictionary<Guid, string>();
55      AddJob();
56
57    }
58
59    private void AddJob() {
60      jobManager =
61        ServiceLocator.GetJobManager();
62      projects = jobManager.GetAllProjects();
63      cbProject.Items.Add("none");
64      cbProject.SelectedIndex = 0;
65      foreach (Project project in projects.List) {
66        cbProject.Items.Add(project.Name);
67      }
68
69
70    }
71
72    private void AddClientGroups() {
73     foreach (ClientGroup cg in clientGroups.List) {
74       clients.Add(cg.Id, cg.Name);
75        AddClientOrGroup(cg);
76      }
77    }
78
79    private void AddClientOrGroup(ClientGroup clientGroup) {
80      foreach (Resource resource in clientGroup.Resources) {
81        if (resource is ClientGroup) {
82          clients.Add(resource.Id, resource.Name);
83          AddClientOrGroup(resource as ClientGroup);
84        }
85      }
86   
87    }
88
89    private void BtnAdd_Click(object sender, EventArgs e) {
90      try {
91        lblError.Text = "";
92        int numJobs = Convert.ToInt32(tbNumJobs.Text);
93        if (numJobs > 0) {
94          for (int i = 0; i < numJobs; i++) {
95            if (cbProject.SelectedIndex != 0) {
96            //  foreach (Job pjob in jobGroups.List) {
97            //    if (cbParJob.SelectedItem.ToString().Equals(pjob.Id.ToString())) {
98            //      Job job = new Job { ParentJob = pjob, State = State.offline, CoresNeeded = 1 };
99            //      job.SerializedJob = PersistenceManager.SaveToGZip(new TestJob());
100            //      Response resp = jobManager.AddNewJob(job);
101            //    }
102            //  }
103            //} else {
104            //  Job job = new Job { State = State.offline, CoresNeeded = 1 };
105            //  job.SerializedJob = PersistenceManager.SaveToGZip(new TestJob());
106            //  Response resp = jobManager.AddNewJob(job);
107            }
108          }
109          if (addJobEvent != null) {
110            addJobEvent();
111          }
112          this.Close();
113        } else {
114          lblError.Text = "Wrong number of Jobs";
115        }
116
117      }
118      catch {
119        lblError.Text = "There should be a number";
120      }
121    }
122
123    private void BtnClose_Click(object sender, EventArgs e) {
124      this.Close();
125    }
126
127    private void cbAllGroups_CheckedChanged(object sender, EventArgs e) {
128      foreach (Control control in gbGroups.Controls) {
129        control.Enabled = !cbAllGroups.Checked;
130      }
131    }
132
133
134  }
135}
Note: See TracBrowser for help on using the repository browser.