Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs @ 6110

Last change on this file since 6110 was 6110, checked in by cneumuel, 13 years ago

#1233

  • renamed engines to executors
  • changed locking in StartJobInAppDomain
  • avoid destruction of proxy object after 5 minutes for Slave.Core
  • added JobStarted event and fixed ExecutionStateChanged and ExecutionTimeChanged
  • slaves which are moved to another slavegroup will pause their jobs now, if they must not calculate them
File size: 21.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.ServiceModel;
5using HeuristicLab.Services.Hive.Common;
6using HeuristicLab.Services.Hive.Common.DataTransfer;
7using HeuristicLab.Services.Hive.Common.ServiceContracts;
8
9namespace HeuristicLab.Services.Hive {
10
11  /// <summary>
12  /// Implementation of the Hive service (interface <see cref="IHiveService"/>).
13  /// We need 'IgnoreExtensionDataObject' Attribute for the slave to work.
14  /// </summary>
15  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IgnoreExtensionDataObject = true)]
16  public class HiveService : IHiveService {
17    private DataAccess.IHiveDao dao {
18      get { return ServiceLocator.Instance.HiveDao; }
19    }
20    private HeuristicLab.Services.Hive.DataAccess.TransactionManager trans {
21      get { return ServiceLocator.Instance.TransactionManager; }
22    }
23    private IAuthorizationManager auth {
24      get { return ServiceLocator.Instance.AuthorizationManager; }
25    }
26    private ILifecycleManager lifecycleManager {
27      get { return ServiceLocator.Instance.LifecycleManager; }
28    }
29    private HeartbeatManager heartbeatManager {
30      get { return ServiceLocator.Instance.HeartbeatManager; }
31    }
32
33    #region Job Methods
34    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
35    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
36    public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds) {
37      return trans.UseTransaction(() => {
38        job.Id = dao.AddJob(job);
39        jobData.JobId = job.Id;
40        jobData.LastUpdate = DateTime.Now;
41        if (resourceIds != null) {
42          foreach (Guid slaveGroupId in resourceIds) {
43            dao.AssignJobToResource(job.Id, slaveGroupId);
44          }
45        } else {
46          // todo: use default group
47        }
48        dao.AddJobData(jobData);
49        dao.UpdateJobState(job.Id, JobState.Waiting, null, auth.UserId, null);
50        return jobData.JobId;
51      });
52    }
53
54    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
55    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
56    public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) {
57      return trans.UseTransaction(() => {
58        job.ParentJobId = parentJobId;
59        return AddJob(job, jobData, dao.GetAssignedResources(parentJobId).Select(x => x.Id));
60      });
61    }
62
63    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
64    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
65    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
66    public Job GetJob(Guid jobId) {
67      return dao.GetJob(jobId);
68    }
69
70    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
71    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
72    public IEnumerable<Job> GetJobs() {
73      return dao.GetJobs(x => true);
74    }
75
76    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
77    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
78    public IEnumerable<LightweightJob> GetLightweightJobs(IEnumerable<Guid> jobIds) {
79      return dao.GetJobs(x => jobIds.Contains(x.JobId)).Select(x => new LightweightJob(x)).ToArray();
80    }
81
82    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
83    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
84    public IEnumerable<LightweightJob> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
85      return GetChildJobs(parentJobId, recursive, includeParent).Select(x => new LightweightJob(x)).ToArray();
86    }
87
88    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
89    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
90    public IEnumerable<LightweightJob> GetLightweightExperimentJobs(Guid experimentId) {
91      return dao.GetJobs(x => x.HiveExperimentId == experimentId).Select(x => new LightweightJob(x)).ToArray();
92    }
93
94    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
95    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
96    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
97    public JobData GetJobData(Guid jobId) {
98      return dao.GetJobData(jobId);
99    }
100
101    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
102    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
103    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
104    public void UpdateJob(Job job) {
105      trans.UseTransaction(() => {
106        dao.UpdateJob(job);
107      });
108    }
109
110    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
111    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
112    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
113    public void UpdateJobData(Job job, JobData jobData) {
114      trans.UseTransaction(() => {
115        jobData.LastUpdate = DateTime.Now;
116        dao.UpdateJob(job);
117        dao.UpdateJobData(jobData);
118      });
119    }
120
121    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
122    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
123    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
124    public void DeleteJob(Guid jobId) {
125      trans.UseTransaction(() => {
126        dao.DeleteJob(jobId);
127      });
128    }
129
130    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
131    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
132    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
133    public void DeleteChildJobs(Guid parentJobId) {
134      trans.UseTransaction(() => {
135        var jobs = GetChildJobs(parentJobId, true, false);
136        foreach (var job in jobs) {
137          dao.DeleteJob(job.Id);
138          dao.DeleteJobData(job.Id);
139        };
140      });
141    }
142
143    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
144    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
145    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
146    public Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception) {
147      return trans.UseTransaction(() => {
148        Job job = dao.UpdateJobState(jobId, jobState, slaveId, userId, exception);
149       
150        if (job.Command.HasValue && job.Command.Value == Command.Pause && job.State == JobState.Paused) {
151          job.Command = null;
152        } else if (job.Command.HasValue && job.Command.Value == Command.Abort && job.State == JobState.Aborted) {
153          job.Command = null;
154        } else if (job.Command.HasValue && job.Command.Value == Command.Stop && job.State == JobState.Aborted) {
155          job.Command = null;
156        } else if (jobState == JobState.Paused && !job.Command.HasValue) {
157          // job was paused and uploaded by slave without the user-command to pause it -> set waiting
158          job = dao.UpdateJobState(jobId, JobState.Waiting, slaveId, userId, exception);
159        }
160
161        dao.UpdateJob(job);
162        return job;
163      });
164    }
165    #endregion
166
167    #region Job Control Methods
168    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
169    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
170    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
171    public void StopJob(Guid jobId) {
172      trans.UseTransaction(() => {
173        //dao.UpdateJobState(jobId, JobState.Aborted, null, auth.UserId, string.Empty);
174        var job = dao.GetJob(jobId);
175        job.Command = Command.Stop;
176        dao.UpdateJob(job);
177      });
178    }
179
180    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
181    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
182    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
183    public void PauseJob(Guid jobId) {
184      trans.UseTransaction(() => {
185        //dao.UpdateJobState(jobId, JobState.Paused, null, auth.UserId, string.Empty);
186        var job = dao.GetJob(jobId);
187        job.Command = Command.Pause;
188        dao.UpdateJob(job);
189      });
190    }
191
192    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
193    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
194    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
195    public void RestartJob(Guid jobId) {
196      trans.UseTransaction(() => {
197        Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, auth.UserId, string.Empty);
198        job.Command = null;
199        dao.UpdateJob(job);
200      });
201    }
202    #endregion
203
204    #region HiveExperiment Methods
205    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
206    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
207    public HiveExperiment GetHiveExperiment(Guid id) {
208      return dao.GetHiveExperiments(x =>
209             x.HiveExperimentId == id
210          && (x.OwnerUserId == auth.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == auth.UserId) > 0)
211          ).FirstOrDefault();
212    }
213
214    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
215    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
216    public IEnumerable<HiveExperiment> GetHiveExperiments() {
217      return dao.GetHiveExperiments(x => x.OwnerUserId == auth.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == auth.UserId) > 0);
218    }
219
220    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]   
221    public IEnumerable<HiveExperiment> GetAllHiveExperiments() {
222      return dao.GetHiveExperiments(x => true);
223    }
224
225    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
226    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
227    public Guid AddHiveExperiment(HiveExperiment hiveExperimentDto) {
228      return trans.UseTransaction(() => {
229        hiveExperimentDto.OwnerUserId = auth.UserId;
230        hiveExperimentDto.DateCreated = DateTime.Now;
231        return dao.AddHiveExperiment(hiveExperimentDto);
232      });
233    }
234
235    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
236    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
237    public void UpdateHiveExperiment(HiveExperiment hiveExperimentDto) {
238      trans.UseTransaction(() => {
239        dao.UpdateHiveExperiment(hiveExperimentDto);
240      });
241    }
242
243    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
244    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
245    public void DeleteHiveExperiment(Guid hiveExperimentId) {
246      trans.UseTransaction(() => {
247        HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId);
248        dao.DeleteHiveExperiment(hiveExperimentId); // child jobs will be deleted by db-trigger
249      });
250    }
251    #endregion
252
253    #region Login Methods
254    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
255    public void Hello(Slave slaveInfo) {
256      trans.UseTransaction(() => {
257        var slave = dao.GetSlave(slaveInfo.Id);
258
259        if (slave == null) {
260          dao.AddSlave(slaveInfo);
261        } else {
262          var dbSlave = dao.GetSlave(slaveInfo.Id);
263
264          dbSlave.Name = slaveInfo.Name;
265          dbSlave.Description = slaveInfo.Description;
266
267          dbSlave.Cores = slaveInfo.Cores;
268          dbSlave.CpuArchitecture = slaveInfo.CpuArchitecture;
269          dbSlave.CpuSpeed = slaveInfo.CpuSpeed;
270          dbSlave.FreeCores = slaveInfo.FreeCores;
271          dbSlave.FreeMemory = slaveInfo.FreeMemory;
272          dbSlave.Memory = slaveInfo.Memory;
273          dbSlave.OperatingSystem = slaveInfo.OperatingSystem;
274         
275          dbSlave.LastHeartbeat = DateTime.Now;         
276          dbSlave.SlaveState = SlaveState.Idle;
277
278          // don't update those properties:
279          // dbSlave.IsAllowedToCalculate = slaveInfo.IsAllowedToCalculate;
280          // dbSlave.ParentResourceId = slaveInfo.ParentResourceId;
281
282          dao.UpdateSlave(dbSlave);
283        }
284      });
285    }
286
287    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
288    public void GoodBye(Guid slaveId) {
289      trans.UseTransaction(() => {
290        var slave = dao.GetSlave(slaveId);
291        if (slave != null) {
292          slave.SlaveState = SlaveState.Offline;
293          dao.UpdateSlave(slave);
294        }
295      });
296    }
297    #endregion
298
299    #region Heartbeat Methods
300    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
301    public List<MessageContainer> Heartbeat(Heartbeat heartbeat) {
302      TriggerLifecycle(false);
303      return trans.UseTransaction(() => heartbeatManager.ProcessHeartbeat(heartbeat));
304    }
305    #endregion
306
307    #region Plugin Methods
308    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
309    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
310    public Guid AddPlugin(Plugin plugin, List<PluginData> pluginDatas) {
311      return trans.UseTransaction(() => {
312        plugin.UserId = auth.UserId;
313        plugin.DateCreated = DateTime.Now;
314        if (!plugin.IsLocal) {
315          var existing = dao.GetPlugins(x => x.Name == plugin.Name && x.Version == plugin.Version.ToString() && !x.IsLocal);
316          if (existing.Count() > 0) {
317            // a plugin with the same name and version already exists.
318            throw new FaultException<PluginAlreadyExistsFault>(new PluginAlreadyExistsFault(existing.Single().Id));
319          }
320        }
321        Guid pluginId = dao.AddPlugin(plugin);
322        foreach (PluginData pluginData in pluginDatas) {
323          pluginData.PluginId = pluginId;
324          dao.AddPluginData(pluginData);
325        }
326        return pluginId;
327      });
328    }
329
330    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
331    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
332    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
333    public Plugin GetPlugin(Guid pluginId) {
334      return dao.GetPlugin(pluginId);
335    }
336
337    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
338    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
339    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
340    public IEnumerable<Plugin> GetPlugins() {
341      return dao.GetPlugins(x => x.IsLocal == false);
342    }
343
344    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
345    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
346    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
347    public IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds) {
348      List<PluginData> pluginDatas = new List<PluginData>();
349
350      return trans.UseTransaction(() => {
351        foreach (Guid guid in pluginIds) {
352          List<PluginData> pluginData = dao.GetPluginDatas(x => x.PluginId == guid).ToList();
353          if (pluginData != null) {
354            pluginDatas.AddRange(pluginData);
355          } else {
356            //ignore ?
357          }
358        }
359        return pluginDatas;
360      });
361    }
362
363    #endregion
364
365    #region Slave Methods
366    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
367    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
368    public Guid AddSlave(Slave slave) {
369      return trans.UseTransaction(() => dao.AddSlave(slave));
370    }
371
372    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
373    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
374    public Guid AddSlaveGroup(SlaveGroup slaveGroup) {
375      return trans.UseTransaction(() => dao.AddSlaveGroup(slaveGroup));
376    }
377
378    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
379    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
380    public Slave GetSlave(Guid slaveId) {
381      return dao.GetSlave(slaveId);
382    }
383
384    public SlaveGroup GetSlaveGroup(Guid slaveGroupId) {
385      return dao.GetSlaveGroup(slaveGroupId);
386    }
387
388    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
389    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
390    public IEnumerable<Slave> GetSlaves() {
391      return dao.GetSlaves(x => true);
392    }
393
394    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
395    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
396    public IEnumerable<SlaveGroup> GetSlaveGroups() {
397      return dao.GetSlaveGroups(x => true);
398    }
399
400    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
401    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
402    public void UpdateSlave(Slave slave) {
403      trans.UseTransaction(() => {
404        dao.UpdateSlave(slave);
405      });
406    }
407
408    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
409    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
410    public void UpdateSlaveGroup(SlaveGroup slaveGroup) {
411      trans.UseTransaction(() => {
412        dao.UpdateSlaveGroup(slaveGroup);
413      });
414    }
415
416    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
417    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
418    public void DeleteSlave(Guid slaveId) {
419      trans.UseTransaction(() => {
420        dao.DeleteSlave(slaveId);
421      });
422    }
423
424    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
425    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
426    public void DeleteSlaveGroup(Guid slaveGroupId) {
427      trans.UseTransaction(() => {
428        dao.DeleteSlaveGroup(slaveGroupId);
429      });
430    }
431
432    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
433    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
434    public void AddResourceToGroup(Guid slaveGroupId, Guid resourceId) {
435      trans.UseTransaction(() => {
436        var resource = dao.GetResource(resourceId);
437        resource.ParentResourceId = slaveGroupId;
438        dao.UpdateResource(resource);
439      });
440    }
441
442    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
443    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
444    public void RemoveResourceFromGroup(Guid slaveGroupId, Guid resourceId) {
445      trans.UseTransaction(() => {
446        var resource = dao.GetResource(resourceId);
447        resource.ParentResourceId = null;
448        dao.UpdateResource(resource);
449      });
450    }
451
452    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
453    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
454    public Guid GetResourceId(string resourceName) {
455      return trans.UseTransaction(() => {
456        var resource = dao.GetResources(x => x.Name == resourceName).FirstOrDefault();
457        if (resource != null) {
458          return resource.Id;
459        } else {
460          return Guid.Empty;
461        }
462      });
463    }
464
465    public void TriggerLifecycle(bool force) {
466      trans.UseTransaction(() => {
467        DateTime lastCleanup = dao.GetLastCleanup();
468        if (force || DateTime.Now - lastCleanup > TimeSpan.FromSeconds(59)) {
469          dao.SetLastCleanup(DateTime.Now);
470          lifecycleManager.Cleanup();
471        }
472      });
473    }
474    #endregion
475
476    #region Helper Methods
477    private IEnumerable<Job> GetChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
478      var jobs = new List<Job>(dao.GetJobs(x => parentJobId == null ? !x.ParentJobId.HasValue : x.ParentJobId.Value == parentJobId));
479
480      if (recursive) {
481        var childs = new List<Job>();
482        foreach (var job in jobs) {
483          childs.AddRange(GetChildJobs(job.Id, recursive, false));
484        }
485        jobs.AddRange(childs);
486      }
487
488      if (includeParent) jobs.Add(GetJob(parentJobId.Value));
489
490      return jobs;
491    }
492
493    #endregion
494
495    #region Appointment Methods
496
497    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
498    public Guid AddAppointment(Appointment appointment) {
499      return trans.UseTransaction(() => dao.AddAppointment(appointment));
500    }
501
502    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
503    public void DeleteAppointment(Guid appointmentId) {
504      trans.UseTransaction(() => {
505        dao.DeleteAppointment(appointmentId);
506      });
507    }
508
509    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
510    public void UpdateAppointment(Appointment appointment) {
511      trans.UseTransaction(() => {
512        dao.UpdateAppointment(appointment);
513      });
514    }
515
516    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
517    public IEnumerable<Appointment> GetScheduleForResource(Guid resourceId) {
518      return trans.UseTransaction(() => dao.GetAppointments(x => x.ResourceId == resourceId));
519    }
520    #endregion
521  }
522}
Note: See TracBrowser for help on using the repository browser.