Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HivePerformance/sources/HeuristicLab.Services.Hive/3.3/Convert.cs @ 9393

Last change on this file since 9393 was 9393, checked in by pfleck, 11 years ago

#2030
Changed Linq.Binary to byte array to avoid hash computation.
DataContext in HiveOperationContext is now lazy initialized.
Added missing HiveDao from last commit failure.

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