Changeset 3011 for trunk/sources/HeuristicLab.Hive.Server.Console/3.2
- Timestamp:
- 03/12/10 10:57:21 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Hive.Server.Console/3.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.Console/3.2/AddJobForm.cs
r2092 r3011 1 #region License Information1 #region License Information 2 2 /* HeuristicLab 3 3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 43 43 public event addDelegate addJobEvent; 44 44 45 ResponseList<Project > projects = null;45 ResponseList<ProjectDto> projects = null; 46 46 IJobManager jobManager; 47 47 IClientManager clientManager; 48 ResponseList<ClientGroup > clientGroups;48 ResponseList<ClientGroupDto> clientGroups; 49 49 50 50 Dictionary<Guid, string> clients = null; … … 69 69 cbProject.Items.Add("none"); 70 70 cbProject.SelectedIndex = 0; 71 foreach (Project project in projects.List) {71 foreach (ProjectDto project in projects.List) { 72 72 cbProject.Items.Add(project.Name); 73 73 } … … 86 86 87 87 private void AddClientGroups() { 88 foreach (ClientGroup cg in clientGroups.List) {88 foreach (ClientGroupDto cg in clientGroups.List) { 89 89 if (cg.Id != Guid.Empty) 90 90 clients.Add(cg.Id, cg.Name); … … 93 93 } 94 94 95 private void AddClientOrGroup(ClientGroup clientGroup) {96 foreach (Resource resource in clientGroup.Resources) {97 if (resource is ClientGroup ) {95 private void AddClientOrGroup(ClientGroupDto clientGroup) { 96 foreach (ResourceDto resource in clientGroup.Resources) { 97 if (resource is ClientGroupDto) { 98 98 if (resource.Id != Guid.Empty) 99 99 clients.Add(resource.Id, resource.Name); 100 AddClientOrGroup(resource as ClientGroup );100 AddClientOrGroup(resource as ClientGroupDto); 101 101 } 102 102 } … … 110 110 if (numJobs > 0) { 111 111 for (int i = 0; i < numJobs; i++) { 112 Job job = new Job{ State = State.offline, CoresNeeded = 1 };112 JobDto job = new JobDto { State = State.offline, CoresNeeded = 1 }; 113 113 114 114 // if project selected (0 -> none) -
trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerManagementConsole.cs
r2118 r3011 48 48 49 49 #region private variables 50 private ResponseList<Job > jobs = null;50 private ResponseList<JobDto> jobs = null; 51 51 52 52 List<ListViewGroup> jobGroup; … … 54 54 private List<Changes> changes = new List<Changes>(); 55 55 56 private Job currentJob = null;57 private Client Info currentClient = null;56 private JobDto currentJob = null; 57 private ClientDto currentClient = null; 58 58 59 59 private TreeNode currentGroupNode = null; … … 93 93 IJobManager jobManager = ServiceLocator.GetJobManager(); 94 94 if (lvJobControl.SelectedItems.Count == 1) { 95 jobManager.AbortJob(((Job )(lvJobControl.SelectedItems[0].Tag)).Id);95 jobManager.AbortJob(((JobDto)(lvJobControl.SelectedItems[0].Tag)).Id); 96 96 } 97 97 }; … … 101 101 IJobManager jobManager = ServiceLocator.GetJobManager(); 102 102 if (lvJobControl.SelectedItems.Count == 1) { 103 jobManager.RequestSnapshot(((Job )(lvJobControl.SelectedItems[0].Tag)).Id);103 jobManager.RequestSnapshot(((JobDto)(lvJobControl.SelectedItems[0].Tag)).Id); 104 104 } 105 105 }; … … 109 109 AddGroup addgroup = new AddGroup(); 110 110 parentgroup = Guid.Empty; 111 if ((tvClientControl.SelectedNode != null) && (((ClientGroup )tvClientControl.SelectedNode.Tag).Id != Guid.Empty)) {112 parentgroup = ((ClientGroup )tvClientControl.SelectedNode.Tag).Id;111 if ((tvClientControl.SelectedNode != null) && (((ClientGroupDto)tvClientControl.SelectedNode.Tag).Id != Guid.Empty)) { 112 parentgroup = ((ClientGroupDto)tvClientControl.SelectedNode.Tag).Id; 113 113 } 114 114 addgroup.addGroupEvent += new AddGroupDelegate(addgroup_addGroupEvent); … … 120 120 IClientManager clientManager = ServiceLocator.GetClientManager(); 121 121 if (tvClientControl.SelectedNode != null) { 122 Response resp = clientManager.DeleteClientGroup(((ClientGroup )tvClientControl.SelectedNode.Tag).Id);122 Response resp = clientManager.DeleteClientGroup(((ClientGroupDto)tvClientControl.SelectedNode.Tag).Id); 123 123 if (tvClientControl.SelectedNode == currentGroupNode) { 124 124 currentGroupNode = null; … … 147 147 Point mouseLocation = tvClientControl.PointToClient(new Point(e.X, e.Y)); 148 148 TreeNode node = tvClientControl.GetNodeAt(mouseLocation); 149 if (node != null && ((ClientGroup )node.Tag).Id != Guid.Empty) {149 if (node != null && ((ClientGroupDto)node.Tag).Id != Guid.Empty) { 150 150 e.Effect = DragDropEffects.Move; 151 151 if (hoverNode == null) { … … 170 170 Point dropLocation = (sender as TreeView).PointToClient(new Point(e.X, e.Y)); 171 171 TreeNode dropNode = (sender as TreeView).GetNodeAt(dropLocation); 172 if (((ClientGroup )dropNode.Tag).Id != Guid.Empty) {173 Dictionary<Client Info, Guid> clients = new Dictionary<ClientInfo, Guid>();172 if (((ClientGroupDto)dropNode.Tag).Id != Guid.Empty) { 173 Dictionary<ClientDto, Guid> clients = new Dictionary<ClientDto, Guid>(); 174 174 foreach (ListViewItem lvi in lvClientControl.SelectedItems) { 175 175 Guid groupId = Guid.Empty; 176 176 foreach (ListViewGroup lvg in lvClientGroups) { 177 if (lvi.Group.Header == ((ClientGroup )lvg.Tag).Name) {178 groupId = ((ClientGroup )lvg.Tag).Id;177 if (lvi.Group.Header == ((ClientGroupDto)lvg.Tag).Name) { 178 groupId = ((ClientGroupDto)lvg.Tag).Id; 179 179 } 180 180 } 181 clients.Add((Client Info)lvi.Tag, groupId);182 } 183 ChangeGroup(clients, ((ClientGroup )dropNode.Tag).Id);181 clients.Add((ClientDto)lvi.Tag, groupId); 182 } 183 ChangeGroup(clients, ((ClientGroupDto)dropNode.Tag).Id); 184 184 } 185 185 tvClientControl_DragLeave(null, EventArgs.Empty); … … 194 194 /// <param name="clients">list of clients</param> 195 195 /// <param name="clientgroupID">group of clients</param> 196 private void ChangeGroup(Dictionary<Client Info, Guid> clients, Guid clientgroupID) {196 private void ChangeGroup(Dictionary<ClientDto, Guid> clients, Guid clientgroupID) { 197 197 IClientManager clientManager = ServiceLocator.GetClientManager(); 198 foreach (KeyValuePair<Client Info, Guid> client in clients) {198 foreach (KeyValuePair<ClientDto, Guid> client in clients) { 199 199 if (client.Key.Id != Guid.Empty) { 200 200 Response resp = clientManager.DeleteResourceFromGroup(client.Value, client.Key.Id); … … 224 224 changes.Clear(); 225 225 226 ResponseList<Job > jobsOld = jobs;226 ResponseList<JobDto> jobsOld = jobs; 227 227 try { 228 228 IJobManager jobManager = … … 231 231 jobs = jobManager.GetAllJobs(); 232 232 233 IDictionary<int, Job > jobsOldHelp;233 IDictionary<int, JobDto> jobsOldHelp; 234 234 CloneList(jobsOld, out jobsOldHelp); 235 235 … … 269 269 if (jobs != null && jobs.List != null) { 270 270 271 foreach (Job job in jobs.List) {271 foreach (JobDto job in jobs.List) { 272 272 if (job.State == State.calculating) { 273 273 ListViewItem lvi = new ListViewItem(job.Id.ToString(), 1, lvJobCalculating); … … 312 312 tvClientControl.Nodes.Clear(); 313 313 try { 314 ResponseList<ClientGroup > clientGroups = ClientManager.GetAllClientGroups();314 ResponseList<ClientGroupDto> clientGroups = ClientManager.GetAllClientGroups(); 315 315 316 316 if (clientGroups != null && clientGroups.List != null) { 317 foreach (ClientGroup cg in clientGroups.List) {317 foreach (ClientGroupDto cg in clientGroups.List) { 318 318 AddClientOrGroup(cg, null); 319 319 } … … 333 333 } 334 334 335 private void AddClientOrGroup(ClientGroup clientGroup, TreeNode currentNode) {335 private void AddClientOrGroup(ClientGroupDto clientGroup, TreeNode currentNode) { 336 336 currentNode = CreateTreeNode(clientGroup, currentNode); 337 337 List<ListViewItem> clientGroupList = new List<ListViewItem>(); … … 345 345 lvg.Tag = clientGroup; 346 346 lvClientGroups.Add(lvg); 347 foreach (Resource resource in clientGroup.Resources) {348 if (resource is Client Info) {349 int percentageUsage = CapacityRam(((Client Info)resource).NrOfCores, ((ClientInfo)resource).NrOfFreeCores);347 foreach (ResourceDto resource in clientGroup.Resources) { 348 if (resource is ClientDto) { 349 int percentageUsage = CapacityRam(((ClientDto)resource).NrOfCores, ((ClientDto)resource).NrOfFreeCores); 350 350 int usage = 3; 351 if ((((Client Info)resource).State != State.offline) &&352 (((Client Info)resource).State != State.nullState)) {351 if ((((ClientDto)resource).State != State.offline) && 352 (((ClientDto)resource).State != State.nullState)) { 353 353 if ((percentageUsage >= 0) && (percentageUsage <= 25)) { 354 354 usage = 0; … … 360 360 } 361 361 ListViewItem lvi = new ListViewItem(resource.Name, usage, lvg); 362 lvi.Tag = resource as Client Info;362 lvi.Tag = resource as ClientDto; 363 363 clientGroupList.Add(lvi); 364 } else if (resource is ClientGroup ) {365 AddClientOrGroup(resource as ClientGroup , currentNode);364 } else if (resource is ClientGroupDto) { 365 AddClientOrGroup(resource as ClientGroupDto, currentNode); 366 366 } 367 367 } … … 369 369 } 370 370 371 private TreeNode CreateTreeNode(ClientGroup clientGroup, TreeNode currentNode) {371 private TreeNode CreateTreeNode(ClientGroupDto clientGroup, TreeNode currentNode) { 372 372 TreeNode tn; 373 373 if (string.IsNullOrEmpty(clientGroup.Name)) { … … 390 390 lvClientControl.Groups.Add(lvg); 391 391 lvg.Tag = node.Tag; 392 foreach (ListViewItem item in clientList[((ClientGroup )node.Tag).Id]) {392 foreach (ListViewItem item in clientList[((ClientGroupDto)node.Tag).Id]) { 393 393 item.Group = lvg; 394 394 lvClientControl.Items.Add(item); … … 475 475 IJobManager jobManager = 476 476 ServiceLocator.GetJobManager(); 477 ResponseObject<JobResult> jobRes = jobManager.GetLastJobResultOf(currentJob.Id); 477 ResponseObject<JobResult> jobRes = null; 478 //Todo: jobManager.GetLastJobResultOf(currentJob.Id); 478 479 479 480 if (jobRes != null && jobRes.Obj != null) { … … 532 533 for (int i = 0; i < lvJobControl.Items.Count; i++) { 533 534 if (lvJobControl.Items[i].Text == change.ID.ToString()) { 534 foreach (Job job in jobs.List) {535 foreach (JobDto job in jobs.List) { 535 536 if (job.Id == change.ID) { 536 537 lvJobControl.Items[i].Tag = job; … … 562 563 ListViewItem lvi = new ListViewItem( 563 564 change.ID.ToString(), 2, jobGroup[2]); 564 foreach (Job job in jobs.List) {565 foreach (JobDto job in jobs.List) { 565 566 if (job.Id == change.ID) { 566 567 lvi.Tag = job; … … 612 613 613 614 private void OnLVJobControlClicked(object sender, EventArgs e) { 614 currentJob = (Job )lvJobControl.SelectedItems[0].Tag;615 currentJob = (JobDto)lvJobControl.SelectedItems[0].Tag; 615 616 JobClicked(); 616 617 } … … 629 630 ListViewHitTestInfo hitTestInfo = lvJobControl.HitTest(e.Location); 630 631 if (e.Button == MouseButtons.Right && hitTestInfo.Item != null && lvJobControl.SelectedItems.Count == 1) { 631 Job selectedJob = (Job)lvJobControl.SelectedItems[0].Tag;632 JobDto selectedJob = (JobDto)lvJobControl.SelectedItems[0].Tag; 632 633 633 634 if (selectedJob != null && selectedJob.State == State.calculating) { … … 649 650 AddGroup addgroup = new AddGroup(); 650 651 parentgroup = Guid.Empty; 651 if ((tvClientControl.SelectedNode != null) && (((ClientGroup )tvClientControl.SelectedNode.Tag).Id != Guid.Empty)) {652 parentgroup = ((ClientGroup )tvClientControl.SelectedNode.Tag).Id;652 if ((tvClientControl.SelectedNode != null) && (((ClientGroupDto)tvClientControl.SelectedNode.Tag).Id != Guid.Empty)) { 653 parentgroup = ((ClientGroupDto)tvClientControl.SelectedNode.Tag).Id; 653 654 } 654 655 addgroup.addGroupEvent += new AddGroupDelegate(addgroup_addGroupEvent); … … 663 664 664 665 private void OnLVClientClicked(object sender, EventArgs e) { 665 currentClient = (Client Info)lvClientControl.SelectedItems[0].Tag;666 currentClient = (ClientDto)lvClientControl.SelectedItems[0].Tag; 666 667 ClientClicked(); 667 668 } … … 675 676 if (e.Button != MouseButtons.Right) return; 676 677 if (hitTestInfo.Node != null) { 677 Resource selectedGroup = (Resource)tvClientControl.SelectedNode.Tag;678 ResourceDto selectedGroup = (ResourceDto)tvClientControl.SelectedNode.Tag; 678 679 679 680 if (selectedGroup != null) { … … 690 691 IJobManager jobManager = ServiceLocator.GetJobManager(); 691 692 692 Project pg = new Project() { Name = name };693 ProjectDto pg = new ProjectDto() { Name = name }; 693 694 jobManager.CreateProject(pg); 694 695 … … 699 700 700 701 if (parentgroup != Guid.Empty) { 701 ClientGroup cg = new ClientGroup() { Name = name };702 ResponseObject<ClientGroup > respcg = clientManager.AddClientGroup(cg);702 ClientGroupDto cg = new ClientGroupDto() { Name = name }; 703 ResponseObject<ClientGroupDto> respcg = clientManager.AddClientGroup(cg); 703 704 Response res = clientManager.AddResourceToGroup(parentgroup, respcg.Obj); 704 705 if (res != null && !res.Success) { … … 706 707 } 707 708 } else { 708 ClientGroup cg = new ClientGroup() { Name = name };709 ClientGroupDto cg = new ClientGroupDto() { Name = name }; 709 710 clientManager.AddClientGroup(cg); 710 711 } … … 762 763 #region Helper methods 763 764 764 private void CloneList(ResponseList<Job > oldList, out IDictionary<int, Job> newList) {765 newList = new Dictionary<int, Job >();765 private void CloneList(ResponseList<JobDto> oldList, out IDictionary<int, JobDto> newList) { 766 newList = new Dictionary<int, JobDto>(); 766 767 for (int i = 0; i < oldList.List.Count; i++) { 767 768 newList.Add(i, oldList.List[i]); … … 769 770 } 770 771 771 private bool IsEqual(Client Info ci1, ClientInfo ci2) {772 private bool IsEqual(ClientDto ci1, ClientDto ci2) { 772 773 if (ci2 == null) { 773 774 return false; … … 786 787 } 787 788 788 private void GetDelta(IList<Job > oldJobs, IDictionary<int, Job> helpJobs) {789 private void GetDelta(IList<JobDto> oldJobs, IDictionary<int, JobDto> helpJobs) { 789 790 bool found = false; 790 791 for (int i = 0; i < jobs.List.Count; i++) { 791 Job job = jobs.List[i];792 JobDto job = jobs.List[i]; 792 793 for (int j = 0; j < oldJobs.Count; j++) { 793 794 794 Job jobold = oldJobs[j];795 JobDto jobold = oldJobs[j]; 795 796 796 797 if (job.Id.Equals(jobold.Id)) { … … 814 815 815 816 int removeAt = -1; 816 foreach (KeyValuePair<int, Job > kvp in helpJobs) {817 foreach (KeyValuePair<int, JobDto> kvp in helpJobs) { 817 818 if (job.Id.Equals(kvp.Value.Id)) { 818 819 removeAt = kvp.Key; … … 832 833 found = false; 833 834 } 834 foreach (KeyValuePair<int, Job > kvp in helpJobs) {835 foreach (KeyValuePair<int, JobDto> kvp in helpJobs) { 835 836 changes.Add(new Changes { Types = Type.Job, ID = kvp.Value.Id, ChangeType = Change.Delete, Position = kvp.Key }); 836 837 } … … 844 845 ResponseList<JobResult> jobRes = jobManager.GetAllJobResults(currentJob.Id); 845 846 846 if (jobRes .List != null) {847 if (jobRes != null && jobRes.List != null) { 847 848 foreach (JobResult jobresult in jobRes.List) { 848 849 ListViewItem curSnapshot = new ListViewItem(jobresult.ClientId.ToString()); … … 854 855 } 855 856 856 if ((jobRes.List == null) &&(jobRes.List.Count == 0)) {857 if ((jobRes.List == null) || (jobRes.List.Count == 0)) { 857 858 lvSnapshots.Visible = false; 858 859 } else {
Note: See TracChangeset
for help on using the changeset viewer.