1 | using System;
|
---|
2 | using System.Linq;
|
---|
3 | using DA = HeuristicLab.Services.Hive.DataAccess;
|
---|
4 | using DT = HeuristicLab.Services.Hive.DataTransfer;
|
---|
5 |
|
---|
6 | namespace HeuristicLab.Services.Hive {
|
---|
7 | public static class Converter {
|
---|
8 |
|
---|
9 | #region Task
|
---|
10 | public static DT.Task ToDto(this DA.Task source) {
|
---|
11 | if (source == null) return null;
|
---|
12 | return new DT.Task {
|
---|
13 | Id = source.TaskId,
|
---|
14 | State = source.State.ToDto(),
|
---|
15 | ExecutionTime = TimeSpan.FromMilliseconds(source.ExecutionTimeMs),
|
---|
16 | LastHeartbeat = source.LastHeartbeat,
|
---|
17 | ParentTaskId = source.ParentTaskId,
|
---|
18 | Priority = source.Priority,
|
---|
19 | CoresNeeded = source.CoresNeeded,
|
---|
20 | MemoryNeeded = source.MemoryNeeded,
|
---|
21 | IsParentTask = source.IsParentTask,
|
---|
22 | FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished,
|
---|
23 | Command = source.Command.ToDto(),
|
---|
24 | JobId = source.JobId,
|
---|
25 | IsPrivileged = source.IsPrivileged,
|
---|
26 | PluginsNeededIds = source.RequiredPlugins.Select(x => x.PluginId).ToList(),
|
---|
27 | StateLog = source.StateLogs.Select(x => x.ToDto()).OrderBy(x => x.DateTime).ToList(),
|
---|
28 | LastTaskDataUpdate = source.JobData == null ? DateTime.MinValue : source.JobData.LastUpdate
|
---|
29 | };
|
---|
30 | }
|
---|
31 |
|
---|
32 | public static DA.Task ToEntity(this DT.Task source) {
|
---|
33 | if (source == null) return null;
|
---|
34 | var result = new DA.Task();
|
---|
35 | source.CopyToEntity(result);
|
---|
36 | return result;
|
---|
37 | }
|
---|
38 |
|
---|
39 | public static void CopyToEntity(this DT.Task source, DA.Task target) {
|
---|
40 | if ((source == null) || (target == null)) return;
|
---|
41 | target.TaskId = source.Id;
|
---|
42 | target.State = source.State.ToEntity();
|
---|
43 | target.ExecutionTimeMs = source.ExecutionTime.TotalMilliseconds;
|
---|
44 | target.LastHeartbeat = source.LastHeartbeat;
|
---|
45 | target.ParentTaskId = source.ParentTaskId;
|
---|
46 | target.Priority = source.Priority;
|
---|
47 | target.CoresNeeded = source.CoresNeeded;
|
---|
48 | target.MemoryNeeded = source.MemoryNeeded;
|
---|
49 | target.IsParentTask = source.IsParentTask;
|
---|
50 | target.FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished;
|
---|
51 | target.Command = source.Command.ToEntity();
|
---|
52 | target.JobId = source.JobId;
|
---|
53 | target.IsPrivileged = source.IsPrivileged;
|
---|
54 | var ids = target.RequiredPlugins.Select(x => x.PluginId);
|
---|
55 | target.RequiredPlugins.AddRange(source.PluginsNeededIds
|
---|
56 | .Where(x => !ids.Contains(x))
|
---|
57 | .Select(x => new DA.RequiredPlugin {
|
---|
58 | PluginId = x
|
---|
59 | })
|
---|
60 | );
|
---|
61 | target.StateLogs.AddRange(source.StateLog
|
---|
62 | .Where(x => x.Id == Guid.Empty)
|
---|
63 | .Select(x => x.ToEntity())
|
---|
64 | );
|
---|
65 | // result.JobData missing
|
---|
66 | // result.AssignedResources missing
|
---|
67 | }
|
---|
68 | #endregion
|
---|
69 |
|
---|
70 | #region TaskData
|
---|
71 | public static DT.TaskData ToDto(this DA.TaskData source) {
|
---|
72 | if (source == null) return null;
|
---|
73 | return new DT.TaskData {
|
---|
74 | TaskId = source.TaskId,
|
---|
75 | Data = source.Data,
|
---|
76 | LastUpdate = source.LastUpdate
|
---|
77 | };
|
---|
78 | }
|
---|
79 |
|
---|
80 | public static DA.TaskData ToEntity(this DT.TaskData source) {
|
---|
81 | if (source == null) return null;
|
---|
82 | var result = new DA.TaskData();
|
---|
83 | source.CopyToEntity(result);
|
---|
84 | return result;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public static void CopyToEntity(this DT.TaskData source, DA.TaskData target) {
|
---|
88 | if ((source == null) || (target == null)) return;
|
---|
89 | target.TaskId = source.TaskId;
|
---|
90 | target.Data = source.Data;
|
---|
91 | target.LastUpdate = source.LastUpdate;
|
---|
92 | }
|
---|
93 | #endregion
|
---|
94 |
|
---|
95 | #region Job
|
---|
96 | public static DT.Job ToDto(this DA.Job source) {
|
---|
97 | return new DT.Job {
|
---|
98 | Id = source.JobId,
|
---|
99 | Description = source.Description,
|
---|
100 | Name = source.Name,
|
---|
101 | OwnerUserId = source.OwnerUserId,
|
---|
102 | DateCreated = source.DateCreated,
|
---|
103 | ResourceNames = source.ResourceIds
|
---|
104 | };
|
---|
105 | }
|
---|
106 |
|
---|
107 | public static DA.Job ToEntity(this DT.Job source) {
|
---|
108 | if (source == null) return null;
|
---|
109 | var result = new DA.Job();
|
---|
110 | source.CopyToEntity(result);
|
---|
111 | return result;
|
---|
112 | }
|
---|
113 |
|
---|
114 | public static void CopyToEntity(this DT.Job source, DA.Job target) {
|
---|
115 | if ((source == null) || (target == null)) return;
|
---|
116 | target.JobId = source.Id;
|
---|
117 | target.Description = source.Description;
|
---|
118 | target.Name = source.Name;
|
---|
119 | target.OwnerUserId = source.OwnerUserId;
|
---|
120 | target.DateCreated = source.DateCreated;
|
---|
121 | target.ResourceIds = source.ResourceNames;
|
---|
122 | }
|
---|
123 | #endregion
|
---|
124 |
|
---|
125 | #region JobPermission
|
---|
126 | public static DT.JobPermission ToDto(this DA.JobPermission source) {
|
---|
127 | if (source == null) return null;
|
---|
128 | return new DT.JobPermission {
|
---|
129 | JobId = source.JobId,
|
---|
130 | GrantedUserId = source.GrantedUserId,
|
---|
131 | GrantedByUserId = source.GrantedByUserId,
|
---|
132 | Permission = source.Permission.ToDto()
|
---|
133 | };
|
---|
134 | }
|
---|
135 |
|
---|
136 | public static DA.JobPermission ToEntity(this DT.JobPermission source) {
|
---|
137 | if (source == null) return null;
|
---|
138 | var result = new DA.JobPermission();
|
---|
139 | source.CopyToEntity(result);
|
---|
140 | return result;
|
---|
141 | }
|
---|
142 |
|
---|
143 | public static void CopyToEntity(this DT.JobPermission source, DA.JobPermission target) {
|
---|
144 | if ((source == null) || (target == null)) return;
|
---|
145 | target.JobId = source.JobId;
|
---|
146 | target.GrantedUserId = source.GrantedUserId;
|
---|
147 | target.GrantedByUserId = source.GrantedByUserId;
|
---|
148 | target.Permission = source.Permission.ToEntity();
|
---|
149 | }
|
---|
150 | #endregion
|
---|
151 |
|
---|
152 | #region Slave
|
---|
153 | public static DT.Slave ToDto(this DA.Slave source) {
|
---|
154 | if (source == null) return null;
|
---|
155 | return new DT.Slave {
|
---|
156 | Id = source.ResourceId,
|
---|
157 | ParentResourceId = source.ParentResourceId,
|
---|
158 | Cores = source.Cores,
|
---|
159 | CpuSpeed = source.CpuSpeed,
|
---|
160 | FreeCores = source.FreeCores,
|
---|
161 | FreeMemory = source.FreeMemory,
|
---|
162 | IsAllowedToCalculate = source.IsAllowedToCalculate,
|
---|
163 | Memory = source.Memory,
|
---|
164 | Name = source.Name,
|
---|
165 | SlaveState = source.SlaveState.ToDto(),
|
---|
166 | CpuArchitecture = source.CpuArchitecture.ToDto(),
|
---|
167 | OperatingSystem = source.OperatingSystem,
|
---|
168 | LastHeartbeat = source.LastHeartbeat,
|
---|
169 | CpuUtilization = source.CpuUtilization,
|
---|
170 | HbInterval = source.HbInterval,
|
---|
171 | IsDisposable = source.IsDisposable,
|
---|
172 | OwnerUserId = source.OwnerUserId
|
---|
173 | };
|
---|
174 | }
|
---|
175 | public static DA.Slave ToEntity(this DT.Slave source) {
|
---|
176 | if (source == null) return null;
|
---|
177 | var result = new DA.Slave();
|
---|
178 | source.CopyToEntity(result);
|
---|
179 | return result;
|
---|
180 | }
|
---|
181 | public static void CopyToEntity(this DT.Slave source, DA.Slave target) {
|
---|
182 | if ((source == null) || (target == null)) return;
|
---|
183 | target.ResourceId = source.Id;
|
---|
184 | target.ParentResourceId = source.ParentResourceId;
|
---|
185 | target.Cores = source.Cores;
|
---|
186 | target.CpuSpeed = source.CpuSpeed;
|
---|
187 | target.FreeCores = source.FreeCores;
|
---|
188 | target.FreeMemory = source.FreeMemory;
|
---|
189 | target.IsAllowedToCalculate = source.IsAllowedToCalculate;
|
---|
190 | target.Memory = source.Memory;
|
---|
191 | target.Name = source.Name;
|
---|
192 | target.SlaveState = source.SlaveState.ToEntity();
|
---|
193 | target.CpuArchitecture = source.CpuArchitecture.ToEntity();
|
---|
194 | target.OperatingSystem = source.OperatingSystem;
|
---|
195 | target.LastHeartbeat = source.LastHeartbeat;
|
---|
196 | target.CpuUtilization = source.CpuUtilization;
|
---|
197 | target.HbInterval = source.HbInterval;
|
---|
198 | target.IsDisposable = source.IsDisposable;
|
---|
199 | target.OwnerUserId = source.OwnerUserId;
|
---|
200 | }
|
---|
201 | #endregion
|
---|
202 |
|
---|
203 | #region State
|
---|
204 | public static DT.TaskState ToDto(this DA.TaskState source) {
|
---|
205 | switch (source) {
|
---|
206 | case DA.TaskState.Aborted: return DT.TaskState.Aborted;
|
---|
207 | case DA.TaskState.Calculating: return DT.TaskState.Calculating;
|
---|
208 | case DA.TaskState.Failed: return DT.TaskState.Failed;
|
---|
209 | case DA.TaskState.Finished: return DT.TaskState.Finished;
|
---|
210 | case DA.TaskState.Offline: return DT.TaskState.Offline;
|
---|
211 | case DA.TaskState.Paused: return DT.TaskState.Paused;
|
---|
212 | case DA.TaskState.Transferring: return DT.TaskState.Transferring;
|
---|
213 | case DA.TaskState.Waiting: return DT.TaskState.Waiting;
|
---|
214 | default: return DT.TaskState.Failed;
|
---|
215 | }
|
---|
216 | }
|
---|
217 |
|
---|
218 | public static DA.TaskState ToEntity(this DT.TaskState source) {
|
---|
219 | switch (source) {
|
---|
220 | case DT.TaskState.Aborted: return DA.TaskState.Aborted;
|
---|
221 | case DT.TaskState.Calculating: return DA.TaskState.Calculating;
|
---|
222 | case DT.TaskState.Failed: return DA.TaskState.Failed;
|
---|
223 | case DT.TaskState.Finished: return DA.TaskState.Finished;
|
---|
224 | case DT.TaskState.Offline: return DA.TaskState.Offline;
|
---|
225 | case DT.TaskState.Paused: return DA.TaskState.Paused;
|
---|
226 | case DT.TaskState.Transferring: return DA.TaskState.Transferring;
|
---|
227 | case DT.TaskState.Waiting: return DA.TaskState.Waiting;
|
---|
228 | default: return DA.TaskState.Failed;
|
---|
229 | }
|
---|
230 | }
|
---|
231 | #endregion
|
---|
232 |
|
---|
233 | #region StateLogs
|
---|
234 | public static DT.StateLog ToDto(this DA.StateLog source) {
|
---|
235 | return new DT.StateLog {
|
---|
236 | Id = source.StateLogId,
|
---|
237 | State = source.State.ToDto(),
|
---|
238 | DateTime = source.DateTime,
|
---|
239 | TaskId = source.TaskId,
|
---|
240 | UserId = source.UserId,
|
---|
241 | SlaveId = source.SlaveId,
|
---|
242 | Exception = source.Exception
|
---|
243 | };
|
---|
244 | }
|
---|
245 |
|
---|
246 | public static DA.StateLog ToEntity(this DT.StateLog source) {
|
---|
247 | return new DA.StateLog {
|
---|
248 | StateLogId = source.Id,
|
---|
249 | State = source.State.ToEntity(),
|
---|
250 | DateTime = source.DateTime,
|
---|
251 | TaskId = source.TaskId,
|
---|
252 | UserId = source.UserId,
|
---|
253 | SlaveId = source.SlaveId,
|
---|
254 | Exception = source.Exception
|
---|
255 | };
|
---|
256 | }
|
---|
257 | #endregion
|
---|
258 |
|
---|
259 | #region Plugin
|
---|
260 | public static DT.Plugin ToDto(this DA.Plugin source) {
|
---|
261 | if (source == null) return null;
|
---|
262 | return new DT.Plugin {
|
---|
263 | Id = source.PluginId,
|
---|
264 | Name = source.Name,
|
---|
265 | Version = new Version(source.Version),
|
---|
266 | UserId = source.UserId,
|
---|
267 | DateCreated = source.DateCreated,
|
---|
268 | Hash = source.Hash
|
---|
269 | };
|
---|
270 | }
|
---|
271 | public static DA.Plugin ToEntity(this DT.Plugin source) {
|
---|
272 | if (source == null) return null;
|
---|
273 | var result = new DA.Plugin();
|
---|
274 | source.CopyToEntity(result);
|
---|
275 | return result;
|
---|
276 | }
|
---|
277 | public static void CopyToEntity(this DT.Plugin source, DA.Plugin target) {
|
---|
278 | if ((source == null) || (target == null)) return;
|
---|
279 | target.PluginId = source.Id;
|
---|
280 | target.Name = source.Name;
|
---|
281 | target.Version = source.Version.ToString();
|
---|
282 | target.UserId = source.UserId;
|
---|
283 | target.DateCreated = source.DateCreated;
|
---|
284 | target.Hash = source.Hash;
|
---|
285 | }
|
---|
286 | #endregion
|
---|
287 |
|
---|
288 | #region PluginData
|
---|
289 | public static DT.PluginData ToDto(this DA.PluginData source) {
|
---|
290 | if (source == null) return null;
|
---|
291 | return new DT.PluginData {
|
---|
292 | Id = source.PluginDataId,
|
---|
293 | PluginId = source.PluginId,
|
---|
294 | Data = source.Data.ToArray(),
|
---|
295 | FileName = source.FileName
|
---|
296 | };
|
---|
297 | }
|
---|
298 |
|
---|
299 | public static DA.PluginData ToEntity(this DT.PluginData source) {
|
---|
300 | if (source == null) return null;
|
---|
301 | var result = new DA.PluginData();
|
---|
302 | source.CopyToEntity(result);
|
---|
303 | return result;
|
---|
304 | }
|
---|
305 |
|
---|
306 | public static void CopyToEntity(this DT.PluginData source, DA.PluginData target) {
|
---|
307 | if ((source == null) || (target == null)) return;
|
---|
308 | target.PluginDataId = source.Id;
|
---|
309 | target.PluginId = source.PluginId;
|
---|
310 | target.Data = source.Data;
|
---|
311 | target.FileName = source.FileName;
|
---|
312 | }
|
---|
313 | #endregion
|
---|
314 |
|
---|
315 | #region ResourcePermission
|
---|
316 | public static DT.ResourcePermission ToDto(this DA.ResourcePermission source) {
|
---|
317 | if (source == null) return null;
|
---|
318 | return new DT.ResourcePermission {
|
---|
319 | ResourceId = source.ResourceId,
|
---|
320 | GrantedUserId = source.GrantedUserId,
|
---|
321 | GrantedByUserId = source.GrantedByUserId
|
---|
322 | };
|
---|
323 | }
|
---|
324 | public static DA.ResourcePermission ToEntity(this DT.ResourcePermission source) {
|
---|
325 | if (source == null) return null;
|
---|
326 | var result = new DA.ResourcePermission();
|
---|
327 | source.CopyToEntity(result);
|
---|
328 | return result;
|
---|
329 | }
|
---|
330 | public static void CopyToEntity(this DT.ResourcePermission source, DA.ResourcePermission target) {
|
---|
331 | if ((source == null) || (target == null)) return;
|
---|
332 | target.ResourceId = source.ResourceId;
|
---|
333 | target.GrantedUserId = source.GrantedUserId;
|
---|
334 | target.GrantedByUserId = source.GrantedByUserId;
|
---|
335 | }
|
---|
336 | #endregion
|
---|
337 |
|
---|
338 | #region SlaveGroup
|
---|
339 | public static DT.SlaveGroup ToDto(this DA.SlaveGroup source) {
|
---|
340 | if (source == null) return null;
|
---|
341 | return new DT.SlaveGroup {
|
---|
342 | Id = source.ResourceId,
|
---|
343 | Name = source.Name,
|
---|
344 | ParentResourceId = source.ParentResourceId,
|
---|
345 | HbInterval = source.HbInterval,
|
---|
346 | OwnerUserId = source.OwnerUserId
|
---|
347 | };
|
---|
348 | }
|
---|
349 |
|
---|
350 | public static DA.SlaveGroup ToEntity(this DT.SlaveGroup source) {
|
---|
351 | if (source == null) return null;
|
---|
352 | var result = new DA.SlaveGroup();
|
---|
353 | source.CopyToEntity(result);
|
---|
354 | return result;
|
---|
355 | }
|
---|
356 |
|
---|
357 | public static void CopyToEntity(this DT.SlaveGroup source, DA.SlaveGroup target) {
|
---|
358 | if ((source == null) || (target == null)) return;
|
---|
359 | target.ResourceId = source.Id;
|
---|
360 | target.Name = source.Name;
|
---|
361 | target.ParentResourceId = source.ParentResourceId;
|
---|
362 | target.HbInterval = source.HbInterval;
|
---|
363 | target.OwnerUserId = source.OwnerUserId;
|
---|
364 | }
|
---|
365 | #endregion
|
---|
366 |
|
---|
367 | #region Downtimes
|
---|
368 | public static DT.Downtime ToDto(this DA.Downtime source) {
|
---|
369 | if (source == null) return null;
|
---|
370 | return new DT.Downtime {
|
---|
371 | Id = source.DowntimeId,
|
---|
372 | AllDayEvent = source.AllDayEvent,
|
---|
373 | EndDate = source.EndDate,
|
---|
374 | Recurring = source.Recurring,
|
---|
375 | RecurringId = source.RecurringId,
|
---|
376 | ResourceId = source.ResourceId,
|
---|
377 | StartDate = source.StartDate,
|
---|
378 | DowntimeType = source.DowntimeType
|
---|
379 | };
|
---|
380 | }
|
---|
381 | public static DA.Downtime ToEntity(this DT.Downtime source) {
|
---|
382 | if (source == null) return null;
|
---|
383 | var result = new DA.Downtime();
|
---|
384 | source.CopyToEntity(result);
|
---|
385 | return result;
|
---|
386 | }
|
---|
387 | public static void CopyToEntity(this DT.Downtime source, DA.Downtime target) {
|
---|
388 | if ((source == null) || (target == null)) return;
|
---|
389 | target.DowntimeId = source.Id;
|
---|
390 | target.AllDayEvent = source.AllDayEvent;
|
---|
391 | target.EndDate = source.EndDate;
|
---|
392 | target.Recurring = source.Recurring;
|
---|
393 | target.RecurringId = source.RecurringId;
|
---|
394 | target.ResourceId = source.ResourceId;
|
---|
395 | target.StartDate = source.StartDate;
|
---|
396 | target.DowntimeType = source.DowntimeType;
|
---|
397 | }
|
---|
398 | #endregion
|
---|
399 |
|
---|
400 |
|
---|
401 | #region Command
|
---|
402 | public static DT.Command? ToDto(this DA.Command? source) {
|
---|
403 | if (source.HasValue) {
|
---|
404 | switch (source) {
|
---|
405 | case DA.Command.Abort: return DT.Command.Abort;
|
---|
406 | case DA.Command.Pause: return DT.Command.Pause;
|
---|
407 | case DA.Command.Stop: return DT.Command.Stop;
|
---|
408 | default: return DT.Command.Pause;
|
---|
409 | }
|
---|
410 | }
|
---|
411 | return null;
|
---|
412 | }
|
---|
413 |
|
---|
414 | public static DA.Command? ToEntity(this DT.Command? source) {
|
---|
415 | if (source.HasValue) {
|
---|
416 | switch (source) {
|
---|
417 | case DT.Command.Abort: return DA.Command.Abort;
|
---|
418 | case DT.Command.Pause: return DA.Command.Pause;
|
---|
419 | case DT.Command.Stop: return DA.Command.Stop;
|
---|
420 | default: return DA.Command.Pause;
|
---|
421 | }
|
---|
422 | }
|
---|
423 | return null;
|
---|
424 | }
|
---|
425 | #endregion
|
---|
426 |
|
---|
427 | #region Permission
|
---|
428 | public static DT.Permission ToDto(this DA.Permission source) {
|
---|
429 | switch (source) {
|
---|
430 | case DA.Permission.Full: return DT.Permission.Full;
|
---|
431 | case DA.Permission.NotAllowed: return DT.Permission.NotAllowed;
|
---|
432 | case DA.Permission.Read: return DT.Permission.Read;
|
---|
433 | default: return DT.Permission.NotAllowed;
|
---|
434 | }
|
---|
435 | }
|
---|
436 |
|
---|
437 | public static DA.Permission ToEntity(this DT.Permission source) {
|
---|
438 | switch (source) {
|
---|
439 | case DT.Permission.Full: return DA.Permission.Full;
|
---|
440 | case DT.Permission.NotAllowed: return DA.Permission.NotAllowed;
|
---|
441 | case DT.Permission.Read: return DA.Permission.Read;
|
---|
442 | default: return DA.Permission.NotAllowed;
|
---|
443 | }
|
---|
444 | }
|
---|
445 | #endregion
|
---|
446 |
|
---|
447 | #region CpuArchiteture
|
---|
448 | public static DT.CpuArchitecture ToDto(this DA.CpuArchitecture source) {
|
---|
449 | switch (source) {
|
---|
450 | case DA.CpuArchitecture.x64: return DT.CpuArchitecture.x64;
|
---|
451 | case DA.CpuArchitecture.x86: return DT.CpuArchitecture.x86;
|
---|
452 | default: return DT.CpuArchitecture.x86;
|
---|
453 | }
|
---|
454 | }
|
---|
455 |
|
---|
456 | public static DA.CpuArchitecture ToEntity(this DT.CpuArchitecture source) {
|
---|
457 | switch (source) {
|
---|
458 | case DT.CpuArchitecture.x64: return DA.CpuArchitecture.x64;
|
---|
459 | case DT.CpuArchitecture.x86: return DA.CpuArchitecture.x86;
|
---|
460 | default: return DA.CpuArchitecture.x86;
|
---|
461 | }
|
---|
462 | }
|
---|
463 | #endregion
|
---|
464 |
|
---|
465 | #region SlaveState
|
---|
466 | public static DT.SlaveState ToDto(this DA.SlaveState source) {
|
---|
467 | switch (source) {
|
---|
468 | case DA.SlaveState.Calculating: return DT.SlaveState.Calculating;
|
---|
469 | case DA.SlaveState.Idle: return DT.SlaveState.Idle;
|
---|
470 | case DA.SlaveState.Offline: return DT.SlaveState.Offline;
|
---|
471 | default: return DT.SlaveState.Offline;
|
---|
472 | }
|
---|
473 | }
|
---|
474 |
|
---|
475 | public static DA.SlaveState ToEntity(this DT.SlaveState source) {
|
---|
476 | switch (source) {
|
---|
477 | case DT.SlaveState.Calculating: return DA.SlaveState.Calculating;
|
---|
478 | case DT.SlaveState.Idle: return DA.SlaveState.Idle;
|
---|
479 | case DT.SlaveState.Offline: return DA.SlaveState.Offline;
|
---|
480 | default: return DA.SlaveState.Offline;
|
---|
481 | }
|
---|
482 | }
|
---|
483 | #endregion
|
---|
484 |
|
---|
485 | #region UserPriority
|
---|
486 | public static DT.UserPriority ToDto(this DA.UserPriority source) {
|
---|
487 | if (source == null) return null;
|
---|
488 | return new DT.UserPriority() {
|
---|
489 | Id = source.UserId,
|
---|
490 | DateEnqueued = source.DateEnqueued
|
---|
491 | };
|
---|
492 | }
|
---|
493 | public static DA.UserPriority ToEntity(this DT.UserPriority source) {
|
---|
494 | if (source == null) return null;
|
---|
495 | var result = new DA.UserPriority();
|
---|
496 | source.CopyToEntity(result);
|
---|
497 | return result;
|
---|
498 | }
|
---|
499 | public static void CopyToEntity(this DT.UserPriority source, DA.UserPriority target) {
|
---|
500 | if ((source == null) || (target == null)) return;
|
---|
501 | target.UserId = source.Id;
|
---|
502 | target.DateEnqueued = source.DateEnqueued;
|
---|
503 | }
|
---|
504 | #endregion
|
---|
505 |
|
---|
506 | }
|
---|
507 | }
|
---|