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 |
|
---|
34 | namespace HeuristicLab.Hive.Server.Console {
|
---|
35 |
|
---|
36 | public delegate void closeForm(bool cf);
|
---|
37 |
|
---|
38 | public partial class HiveServerManagementConsole : Form {
|
---|
39 |
|
---|
40 | public event closeForm closeFormEvent;
|
---|
41 |
|
---|
42 | ResponseList<ClientGroup> clients = null;
|
---|
43 | ResponseList<ClientInfo> clientInfo = null;
|
---|
44 | ResponseList<Job> jobs = null;
|
---|
45 | ResponseList<UserGroup> userGroups = null;
|
---|
46 | ResponseList<User> usersList = null;
|
---|
47 |
|
---|
48 | public HiveServerManagementConsole() {
|
---|
49 | InitializeComponent();
|
---|
50 | addClients();
|
---|
51 | addJobs();
|
---|
52 | addUsers();
|
---|
53 |
|
---|
54 | timerSyncronize.Tick += new EventHandler(tickSync);
|
---|
55 | timerSyncronize.Start();
|
---|
56 | }
|
---|
57 |
|
---|
58 | private void tickSync(object obj, EventArgs e) {
|
---|
59 | addClients();
|
---|
60 | addJobs();
|
---|
61 | addUsers();
|
---|
62 | }
|
---|
63 |
|
---|
64 | private void addClients() {
|
---|
65 | IClientManager clientManager =
|
---|
66 | ServiceLocator.GetClientManager();
|
---|
67 |
|
---|
68 | clients = clientManager.GetAllClientGroups();
|
---|
69 |
|
---|
70 | lvClientControl.Items.Clear();
|
---|
71 | tvClientControl.Nodes.Clear();
|
---|
72 | int count = 0;
|
---|
73 | foreach (ClientGroup cg in clients.List) {
|
---|
74 | tvClientControl.Nodes.Add(cg.Name);
|
---|
75 | ListViewGroup lvg = new ListViewGroup(cg.Name, HorizontalAlignment.Left);
|
---|
76 | foreach (ClientInfo ci in clientManager.GetAllClients().List) {
|
---|
77 | tvClientControl.Nodes[tvClientControl.Nodes.Count - 1].Nodes.Add(ci.Name);
|
---|
78 | lvClientControl.Items.Add(new ListViewItem(ci.Name, count, lvg));
|
---|
79 | count = (count + 1) % 3;
|
---|
80 | }
|
---|
81 | lvClientControl.Groups.Add(lvg);
|
---|
82 | } // Groups
|
---|
83 |
|
---|
84 | clientInfo = clientManager.GetAllClients();
|
---|
85 | ListViewGroup lvunsorted = new ListViewGroup("unsorted", HorizontalAlignment.Left);
|
---|
86 | foreach (ClientInfo ci in clientInfo.List) {
|
---|
87 | tvClientControl.Nodes.Add(ci.Name);
|
---|
88 | lvClientControl.Items.Add(new ListViewItem(ci.Name, count, lvunsorted));
|
---|
89 | count = (count + 1) % 3;
|
---|
90 | }
|
---|
91 | lvClientControl.Groups.Add(lvunsorted);
|
---|
92 | }
|
---|
93 |
|
---|
94 | private void addJobs() {
|
---|
95 | IJobManager jobManager =
|
---|
96 | ServiceLocator.GetJobManager();
|
---|
97 | jobs = jobManager.GetAllJobs();
|
---|
98 |
|
---|
99 | lvJobControl.Items.Clear();
|
---|
100 | tvJobControl.Nodes.Clear();
|
---|
101 |
|
---|
102 | foreach (Job job in jobs.List) {
|
---|
103 | tvJobControl.Nodes.Add(job.Id.ToString());
|
---|
104 | lvJobControl.Items.Add(new ListViewItem(job.Id.ToString(), 0));
|
---|
105 | } // Jobs
|
---|
106 |
|
---|
107 | }
|
---|
108 |
|
---|
109 | private void addUsers() {
|
---|
110 | IUserRoleManager userRoleManager =
|
---|
111 | ServiceLocator.GetUserRoleManager();
|
---|
112 |
|
---|
113 | userGroups = userRoleManager.GetAllUserGroups();
|
---|
114 |
|
---|
115 | lvUserControl.Items.Clear();
|
---|
116 | tvUserControl.Nodes.Clear();
|
---|
117 |
|
---|
118 | foreach (UserGroup ug in userGroups.List) {
|
---|
119 | tvUserControl.Nodes.Add(ug.Name);
|
---|
120 | ListViewGroup lvg = new ListViewGroup(ug.Name, HorizontalAlignment.Left);
|
---|
121 |
|
---|
122 | foreach (PermissionOwner permOwner in ug.Members) {
|
---|
123 | if (permOwner is User) {
|
---|
124 | User users = permOwner as User;
|
---|
125 | tvUserControl.Nodes[tvUserControl.Nodes.Count - 1].Nodes.Add(users.Name);
|
---|
126 | lvUserControl.Items.Add(new ListViewItem(users.Name, 0, lvg));
|
---|
127 | }
|
---|
128 | }
|
---|
129 | lvUserControl.Groups.Add(lvg);
|
---|
130 |
|
---|
131 | } // Users
|
---|
132 | usersList = userRoleManager.GetAllUsers();
|
---|
133 | ListViewGroup lvunsorted = new ListViewGroup("unsorted", HorizontalAlignment.Left);
|
---|
134 | foreach (User u in usersList.List) {
|
---|
135 | tvUserControl.Nodes.Add(u.Name);
|
---|
136 | lvUserControl.Items.Add(new ListViewItem(u.Name, 0, lvunsorted));
|
---|
137 | }
|
---|
138 | lvUserControl.Groups.Add(lvunsorted);
|
---|
139 | }
|
---|
140 |
|
---|
141 | /// <summary>
|
---|
142 | /// Send event to Login-GUI when closing
|
---|
143 | /// </summary>
|
---|
144 | /// <param name="sender"></param>
|
---|
145 | /// <param name="e"></param>
|
---|
146 | private void close_Click(object sender, EventArgs e) {
|
---|
147 | if (closeFormEvent != null) {
|
---|
148 | closeFormEvent(true);
|
---|
149 | }
|
---|
150 | this.Close();
|
---|
151 | }
|
---|
152 |
|
---|
153 | /// <summary>
|
---|
154 | /// Send evnt to Login-GUI when closing
|
---|
155 | /// </summary>
|
---|
156 | /// <param name="sender"></param>
|
---|
157 | /// <param name="e"></param>
|
---|
158 | private void HiveServerConsoleInformation_FormClosing(object sender, FormClosingEventArgs e) {
|
---|
159 | if (closeFormEvent != null) {
|
---|
160 | closeFormEvent(true);
|
---|
161 | }
|
---|
162 |
|
---|
163 | }
|
---|
164 |
|
---|
165 | private void jobToolStripMenuItem1_Click(object sender, EventArgs e) {
|
---|
166 | AddJobForm newForm = new AddJobForm();
|
---|
167 | newForm.Show();
|
---|
168 | }
|
---|
169 |
|
---|
170 | private void userToolStripMenuItem1_Click(object sender, EventArgs e) {
|
---|
171 | AddUserForm newForm = new AddUserForm("User", false);
|
---|
172 | newForm.Show();
|
---|
173 | }
|
---|
174 |
|
---|
175 | private void groupToolStripMenuItem2_Click(object sender, EventArgs e) {
|
---|
176 | AddUserForm newForm = new AddUserForm("User", true);
|
---|
177 | newForm.Show();
|
---|
178 |
|
---|
179 | }
|
---|
180 |
|
---|
181 | }
|
---|
182 | } |
---|