source: branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Convert.cs @ 12584

Last change on this file since 12584 was 12584, checked in by dglaser, 6 years ago

#2388: Changed all files to connect to localhost / sqlexpress

HeuristicLab.Services.Hive-3.3:

  • Added Converter.cs and NewHiveService.cs, both will be integrated into existing HiveService.cs and Convert.cs when all methods are successfully implemented

HeuristicLab.Services.Hive.Web.Hive-3.3:

  • Added publish profiles

HeuristicLab.Services.WebApp.Statistics-3.3:

  • Added functionality to download TaskData as .hl file
File size: 23.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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 DB = HeuristicLab.Services.Hive.DataAccess;
26using DT = HeuristicLab.Services.Hive.DataTransfer;
27
28namespace HeuristicLab.Services.Hive.DataTransfer {
29  public static class Convert {
30    #region Task
31    public static DT.Task ToDto(DB.Task source) {
32      if (source == null) return null;
33      return new DT.Task {
34        Id = source.TaskId,
35        CoresNeeded = source.CoresNeeded,
36        ExecutionTime = TimeSpan.FromMilliseconds(source.ExecutionTimeMs),
37        MemoryNeeded = source.MemoryNeeded,
38        ParentTaskId = source.ParentTaskId,
39        Priority = source.Priority,
40        PluginsNeededIds = (source.RequiredPlugins == null ? new List<Guid>() : source.RequiredPlugins.Select(x => x.PluginId).ToList()),
41        LastHeartbeat = source.LastHeartbeat,
42        State = Convert.ToDto(source.State),
43        StateLog = (source.StateLogs == null ? new List<DT.StateLog>() : source.StateLogs.Select(x => Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList()),
44        IsParentTask = source.IsParentTask,
45        FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished,
46        Command = Convert.ToDto(source.Command),
47        LastTaskDataUpdate = (source.JobData == null ? DateTime.MinValue : source.JobData.LastUpdate),
48        JobId = source.JobId,
49        IsPrivileged = source.IsPrivileged
50      };
51    }
52
53    public static DB.Task ToEntity(DT.Task source) {
54      if (source == null) return null;
55      var entity = new DB.Task(); ToEntity(source, entity);
56      return entity;
57    }
58    public static void ToEntity(DT.Task source, DB.Task target) {
59      if ((source != null) && (target != null)) {
60        target.TaskId = source.Id;
61        target.CoresNeeded = source.CoresNeeded;
62        target.ExecutionTimeMs = source.ExecutionTime.TotalMilliseconds;
63        target.MemoryNeeded = source.MemoryNeeded;
64        target.ParentTaskId = source.ParentTaskId;
65        target.Priority = source.Priority;
66        target.LastHeartbeat = source.LastHeartbeat;
67        target.State = Convert.ToEntity(source.State);
68        foreach (DT.StateLog sl in source.StateLog.Where(x => x.Id == Guid.Empty)) {
69          target.StateLogs.Add(Convert.ToEntity(sl));
70        }
71        target.IsParentTask = source.IsParentTask;
72        target.FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished;
73        target.Command = Convert.ToEntity(source.Command);
74        // RequiredPlugins are added by Dao
75        target.JobId = source.JobId;
76        target.IsPrivileged = source.IsPrivileged;
77      }
78    }
79
80    public static void ToEntityTaskOnly(DT.Task source, DB.Task target) {
81      if ((source != null) && (target != null)) {
82        target.TaskId = source.Id;
83        target.CoresNeeded = source.CoresNeeded;
84        target.ExecutionTimeMs = source.ExecutionTime.TotalMilliseconds;
85        target.MemoryNeeded = source.MemoryNeeded;
86        target.ParentTaskId = source.ParentTaskId;
87        target.Priority = source.Priority;
88        target.LastHeartbeat = source.LastHeartbeat;
89        target.State = Convert.ToEntity(source.State);
90        target.IsParentTask = source.IsParentTask;
91        target.FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished;
92        target.Command = Convert.ToEntity(source.Command);
93        // RequiredPlugins are added by Dao
94        target.JobId = source.JobId;
95        target.IsPrivileged = source.IsPrivileged;
96      }
97    }
98    #endregion
99
100    #region TaskData
101    public static DT.TaskData ToDto(DB.TaskData source) {
102      if (source == null) return null;
103      return new DT.TaskData { TaskId = source.TaskId, Data = source.Data, LastUpdate = source.LastUpdate };
104    }
105    public static DB.TaskData ToEntity(DT.TaskData source) {
106      if (source == null) return null;
107      var entity = new DB.TaskData(); ToEntity(source, entity);
108      return entity;
109    }
110    public static void ToEntity(DT.TaskData source, DB.TaskData target) {
111      if ((source != null) && (target != null)) {
112        target.TaskId = source.TaskId;
113        target.Data = source.Data;
114        target.LastUpdate = source.LastUpdate;
115      }
116    }
117    #endregion
118
119    #region StateLog
120    public static DT.StateLog ToDto(DB.StateLog source) {
121      if (source == null) return null;
122      return new DT.StateLog { Id = source.StateLogId, DateTime = source.DateTime, Exception = source.Exception, TaskId = source.TaskId, SlaveId = source.SlaveId, State = Convert.ToDto(source.State), UserId = source.UserId };
123    }
124    public static DB.StateLog ToEntity(DT.StateLog source) {
125      if (source == null) return null;
126      var entity = new DB.StateLog(); ToEntity(source, entity);
127      return entity;
128    }
129    public static void ToEntity(DT.StateLog source, DB.StateLog target) {
130      if ((source != null) && (target != null)) {
131        target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.TaskId = source.TaskId; target.SlaveId = source.SlaveId; target.State = Convert.ToEntity(source.State); target.UserId = source.UserId;
132      }
133    }
134    #endregion
135
136    #region Downtimes
137    public static DT.Downtime ToDto(DB.Downtime source) {
138      if (source == null) return null;
139      return new DT.Downtime { Id = source.DowntimeId, AllDayEvent = source.AllDayEvent, EndDate = source.EndDate, Recurring = source.Recurring, RecurringId = source.RecurringId, ResourceId = source.ResourceId, StartDate = source.StartDate, DowntimeType = source.DowntimeType };
140    }
141    public static DB.Downtime ToEntity(DT.Downtime source) {
142      if (source == null) return null;
143      var entity = new DB.Downtime(); ToEntity(source, entity);
144      return entity;
145    }
146    public static void ToEntity(DT.Downtime source, DB.Downtime target) {
147      if ((source != null) && (target != null)) {
148        target.DowntimeId = source.Id; target.AllDayEvent = source.AllDayEvent; target.EndDate = source.EndDate; target.Recurring = source.Recurring; target.RecurringId = source.RecurringId; target.ResourceId = source.ResourceId; target.StartDate = source.StartDate; target.DowntimeType = source.DowntimeType;
149      }
150    }
151    #endregion
152
153    #region Job
154    public static DT.Job ToDto(DB.Job source) {
155      if (source == null) return null;
156      return new DT.Job { Id = source.JobId, Description = source.Description, Name = source.Name, OwnerUserId = source.OwnerUserId, DateCreated = source.DateCreated, ResourceNames = source.ResourceIds };
157    }
158    public static DB.Job ToEntity(DT.Job source) {
159      if (source == null) return null;
160      var entity = new DB.Job(); ToEntity(source, entity);
161      return entity;
162    }
163    public static void ToEntity(DT.Job source, DB.Job target) {
164      if ((source != null) && (target != null)) {
165        target.JobId = source.Id; target.Description = source.Description; target.Name = source.Name; target.OwnerUserId = source.OwnerUserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames;
166      }
167    }
168    #endregion
169
170    #region JobPermission
171    public static DT.JobPermission ToDto(DB.JobPermission source) {
172      if (source == null) return null;
173      return new DT.JobPermission { JobId = source.JobId, GrantedUserId = source.GrantedUserId, GrantedByUserId = source.GrantedByUserId, Permission = Convert.ToDto(source.Permission) };
174    }
175    public static DB.JobPermission ToEntity(DT.JobPermission source) {
176      if (source == null) return null;
177      var entity = new DB.JobPermission(); ToEntity(source, entity);
178      return entity;
179    }
180    public static void ToEntity(DT.JobPermission source, DB.JobPermission target) {
181      if ((source != null) && (target != null)) {
182        target.JobId = source.JobId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId; target.Permission = Convert.ToEntity(source.Permission);
183      }
184    }
185    #endregion
186
187    #region Plugin
188    public static DT.Plugin ToDto(DB.Plugin source) {
189      if (source == null) return null;
190      return new DT.Plugin { Id = source.PluginId, Name = source.Name, Version = new Version(source.Version), UserId = source.UserId, DateCreated = source.DateCreated, Hash = source.Hash };
191    }
192    public static DB.Plugin ToEntity(DT.Plugin source) {
193      if (source == null) return null;
194      var entity = new DB.Plugin(); ToEntity(source, entity);
195      return entity;
196    }
197    public static void ToEntity(DT.Plugin source, DB.Plugin target) {
198      if ((source != null) && (target != null)) {
199        target.PluginId = source.Id; target.Name = source.Name; target.Version = source.Version.ToString(); target.UserId = source.UserId; target.DateCreated = source.DateCreated; target.Hash = source.Hash;
200      }
201    }
202    #endregion
203
204    #region PluginData
205    public static DT.PluginData ToDto(DB.PluginData source) {
206      if (source == null) return null;
207      return new DT.PluginData { Id = source.PluginDataId, PluginId = source.PluginId, Data = source.Data.ToArray(), FileName = source.FileName };
208    }
209    public static DB.PluginData ToEntity(DT.PluginData source) {
210      if (source == null) return null;
211      var entity = new DB.PluginData(); ToEntity(source, entity);
212      return entity;
213    }
214    public static void ToEntity(DT.PluginData source, DB.PluginData target) {
215      if ((source != null) && (target != null)) {
216        target.PluginDataId = source.Id;
217        target.PluginId = source.PluginId;
218        target.Data = source.Data;
219        target.FileName = source.FileName;
220      }
221    }
222    #endregion
223
224    #region Resource
225    public static DT.Resource ToDto(DB.Resource source) {
226      if (source == null) return null;
227      return new DT.Resource { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval, OwnerUserId = source.OwnerUserId };
228    }
229    public static DB.Resource ToEntity(DT.Resource source) {
230      if (source == null) return null;
231      var entity = new DB.Resource(); ToEntity(source, entity);
232      return entity;
233    }
234    public static void ToEntity(DT.Resource source, DB.Resource target) {
235      if ((source != null) && (target != null)) {
236        target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval; target.OwnerUserId = source.OwnerUserId;
237      }
238    }
239    #endregion
240
241    #region SlaveGroup
242    public static DT.SlaveGroup ToDto(DB.SlaveGroup source) {
243      if (source == null) return null;
244      return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval, OwnerUserId = source.OwnerUserId };
245    }
246    public static DB.SlaveGroup ToEntity(DT.SlaveGroup source) {
247      if (source == null) return null;
248      var entity = new DB.SlaveGroup(); ToEntity(source, entity);
249      return entity;
250    }
251    public static void ToEntity(DT.SlaveGroup source, DB.SlaveGroup target) {
252      if ((source != null) && (target != null)) {
253        target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval; target.OwnerUserId = source.OwnerUserId;
254      }
255    }
256    #endregion
257
258    #region Slave
259    public static DT.Slave ToDto(DB.Slave source) {
260      if (source == null) return null;
261      return new DT.Slave {
262        Id = source.ResourceId,
263        ParentResourceId = source.ParentResourceId,
264        Cores = source.Cores,
265        CpuSpeed = source.CpuSpeed,
266        FreeCores = source.FreeCores,
267        FreeMemory = source.FreeMemory,
268        IsAllowedToCalculate = source.IsAllowedToCalculate,
269        Memory = source.Memory,
270        Name = source.Name,
271        SlaveState = Convert.ToDto(source.SlaveState),
272        CpuArchitecture = Convert.ToDto(source.CpuArchitecture),
273        OperatingSystem = source.OperatingSystem,
274        LastHeartbeat = source.LastHeartbeat,
275        CpuUtilization = source.CpuUtilization,
276        HbInterval = source.HbInterval,
277        IsDisposable = source.IsDisposable,
278        OwnerUserId = source.OwnerUserId
279      };
280    }
281    public static DB.Slave ToEntity(DT.Slave source) {
282      if (source == null) return null;
283      var entity = new DB.Slave(); ToEntity(source, entity);
284      return entity;
285    }
286    public static void ToEntity(DT.Slave source, DB.Slave target) {
287      if ((source != null) && (target != null)) {
288        target.ResourceId = source.Id;
289        target.ParentResourceId = source.ParentResourceId;
290        target.Cores = source.Cores;
291        target.CpuSpeed = source.CpuSpeed;
292        target.FreeCores = source.FreeCores;
293        target.FreeMemory = source.FreeMemory;
294        target.IsAllowedToCalculate = source.IsAllowedToCalculate;
295        target.Memory = source.Memory;
296        target.Name = source.Name;
297        target.SlaveState = Convert.ToEntity(source.SlaveState);
298        target.CpuArchitecture = Convert.ToEntity(source.CpuArchitecture);
299        target.OperatingSystem = source.OperatingSystem;
300        target.LastHeartbeat = source.LastHeartbeat;
301        target.CpuUtilization = source.CpuUtilization;
302        target.HbInterval = source.HbInterval;
303        target.IsDisposable = source.IsDisposable;
304        target.OwnerUserId = source.OwnerUserId;
305      }
306    }
307    #endregion
308
309    #region ResourcePermission
310    public static DT.ResourcePermission ToDto(DB.ResourcePermission source) {
311      if (source == null) return null;
312      return new DT.ResourcePermission { ResourceId = source.ResourceId, GrantedUserId = source.GrantedUserId, GrantedByUserId = source.GrantedByUserId };
313    }
314    public static DB.ResourcePermission ToEntity(DT.ResourcePermission source) {
315      if (source == null) return null;
316      var entity = new DB.ResourcePermission(); ToEntity(source, entity);
317      return entity;
318    }
319    public static void ToEntity(DT.ResourcePermission source, DB.ResourcePermission target) {
320      if ((source != null) && (target != null)) {
321        target.ResourceId = source.ResourceId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId;
322      }
323    }
324    #endregion
325
326    #region SlaveStatistics
327    public static DT.SlaveStatistics ToDto(DB.SlaveStatistics source) {
328      if (source == null) return null;
329      return new DT.SlaveStatistics {
330        Id = source.StatisticsId,
331        SlaveId = source.SlaveId,
332        Cores = source.Cores,
333        CpuUtilization = source.CpuUtilization,
334        FreeCores = source.FreeCores,
335        FreeMemory = source.FreeMemory,
336        Memory = source.Memory
337      };
338    }
339    public static DB.SlaveStatistics ToEntity(DT.SlaveStatistics source) {
340      if (source == null) return null;
341      var entity = new DB.SlaveStatistics(); ToEntity(source, entity);
342      return entity;
343    }
344    public static void ToEntity(DT.SlaveStatistics source, DB.SlaveStatistics target) {
345      if ((source != null) && (target != null)) {
346        target.StatisticsId = source.Id;
347        target.SlaveId = source.SlaveId;
348        target.Cores = source.Cores;
349        target.CpuUtilization = source.CpuUtilization;
350        target.FreeCores = source.FreeCores;
351        target.FreeMemory = source.FreeMemory;
352        target.Memory = source.Memory;
353      }
354    }
355    #endregion
356
357    #region Statistics
358    public static DT.Statistics ToDto(DB.Statistics source) {
359      if (source == null) return null;
360      return new DT.Statistics {
361        Id = source.StatisticsId,
362        TimeStamp = source.Timestamp,
363        SlaveStatistics = source.SlaveStatistics.Select(x => Convert.ToDto(x)).ToArray(),
364        UserStatistics = source.UserStatistics.Select(x => Convert.ToDto(x)).ToArray()
365      };
366    }
367    public static DB.Statistics ToEntity(DT.Statistics source) {
368      if (source == null) return null;
369      var entity = new DB.Statistics(); ToEntity(source, entity);
370      return entity;
371    }
372    public static void ToEntity(DT.Statistics source, DB.Statistics target) {
373      if ((source != null) && (target != null)) {
374        target.StatisticsId = source.Id;
375        target.Timestamp = source.TimeStamp;
376
377      }
378    }
379    #endregion
380
381    #region UserStatistics
382    public static DT.UserStatistics ToDto(DB.UserStatistics source) {
383      if (source == null) return null;
384      return new DT.UserStatistics {
385        Id = source.StatisticsId,
386        UserId = source.UserId,
387        UsedCores = source.UsedCores,
388        ExecutionTime = TimeSpan.FromMilliseconds(source.ExecutionTimeMs),
389        ExecutionTimeFinishedJobs = TimeSpan.FromMilliseconds(source.ExecutionTimeMsFinishedJobs),
390        StartToEndTime = TimeSpan.FromMilliseconds(source.StartToEndTimeMs)
391      };
392    }
393    public static DB.UserStatistics ToEntity(DT.UserStatistics source) {
394      if (source == null) return null;
395      var entity = new DB.UserStatistics(); ToEntity(source, entity);
396      return entity;
397    }
398    public static void ToEntity(DT.UserStatistics source, DB.UserStatistics target) {
399      if ((source != null) && (target != null)) {
400        target.StatisticsId = source.Id;
401        target.UserId = source.UserId;
402        target.UsedCores = source.UsedCores;
403        target.ExecutionTimeMs = source.ExecutionTime.TotalMilliseconds;
404        target.ExecutionTimeMsFinishedJobs = source.ExecutionTimeFinishedJobs.TotalMilliseconds;
405        target.StartToEndTimeMs = source.StartToEndTime.TotalMilliseconds;
406      }
407    }
408    #endregion
409
410    #region TaskData
411    public static DT.TaskState ToDto(DB.TaskState source) {
412      if (source == DB.TaskState.Aborted) {
413        return TaskState.Aborted;
414      } else if (source == DB.TaskState.Calculating) {
415        return TaskState.Calculating;
416      } else if (source == DB.TaskState.Failed) {
417        return TaskState.Failed;
418      } else if (source == DB.TaskState.Finished) {
419        return TaskState.Finished;
420      } else if (source == DB.TaskState.Offline) {
421        return TaskState.Offline;
422      } else if (source == DB.TaskState.Paused) {
423        return TaskState.Paused;
424      } else if (source == DB.TaskState.Transferring) {
425        return TaskState.Transferring;
426      } else if (source == DB.TaskState.Waiting) {
427        return TaskState.Waiting;
428      } else
429        return TaskState.Failed;
430    }
431
432    public static DB.TaskState ToEntity(DT.TaskState source) {
433      if (source == DT.TaskState.Aborted) {
434        return DB.TaskState.Aborted;
435      } else if (source == DT.TaskState.Calculating) {
436        return DB.TaskState.Calculating;
437      } else if (source == DT.TaskState.Failed) {
438        return DB.TaskState.Failed;
439      } else if (source == DT.TaskState.Finished) {
440        return DB.TaskState.Finished;
441      } else if (source == DT.TaskState.Offline) {
442        return DB.TaskState.Offline;
443      } else if (source == DT.TaskState.Paused) {
444        return DB.TaskState.Paused;
445      } else if (source == DT.TaskState.Transferring) {
446        return DB.TaskState.Transferring;
447      } else if (source == DT.TaskState.Waiting) {
448        return DB.TaskState.Waiting;
449      } else
450        return DB.TaskState.Failed;
451    }
452    #endregion
453
454    #region Permission
455    public static DT.Permission ToDto(DB.Permission source) {
456      if (source == DB.Permission.Full) {
457        return Permission.Full;
458      } else if (source == DB.Permission.NotAllowed) {
459        return Permission.NotAllowed;
460      } else if (source == DB.Permission.Read) {
461        return Permission.Read;
462      } else
463        return Permission.NotAllowed;
464    }
465
466    public static DB.Permission ToEntity(DT.Permission source) {
467      if (source == DT.Permission.Full) {
468        return DB.Permission.Full;
469      } else if (source == DT.Permission.NotAllowed) {
470        return DB.Permission.NotAllowed;
471      } else if (source == DT.Permission.Read) {
472        return DB.Permission.Read;
473      } else
474        return DB.Permission.NotAllowed;
475    }
476    #endregion
477
478    #region Command
479    public static DT.Command? ToDto(DB.Command? source) {
480      if (source.HasValue) {
481        if (source.Value == DB.Command.Abort) {
482          return Command.Abort;
483        } else if (source.Value == DB.Command.Pause) {
484          return Command.Pause;
485        } else if (source.Value == DB.Command.Stop) {
486          return Command.Stop;
487        } else
488          return Command.Pause;
489      }
490      return null;
491    }
492
493    public static DB.Command? ToEntity(DT.Command? source) {
494      if (source.HasValue) {
495        if (source == DT.Command.Abort) {
496          return DB.Command.Abort;
497        } else if (source == DT.Command.Pause) {
498          return DB.Command.Pause;
499        } else if (source == DT.Command.Stop) {
500          return DB.Command.Stop;
501        } else
502          return DB.Command.Pause;
503      } else
504        return null;
505    }
506    #endregion
507
508    #region CpuArchiteture
509    public static DT.CpuArchitecture ToDto(DB.CpuArchitecture source) {
510      if (source == DB.CpuArchitecture.x64) {
511        return CpuArchitecture.x64;
512      } else if (source == DB.CpuArchitecture.x86) {
513        return CpuArchitecture.x86;
514      } else
515        return CpuArchitecture.x86;
516    }
517
518    public static DB.CpuArchitecture ToEntity(DT.CpuArchitecture source) {
519      if (source == DT.CpuArchitecture.x64) {
520        return DB.CpuArchitecture.x64;
521      } else if (source == DT.CpuArchitecture.x86) {
522        return DB.CpuArchitecture.x86;
523      } else
524        return DB.CpuArchitecture.x86;
525    }
526    #endregion
527
528    #region SlaveState
529    public static DT.SlaveState ToDto(DB.SlaveState source) {
530      if (source == DB.SlaveState.Calculating) {
531        return SlaveState.Calculating;
532      } else if (source == DB.SlaveState.Idle) {
533        return SlaveState.Idle;
534      } else if (source == DB.SlaveState.Offline) {
535        return SlaveState.Offline;
536      } else
537        return SlaveState.Offline;
538    }
539
540    public static DB.SlaveState ToEntity(DT.SlaveState source) {
541      if (source == DT.SlaveState.Calculating) {
542        return DB.SlaveState.Calculating;
543      } else if (source == DT.SlaveState.Idle) {
544        return DB.SlaveState.Idle;
545      } else if (source == DT.SlaveState.Offline) {
546        return DB.SlaveState.Offline;
547      } else
548        return DB.SlaveState.Offline;
549    }
550    #endregion
551
552    #region UserPriority
553    public static DT.UserPriority ToDto(DB.UserPriority source) {
554      if (source == null) return null;
555      return new DT.UserPriority() { Id = source.UserId, DateEnqueued = source.DateEnqueued };
556    }
557    public static DB.UserPriority ToEntity(DT.UserPriority source) {
558      if (source == null) return null;
559      var entity = new DB.UserPriority(); ToEntity(source, entity);
560      return entity;
561    }
562    public static void ToEntity(DT.UserPriority source, DB.UserPriority target) {
563      if ((source != null) && (target != null)) {
564        target.UserId = source.Id;
565        target.DateEnqueued = source.DateEnqueued;
566      }
567    }
568    #endregion
569  }
570}
Note: See TracBrowser for help on using the repository browser.