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;
|
---|
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;
|
---|
33 | using HeuristicLab.Hive.JobBase;
|
---|
34 | using HeuristicLab.Core;
|
---|
35 |
|
---|
36 | namespace 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 | }
|
---|