Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.Console/HiveServerManagementConsole.cs @ 956

Last change on this file since 956 was 956, checked in by aleitner, 15 years ago

Added new Form for Add Job or Add User - Tests with new interfaces in Server (#380)

File size: 4.6 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;
33
34namespace 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<Job> jobs = null;
44    ResponseList<UserGroup> userGroups = null;
45
46    public HiveServerManagementConsole() {
47      InitializeComponent();
48      addItems();
49    }
50
51    private void addItems() {
52      IClientManager clientManager =
53        ServiceLocator.GetClientManager();
54
55      IJobManager jobManager =
56        ServiceLocator.GetJobManager();
57
58      IUserRoleManager userRoleManager =
59        ServiceLocator.GetUserRoleManager();
60
61      //UserGroup usergr = new UserGroup { Name = "testusers" };
62      //User u = new User { Name = "Anita", Password = "Anita" };
63
64      //ResponseObject<User> respUser = userRoleManager.AddNewUser(u);
65      //ResponseObject<UserGroup> respUserGroup = userRoleManager.AddNewUserGroup(usergr);
66      //u = respUser.Obj;
67      //usergr = respUserGroup.Obj;
68      //userRoleManager.AddUserToGroup(usergr.PermissionOwnerId, u.PermissionOwnerId);
69
70      clients = clientManager.GetAllClientGroups();
71      jobs = jobManager.GetAllJobs();
72      userGroups = userRoleManager.GetAllUserGroups();
73
74
75     // Response resp = userRoleManager.RemoveUserGroup(userGroups.List[userGroups.List.Count - 1].PermissionOwnerId);
76
77      userGroups = userRoleManager.GetAllUserGroups();
78      ResponseList<User> respList = userRoleManager.GetAllUsers();
79      lvClientControl.Items.Clear();
80      int count = 0;
81      foreach (ClientGroup cg in clients.List) {
82        tvClientControl.Nodes.Add(cg.Name);
83        ListViewGroup lvg = new ListViewGroup(cg.Name, HorizontalAlignment.Left);
84        foreach (ClientInfo ci in clientManager.GetAllClients().List) {
85          tvClientControl.Nodes[tvClientControl.Nodes.Count - 1].Nodes.Add(ci.Name);
86          lvClientControl.Items.Add(new ListViewItem(ci.Name, count, lvg));
87          count = (count + 1) % 3;
88        }
89        lvClientControl.Groups.Add(lvg);
90      }
91
92
93      foreach (Job job in jobs.List) {
94        tvJobControl.Nodes.Add(job.JobId.ToString());
95      }
96      foreach (UserGroup ug in userGroups.List) {
97        tvUserControl.Nodes.Add(ug.Name);
98        ListViewGroup lvg = new ListViewGroup(ug.Name, HorizontalAlignment.Left);
99
100        foreach (User users in ug.Members) {
101          tvUserControl.Nodes[tvUserControl.Nodes.Count - 1].Nodes.Add(users.Name);
102          lvUserControl.Items.Add(new ListViewItem(users.Name, count, lvg));
103        }
104        lvUserControl.Groups.Add(lvg);
105      }
106    }
107
108    /// <summary>
109    /// Send event to Login-GUI when closing
110    /// </summary>
111    /// <param name="sender"></param>
112    /// <param name="e"></param>
113    private void close_Click(object sender, EventArgs e) {
114      if (closeFormEvent != null) {
115        closeFormEvent(true);
116      }
117      this.Close();
118    }
119
120    /// <summary>
121    /// Send evnt to Login-GUI when closing
122    /// </summary>
123    /// <param name="sender"></param>
124    /// <param name="e"></param>
125    private void HiveServerConsoleInformation_FormClosing(object sender, FormClosingEventArgs e) {
126      if (closeFormEvent != null) {
127        closeFormEvent(true);
128      }
129
130    }
131
132    private void jobToolStripMenuItem1_Click(object sender, EventArgs e) {
133      AddNewForm newForm = new AddNewForm("Job", false);
134      newForm.Show();
135    }
136
137  }
138}
Note: See TracBrowser for help on using the repository browser.