1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.ServiceModel;
|
---|
5 | using HeuristicLab.Services.Hive.Common;
|
---|
6 | using HeuristicLab.Services.Hive.Common.DataTransfer;
|
---|
7 | using HeuristicLab.Services.Hive.Common.ServiceContracts;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.Services.Hive {
|
---|
10 |
|
---|
11 | /// <summary>
|
---|
12 | /// Implementation of the Hive service (interface <see cref="IHiveService"/>).
|
---|
13 | /// </summary>
|
---|
14 | [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
|
---|
15 | public class HiveService : IHiveService {
|
---|
16 | private DataAccess.IHiveDao dao {
|
---|
17 | get { return ServiceLocator.Instance.HiveDao; }
|
---|
18 | }
|
---|
19 | private HeuristicLab.Services.Hive.DataAccess.TransactionManager trans {
|
---|
20 | get { return ServiceLocator.Instance.TransactionManager; }
|
---|
21 | }
|
---|
22 | private IAuthorizationManager auth {
|
---|
23 | get { return ServiceLocator.Instance.AuthorizationManager; }
|
---|
24 | }
|
---|
25 | private ILifecycleManager lifecycleManager {
|
---|
26 | get { return ServiceLocator.Instance.LifecycleManager; }
|
---|
27 | }
|
---|
28 | private HeartbeatManager heartbeatManager {
|
---|
29 | get { return ServiceLocator.Instance.HeartbeatManager; }
|
---|
30 | }
|
---|
31 |
|
---|
32 | #region Job Methods
|
---|
33 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
34 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
35 | public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds) {
|
---|
36 | using (trans.OpenTransaction()) {
|
---|
37 | job.SetState(JobState.Waiting, auth.UserId);
|
---|
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 | return jobData.JobId;
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
54 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
55 | public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) {
|
---|
56 | using (trans.OpenTransaction()) {
|
---|
57 | job.ParentJobId = parentJobId;
|
---|
58 | return AddJob(job, jobData, dao.GetAssignedResources(parentJobId).Select(x => x.Id));
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
63 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
64 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
65 | public Job GetJob(Guid jobId) {
|
---|
66 | return dao.GetJob(jobId);
|
---|
67 | }
|
---|
68 |
|
---|
69 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
70 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
71 | public IEnumerable<Job> GetJobs() {
|
---|
72 | return dao.GetJobs(x => true);
|
---|
73 | }
|
---|
74 |
|
---|
75 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
76 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
77 | public IEnumerable<LightweightJob> GetLightweightJobs(IEnumerable<Guid> jobIds) {
|
---|
78 | return dao.GetJobs(x => jobIds.Contains(x.JobId)).Select(x => new LightweightJob(x)).ToArray();
|
---|
79 | }
|
---|
80 |
|
---|
81 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
82 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
83 | public IEnumerable<LightweightJob> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
|
---|
84 | return GetChildJobs(parentJobId, recursive, includeParent).Select(x => new LightweightJob(x)).ToArray();
|
---|
85 | }
|
---|
86 |
|
---|
87 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
88 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
89 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
90 | public JobData GetJobData(Guid jobId) {
|
---|
91 | return dao.GetJobData(jobId);
|
---|
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 void UpdateJob(Job job) {
|
---|
98 | using (trans.OpenTransaction()) {
|
---|
99 | dao.UpdateJob(job);
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
104 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
105 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
106 | public void UpdateJobData(Job job, JobData jobData) {
|
---|
107 | using (trans.OpenTransaction()) {
|
---|
108 | jobData.LastUpdate = DateTime.Now;
|
---|
109 | dao.UpdateJob(job);
|
---|
110 | dao.UpdateJobData(jobData);
|
---|
111 | }
|
---|
112 | }
|
---|
113 |
|
---|
114 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
115 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
116 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
117 | public void DeleteJob(Guid jobId) {
|
---|
118 | using (trans.OpenTransaction()) {
|
---|
119 | dao.DeleteJob(jobId);
|
---|
120 | }
|
---|
121 | }
|
---|
122 |
|
---|
123 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
124 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
125 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
126 | public void DeleteChildJobs(Guid parentJobId) {
|
---|
127 | using (trans.OpenTransaction()) {
|
---|
128 | var jobs = GetChildJobs(parentJobId, true, false);
|
---|
129 | foreach (var job in jobs) {
|
---|
130 | dao.DeleteJob(job.Id);
|
---|
131 | dao.DeleteJobData(job.Id);
|
---|
132 | };
|
---|
133 | }
|
---|
134 | }
|
---|
135 |
|
---|
136 | #endregion
|
---|
137 |
|
---|
138 | #region Job Control Methods
|
---|
139 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
140 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
141 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
142 | public void StopJob(Guid jobId) {
|
---|
143 | using (trans.OpenTransaction()) {
|
---|
144 | throw new NotImplementedException();
|
---|
145 | }
|
---|
146 | }
|
---|
147 |
|
---|
148 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
149 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
150 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
151 | public void PauseJob(Guid jobId) {
|
---|
152 | using (trans.OpenTransaction()) {
|
---|
153 | throw new NotImplementedException();
|
---|
154 | }
|
---|
155 | }
|
---|
156 | #endregion
|
---|
157 |
|
---|
158 | #region HiveExperiment Methods
|
---|
159 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
160 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
161 | public HiveExperiment GetHiveExperiment(Guid id) {
|
---|
162 | return dao.GetHiveExperiments(x =>
|
---|
163 | x.HiveExperimentId == id
|
---|
164 | && (x.OwnerUserId == auth.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == auth.UserId) > 0)
|
---|
165 | ).FirstOrDefault();
|
---|
166 | }
|
---|
167 |
|
---|
168 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
169 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
170 | public IEnumerable<HiveExperiment> GetHiveExperiments() {
|
---|
171 | return dao.GetHiveExperiments(x => x.OwnerUserId == auth.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == auth.UserId) > 0);
|
---|
172 | }
|
---|
173 |
|
---|
174 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
175 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
176 | public Guid AddHiveExperiment(HiveExperiment hiveExperimentDto) {
|
---|
177 | using (trans.OpenTransaction()) {
|
---|
178 | hiveExperimentDto.OwnerUserId = auth.UserId;
|
---|
179 | hiveExperimentDto.DateCreated = DateTime.Now;
|
---|
180 | return dao.AddHiveExperiment(hiveExperimentDto);
|
---|
181 | }
|
---|
182 | }
|
---|
183 |
|
---|
184 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
185 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
186 | public void UpdateHiveExperiment(HiveExperiment hiveExperimentDto) {
|
---|
187 | using (trans.OpenTransaction()) {
|
---|
188 | dao.UpdateHiveExperiment(hiveExperimentDto);
|
---|
189 | }
|
---|
190 | }
|
---|
191 |
|
---|
192 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
193 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
194 | public void DeleteHiveExperiment(Guid hiveExperimentId) {
|
---|
195 | using (trans.OpenTransaction()) {
|
---|
196 | HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId);
|
---|
197 | dao.DeleteHiveExperiment(hiveExperimentId); // child jobs will be deleted by db-trigger
|
---|
198 | }
|
---|
199 | }
|
---|
200 | #endregion
|
---|
201 |
|
---|
202 | #region Login Methods
|
---|
203 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
204 | public void Hello(Slave slaveInfo) {
|
---|
205 | using (trans.OpenTransaction()) {
|
---|
206 | var slave = dao.GetSlave(slaveInfo.Id);
|
---|
207 |
|
---|
208 | if (slave == null) {
|
---|
209 | dao.AddSlave(slaveInfo);
|
---|
210 | } else {
|
---|
211 | dao.UpdateSlave(slaveInfo);
|
---|
212 | }
|
---|
213 | }
|
---|
214 | }
|
---|
215 |
|
---|
216 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
217 | public void GoodBye(Guid slaveId) {
|
---|
218 | using (trans.OpenTransaction()) {
|
---|
219 | var slave = dao.GetSlave(slaveId);
|
---|
220 | if (slave != null) {
|
---|
221 | slave.SlaveState = SlaveState.Offline;
|
---|
222 | dao.UpdateSlave(slave);
|
---|
223 | }
|
---|
224 | }
|
---|
225 | }
|
---|
226 | #endregion
|
---|
227 |
|
---|
228 | #region Heartbeat Methods
|
---|
229 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
230 | public List<MessageContainer> Heartbeat(Heartbeat heartbeat) {
|
---|
231 | TriggerLifecycle();
|
---|
232 |
|
---|
233 | using (trans.OpenTransaction()) {
|
---|
234 | return heartbeatManager.ProcessHeartbeat(heartbeat);
|
---|
235 | }
|
---|
236 | }
|
---|
237 | #endregion
|
---|
238 |
|
---|
239 | #region Plugin Methods
|
---|
240 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
241 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
242 | public Guid AddPlugin(Plugin plugin, List<PluginData> pluginDatas) {
|
---|
243 | using (trans.OpenTransaction()) {
|
---|
244 | plugin.UserId = auth.UserId;
|
---|
245 | plugin.DateCreated = DateTime.Now;
|
---|
246 | Guid pluginId = dao.AddPlugin(plugin);
|
---|
247 | foreach (PluginData pluginData in pluginDatas) {
|
---|
248 | pluginData.PluginId = pluginId;
|
---|
249 | dao.AddPluginData(pluginData);
|
---|
250 | }
|
---|
251 | return pluginId;
|
---|
252 | }
|
---|
253 | }
|
---|
254 |
|
---|
255 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
256 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
257 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
258 | public IEnumerable<Plugin> GetPlugins() {
|
---|
259 | return dao.GetPlugins(x => x.IsLocal == false);
|
---|
260 | }
|
---|
261 |
|
---|
262 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
263 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
264 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
|
---|
265 | public IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds) {
|
---|
266 | List<PluginData> pluginDatas = new List<PluginData>();
|
---|
267 |
|
---|
268 | using (trans.OpenTransaction()) {
|
---|
269 | foreach (Guid guid in pluginIds) {
|
---|
270 | List<PluginData> pluginData = dao.GetPluginDatas(x => x.PluginId == guid).ToList();
|
---|
271 | if (pluginData != null) {
|
---|
272 | pluginDatas.AddRange(pluginData);
|
---|
273 | } else {
|
---|
274 | //ignore ?
|
---|
275 | }
|
---|
276 | }
|
---|
277 | return pluginDatas;
|
---|
278 | }
|
---|
279 | }
|
---|
280 |
|
---|
281 | #endregion
|
---|
282 |
|
---|
283 | #region Slave Methods
|
---|
284 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
285 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
286 | public Guid AddSlave(Slave slave) {
|
---|
287 | using (trans.OpenTransaction()) {
|
---|
288 | return dao.AddSlave(slave);
|
---|
289 | }
|
---|
290 | }
|
---|
291 |
|
---|
292 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
293 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
294 | public Guid AddSlaveGroup(SlaveGroup slaveGroup) {
|
---|
295 | using (trans.OpenTransaction()) {
|
---|
296 | return dao.AddSlaveGroup(slaveGroup);
|
---|
297 | }
|
---|
298 | }
|
---|
299 |
|
---|
300 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
301 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
302 | public Slave GetSlave(Guid slaveId) {
|
---|
303 | return dao.GetSlave(slaveId);
|
---|
304 | }
|
---|
305 |
|
---|
306 | public SlaveGroup GetSlaveGroup(Guid slaveGroupId) {
|
---|
307 | return dao.GetSlaveGroup(slaveGroupId);
|
---|
308 | }
|
---|
309 |
|
---|
310 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
311 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
312 | public IEnumerable<Slave> GetSlaves() {
|
---|
313 | return dao.GetSlaves(x => true);
|
---|
314 | }
|
---|
315 |
|
---|
316 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
317 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
318 | public IEnumerable<SlaveGroup> GetSlaveGroups() {
|
---|
319 | return dao.GetSlaveGroups(x => true);
|
---|
320 | }
|
---|
321 |
|
---|
322 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
323 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
324 | public void UpdateSlave(Slave slave) {
|
---|
325 | using (trans.OpenTransaction()) {
|
---|
326 | dao.UpdateSlave(slave);
|
---|
327 | }
|
---|
328 | }
|
---|
329 |
|
---|
330 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
331 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
332 | public void UpdateSlaveGroup(SlaveGroup slaveGroup) {
|
---|
333 | using (trans.OpenTransaction()) {
|
---|
334 | dao.UpdateSlaveGroup(slaveGroup);
|
---|
335 | }
|
---|
336 | }
|
---|
337 |
|
---|
338 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
339 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
340 | public void DeleteSlave(Guid slaveId) {
|
---|
341 | using (trans.OpenTransaction()) {
|
---|
342 | dao.DeleteSlave(slaveId);
|
---|
343 | }
|
---|
344 | }
|
---|
345 |
|
---|
346 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
347 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
348 | public void DeleteSlaveGroup(Guid slaveGroupId) {
|
---|
349 | using (trans.OpenTransaction()) {
|
---|
350 | dao.DeleteSlaveGroup(slaveGroupId);
|
---|
351 | }
|
---|
352 | }
|
---|
353 |
|
---|
354 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
355 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
356 | public void AddResourceToGroup(Guid slaveGroupId, Guid resourceId) {
|
---|
357 | using (trans.OpenTransaction()) {
|
---|
358 | var resource = dao.GetResource(resourceId);
|
---|
359 | resource.ParentResourceId = slaveGroupId;
|
---|
360 | dao.UpdateResource(resource);
|
---|
361 | }
|
---|
362 | }
|
---|
363 |
|
---|
364 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
365 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
366 | public void RemoveResourceFromGroup(Guid slaveGroupId, Guid resourceId) {
|
---|
367 | using (trans.OpenTransaction()) {
|
---|
368 | var resource = dao.GetResource(resourceId);
|
---|
369 | resource.ParentResourceId = null;
|
---|
370 | dao.UpdateResource(resource);
|
---|
371 | }
|
---|
372 | }
|
---|
373 |
|
---|
374 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
|
---|
375 | // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
|
---|
376 | public Guid GetResourceId(string resourceName) {
|
---|
377 | using (trans.OpenTransaction()) {
|
---|
378 | var resource = dao.GetResources(x => x.Name == resourceName).FirstOrDefault();
|
---|
379 | if (resource != null) {
|
---|
380 | return resource.Id;
|
---|
381 | } else {
|
---|
382 | return Guid.Empty;
|
---|
383 | }
|
---|
384 | }
|
---|
385 | }
|
---|
386 |
|
---|
387 | public void TriggerLifecycle() {
|
---|
388 | using (trans.OpenTransaction()) {
|
---|
389 | DateTime lastCleanup = dao.GetLastCleanup();
|
---|
390 | if (DateTime.Now - lastCleanup > TimeSpan.FromSeconds(59)) {
|
---|
391 | dao.SetLastCleanup(DateTime.Now);
|
---|
392 | lifecycleManager.Cleanup();
|
---|
393 | }
|
---|
394 | }
|
---|
395 | }
|
---|
396 | #endregion
|
---|
397 |
|
---|
398 | #region Helper Methods
|
---|
399 | private IEnumerable<Job> GetChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
|
---|
400 | var jobs = new List<Job>(dao.GetJobs(x => parentJobId == null ? !x.ParentJobId.HasValue : x.ParentJobId.Value == parentJobId));
|
---|
401 |
|
---|
402 | if (recursive) {
|
---|
403 | var childs = new List<Job>();
|
---|
404 | foreach (var job in jobs) {
|
---|
405 | childs.AddRange(GetChildJobs(job.Id, recursive, false));
|
---|
406 | }
|
---|
407 | jobs.AddRange(childs);
|
---|
408 | }
|
---|
409 |
|
---|
410 | if (includeParent) jobs.Add(GetJob(parentJobId.Value));
|
---|
411 |
|
---|
412 | return jobs;
|
---|
413 | }
|
---|
414 |
|
---|
415 | #endregion
|
---|
416 | }
|
---|
417 | }
|
---|