Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs @ 15411

Last change on this file since 15411 was 15411, checked in by jkarder, 7 years ago

#2839: worked on database model

File size: 44.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 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.Security;
26using System.ServiceModel;
27using HeuristicLab.Services.Access;
28using HeuristicLab.Services.Hive.DataAccess.Interfaces;
29using HeuristicLab.Services.Hive.DataTransfer;
30using HeuristicLab.Services.Hive.Manager;
31using HeuristicLab.Services.Hive.ServiceContracts;
32using DA = HeuristicLab.Services.Hive.DataAccess;
33using DT = HeuristicLab.Services.Hive.DataTransfer;
34
35namespace HeuristicLab.Services.Hive {
36  /// <summary>
37  /// Implementation of the Hive service (interface <see cref="IHiveService"/>).
38  /// We need 'IgnoreExtensionDataObject' Attribute for the slave to work.
39  /// </summary>
40  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IgnoreExtensionDataObject = true)]
41  [HiveOperationContextBehavior]
42  public class HiveService : IHiveService {
43    private static readonly DA.TaskState[] CompletedStates = { DA.TaskState.Finished, DA.TaskState.Aborted, DA.TaskState.Failed };
44
45    private IPersistenceManager PersistenceManager {
46      get { return ServiceLocator.Instance.PersistenceManager; }
47    }
48
49    private IUserManager UserManager {
50      get { return ServiceLocator.Instance.UserManager; }
51    }
52
53    private IRoleVerifier RoleVerifier {
54      get { return ServiceLocator.Instance.RoleVerifier; }
55    }
56
57    private IAuthorizationManager AuthorizationManager {
58      get { return ServiceLocator.Instance.AuthorizationManager; }
59    }
60    private IEventManager EventManager {
61      get { return ServiceLocator.Instance.EventManager; }
62    }
63    private HeartbeatManager HeartbeatManager {
64      get { return ServiceLocator.Instance.HeartbeatManager; }
65    }
66
67    #region Task Methods
68    public Guid AddTask(DT.Task task, DT.TaskData taskData, IEnumerable<Guid> resourceIds) {
69      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
70      var pm = PersistenceManager;
71      using (new PerformanceLogger("AddTask")) {
72        var taskDao = pm.TaskDao;
73        var stateLogDao = pm.StateLogDao;
74        var newTask = task.ToEntity();
75        newTask.JobData = taskData.ToEntity();
76        newTask.JobData.LastUpdate = DateTime.Now;
77        newTask.AssignedTaskResources.AddRange(resourceIds.Select(
78          x => new DA.AssignedTaskResource {
79            ResourceId = x
80          }));
81        newTask.State = DA.TaskState.Waiting;
82        return pm.UseTransaction(() => {
83          taskDao.Save(newTask);
84          pm.SubmitChanges();
85          stateLogDao.Save(new DA.StateLog {
86            State = DA.TaskState.Waiting,
87            DateTime = DateTime.Now,
88            TaskId = newTask.TaskId,
89            UserId = UserManager.CurrentUserId,
90            SlaveId = null,
91            Exception = null
92          });
93          pm.SubmitChanges();
94          return newTask.TaskId;
95        }, false, true);
96      }
97    }
98
99    public Guid AddChildTask(Guid parentTaskId, DT.Task task, DT.TaskData taskData) {
100      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
101      IEnumerable<Guid> resourceIds;
102      var pm = PersistenceManager;
103      using (new PerformanceLogger("AddChildTask")) {
104        var assignedTaskResourceDao = pm.AssignedTaskResourceDao;
105        resourceIds = pm.UseTransaction(() => {
106          return assignedTaskResourceDao.GetByTaskId(parentTaskId)
107            .Select(x => x.ResourceId)
108            .ToList();
109        });
110      }
111      task.ParentTaskId = parentTaskId;
112      return AddTask(task, taskData, resourceIds);
113    }
114
115    public DT.Task GetTask(Guid taskId) {
116      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
117      AuthorizationManager.AuthorizeForTask(taskId, Permission.Read);
118      var pm = PersistenceManager;
119      using (new PerformanceLogger("GetTask")) {
120        var taskDao = pm.TaskDao;
121        return pm.UseTransaction(() => {
122          var task = taskDao.GetById(taskId);
123          return task.ToDto();
124        });
125      }
126    }
127
128    public IEnumerable<DT.LightweightTask> GetLightweightJobTasks(Guid jobId) {
129      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
130      AuthorizationManager.AuthorizeForJob(jobId, Permission.Read);
131      var pm = PersistenceManager;
132      using (new PerformanceLogger("GetLightweightJobTasks")) {
133        var taskDao = pm.TaskDao;
134        return pm.UseTransaction(() => {
135          return taskDao.GetByJobId(jobId)
136            .ToList()
137            .Select(x => new DT.LightweightTask {
138              Id = x.TaskId,
139              ExecutionTime = TimeSpan.FromMilliseconds(x.ExecutionTimeMs),
140              ParentTaskId = x.ParentTaskId,
141              StateLog = x.StateLogs.OrderBy(y => y.DateTime)
142                                    .Select(z => z.ToDto())
143                                    .ToList(),
144              State = x.State.ToDto(),
145              Command = x.Command.ToDto(),
146              LastTaskDataUpdate = x.JobData.LastUpdate
147            })
148            .ToList();
149        }, false, true);
150      }
151    }
152
153    public IEnumerable<DT.LightweightTask> GetLightweightJobTasksWithoutStateLog(Guid jobId) {
154      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
155      AuthorizationManager.AuthorizeForJob(jobId, Permission.Read);
156      var pm = PersistenceManager;
157      using (new PerformanceLogger("GetLightweightJobTasksWithoutStateLog")) {
158        var taskDao = pm.TaskDao;
159        return pm.UseTransaction(() => {
160          return taskDao.GetByJobId(jobId)
161            .ToList()
162            .Select(x => new DT.LightweightTask {
163              Id = x.TaskId,
164              ExecutionTime = TimeSpan.FromMilliseconds(x.ExecutionTimeMs),
165              ParentTaskId = x.ParentTaskId,
166              StateLog = new List<DT.StateLog>(),
167              State = x.State.ToDto(),
168              Command = x.Command.ToDto(),
169              LastTaskDataUpdate = x.JobData.LastUpdate
170            })
171            .ToList();
172        }, false, true);
173      }
174    }
175
176    public DT.TaskData GetTaskData(Guid taskId) {
177      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
178      AuthorizationManager.AuthorizeForTask(taskId, Permission.Read);
179      var pm = PersistenceManager;
180      using (new PerformanceLogger("GetTaskData")) {
181        var taskDataDao = pm.TaskDataDao;
182        return pm.UseTransaction(() => taskDataDao.GetById(taskId).ToDto());
183      }
184    }
185
186    public void UpdateTask(DT.Task taskDto) {
187      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
188      AuthorizationManager.AuthorizeForTask(taskDto.Id, Permission.Full);
189      var pm = PersistenceManager;
190      using (new PerformanceLogger("UpdateTask")) {
191        var taskDao = pm.TaskDao;
192        pm.UseTransaction(() => {
193          var task = taskDao.GetById(taskDto.Id);
194          taskDto.CopyToEntity(task);
195          pm.SubmitChanges();
196        });
197      }
198    }
199
200    public void UpdateTaskData(DT.Task taskDto, DT.TaskData taskDataDto) {
201      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
202      AuthorizationManager.AuthorizeForTask(taskDto.Id, Permission.Full);
203      var pm = PersistenceManager;
204      using (new PerformanceLogger("UpdateTaskData")) {
205        var taskDao = pm.TaskDao;
206        var taskDataDao = pm.TaskDataDao;
207        pm.UseTransaction(() => {
208          var task = taskDao.GetById(taskDto.Id);
209          var taskData = taskDataDao.GetById(taskDataDto.TaskId);
210          taskDto.CopyToEntity(task);
211          taskDataDto.CopyToEntity(taskData);
212          taskData.LastUpdate = DateTime.Now;
213          pm.SubmitChanges();
214        });
215      }
216    }
217
218    public DT.Task UpdateTaskState(Guid taskId, DT.TaskState taskState, Guid? slaveId, Guid? userId, string exception) {
219      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
220      AuthorizationManager.AuthorizeForTask(taskId, Permission.Full);
221      var pm = PersistenceManager;
222      using (new PerformanceLogger("UpdateTaskState")) {
223        var taskDao = pm.TaskDao;
224        return pm.UseTransaction(() => {
225          var task = taskDao.GetById(taskId);
226          UpdateTaskState(pm, task, taskState, slaveId, userId, exception);
227          pm.SubmitChanges();
228          return task.ToDto();
229        });
230      }
231    }
232    #endregion
233
234    #region Task Control Methods
235    public void StopTask(Guid taskId) {
236      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
237      AuthorizationManager.AuthorizeForTask(taskId, Permission.Full);
238      var pm = PersistenceManager;
239      using (new PerformanceLogger("StopTask")) {
240        var taskDao = pm.TaskDao;
241        pm.UseTransaction(() => {
242          var task = taskDao.GetById(taskId);
243          if (task.State == DA.TaskState.Calculating || task.State == DA.TaskState.Transferring) {
244            task.Command = DA.Command.Stop;
245          } else if (task.State != DA.TaskState.Aborted
246                     && task.State != DA.TaskState.Finished
247                     && task.State != DA.TaskState.Failed) {
248            UpdateTaskState(pm, task, DT.TaskState.Aborted, null, null, string.Empty);
249          }
250          pm.SubmitChanges();
251        });
252      }
253    }
254
255    public void PauseTask(Guid taskId) {
256      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
257      AuthorizationManager.AuthorizeForTask(taskId, Permission.Full);
258      var pm = PersistenceManager;
259      using (new PerformanceLogger("PauseTask")) {
260        var taskDao = pm.TaskDao;
261        pm.UseTransaction(() => {
262          var task = taskDao.GetById(taskId);
263          if (task.State == DA.TaskState.Calculating || task.State == DA.TaskState.Transferring) {
264            task.Command = DA.Command.Pause;
265          } else if (task.State != DA.TaskState.Paused
266                     && task.State != DA.TaskState.Aborted
267                     && task.State != DA.TaskState.Finished
268                     && task.State != DA.TaskState.Failed) {
269            UpdateTaskState(pm, task, DT.TaskState.Paused, null, null, string.Empty);
270          }
271          pm.SubmitChanges();
272        });
273      }
274    }
275
276    public void RestartTask(Guid taskId) {
277      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
278      AuthorizationManager.AuthorizeForTask(taskId, Permission.Full);
279      var pm = PersistenceManager;
280      using (new PerformanceLogger("RestartTask")) {
281        var taskDao = pm.TaskDao;
282        pm.UseTransaction(() => {
283          var task = taskDao.GetById(taskId);
284          task.Command = null;
285          UpdateTaskState(pm, task, DT.TaskState.Waiting, null, UserManager.CurrentUserId, string.Empty);
286          pm.SubmitChanges();
287        });
288      }
289    }
290    #endregion
291
292    #region Job Methods
293    public DT.Job GetJob(Guid id) {
294      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
295      AuthorizationManager.AuthorizeForJob(id, DT.Permission.Read);
296      var pm = PersistenceManager;
297      using (new PerformanceLogger("GetJob")) {
298        var jobDao = pm.JobDao;
299        var jobPermissionDao = pm.JobPermissionDao;
300        var taskDao = pm.TaskDao;
301        var currentUserId = UserManager.CurrentUserId;
302        return pm.UseTransaction(() => {
303          var job = jobDao.GetById(id).ToDto();
304          if (job != null) {
305            var statistics = taskDao.GetByJobId(job.Id)
306              .GroupBy(x => x.JobId)
307              .Select(x => new {
308                TotalCount = x.Count(),
309                CalculatingCount = x.Count(y => y.State == DA.TaskState.Calculating),
310                FinishedCount = x.Count(y => CompletedStates.Contains(y.State))
311              }).FirstOrDefault();
312            if (statistics != null) {
313              job.JobCount = statistics.TotalCount;
314              job.CalculatingCount = statistics.CalculatingCount;
315              job.FinishedCount = statistics.FinishedCount;
316            }
317            job.OwnerUsername = UserManager.GetUserNameById(job.OwnerUserId);
318            if (currentUserId == job.OwnerUserId) {
319              job.Permission = Permission.Full;
320            } else {
321              var jobPermission = jobPermissionDao.GetByJobAndUserId(job.Id, currentUserId);
322              job.Permission = jobPermission == null ? Permission.NotAllowed : jobPermission.Permission.ToDto();
323            }
324          }
325          return job;
326        });
327      }
328    }
329
330    public IEnumerable<DT.Job> GetJobs() {
331      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
332      var pm = PersistenceManager;
333      using (new PerformanceLogger("GetJobs")) {
334        var jobDao = pm.JobDao;
335        var jobPermissionDao = pm.JobPermissionDao;
336        var taskDao = pm.TaskDao;
337        var currentUserId = UserManager.CurrentUserId;
338        return pm.UseTransaction(() => {
339          var jobs = jobDao.GetAll()
340            .Where(x => x.OwnerUserId == currentUserId
341                     || x.JobPermissions.Count(y => y.Permission != DA.Permission.NotAllowed
342                                                 && y.GrantedUserId == currentUserId) > 0)
343            .Select(x => x.ToDto())
344            .ToList();
345          var statistics = taskDao.GetAll()
346              .GroupBy(x => x.JobId)
347              .Select(x => new {
348                x.Key,
349                TotalCount = x.Count(),
350                CalculatingCount = x.Count(y => y.State == DA.TaskState.Calculating),
351                FinishedCount = x.Count(y => CompletedStates.Contains(y.State))
352              })
353              .ToList();
354          foreach (var job in jobs) {
355            var statistic = statistics.FirstOrDefault(x => x.Key == job.Id);
356            if (statistic != null) {
357              job.JobCount = statistic.TotalCount;
358              job.CalculatingCount = statistic.CalculatingCount;
359              job.FinishedCount = statistic.FinishedCount;
360            }
361            job.OwnerUsername = UserManager.GetUserNameById(job.OwnerUserId);
362            if (currentUserId == job.OwnerUserId) {
363              job.Permission = Permission.Full;
364            } else {
365              var jobPermission = jobPermissionDao.GetByJobAndUserId(job.Id, currentUserId);
366              job.Permission = jobPermission == null ? Permission.NotAllowed : jobPermission.Permission.ToDto();
367            }
368          }
369          return jobs;
370        });
371      }
372    }
373
374    public Guid AddJob(DT.Job jobDto) {
375      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
376      var pm = PersistenceManager;
377      using (new PerformanceLogger("AddJob")) {
378        var jobDao = pm.JobDao;
379        var userPriorityDao = pm.UserPriorityDao;
380        return pm.UseTransaction(() => {
381          jobDto.OwnerUserId = UserManager.CurrentUserId;
382          jobDto.DateCreated = DateTime.Now;
383          var job = jobDao.Save(jobDto.ToEntity());
384          if (userPriorityDao.GetById(jobDto.OwnerUserId) == null) {
385            userPriorityDao.Save(new DA.UserPriority {
386              UserId = jobDto.OwnerUserId,
387              DateEnqueued = jobDto.DateCreated
388            });
389          }
390          pm.SubmitChanges();
391          return job.JobId;
392        });
393      }
394    }
395
396    public void UpdateJob(DT.Job jobDto) {
397      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
398      AuthorizationManager.AuthorizeForJob(jobDto.Id, DT.Permission.Full);
399      var pm = PersistenceManager;
400      using (new PerformanceLogger("UpdateJob")) {
401        bool exists = true;
402        var jobDao = pm.JobDao;
403        pm.UseTransaction(() => {
404          var job = jobDao.GetById(jobDto.Id);
405          if (job == null) {
406            exists = false;
407            job = new DA.Job();
408          }
409          jobDto.CopyToEntity(job);
410          if (!exists) {
411            jobDao.Save(job);
412          }
413          pm.SubmitChanges();
414        });
415      }
416    }
417
418    public void DeleteJob(Guid jobId) {
419      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
420      AuthorizationManager.AuthorizeForJob(jobId, DT.Permission.Full);
421      var pm = PersistenceManager;
422      using (new PerformanceLogger("DeleteJob")) {
423        var jobDao = pm.JobDao;
424        pm.UseTransaction(() => {
425          // child task will be deleted by db-trigger
426          jobDao.Delete(jobId);
427          pm.SubmitChanges();
428        });
429      }
430    }
431    #endregion
432
433    #region JobPermission Methods
434    public void GrantPermission(Guid jobId, Guid grantedUserId, DT.Permission permission) {
435      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
436      AuthorizationManager.AuthorizeForJob(jobId, Permission.Full);
437      var pm = PersistenceManager;
438      using (new PerformanceLogger("GrantPermission")) {
439        var jobPermissionDao = pm.JobPermissionDao;
440        var currentUserId = UserManager.CurrentUserId;
441        pm.UseTransaction(() => {
442          jobPermissionDao.SetJobPermission(jobId, currentUserId, grantedUserId, permission.ToEntity());
443          pm.SubmitChanges();
444        });
445      }
446    }
447
448    public void RevokePermission(Guid jobId, Guid grantedUserId) {
449      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
450      AuthorizationManager.AuthorizeForJob(jobId, Permission.Full);
451      var pm = PersistenceManager;
452      using (new PerformanceLogger("RevokePermission")) {
453        var jobPermissionDao = pm.JobPermissionDao;
454        var currentUserId = UserManager.CurrentUserId;
455        pm.UseTransaction(() => {
456          jobPermissionDao.SetJobPermission(jobId, currentUserId, grantedUserId, DA.Permission.NotAllowed);
457          pm.SubmitChanges();
458        });
459      }
460    }
461
462    public IEnumerable<JobPermission> GetJobPermissions(Guid jobId) {
463      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
464      AuthorizationManager.AuthorizeForJob(jobId, Permission.Full);
465      var pm = PersistenceManager;
466      using (new PerformanceLogger("GetJobPermissions")) {
467        var jobPermissionDao = pm.JobPermissionDao;
468        return pm.UseTransaction(() => jobPermissionDao.GetByJobId(jobId)
469          .Select(x => x.ToDto())
470          .ToList()
471        );
472      }
473    }
474
475    // BackwardsCompatibility3.3
476    #region Backwards compatible code, remove with 3.4
477    public bool IsAllowedPrivileged() {
478      return true;
479    }
480    #endregion
481    #endregion
482
483    #region Login Methods
484    public void Hello(DT.Slave slaveInfo) {
485      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Slave);
486      if (UserManager.CurrentUser.UserName != "hiveslave") {
487        slaveInfo.OwnerUserId = UserManager.CurrentUserId;
488      }
489      var pm = PersistenceManager;
490      using (new PerformanceLogger("Hello")) {
491        var slaveDao = pm.SlaveDao;
492        pm.UseTransaction(() => {
493          var slave = slaveDao.GetById(slaveInfo.Id);
494          if (slave == null) {
495            slaveDao.Save(slaveInfo.ToEntity());
496          } else {
497            bool oldIsAllowedToCalculate = slave.IsAllowedToCalculate;
498            Guid? oldParentResourceId = slave.ParentResourceId;
499            slaveInfo.CopyToEntity(slave);
500            slave.IsAllowedToCalculate = oldIsAllowedToCalculate;
501            slave.ParentResourceId = oldParentResourceId;
502            slave.LastHeartbeat = DateTime.Now;
503            slave.SlaveState = DA.SlaveState.Idle;
504          }
505          pm.SubmitChanges();
506        });
507      }
508    }
509
510    public void GoodBye(Guid slaveId) {
511      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Slave);
512      var pm = PersistenceManager;
513      using (new PerformanceLogger("GoodBye")) {
514        var slaveDao = pm.SlaveDao;
515        pm.UseTransaction(() => {
516          var slave = slaveDao.GetById(slaveId);
517          if (slave != null) {
518            slave.SlaveState = DA.SlaveState.Offline;
519            pm.SubmitChanges();
520          }
521        });
522      }
523    }
524    #endregion
525
526    #region Heartbeat Methods
527    public List<MessageContainer> Heartbeat(DT.Heartbeat heartbeat) {
528      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Slave);
529      List<MessageContainer> result = new List<MessageContainer>();
530      try {
531        using (new PerformanceLogger("ProcessHeartbeat")) {
532          result = HeartbeatManager.ProcessHeartbeat(heartbeat);
533        }
534      } catch (Exception ex) {
535        DA.LogFactory.GetLogger(this.GetType().Namespace).Log(string.Format("Exception processing Heartbeat: {0}", ex));
536      }
537      if (HeuristicLab.Services.Hive.Properties.Settings.Default.TriggerEventManagerInHeartbeat) {
538        TriggerEventManager(false);
539      }
540      return result;
541    }
542    #endregion
543
544    #region Plugin Methods
545    public DT.Plugin GetPlugin(Guid pluginId) {
546      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
547      var pm = PersistenceManager;
548      using (new PerformanceLogger("GetPlugin")) {
549        var pluginDao = pm.PluginDao;
550        return pm.UseTransaction(() => pluginDao.GetById(pluginId).ToDto());
551      }
552    }
553
554    public Guid AddPlugin(DT.Plugin plugin, List<DT.PluginData> pluginData) {
555      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
556      var pm = PersistenceManager;
557      using (new PerformanceLogger("AddPlugin")) {
558        var pluginDao = pm.PluginDao;
559        plugin.UserId = UserManager.CurrentUserId;
560        plugin.DateCreated = DateTime.Now;
561        return pm.UseTransaction(() => {
562          var pluginEntity = pluginDao.GetByHash(plugin.Hash).SingleOrDefault();
563          if (pluginEntity != null) {
564            throw new FaultException<PluginAlreadyExistsFault>(new PluginAlreadyExistsFault(pluginEntity.PluginId));
565          }
566          pluginEntity = plugin.ToEntity();
567          foreach (var data in pluginData) {
568            data.PluginId = default(Guid); // real id will be assigned from linq2sql
569            pluginEntity.PluginData.Add(data.ToEntity());
570          }
571          pluginDao.Save(pluginEntity);
572          pm.SubmitChanges();
573          return pluginEntity.PluginId;
574        });
575      }
576    }
577
578    public IEnumerable<DT.Plugin> GetPlugins() {
579      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
580      var pm = PersistenceManager;
581      using (new PerformanceLogger("GetPlugins")) {
582        var pluginDao = pm.PluginDao;
583        return pm.UseTransaction(() => pluginDao.GetAll()
584          .Where(x => x.Hash != null)
585          .Select(x => x.ToDto())
586          .ToList()
587        );
588      }
589    }
590
591    public IEnumerable<DT.PluginData> GetPluginDatas(List<Guid> pluginIds) {
592      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
593      var pm = PersistenceManager;
594      using (new PerformanceLogger("GetPluginDatas")) {
595        var pluginDataDao = pm.PluginDataDao;
596        return pm.UseTransaction(() => pluginDataDao.GetAll()
597            .Where(x => pluginIds.Contains(x.PluginId))
598            .Select(x => x.ToDto())
599            .ToList()
600        );
601      }
602    }
603    #endregion
604
605    #region Project Methods
606    public Guid AddProject(DT.Project projectDto) {
607      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
608      var pm = PersistenceManager;
609      using (new PerformanceLogger("AddProject")) {
610        var projectDao = pm.ProjectDao;
611        return pm.UseTransaction(() => {
612          var project = projectDao.Save(projectDto.ToEntity());
613          pm.SubmitChanges();
614          return project.ProjectId;
615        });
616      }
617    }
618
619    public void UpdateProject(DT.Project projectDto) {
620      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
621      var pm = PersistenceManager;
622      using (new PerformanceLogger("UpdateProject")) {
623        var projectDao = pm.ProjectDao;
624        pm.UseTransaction(() => {
625          var project = projectDao.GetById(projectDto.Id);
626          if (project != null) {
627            projectDto.CopyToEntity(project);
628          } else {
629            projectDao.Save(projectDto.ToEntity());
630          }
631          pm.SubmitChanges();
632        });
633      }
634    }
635
636    public void DeleteProject(Guid projectId) {
637      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
638      AuthorizationManager.AuthorizeForProjectAdministration(projectId);
639      var pm = PersistenceManager;
640      using (new PerformanceLogger("DeleteProject")) {
641        var projectDao = pm.ProjectDao;
642        pm.UseTransaction(() => {
643          projectDao.Delete(projectId);
644          pm.SubmitChanges();
645        });
646      }
647    }
648
649    public DT.Project GetProject(Guid projectId) {
650      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
651      var pm = PersistenceManager;
652      using (new PerformanceLogger("GetProject")) {
653        var projectDao = pm.ProjectDao;
654        return pm.UseTransaction(() => projectDao.GetById(projectId).ToDto());
655      }
656    }
657
658    public IEnumerable<DT.Project> GetProjects() {
659      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
660      bool isAdministrator = RoleVerifier.IsInRole(HiveRoles.Administrator);
661      var pm = PersistenceManager;
662      using (new PerformanceLogger("GetProjects")) {
663        var projectDao = pm.ProjectDao;
664        var projectPermissionDao = pm.ProjectPermissionDao;
665        var currentUserId = UserManager.CurrentUserId;
666        return pm.UseTransaction(() => {
667          var projectPermissions = projectPermissionDao.GetAll();
668          return projectDao.GetAll().ToList()
669            .Where(x => isAdministrator
670              || x.OwnerUserId == currentUserId
671              || UserManager.VerifyUser(currentUserId, projectPermissions
672                  .Where(y => y.ProjectId == x.ProjectId)
673                  .Select(z => z.GrantedUserId)
674                  .ToList())
675              )
676            .Select(x => x.ToDto())
677            .ToList();
678        });
679      }
680    }
681    #endregion
682
683    #region ProjectPermission Methods
684    public void GrantProjectPermissions(Guid projectId, Guid[] grantedUserIds) {
685      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
686      AuthorizationManager.AuthorizeForProjectAdministration(projectId);
687      var pm = PersistenceManager;
688      using (new PerformanceLogger("GrantProjectPermissions")) {
689        pm.UseTransaction(() => {
690          var project = AuthorizeForProject(pm, projectId);
691          var projectPermissions = project.ProjectPermissions.ToList();
692          foreach (var id in grantedUserIds) {
693            if (projectPermissions.All(x => x.GrantedUserId != id)) {
694              project.ProjectPermissions.Add(new DA.ProjectPermission {
695                GrantedUserId = id,
696                GrantedByUserId = UserManager.CurrentUserId
697              });
698            }
699          }
700          pm.SubmitChanges();
701        });
702      }
703    }
704
705    public void RevokeProjectPermissions(Guid projectId, Guid[] grantedUserIds) {
706      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
707      AuthorizationManager.AuthorizeForProjectAdministration(projectId);
708      var pm = PersistenceManager;
709      using (new PerformanceLogger("RevokeProjectPermissions")) {
710        var projectPermissionDao = pm.ProjectPermissionDao;
711        pm.UseTransaction(() => {
712          projectPermissionDao.DeleteByProjectAndGrantedUserId(projectId, grantedUserIds);
713          pm.SubmitChanges();
714        });
715      }
716    }
717
718    public IEnumerable<DT.ProjectPermission> GetProjectPermissions(Guid projectId) {
719      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
720      var pm = PersistenceManager;
721      using (new PerformanceLogger("GetProjectPermissions")) {
722        var projectPermissionDao = pm.ProjectPermissionDao;
723        return pm.UseTransaction(() => projectPermissionDao.GetByProjectId(projectId)
724          .Select(x => x.ToDto())
725          .ToList()
726        );
727      }
728    }
729    #endregion
730
731    #region AssignedProjectResource Methods
732    public void AssignProjectResources(Guid projectId, Guid[] resourceIds) {
733      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
734      AuthorizationManager.AuthorizeForProjectAdministration(projectId);
735      var pm = PersistenceManager;
736      using (new PerformanceLogger("AssignProjectResources")) {
737        pm.UseTransaction(() => {
738          var project = AuthorizeForProject(pm, projectId);
739          var assignedProjectResources = project.AssignedProjectResources.ToList();
740          foreach (var id in resourceIds) {
741            if (assignedProjectResources.All(x => x.ResourceId != id)) {
742              project.AssignedProjectResources.Add(new DA.AssignedProjectResource {
743                ResourceId = id
744              });
745            }
746          }
747          pm.SubmitChanges();
748        });
749      }
750    }
751
752    public void UnassignProjectResources(Guid projectId, Guid[] resourceIds) {
753      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
754      AuthorizationManager.AuthorizeForProjectAdministration(projectId);
755      var pm = PersistenceManager;
756      using (new PerformanceLogger("UnassignProjectResources")) {
757        var assignedProjectResourceDao = pm.AssignedProjectResourceDao;
758        pm.UseTransaction(() => {
759          assignedProjectResourceDao.DeleteByProjectAndGrantedUserId(projectId, resourceIds);
760          pm.SubmitChanges();
761        });
762      }
763    }
764
765    public IEnumerable<AssignedProjectResource> GetAssignedResourcesForProject(Guid projectId) {
766      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
767      var pm = PersistenceManager;
768      using (new PerformanceLogger("GetAssignedResourcesForProject")) {
769        var assignedProjectResourceDao = pm.AssignedProjectResourceDao;
770        return pm.UseTransaction(() => assignedProjectResourceDao.GetByProjectId(projectId)
771          .Select(x => x.ToDto())
772          .ToList()
773        );
774      }
775    }
776    #endregion
777
778    #region Slave Methods
779    public Guid AddSlave(DT.Slave slaveDto) {
780      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
781      var pm = PersistenceManager;
782      using (new PerformanceLogger("AddSlave")) {
783        var slaveDao = pm.SlaveDao;
784        return pm.UseTransaction(() => {
785          var slave = slaveDao.Save(slaveDto.ToEntity());
786          pm.SubmitChanges();
787          return slave.ResourceId;
788        });
789      }
790    }
791
792    public Guid AddSlaveGroup(DT.SlaveGroup slaveGroupDto) {
793      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
794      var pm = PersistenceManager;
795      using (new PerformanceLogger("AddSlaveGroup")) {
796        var slaveGroupDao = pm.SlaveGroupDao;
797        return pm.UseTransaction(() => {
798          if (slaveGroupDto.Id == Guid.Empty) {
799            slaveGroupDto.Id = Guid.NewGuid();
800          }
801          var slaveGroup = slaveGroupDao.Save(slaveGroupDto.ToEntity());
802          pm.SubmitChanges();
803          return slaveGroup.ResourceId;
804        });
805      }
806    }
807
808    public DT.Slave GetSlave(Guid slaveId) {
809      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
810      var pm = PersistenceManager;
811      using (new PerformanceLogger("GetSlave")) {
812        var slaveDao = pm.SlaveDao;
813        return pm.UseTransaction(() => slaveDao.GetById(slaveId).ToDto());
814      }
815    }
816
817    public IEnumerable<DT.Slave> GetSlaves() {
818      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
819      bool isAdministrator = RoleVerifier.IsInRole(HiveRoles.Administrator);
820      var pm = PersistenceManager;
821      using (new PerformanceLogger("GetSlaves")) {
822        var slaveDao = pm.SlaveDao;
823        var resourcePermissionDao = pm.ProjectPermissionDao;
824        var currentUserId = UserManager.CurrentUserId;
825        return pm.UseTransaction(() => {
826          var resourcePermissions = resourcePermissionDao.GetAll();
827          return slaveDao.GetAll().ToList()
828            .Where(x => isAdministrator
829              || x.OwnerUserId == null
830              || x.OwnerUserId == currentUserId
831              || UserManager.VerifyUser(currentUserId, resourcePermissions
832                  .Where(y => y.ResourceId == x.ResourceId)
833                  .Select(z => z.GrantedUserId)
834                  .ToList())
835              )
836            .Select(x => x.ToDto())
837            .ToList();
838        });
839      }
840    }
841
842    public IEnumerable<DT.SlaveGroup> GetSlaveGroups() {
843      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
844      bool isAdministrator = RoleVerifier.IsInRole(HiveRoles.Administrator);
845      var pm = PersistenceManager;
846      using (new PerformanceLogger("GetSlaveGroups")) {
847        var slaveGroupDao = pm.SlaveGroupDao;
848        var resourcePermissionDao = pm.ProjectPermissionDao;
849        var currentUserId = UserManager.CurrentUserId;
850        return pm.UseTransaction(() => {
851          var resourcePermissions = resourcePermissionDao.GetAll();
852          return slaveGroupDao.GetAll().ToList()
853            .Where(x => isAdministrator
854              || x.OwnerUserId == null
855              || x.OwnerUserId == currentUserId
856              || UserManager.VerifyUser(currentUserId, resourcePermissions
857                  .Where(y => y.ResourceId == x.ResourceId)
858                  .Select(z => z.GrantedUserId)
859                  .ToList())
860              )
861            .Select(x => x.ToDto())
862            .ToList();
863        });
864      }
865    }
866
867    public void UpdateSlave(DT.Slave slaveDto) {
868      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
869      var pm = PersistenceManager;
870      using (new PerformanceLogger("UpdateSlave")) {
871        var slaveDao = pm.SlaveDao;
872        pm.UseTransaction(() => {
873          var slave = slaveDao.GetById(slaveDto.Id);
874          if (slave != null) {
875            slaveDto.CopyToEntity(slave);
876          } else {
877            slaveDao.Save(slaveDto.ToEntity());
878          }
879          pm.SubmitChanges();
880        });
881      }
882    }
883
884    public void UpdateSlaveGroup(DT.SlaveGroup slaveGroupDto) {
885      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
886      var pm = PersistenceManager;
887      using (new PerformanceLogger("UpdateSlaveGroup")) {
888        var slaveGroupDao = pm.SlaveGroupDao;
889        pm.UseTransaction(() => {
890          var slaveGroup = slaveGroupDao.GetById(slaveGroupDto.Id);
891          if (slaveGroup != null) {
892            slaveGroupDto.CopyToEntity(slaveGroup);
893          } else {
894            slaveGroupDao.Save(slaveGroupDto.ToEntity());
895          }
896          pm.SubmitChanges();
897        });
898      }
899    }
900
901    public void DeleteSlave(Guid slaveId) {
902      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
903      AuthorizationManager.AuthorizeForResourceAdministration(slaveId);
904      var pm = PersistenceManager;
905      using (new PerformanceLogger("DeleteSlave")) {
906        var slaveDao = pm.SlaveDao;
907        pm.UseTransaction(() => {
908          slaveDao.Delete(slaveId);
909          pm.SubmitChanges();
910        });
911      }
912    }
913
914    public void DeleteSlaveGroup(Guid slaveGroupId) {
915      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
916      AuthorizationManager.AuthorizeForResourceAdministration(slaveGroupId);
917      var pm = PersistenceManager;
918      using (new PerformanceLogger("DeleteSlaveGroup")) {
919        var slaveGroupDao = pm.SlaveGroupDao;
920        pm.UseTransaction(() => {
921          slaveGroupDao.Delete(slaveGroupId);
922          pm.SubmitChanges();
923        });
924      }
925    }
926
927    public void AddResourceToGroup(Guid slaveGroupId, Guid resourceId) {
928      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
929      var pm = PersistenceManager;
930      using (new PerformanceLogger("AddResourceToGroup")) {
931        var resourceDao = pm.ResourceDao;
932        pm.UseTransaction(() => {
933          var resource = resourceDao.GetById(resourceId);
934          resource.ParentResourceId = slaveGroupId;
935          pm.SubmitChanges();
936        });
937      }
938    }
939
940    public void RemoveResourceFromGroup(Guid slaveGroupId, Guid resourceId) {
941      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
942      var pm = PersistenceManager;
943      using (new PerformanceLogger("RemoveResourceFromGroup")) {
944        var resourceDao = pm.ResourceDao;
945        pm.UseTransaction(() => {
946          var resource = resourceDao.GetById(resourceId);
947          resource.ParentResourceId = null;
948          pm.SubmitChanges();
949        });
950      }
951    }
952
953    public Guid GetResourceId(string resourceName) {
954      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
955      var pm = PersistenceManager;
956      using (new PerformanceLogger("GetResourceId")) {
957        var resourceDao = pm.ResourceDao;
958        return pm.UseTransaction(() => {
959          var resource = resourceDao.GetByName(resourceName);
960          return resource != null ? resource.ResourceId : Guid.Empty;
961        });
962      }
963    }
964
965    public void TriggerEventManager(bool force) {
966      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
967      // use a serializable transaction here to ensure not two threads execute this simultaniously (mutex-lock would not work since IIS may use multiple AppDomains)
968      bool cleanup;
969      var pm = PersistenceManager;
970      using (new PerformanceLogger("TriggerEventManager")) {
971        cleanup = false;
972        var lifecycleDao = pm.LifecycleDao;
973        pm.UseTransaction(() => {
974          var lastLifecycle = lifecycleDao.GetLastLifecycle();
975          DateTime lastCleanup = lastLifecycle != null ? lastLifecycle.LastCleanup : DateTime.MinValue;
976          if (force || DateTime.Now - lastCleanup > HeuristicLab.Services.Hive.Properties.Settings.Default.CleanupInterval) {
977            lifecycleDao.UpdateLifecycle();
978            cleanup = true;
979            pm.SubmitChanges();
980          }
981        }, true);
982      }
983      if (cleanup) {
984        EventManager.Cleanup();
985      }
986    }
987
988    public int GetNewHeartbeatInterval(Guid slaveId) {
989      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Slave);
990      var pm = PersistenceManager;
991      using (new PerformanceLogger("GetNewHeartbeatInterval")) {
992        var slaveDao = pm.SlaveDao;
993        return pm.UseTransaction(() => {
994          var slave = slaveDao.GetById(slaveId);
995          if (slave != null) {
996            return slave.HbInterval;
997          }
998          return -1;
999        });
1000      }
1001    }
1002    #endregion
1003
1004    #region Downtime Methods
1005    public Guid AddDowntime(DT.Downtime downtimeDto) {
1006      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
1007      AuthorizationManager.AuthorizeForResourceAdministration(downtimeDto.ResourceId);
1008      var pm = PersistenceManager;
1009      using (new PerformanceLogger("AddDowntime")) {
1010        var downtimeDao = pm.DowntimeDao;
1011        return pm.UseTransaction(() => {
1012          var downtime = downtimeDao.Save(downtimeDto.ToEntity());
1013          pm.SubmitChanges();
1014          return downtime.ResourceId;
1015        });
1016      }
1017    }
1018
1019    public void DeleteDowntime(Guid downtimeId) {
1020      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
1021      var pm = PersistenceManager;
1022      using (new PerformanceLogger("DeleteDowntime")) {
1023        var downtimeDao = pm.DowntimeDao;
1024        pm.UseTransaction(() => {
1025          downtimeDao.Delete(downtimeId);
1026          pm.SubmitChanges();
1027        });
1028      }
1029    }
1030
1031    public void UpdateDowntime(DT.Downtime downtimeDto) {
1032      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
1033      AuthorizationManager.AuthorizeForResourceAdministration(downtimeDto.ResourceId);
1034      var pm = PersistenceManager;
1035      using (new PerformanceLogger("UpdateDowntime")) {
1036        var downtimeDao = pm.DowntimeDao;
1037        pm.UseTransaction(() => {
1038          var downtime = downtimeDao.GetById(downtimeDto.Id);
1039          if (downtime != null) {
1040            downtimeDto.CopyToEntity(downtime);
1041          } else {
1042            downtimeDao.Save(downtimeDto.ToEntity());
1043          }
1044          pm.SubmitChanges();
1045        });
1046      }
1047    }
1048
1049    public IEnumerable<DT.Downtime> GetDowntimesForResource(Guid resourceId) {
1050      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
1051      var pm = PersistenceManager;
1052      using (new PerformanceLogger("GetDowntimesForResource")) {
1053        var downtimeDao = pm.DowntimeDao;
1054        return pm.UseTransaction(() => downtimeDao.GetByResourceId(resourceId)
1055          .Select(x => x.ToDto())
1056          .ToList()
1057        );
1058      }
1059    }
1060    #endregion
1061
1062    #region User Methods
1063    public string GetUsernameByUserId(Guid userId) {
1064      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
1065      var user = UserManager.GetUserById(userId);
1066      return user != null ? user.UserName : null;
1067    }
1068
1069    public Guid GetUserIdByUsername(string username) {
1070      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
1071      var user = ServiceLocator.Instance.UserManager.GetUserByName(username);
1072      return user != null ? (Guid?)user.ProviderUserKey ?? Guid.Empty : Guid.Empty;
1073    }
1074    #endregion
1075
1076    #region UserPriorities Methods
1077    public IEnumerable<DT.UserPriority> GetUserPriorities() {
1078      var pm = PersistenceManager;
1079      using (new PerformanceLogger("GetUserPriorities")) {
1080        var userPriorityDao = pm.UserPriorityDao;
1081        return pm.UseTransaction(() => userPriorityDao.GetAll()
1082          .Select(x => x.ToDto())
1083          .ToList()
1084        );
1085      }
1086    }
1087    #endregion
1088
1089    #region Private Helper Methods
1090    private void UpdateTaskState(IPersistenceManager pm, DA.Task task, DT.TaskState taskState, Guid? slaveId, Guid? userId, string exception) {
1091      var stateLogDao = pm.StateLogDao;
1092      var taskStateEntity = taskState.ToEntity();
1093
1094      if (task.State == DA.TaskState.Transferring && taskStateEntity == DA.TaskState.Paused && task.Command == null) {
1095        // slave paused and uploaded the task (no user-command) -> set waiting.
1096        taskStateEntity = DA.TaskState.Waiting;
1097      }
1098
1099      stateLogDao.Save(new DA.StateLog {
1100        State = taskStateEntity,
1101        DateTime = DateTime.Now,
1102        TaskId = task.TaskId,
1103        UserId = userId,
1104        SlaveId = slaveId,
1105        Exception = exception
1106      });
1107
1108      task.State = taskStateEntity;
1109
1110      if (task.Command == DA.Command.Pause && task.State == DA.TaskState.Paused
1111          || task.Command == DA.Command.Abort && task.State == DA.TaskState.Aborted
1112          || task.Command == DA.Command.Stop && task.State == DA.TaskState.Aborted) {
1113        task.Command = null;
1114      }
1115    }
1116
1117    private DA.Project AuthorizeForProject(IPersistenceManager pm, Guid projectId) {
1118      var projectDao = pm.ProjectDao;
1119      var project = projectDao.GetById(projectId);
1120      if (project == null) throw new SecurityException("Not authorized");
1121      if (project.OwnerUserId != UserManager.CurrentUserId
1122          && !RoleVerifier.IsInRole(HiveRoles.Administrator)) {
1123        throw new SecurityException("Not authorized");
1124      }
1125      return project;
1126    }
1127    #endregion
1128  }
1129}
Note: See TracBrowser for help on using the repository browser.