1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2011 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.Linq;
|
---|
25 | using System.ServiceModel;
|
---|
26 | using DA = HeuristicLab.Services.Access.DataAccess;
|
---|
27 | using DT = HeuristicLab.Services.Access.DataTransfer;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Services.Access {
|
---|
30 | [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
|
---|
31 | public class AccessService : IAccessService {
|
---|
32 |
|
---|
33 | #region Client Members
|
---|
34 | public bool ClientExists(Guid id) {
|
---|
35 | if (id != Guid.Empty) {
|
---|
36 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
37 | return (context.Resources.Where(x => x.Id == id).Count() != 0);
|
---|
38 | }
|
---|
39 | }
|
---|
40 | return false;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public DT.Client GetClient(Guid id) {
|
---|
44 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
45 | var query = from c in context.GetTable<DA.Resource>().OfType<DA.Client>()
|
---|
46 | where c.Id == id
|
---|
47 | select c;
|
---|
48 |
|
---|
49 | return Convert.ToDto(query.FirstOrDefault());
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | public IEnumerable<DT.Client> GetClients(IEnumerable<Guid> ids) {
|
---|
54 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
55 | var query = from c in context.GetTable<DA.Resource>().OfType<DA.Client>()
|
---|
56 | where ids.Contains(c.Id)
|
---|
57 | select Convert.ToDto(c);
|
---|
58 | return query.ToList();
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 | public IEnumerable<DT.Client> GetAllClients() {
|
---|
63 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
64 | var query = from c in context.GetTable<DA.Resource>().OfType<DA.Client>()
|
---|
65 | select Convert.ToDto(c);
|
---|
66 | return query.ToList();
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | public Guid AddClient(DT.Client client) {
|
---|
71 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
72 | DA.Client entity = Convert.ToEntity(client);
|
---|
73 | context.Resources.InsertOnSubmit(entity);
|
---|
74 | context.SubmitChanges();
|
---|
75 | return entity.Id;
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | public void UpdateClient(DT.Client client) {
|
---|
80 | AddClient(client);
|
---|
81 | }
|
---|
82 |
|
---|
83 | public void DeleteClient(DT.Client client) {
|
---|
84 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
85 | context.Resources.DeleteOnSubmit(Convert.ToEntity(client));
|
---|
86 | context.SubmitChanges();
|
---|
87 | }
|
---|
88 | }
|
---|
89 | #endregion
|
---|
90 |
|
---|
91 | #region ClientGroup
|
---|
92 | public IEnumerable<DT.ClientGroup> GetAllClientGroups() {
|
---|
93 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
94 | var query = from c in context.GetTable<DA.Resource>().OfType<DA.ClientGroup>()
|
---|
95 | select Convert.ToDto(c);
|
---|
96 | return query.ToList();
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 | public IEnumerable<DT.ClientGroup> GetClientGroups(IEnumerable<Guid> ids) {
|
---|
101 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
102 | var query = from c in context.GetTable<DA.Resource>().OfType<DA.ClientGroup>()
|
---|
103 | where ids.Contains(c.Id)
|
---|
104 | select Convert.ToDto(c);
|
---|
105 | return query.ToList();
|
---|
106 | }
|
---|
107 | }
|
---|
108 |
|
---|
109 | public Guid AddClientGroup(DT.ClientGroup group) {
|
---|
110 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
111 | var entity = Convert.ToEntity(group);
|
---|
112 | context.Resources.InsertOnSubmit(entity);
|
---|
113 | context.SubmitChanges();
|
---|
114 | return entity.Id;
|
---|
115 | }
|
---|
116 | }
|
---|
117 |
|
---|
118 | public void UpdateClientGroup(DT.ClientGroup group) {
|
---|
119 | AddClientGroup(group);
|
---|
120 | }
|
---|
121 |
|
---|
122 | public void DeleteClientGroup(DT.ClientGroup group) {
|
---|
123 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
124 | context.Resources.DeleteOnSubmit(Convert.ToEntity(group));
|
---|
125 | context.SubmitChanges();
|
---|
126 | }
|
---|
127 | }
|
---|
128 |
|
---|
129 | public void AddResourceToGroup(DT.Resource resource, DT.UserGroup group) {
|
---|
130 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
131 | DA.ResourceResourceGroup rrg = new DA.ResourceResourceGroup() {
|
---|
132 | ResourceId = resource.Id,
|
---|
133 | ResourceGroupId = group.Id
|
---|
134 | };
|
---|
135 |
|
---|
136 | context.ResourceResourceGroups.InsertOnSubmit(rrg);
|
---|
137 | context.SubmitChanges();
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | public void RemoveResourceFromGroup(DT.Resource resource, DT.UserGroup group) {
|
---|
142 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
143 | var query = context.ResourceResourceGroups.Where(x => x.ResourceId == resource.Id && x.ResourceGroupId == group.Id);
|
---|
144 | if (query.Count() > 0) {
|
---|
145 | context.ResourceResourceGroups.DeleteOnSubmit(query.First());
|
---|
146 | context.SubmitChanges();
|
---|
147 | }
|
---|
148 | }
|
---|
149 | }
|
---|
150 | #endregion
|
---|
151 |
|
---|
152 | #region ClientGroupMapping
|
---|
153 | public IEnumerable<DT.ClientGroupMapping> GetClientGroupMapping() {
|
---|
154 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
155 | var query = from c in context.GetTable<DA.ResourceResourceGroup>()
|
---|
156 | select Convert.ToDto(c);
|
---|
157 | return query.ToList();
|
---|
158 | }
|
---|
159 | }
|
---|
160 | #endregion
|
---|
161 |
|
---|
162 | #region Resource
|
---|
163 | public IEnumerable<DT.Resource> GetResources() {
|
---|
164 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
165 | var query = from r in context.Resources
|
---|
166 | select Convert.ToDto(r);
|
---|
167 | return query.ToList();
|
---|
168 | }
|
---|
169 | }
|
---|
170 | #endregion
|
---|
171 |
|
---|
172 | #region ClientLog
|
---|
173 | public DT.ClientLog GetLastClientLog(Guid clientId) {
|
---|
174 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
175 | var query = from r in context.ClientLogs
|
---|
176 | where r.ResourceId == clientId
|
---|
177 | select r;
|
---|
178 | return Convert.ToDto(query.OrderBy(x => x.Timestamp).LastOrDefault());
|
---|
179 | }
|
---|
180 | }
|
---|
181 |
|
---|
182 | public IEnumerable<DT.ClientLog> GetClientLogs(Guid clientId) {
|
---|
183 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
184 | var query = from r in context.ClientLogs
|
---|
185 | where r.ResourceId == clientId
|
---|
186 | select Convert.ToDto(r);
|
---|
187 | return query.ToList();
|
---|
188 | }
|
---|
189 | }
|
---|
190 |
|
---|
191 | public IEnumerable<DT.ClientLog> GetClientLogsSince(DateTime startDate) {
|
---|
192 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
193 | var query = from r in context.ClientLogs
|
---|
194 | where r.Timestamp >= startDate
|
---|
195 | select Convert.ToDto(r);
|
---|
196 | return query.ToList();
|
---|
197 | }
|
---|
198 | }
|
---|
199 |
|
---|
200 | public void AddClientLog(DT.ClientLog log) {
|
---|
201 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
202 | context.ClientLogs.InsertOnSubmit(Convert.ToEntity(log));
|
---|
203 | context.SubmitChanges();
|
---|
204 | }
|
---|
205 | }
|
---|
206 |
|
---|
207 | public void DeleteClientLog(DT.ClientLog log) {
|
---|
208 | using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
|
---|
209 | context.ClientLogs.DeleteOnSubmit(Convert.ToEntity(log));
|
---|
210 | context.SubmitChanges();
|
---|
211 | }
|
---|
212 | }
|
---|
213 | #endregion
|
---|
214 |
|
---|
215 | #region User
|
---|
216 | public DT.User Login() {
|
---|
217 | throw new System.NotImplementedException();
|
---|
218 | }
|
---|
219 |
|
---|
220 | public IEnumerable<DT.User> GetAllUsers() {
|
---|
221 | throw new System.NotImplementedException();
|
---|
222 | }
|
---|
223 |
|
---|
224 | public IEnumerable<DT.User> GetUsers(IEnumerable<DT.User> ids) {
|
---|
225 | throw new System.NotImplementedException();
|
---|
226 | }
|
---|
227 |
|
---|
228 | public DT.User AddUser(DT.User user) {
|
---|
229 | throw new System.NotImplementedException();
|
---|
230 | }
|
---|
231 |
|
---|
232 | public void DeleteUser(DT.User user) {
|
---|
233 | throw new System.NotImplementedException();
|
---|
234 | }
|
---|
235 |
|
---|
236 | public void UpdateUser(DT.User user) {
|
---|
237 | throw new System.NotImplementedException();
|
---|
238 | }
|
---|
239 |
|
---|
240 | public void AddUserToRole(DT.Role role, DT.User user) {
|
---|
241 | throw new System.NotImplementedException();
|
---|
242 | }
|
---|
243 |
|
---|
244 | public void RemoveUserFromRole(DT.Role role, DT.User user) {
|
---|
245 | throw new System.NotImplementedException();
|
---|
246 | }
|
---|
247 |
|
---|
248 | public void ResetPassword(DT.User user, string password) {
|
---|
249 | throw new System.NotImplementedException();
|
---|
250 | }
|
---|
251 | #endregion
|
---|
252 |
|
---|
253 | public IEnumerable<DT.UserGroup> GetAllUserGroups() {
|
---|
254 | throw new System.NotImplementedException();
|
---|
255 | }
|
---|
256 |
|
---|
257 | public IEnumerable<DT.UserGroup> GetUserGroups(IEnumerable<Guid> ids) {
|
---|
258 | throw new System.NotImplementedException();
|
---|
259 | }
|
---|
260 |
|
---|
261 | public DT.UserGroup AddUserGroup(DT.UserGroup group) {
|
---|
262 | throw new System.NotImplementedException();
|
---|
263 | }
|
---|
264 |
|
---|
265 | public void UpdateUserGroup(DT.UserGroup group) {
|
---|
266 | throw new System.NotImplementedException();
|
---|
267 | }
|
---|
268 |
|
---|
269 | public void DeleteUserGroup(DT.UserGroup group) {
|
---|
270 | throw new System.NotImplementedException();
|
---|
271 | }
|
---|
272 |
|
---|
273 | public void AddUserGroupBaseToGroup(DT.UserGroupBase resource, DT.UserGroup group) {
|
---|
274 | throw new System.NotImplementedException();
|
---|
275 | }
|
---|
276 |
|
---|
277 | public void RemoveUserGroupBaseFromGroup(DT.UserGroupBase resource, DT.UserGroup group) {
|
---|
278 | throw new System.NotImplementedException();
|
---|
279 | }
|
---|
280 |
|
---|
281 | public IEnumerable<DT.UserGroupBase> GetUsersAndGroups() {
|
---|
282 | throw new System.NotImplementedException();
|
---|
283 | }
|
---|
284 |
|
---|
285 | public IEnumerable<DT.UserGroupMapping> GetUserGroupMapping() {
|
---|
286 | throw new System.NotImplementedException();
|
---|
287 | }
|
---|
288 |
|
---|
289 | public IEnumerable<DT.Role> GetRoles() {
|
---|
290 | throw new System.NotImplementedException();
|
---|
291 | }
|
---|
292 |
|
---|
293 | public DT.Role AddRole(DT.Role role) {
|
---|
294 | throw new System.NotImplementedException();
|
---|
295 | }
|
---|
296 |
|
---|
297 | public void UpdateRole(DT.Role role) {
|
---|
298 | throw new System.NotImplementedException();
|
---|
299 | }
|
---|
300 |
|
---|
301 | public void DeleteRole(DT.Role role) {
|
---|
302 | throw new System.NotImplementedException();
|
---|
303 | }
|
---|
304 |
|
---|
305 | public IEnumerable<DT.Role> GetUserRoles(DT.User user) {
|
---|
306 | throw new System.NotImplementedException();
|
---|
307 | }
|
---|
308 |
|
---|
309 | public void ReportError(DT.ClientError error) {
|
---|
310 | throw new System.NotImplementedException();
|
---|
311 | }
|
---|
312 |
|
---|
313 | public IEnumerable<DT.ClientError> GetClientErrors() {
|
---|
314 | throw new System.NotImplementedException();
|
---|
315 | }
|
---|
316 |
|
---|
317 | public IEnumerable<DT.ClientError> GetLastClientErrors(DateTime startDate) {
|
---|
318 | throw new System.NotImplementedException();
|
---|
319 | }
|
---|
320 |
|
---|
321 | public void DeleteError(DT.ClientError error) {
|
---|
322 | throw new System.NotImplementedException();
|
---|
323 | }
|
---|
324 | }
|
---|
325 | }
|
---|