#region License Information /* HeuristicLab * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using HeuristicLab.Hive.Contracts.Interfaces; using HeuristicLab.Hive.Contracts.BusinessObjects; using HeuristicLab.Hive.Contracts; using HeuristicLab.Hive.JobBase; using HeuristicLab.Core; namespace HeuristicLab.Hive.Server.ServerConsole { public delegate void addDelegate(); public partial class AddJobForm : Form { public event addDelegate addJobEvent; ResponseList projects = null; IJobManager jobManager; IClientManager clientManager; ResponseList clientGroups; Dictionary clients = null; public AddJobForm() { InitializeComponent(); clients = new Dictionary(); AddJob(); } private void AddJob() { jobManager = ServiceLocator.GetJobManager(); projects = jobManager.GetAllProjects(); cbProject.Items.Add("none"); cbProject.SelectedIndex = 0; foreach (Project project in projects.List) { cbProject.Items.Add(project.Name); } } private void AddClientGroups() { foreach (ClientGroup cg in clientGroups.List) { clients.Add(cg.Id, cg.Name); AddClientOrGroup(cg); } } private void AddClientOrGroup(ClientGroup clientGroup) { foreach (Resource resource in clientGroup.Resources) { if (resource is ClientGroup) { clients.Add(resource.Id, resource.Name); AddClientOrGroup(resource as ClientGroup); } } } private void BtnAdd_Click(object sender, EventArgs e) { try { lblError.Text = ""; int numJobs = Convert.ToInt32(tbNumJobs.Text); if (numJobs > 0) { for (int i = 0; i < numJobs; i++) { if (cbProject.SelectedIndex != 0) { // foreach (Job pjob in jobGroups.List) { // if (cbParJob.SelectedItem.ToString().Equals(pjob.Id.ToString())) { // Job job = new Job { ParentJob = pjob, State = State.offline, CoresNeeded = 1 }; // job.SerializedJob = PersistenceManager.SaveToGZip(new TestJob()); // Response resp = jobManager.AddNewJob(job); // } // } //} else { // Job job = new Job { State = State.offline, CoresNeeded = 1 }; // job.SerializedJob = PersistenceManager.SaveToGZip(new TestJob()); // Response resp = jobManager.AddNewJob(job); } } if (addJobEvent != null) { addJobEvent(); } this.Close(); } else { lblError.Text = "Wrong number of Jobs"; } } catch { lblError.Text = "There should be a number"; } } private void BtnClose_Click(object sender, EventArgs e) { this.Close(); } private void cbAllGroups_CheckedChanged(object sender, EventArgs e) { foreach (Control control in gbGroups.Controls) { control.Enabled = !cbAllGroups.Checked; } } } }