[794] | 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;
|
---|
[831] | 30 | using HeuristicLab.Hive.Contracts.Interfaces;
|
---|
| 31 | using HeuristicLab.Hive.Contracts.BusinessObjects;
|
---|
[904] | 32 | using HeuristicLab.Hive.Contracts;
|
---|
[794] | 33 |
|
---|
[1089] | 34 | namespace HeuristicLab.Hive.Server.ServerConsole {
|
---|
[794] | 35 |
|
---|
[1030] | 36 | public delegate void closeForm(bool cf, bool error);
|
---|
[794] | 37 |
|
---|
| 38 | public partial class HiveServerManagementConsole : Form {
|
---|
| 39 |
|
---|
| 40 | public event closeForm closeFormEvent;
|
---|
| 41 |
|
---|
[904] | 42 | ResponseList<ClientGroup> clients = null;
|
---|
[1018] | 43 | ResponseList<ClientInfo> clientInfo = null;
|
---|
[904] | 44 | ResponseList<Job> jobs = null;
|
---|
| 45 | ResponseList<UserGroup> userGroups = null;
|
---|
[1018] | 46 | ResponseList<User> usersList = null;
|
---|
[1089] | 47 | ListView lvClientDetails = null;
|
---|
[844] | 48 |
|
---|
[1098] | 49 | Job currentJob = null;
|
---|
| 50 | ClientInfo currentClient = null;
|
---|
| 51 | User currentUser = null;
|
---|
| 52 |
|
---|
[794] | 53 | public HiveServerManagementConsole() {
|
---|
| 54 | InitializeComponent();
|
---|
[1037] | 55 | AddClients();
|
---|
| 56 | AddJobs();
|
---|
| 57 | AddUsers();
|
---|
[1018] | 58 |
|
---|
[1037] | 59 | timerSyncronize.Tick += new EventHandler(TickSync);
|
---|
[1018] | 60 | timerSyncronize.Start();
|
---|
[844] | 61 | }
|
---|
[831] | 62 |
|
---|
[1037] | 63 | private void TickSync(object obj, EventArgs e) {
|
---|
| 64 | AddClients();
|
---|
| 65 | AddJobs();
|
---|
| 66 | AddUsers();
|
---|
[1018] | 67 | }
|
---|
| 68 |
|
---|
[1037] | 69 | private void AddClients() {
|
---|
[1030] | 70 | try {
|
---|
| 71 | IClientManager clientManager =
|
---|
| 72 | ServiceLocator.GetClientManager();
|
---|
[831] | 73 |
|
---|
[1030] | 74 | clients = clientManager.GetAllClientGroups();
|
---|
[978] | 75 |
|
---|
[1030] | 76 | lvClientControl.Items.Clear();
|
---|
| 77 | tvClientControl.Nodes.Clear();
|
---|
| 78 | int count = 0;
|
---|
| 79 | foreach (ClientGroup cg in clients.List) {
|
---|
| 80 | tvClientControl.Nodes.Add(cg.Name);
|
---|
| 81 | ListViewGroup lvg = new ListViewGroup(cg.Name, HorizontalAlignment.Left);
|
---|
| 82 | foreach (ClientInfo ci in clientManager.GetAllClients().List) {
|
---|
| 83 | tvClientControl.Nodes[tvClientControl.Nodes.Count - 1].Nodes.Add(ci.Name);
|
---|
| 84 | lvClientControl.Items.Add(new ListViewItem(ci.Name, count, lvg));
|
---|
| 85 | count = (count + 1) % 3;
|
---|
| 86 | }
|
---|
| 87 | lvClientControl.Groups.Add(lvg);
|
---|
| 88 | } // Groups
|
---|
| 89 |
|
---|
| 90 | clientInfo = clientManager.GetAllClients();
|
---|
| 91 | ListViewGroup lvunsorted = new ListViewGroup("unsorted", HorizontalAlignment.Left);
|
---|
| 92 | foreach (ClientInfo ci in clientInfo.List) {
|
---|
| 93 | tvClientControl.Nodes.Add(ci.Name);
|
---|
| 94 | lvClientControl.Items.Add(new ListViewItem(ci.Name, count, lvunsorted));
|
---|
[844] | 95 | count = (count + 1) % 3;
|
---|
[831] | 96 | }
|
---|
[1030] | 97 | lvClientControl.Groups.Add(lvunsorted);
|
---|
[1018] | 98 | }
|
---|
[1030] | 99 | catch (Exception ex) {
|
---|
| 100 | closeFormEvent(true, true);
|
---|
| 101 | this.Close();
|
---|
| 102 | }
|
---|
[1018] | 103 | }
|
---|
[956] | 104 |
|
---|
[1037] | 105 | private void AddJobs() {
|
---|
[1030] | 106 | try {
|
---|
| 107 | IJobManager jobManager =
|
---|
| 108 | ServiceLocator.GetJobManager();
|
---|
| 109 | jobs = jobManager.GetAllJobs();
|
---|
[1018] | 110 |
|
---|
[1030] | 111 | lvJobControl.Items.Clear();
|
---|
| 112 | tvJobControl.Nodes.Clear();
|
---|
[1018] | 113 |
|
---|
[1037] | 114 | ListViewGroup lvJobCalculating = new ListViewGroup("calculating", HorizontalAlignment.Left);
|
---|
[1030] | 115 | ListViewGroup lvJobFinished = new ListViewGroup("finished", HorizontalAlignment.Left);
|
---|
[1037] | 116 | ListViewGroup lvJobPending = new ListViewGroup("pending", HorizontalAlignment.Left);
|
---|
| 117 | tvJobControl.Nodes.Add("calculating");
|
---|
[1030] | 118 | tvJobControl.Nodes.Add("finished");
|
---|
[1037] | 119 | tvJobControl.Nodes.Add("pending");
|
---|
[1030] | 120 | foreach (Job job in jobs.List) {
|
---|
[1037] | 121 | if (job.State == State.calculating) {
|
---|
[1030] | 122 | tvJobControl.Nodes[0].Nodes.Add(job.Id.ToString());
|
---|
[1037] | 123 | lvJobControl.Items.Add(new ListViewItem(job.Id.ToString(), 0, lvJobCalculating));
|
---|
| 124 | } else if (job.State == State.finished) {
|
---|
| 125 | tvJobControl.Nodes[1].Nodes.Add(job.Id.ToString());
|
---|
[1030] | 126 | lvJobControl.Items.Add(new ListViewItem(job.Id.ToString(), 0, lvJobFinished));
|
---|
| 127 | } else if (job.State == State.offline) {
|
---|
| 128 | tvJobControl.Nodes[2].Nodes.Add(job.Id.ToString());
|
---|
[1037] | 129 | lvJobControl.Items.Add(new ListViewItem(job.Id.ToString(), 0, lvJobPending));
|
---|
[1030] | 130 | }
|
---|
| 131 | } // Jobs
|
---|
[1037] | 132 | lvJobControl.Groups.Add(lvJobCalculating);
|
---|
[1030] | 133 | lvJobControl.Groups.Add(lvJobFinished);
|
---|
[1037] | 134 | lvJobControl.Groups.Add(lvJobPending);
|
---|
[1030] | 135 | }
|
---|
| 136 | catch (Exception ex) {
|
---|
| 137 | closeFormEvent(true, true);
|
---|
| 138 | this.Close();
|
---|
| 139 | }
|
---|
[1018] | 140 | }
|
---|
| 141 |
|
---|
[1037] | 142 | private void AddUsers() {
|
---|
[1030] | 143 | try {
|
---|
| 144 | IUserRoleManager userRoleManager =
|
---|
| 145 | ServiceLocator.GetUserRoleManager();
|
---|
[1018] | 146 |
|
---|
[1030] | 147 | userGroups = userRoleManager.GetAllUserGroups();
|
---|
[1018] | 148 |
|
---|
[1030] | 149 | lvUserControl.Items.Clear();
|
---|
| 150 | tvUserControl.Nodes.Clear();
|
---|
[1018] | 151 |
|
---|
[1030] | 152 | foreach (UserGroup ug in userGroups.List) {
|
---|
| 153 | tvUserControl.Nodes.Add(ug.Name);
|
---|
| 154 | ListViewGroup lvg = new ListViewGroup(ug.Name, HorizontalAlignment.Left);
|
---|
[956] | 155 |
|
---|
[1030] | 156 | foreach (PermissionOwner permOwner in ug.Members) {
|
---|
| 157 | if (permOwner is User) {
|
---|
| 158 | User users = permOwner as User;
|
---|
| 159 | tvUserControl.Nodes[tvUserControl.Nodes.Count - 1].Nodes.Add(users.Name);
|
---|
| 160 | lvUserControl.Items.Add(new ListViewItem(users.Name, 0, lvg));
|
---|
| 161 | }
|
---|
[1018] | 162 | }
|
---|
[1030] | 163 | lvUserControl.Groups.Add(lvg);
|
---|
| 164 |
|
---|
| 165 | } // Users
|
---|
| 166 | usersList = userRoleManager.GetAllUsers();
|
---|
| 167 | ListViewGroup lvunsorted = new ListViewGroup("unsorted", HorizontalAlignment.Left);
|
---|
| 168 | foreach (User u in usersList.List) {
|
---|
| 169 | tvUserControl.Nodes.Add(u.Name);
|
---|
| 170 | lvUserControl.Items.Add(new ListViewItem(u.Name, 0, lvunsorted));
|
---|
[956] | 171 | }
|
---|
[1030] | 172 | lvUserControl.Groups.Add(lvunsorted);
|
---|
| 173 | }
|
---|
| 174 | catch (Exception ex) {
|
---|
| 175 | closeFormEvent(true, true);
|
---|
| 176 | this.Close();
|
---|
| 177 | }
|
---|
[794] | 178 | }
|
---|
| 179 |
|
---|
| 180 | /// <summary>
|
---|
| 181 | /// Send event to Login-GUI when closing
|
---|
| 182 | /// </summary>
|
---|
| 183 | /// <param name="sender"></param>
|
---|
| 184 | /// <param name="e"></param>
|
---|
[1037] | 185 | private void Close_Click(object sender, EventArgs e) {
|
---|
[794] | 186 | if (closeFormEvent != null) {
|
---|
[1030] | 187 | closeFormEvent(true, false);
|
---|
[794] | 188 | }
|
---|
| 189 | this.Close();
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | /// <summary>
|
---|
| 193 | /// Send evnt to Login-GUI when closing
|
---|
| 194 | /// </summary>
|
---|
| 195 | /// <param name="sender"></param>
|
---|
| 196 | /// <param name="e"></param>
|
---|
| 197 | private void HiveServerConsoleInformation_FormClosing(object sender, FormClosingEventArgs e) {
|
---|
| 198 | if (closeFormEvent != null) {
|
---|
[1030] | 199 | closeFormEvent(true, false);
|
---|
[794] | 200 | }
|
---|
| 201 | }
|
---|
[956] | 202 |
|
---|
[1037] | 203 | private void JobToolStripMenuItem1_Click(object sender, EventArgs e) {
|
---|
[1018] | 204 | AddJobForm newForm = new AddJobForm();
|
---|
[956] | 205 | newForm.Show();
|
---|
| 206 | }
|
---|
| 207 |
|
---|
[1037] | 208 | private void UserToolStripMenuItem1_Click(object sender, EventArgs e) {
|
---|
[1018] | 209 | AddUserForm newForm = new AddUserForm("User", false);
|
---|
[978] | 210 | newForm.Show();
|
---|
| 211 | }
|
---|
| 212 |
|
---|
[1037] | 213 | private void GroupToolStripMenuItem2_Click(object sender, EventArgs e) {
|
---|
[1018] | 214 | AddUserForm newForm = new AddUserForm("User", true);
|
---|
[978] | 215 | newForm.Show();
|
---|
| 216 |
|
---|
| 217 | }
|
---|
| 218 |
|
---|
[1098] | 219 | private void OnLVClientClicked(object sender, EventArgs e) {
|
---|
| 220 | currentClient = clientInfo.List[lvClientControl.SelectedItems[0].Index];
|
---|
| 221 | ClientClicked();
|
---|
| 222 | }
|
---|
| 223 |
|
---|
| 224 | private void OnTVClientClicked(object sender, EventArgs e) {
|
---|
| 225 | // currentClient = clientInfo.List[tvClientControl.SelectedNode.Index];
|
---|
| 226 | // ClientClicked();
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | private void ClientClicked() {
|
---|
[1089] | 230 | scClientControl.Panel2.Controls.Clear();
|
---|
| 231 | scClientControl.Panel2.Controls.Add(plClientDetails);
|
---|
| 232 | pbClientControl.Image = ilClientControl.Images[0];
|
---|
[1098] | 233 | lblClientName.Text = currentClient.Name;
|
---|
| 234 | lblLogin.Text = currentClient.Login.ToString();
|
---|
[1089] | 235 | }
|
---|
| 236 |
|
---|
[1098] | 237 | private void btnClientClose_Click(object sender, EventArgs e) {
|
---|
[1089] | 238 | scClientControl.Panel2.Controls.Clear();
|
---|
| 239 | scClientControl.Panel2.Controls.Add(lvClientControl);
|
---|
| 240 | }
|
---|
| 241 |
|
---|
[1098] | 242 | private void OnLVJobControlClicked(object sender, EventArgs e) {
|
---|
| 243 | currentJob = jobs.List[lvJobControl.SelectedItems[0].Index];
|
---|
| 244 | JobClicked();
|
---|
[1089] | 245 |
|
---|
[1098] | 246 | }
|
---|
| 247 | private void JobClicked() {
|
---|
| 248 | scJobControl.Panel2.Controls.Clear();
|
---|
| 249 | scJobControl.Panel2.Controls.Add(plJobDetails);
|
---|
| 250 | pbJobControl.Image = ilJobControl.Images[0];
|
---|
| 251 | lblJobName.Text = currentJob.Id.ToString();
|
---|
| 252 | }
|
---|
[1089] | 253 |
|
---|
[1098] | 254 | private void btnJobDetailClose_Click(object sender, EventArgs e) {
|
---|
| 255 | scJobControl.Panel2.Controls.Clear();
|
---|
| 256 | scJobControl.Panel2.Controls.Add(lvJobControl);
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 | private void OnLVUserControlClicked(object sender, EventArgs e) {
|
---|
| 260 | currentUser = usersList.List[lvUserControl.SelectedItems[0].Index];
|
---|
| 261 | UserClicked();
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | private void UserClicked() {
|
---|
| 265 | scUserControl.Panel2.Controls.Clear();
|
---|
| 266 | scUserControl.Panel2.Controls.Add(plUserDetails);
|
---|
| 267 | pbUserControl.Image = ilUserControl.Images[0];
|
---|
| 268 | lblUserName.Text = currentUser.Id.ToString();
|
---|
| 269 | }
|
---|
| 270 |
|
---|
| 271 | private void btnUserControlClose_Click(object sender, EventArgs e) {
|
---|
| 272 | scUserControl.Panel2.Controls.Clear();
|
---|
| 273 | scUserControl.Panel2.Controls.Add(lvUserControl);
|
---|
| 274 | }
|
---|
| 275 |
|
---|
[794] | 276 | }
|
---|
[844] | 277 | } |
---|