Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs @ 3031

Last change on this file since 3031 was 3022, checked in by kgrading, 15 years ago

added the calendar in the dal and the server console. Works on every Resource (Group / Client) (#908)

File size: 6.5 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.Linq;
25using System.Text;
26using HeuristicLab.Hive.Contracts.Interfaces;
27using HeuristicLab.Hive.Contracts.BusinessObjects;
28using HeuristicLab.Hive.Contracts;
29using HeuristicLab.Security.Contracts.Interfaces;
30using HeuristicLab.Hive.Server.Core.InternalInterfaces;
31using System.ServiceModel;
32
33
34namespace HeuristicLab.Hive.Server.Core {
35  public class ServerConsoleFacade: IServerConsoleFacade {
36    private IClientManager clientManager =
37      ServiceLocator.GetClientManager();
38
39    private IJobManager jobManager =
40      ServiceLocator.GetJobManager();
41
42    private IHivePermissionManager secMan = ServiceLocator.GetHivePermissionManager();
43
44    public Guid sessionID = Guid.Empty;
45
46    public ServerConsoleFacade() {     
47    }
48
49    public Response Login(string username, string password) {
50      Response resp = new Response();
51     
52      sessionID = secMan.Login(username, password);
53      if (sessionID == Guid.Empty) {
54        resp.Success = false;
55        resp.StatusMessage = ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_FAILED;
56      } else {
57        resp.Success = true;
58        resp.StatusMessage =
59          ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS;
60      }
61      return resp;
62    }
63
64
65    public ResponseList<ClientDto> GetAllClients() {
66      secMan.Authorize("AccessClients", sessionID, Guid.Empty);
67      return clientManager.GetAllClients();
68    }
69
70    public ResponseList<ClientGroupDto> GetAllClientGroups() {
71      //secMan.Authorize("AccessClientGroup", sessionID, Guid.Empty);
72      return clientManager.GetAllClientGroups();
73    }
74
75    public ResponseList<UpTimeStatisticsDto> GetAllUpTimeStatistics() {
76      secMan.Authorize("AccessStatistics", sessionID, Guid.Empty);
77      return clientManager.GetAllUpTimeStatistics();
78    }
79
80    public ResponseObject<ClientGroupDto> AddClientGroup(ClientGroupDto clientGroup) {
81      secMan.Authorize("AddClientGroup", sessionID, Guid.Empty);
82      return clientManager.AddClientGroup(clientGroup);
83    }
84
85    public Response AddResourceToGroup(Guid clientGroupId, ResourceDto resource) {
86      secMan.Authorize("AddResource", sessionID, Guid.Empty);               
87      return clientManager.AddResourceToGroup(clientGroupId, resource);
88    }
89
90    public Response DeleteResourceFromGroup(Guid clientGroupId, Guid resourceId) {
91        return clientManager.DeleteResourceFromGroup(clientGroupId, resourceId);
92    }
93
94    public ResponseList<JobDto> GetAllJobs() {
95      secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
96      return jobManager.GetAllJobs();
97    }
98
99    public ResponseObject<JobDto> GetJobById(Guid jobId) {
100      secMan.Authorize("AccessJobs", sessionID, jobId);
101      return jobManager.GetJobById(jobId);
102    }
103
104    public ResponseObject<JobDto> AddNewJob(SerializedJob job) {
105      secMan.Authorize("AddJob", sessionID, job.JobInfo.Id);
106      return jobManager.AddNewJob(job);
107    }
108
109    public ResponseObject<JobDto> GetLastJobResultOf(Guid jobId) {
110      secMan.Authorize("AccessJobResults", sessionID, jobId);
111      return jobManager.GetLastJobResultOf(jobId);
112    }
113
114    public ResponseObject<SerializedJob> GetLastSerializedJobResultOf(Guid jobId, bool requested) {
115      secMan.Authorize("AccessJobResults", sessionID, jobId);
116      return jobManager.GetLastSerializedJobResultOf(jobId, requested);
117    }
118
119    public ResponseList<JobResult> GetAllJobResults(Guid jobId) {
120      secMan.Authorize("AccessJobResults", sessionID, jobId); 
121      return jobManager.GetAllJobResults(jobId);
122    }
123
124    public Response RemoveJob(Guid jobId) {
125      secMan.Authorize("RemoveJob", sessionID, jobId);
126      return jobManager.RemoveJob(jobId);
127    }
128
129    public Response RequestSnapshot(Guid jobId) {
130      secMan.Authorize("AccessJobResults", sessionID, jobId); 
131      return jobManager.RequestSnapshot(jobId);
132    }
133
134    public Response AbortJob(Guid jobId) {
135      secMan.Authorize("AbortJob", sessionID, Guid.Empty);
136      return jobManager.AbortJob(jobId);
137    }
138
139    public ResponseObject<List<ClientGroupDto>> GetAllGroupsOfResource(Guid resourceId) {
140      secMan.Authorize("AccessUserGroup", sessionID, Guid.Empty);
141      return clientManager.GetAllGroupsOfResource(resourceId);
142    }
143
144    public Response DeleteClientGroup(Guid clientGroupId) {
145      secMan.Authorize("DeleteClientGroup", sessionID, Guid.Empty);
146      return clientManager.DeleteClientGroup(clientGroupId);
147    }
148
149    public ResponseList<ProjectDto> GetAllProjects() {
150      secMan.Authorize("AccessProjects", sessionID, Guid.Empty);
151      return jobManager.GetAllProjects();
152    }
153
154    public Response CreateProject(ProjectDto project) {
155      secMan.Authorize("CreateProjects", sessionID, Guid.Empty);
156      return jobManager.CreateProject(project);
157    }
158
159    public Response ChangeProject(ProjectDto project) {
160      secMan.Authorize("ChangeProjects", sessionID, Guid.Empty);
161      return jobManager.ChangeProject(project);
162    }
163
164    public Response DeleteProject(Guid projectId) {
165      secMan.Authorize("DeleteProjects", sessionID, projectId);
166      return jobManager.DeleteProject(projectId);
167    }
168
169    public ResponseList<JobDto> GetJobsByProject(Guid projectId) {
170      secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
171      return jobManager.GetJobsByProject(projectId);
172    }
173
174    public ResponseList<AppointmentDto> GetUptimeCalendarForResource(Guid guid) {
175      return clientManager.GetUptimeCalendarForResource(guid);
176    }
177
178    public Response SetUptimeCalendarForResource(Guid guid, IEnumerable<AppointmentDto> appointments) {
179      return clientManager.SetUptimeCalendarForResource(guid, appointments);
180    }
181  }
182}
Note: See TracBrowser for help on using the repository browser.