1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2011 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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Data.Linq;
|
---|
25 | using System.Linq;
|
---|
26 | using DB = HeuristicLab.Services.Hive.DataAccess;
|
---|
27 | using DT = HeuristicLab.Services.Hive.DataTransfer;
|
---|
28 |
|
---|
29 | namespace 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 | #endregion
|
---|
82 |
|
---|
83 | #region TaskData
|
---|
84 | public static DT.TaskData ToDto(DB.TaskData source) {
|
---|
85 | if (source == null) return null;
|
---|
86 | return new DT.TaskData { TaskId = source.TaskId, Data = source.Data.ToArray(), LastUpdate = source.LastUpdate };
|
---|
87 | }
|
---|
88 | public static DB.TaskData ToEntity(DT.TaskData source) {
|
---|
89 | if (source == null) return null;
|
---|
90 | var entity = new DB.TaskData(); ToEntity(source, entity);
|
---|
91 | return entity;
|
---|
92 | }
|
---|
93 | public static void ToEntity(DT.TaskData source, DB.TaskData target) {
|
---|
94 | if ((source != null) && (target != null)) {
|
---|
95 | target.TaskId = source.TaskId; target.Data = new Binary(source.Data); target.LastUpdate = source.LastUpdate;
|
---|
96 | }
|
---|
97 | }
|
---|
98 | #endregion
|
---|
99 |
|
---|
100 | #region StateLog
|
---|
101 | public static DT.StateLog ToDto(DB.StateLog source) {
|
---|
102 | if (source == null) return null;
|
---|
103 | 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 };
|
---|
104 | }
|
---|
105 | public static DB.StateLog ToEntity(DT.StateLog source) {
|
---|
106 | if (source == null) return null;
|
---|
107 | var entity = new DB.StateLog(); ToEntity(source, entity);
|
---|
108 | return entity;
|
---|
109 | }
|
---|
110 | public static void ToEntity(DT.StateLog source, DB.StateLog target) {
|
---|
111 | if ((source != null) && (target != null)) {
|
---|
112 | 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;
|
---|
113 | }
|
---|
114 | }
|
---|
115 | #endregion
|
---|
116 |
|
---|
117 | #region Downtimes
|
---|
118 | public static DT.Downtime ToDto(DB.Downtime source) {
|
---|
119 | if (source == null) return null;
|
---|
120 | 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 };
|
---|
121 | }
|
---|
122 | public static DB.Downtime ToEntity(DT.Downtime source) {
|
---|
123 | if (source == null) return null;
|
---|
124 | var entity = new DB.Downtime(); ToEntity(source, entity);
|
---|
125 | return entity;
|
---|
126 | }
|
---|
127 | public static void ToEntity(DT.Downtime source, DB.Downtime target) {
|
---|
128 | if ((source != null) && (target != null)) {
|
---|
129 | 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;
|
---|
130 | }
|
---|
131 | }
|
---|
132 | #endregion
|
---|
133 |
|
---|
134 | #region Job
|
---|
135 | public static DT.Job ToDto(DB.Job source) {
|
---|
136 | if (source == null) return null;
|
---|
137 | return new DT.Job { Id = source.JobId, Description = source.Description, Name = source.Name, OwnerUserId = source.OwnerUserId, DateCreated = source.DateCreated, ResourceNames = source.ResourceIds };
|
---|
138 | }
|
---|
139 | public static DB.Job ToEntity(DT.Job source) {
|
---|
140 | if (source == null) return null;
|
---|
141 | var entity = new DB.Job(); ToEntity(source, entity);
|
---|
142 | return entity;
|
---|
143 | }
|
---|
144 | public static void ToEntity(DT.Job source, DB.Job target) {
|
---|
145 | if ((source != null) && (target != null)) {
|
---|
146 | target.JobId = source.Id; target.Description = source.Description; target.Name = source.Name; target.OwnerUserId = source.OwnerUserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames;
|
---|
147 | }
|
---|
148 | }
|
---|
149 | #endregion
|
---|
150 |
|
---|
151 | #region JobPermission
|
---|
152 | public static DT.JobPermission ToDto(DB.JobPermission source) {
|
---|
153 | if (source == null) return null;
|
---|
154 | return new DT.JobPermission { JobId = source.JobId, GrantedUserId = source.GrantedUserId, GrantedByUserId = source.GrantedByUserId, Permission = Convert.ToDto(source.Permission) };
|
---|
155 | }
|
---|
156 | public static DB.JobPermission ToEntity(DT.JobPermission source) {
|
---|
157 | if (source == null) return null;
|
---|
158 | var entity = new DB.JobPermission(); ToEntity(source, entity);
|
---|
159 | return entity;
|
---|
160 | }
|
---|
161 | public static void ToEntity(DT.JobPermission source, DB.JobPermission target) {
|
---|
162 | if ((source != null) && (target != null)) {
|
---|
163 | target.JobId = source.JobId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId; target.Permission = Convert.ToEntity(source.Permission);
|
---|
164 | }
|
---|
165 | }
|
---|
166 | #endregion
|
---|
167 |
|
---|
168 | #region Plugin
|
---|
169 | public static DT.Plugin ToDto(DB.Plugin source) {
|
---|
170 | if (source == null) return null;
|
---|
171 | return new DT.Plugin { Id = source.PluginId, Name = source.Name, Version = new Version(source.Version), UserId = source.UserId, DateCreated = source.DateCreated, Hash = source.Hash };
|
---|
172 | }
|
---|
173 | public static DB.Plugin ToEntity(DT.Plugin source) {
|
---|
174 | if (source == null) return null;
|
---|
175 | var entity = new DB.Plugin(); ToEntity(source, entity);
|
---|
176 | return entity;
|
---|
177 | }
|
---|
178 | public static void ToEntity(DT.Plugin source, DB.Plugin target) {
|
---|
179 | if ((source != null) && (target != null)) {
|
---|
180 | 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;
|
---|
181 | }
|
---|
182 | }
|
---|
183 | #endregion
|
---|
184 |
|
---|
185 | #region PluginData
|
---|
186 | public static DT.PluginData ToDto(DB.PluginData source) {
|
---|
187 | if (source == null) return null;
|
---|
188 | return new DT.PluginData { Id = source.PluginDataId, PluginId = source.PluginId, Data = source.Data.ToArray(), FileName = source.FileName };
|
---|
189 | }
|
---|
190 | public static DB.PluginData ToEntity(DT.PluginData source) {
|
---|
191 | if (source == null) return null;
|
---|
192 | var entity = new DB.PluginData(); ToEntity(source, entity);
|
---|
193 | return entity;
|
---|
194 | }
|
---|
195 | public static void ToEntity(DT.PluginData source, DB.PluginData target) {
|
---|
196 | if ((source != null) && (target != null)) {
|
---|
197 | target.PluginDataId = source.Id; target.PluginId = source.PluginId; target.Data = new Binary(source.Data); target.FileName = source.FileName;
|
---|
198 | }
|
---|
199 | }
|
---|
200 | #endregion
|
---|
201 |
|
---|
202 | #region Slave
|
---|
203 | public static DT.Slave ToDto(DB.Slave source) {
|
---|
204 | if (source == null) return null;
|
---|
205 | return new DT.Slave {
|
---|
206 | Id = source.ResourceId,
|
---|
207 | ParentResourceId = source.ParentResourceId,
|
---|
208 | Cores = source.Cores,
|
---|
209 | CpuSpeed = source.CpuSpeed,
|
---|
210 | FreeCores = source.FreeCores,
|
---|
211 | FreeMemory = source.FreeMemory,
|
---|
212 | IsAllowedToCalculate = source.IsAllowedToCalculate,
|
---|
213 | Memory = source.Memory,
|
---|
214 | Name = source.Name,
|
---|
215 | SlaveState = Convert.ToDto(source.SlaveState),
|
---|
216 | CpuArchitecture = Convert.ToDto(source.CpuArchitecture),
|
---|
217 | OperatingSystem = source.OperatingSystem,
|
---|
218 | LastHeartbeat = source.LastHeartbeat,
|
---|
219 | CpuUtilization = source.CpuUtilization
|
---|
220 | };
|
---|
221 | }
|
---|
222 | public static DB.Slave ToEntity(DT.Slave source) {
|
---|
223 | if (source == null) return null;
|
---|
224 | var entity = new DB.Slave(); ToEntity(source, entity);
|
---|
225 | return entity;
|
---|
226 | }
|
---|
227 | public static void ToEntity(DT.Slave source, DB.Slave target) {
|
---|
228 | if ((source != null) && (target != null)) {
|
---|
229 | target.ResourceId = source.Id;
|
---|
230 | target.ParentResourceId = source.ParentResourceId;
|
---|
231 | target.Cores = source.Cores;
|
---|
232 | target.CpuSpeed = source.CpuSpeed;
|
---|
233 | target.FreeCores = source.FreeCores;
|
---|
234 | target.FreeMemory = source.FreeMemory;
|
---|
235 | target.IsAllowedToCalculate = source.IsAllowedToCalculate;
|
---|
236 | target.Memory = source.Memory;
|
---|
237 | target.Name = source.Name;
|
---|
238 | target.SlaveState = Convert.ToEntity(source.SlaveState);
|
---|
239 | target.CpuArchitecture = Convert.ToEntity(source.CpuArchitecture);
|
---|
240 | target.OperatingSystem = source.OperatingSystem;
|
---|
241 | target.LastHeartbeat = source.LastHeartbeat;
|
---|
242 | target.CpuUtilization = source.CpuUtilization;
|
---|
243 | }
|
---|
244 | }
|
---|
245 | #endregion
|
---|
246 |
|
---|
247 | #region SlaveGroup
|
---|
248 | public static DT.SlaveGroup ToDto(DB.SlaveGroup source) {
|
---|
249 | if (source == null) return null;
|
---|
250 | return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId };
|
---|
251 | }
|
---|
252 | public static DB.SlaveGroup ToEntity(DT.SlaveGroup source) {
|
---|
253 | if (source == null) return null;
|
---|
254 | var entity = new DB.SlaveGroup(); ToEntity(source, entity);
|
---|
255 | return entity;
|
---|
256 | }
|
---|
257 | public static void ToEntity(DT.SlaveGroup source, DB.SlaveGroup target) {
|
---|
258 | if ((source != null) && (target != null)) {
|
---|
259 | target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId;
|
---|
260 | }
|
---|
261 | }
|
---|
262 | #endregion
|
---|
263 |
|
---|
264 | #region Resource
|
---|
265 | public static DT.Resource ToDto(DB.Resource source) {
|
---|
266 | if (source == null) return null;
|
---|
267 | return new DT.Resource { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId };
|
---|
268 | }
|
---|
269 | public static DB.Resource ToEntity(DT.Resource source) {
|
---|
270 | if (source == null) return null;
|
---|
271 | var entity = new DB.Resource(); ToEntity(source, entity);
|
---|
272 | return entity;
|
---|
273 | }
|
---|
274 | public static void ToEntity(DT.Resource source, DB.Resource target) {
|
---|
275 | if ((source != null) && (target != null)) {
|
---|
276 | target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId;
|
---|
277 | }
|
---|
278 | }
|
---|
279 | #endregion
|
---|
280 |
|
---|
281 | #region Statistics
|
---|
282 | public static DT.Statistics ToDto(DB.Statistics source) {
|
---|
283 | if (source == null) return null;
|
---|
284 | return new DT.Statistics {
|
---|
285 | Id = source.StatisticsId,
|
---|
286 | TimeStamp = source.Timestamp,
|
---|
287 | SlaveStatistics = source.SlaveStatistics.Select(x => Convert.ToDto(x)).ToArray(),
|
---|
288 | UserStatistics = source.UserStatistics.Select(x => Convert.ToDto(x)).ToArray()
|
---|
289 | };
|
---|
290 | }
|
---|
291 | public static DB.Statistics ToEntity(DT.Statistics source) {
|
---|
292 | if (source == null) return null;
|
---|
293 | var entity = new DB.Statistics(); ToEntity(source, entity);
|
---|
294 | return entity;
|
---|
295 | }
|
---|
296 | public static void ToEntity(DT.Statistics source, DB.Statistics target) {
|
---|
297 | if ((source != null) && (target != null)) {
|
---|
298 | target.StatisticsId = source.Id;
|
---|
299 | target.Timestamp = source.TimeStamp;
|
---|
300 |
|
---|
301 | }
|
---|
302 | }
|
---|
303 | #endregion
|
---|
304 |
|
---|
305 | #region SlaveStatistics
|
---|
306 | public static DT.SlaveStatistics ToDto(DB.SlaveStatistics source) {
|
---|
307 | if (source == null) return null;
|
---|
308 | return new DT.SlaveStatistics {
|
---|
309 | Id = source.StatisticsId,
|
---|
310 | SlaveId = source.SlaveId,
|
---|
311 | Cores = source.Cores,
|
---|
312 | CpuUtilization = source.CpuUtilization,
|
---|
313 | FreeCores = source.FreeCores,
|
---|
314 | FreeMemory = source.FreeMemory,
|
---|
315 | Memory = source.Memory
|
---|
316 | };
|
---|
317 | }
|
---|
318 | public static DB.SlaveStatistics ToEntity(DT.SlaveStatistics source) {
|
---|
319 | if (source == null) return null;
|
---|
320 | var entity = new DB.SlaveStatistics(); ToEntity(source, entity);
|
---|
321 | return entity;
|
---|
322 | }
|
---|
323 | public static void ToEntity(DT.SlaveStatistics source, DB.SlaveStatistics target) {
|
---|
324 | if ((source != null) && (target != null)) {
|
---|
325 | target.StatisticsId = source.Id;
|
---|
326 | target.SlaveId = source.SlaveId;
|
---|
327 | target.Cores = source.Cores;
|
---|
328 | target.CpuUtilization = source.CpuUtilization;
|
---|
329 | target.FreeCores = source.FreeCores;
|
---|
330 | target.FreeMemory = source.FreeMemory;
|
---|
331 | target.Memory = source.Memory;
|
---|
332 | }
|
---|
333 | }
|
---|
334 | #endregion
|
---|
335 |
|
---|
336 | #region UserStatistics
|
---|
337 | public static DT.UserStatistics ToDto(DB.UserStatistics source) {
|
---|
338 | if (source == null) return null;
|
---|
339 | return new DT.UserStatistics {
|
---|
340 | Id = source.StatisticsId,
|
---|
341 | UserId = source.UserId,
|
---|
342 | UsedCores = source.UsedCores,
|
---|
343 | ExecutionTime = TimeSpan.FromMilliseconds(source.ExecutionTimeMs),
|
---|
344 | ExecutionTimeFinishedJobs = TimeSpan.FromMilliseconds(source.ExecutionTimeMsFinishedJobs),
|
---|
345 | StartToEndTime = TimeSpan.FromMilliseconds(source.StartToEndTimeMs)
|
---|
346 | };
|
---|
347 | }
|
---|
348 | public static DB.UserStatistics ToEntity(DT.UserStatistics source) {
|
---|
349 | if (source == null) return null;
|
---|
350 | var entity = new DB.UserStatistics(); ToEntity(source, entity);
|
---|
351 | return entity;
|
---|
352 | }
|
---|
353 | public static void ToEntity(DT.UserStatistics source, DB.UserStatistics target) {
|
---|
354 | if ((source != null) && (target != null)) {
|
---|
355 | target.StatisticsId = source.Id;
|
---|
356 | target.UserId = source.UserId;
|
---|
357 | target.UsedCores = source.UsedCores;
|
---|
358 | target.ExecutionTimeMs = source.ExecutionTime.TotalMilliseconds;
|
---|
359 | target.ExecutionTimeMsFinishedJobs = source.ExecutionTimeFinishedJobs.TotalMilliseconds;
|
---|
360 | target.StartToEndTimeMs = source.StartToEndTime.TotalMilliseconds;
|
---|
361 | }
|
---|
362 | }
|
---|
363 | #endregion
|
---|
364 |
|
---|
365 | #region TaskData
|
---|
366 | public static DT.TaskState ToDto(DB.TaskState source) {
|
---|
367 | if (source == DB.TaskState.Aborted) {
|
---|
368 | return TaskState.Aborted;
|
---|
369 | } else if (source == DB.TaskState.Calculating) {
|
---|
370 | return TaskState.Calculating;
|
---|
371 | } else if (source == DB.TaskState.Failed) {
|
---|
372 | return TaskState.Failed;
|
---|
373 | } else if (source == DB.TaskState.Finished) {
|
---|
374 | return TaskState.Finished;
|
---|
375 | } else if (source == DB.TaskState.Offline) {
|
---|
376 | return TaskState.Offline;
|
---|
377 | } else if (source == DB.TaskState.Paused) {
|
---|
378 | return TaskState.Paused;
|
---|
379 | } else if (source == DB.TaskState.Transferring) {
|
---|
380 | return TaskState.Transferring;
|
---|
381 | } else if (source == DB.TaskState.Waiting) {
|
---|
382 | return TaskState.Waiting;
|
---|
383 | } else
|
---|
384 | return TaskState.Failed;
|
---|
385 | }
|
---|
386 |
|
---|
387 | public static DB.TaskState ToEntity(DT.TaskState source) {
|
---|
388 | if (source == DT.TaskState.Aborted) {
|
---|
389 | return DB.TaskState.Aborted;
|
---|
390 | } else if (source == DT.TaskState.Calculating) {
|
---|
391 | return DB.TaskState.Calculating;
|
---|
392 | } else if (source == DT.TaskState.Failed) {
|
---|
393 | return DB.TaskState.Failed;
|
---|
394 | } else if (source == DT.TaskState.Finished) {
|
---|
395 | return DB.TaskState.Finished;
|
---|
396 | } else if (source == DT.TaskState.Offline) {
|
---|
397 | return DB.TaskState.Offline;
|
---|
398 | } else if (source == DT.TaskState.Paused) {
|
---|
399 | return DB.TaskState.Paused;
|
---|
400 | } else if (source == DT.TaskState.Transferring) {
|
---|
401 | return DB.TaskState.Transferring;
|
---|
402 | } else if (source == DT.TaskState.Waiting) {
|
---|
403 | return DB.TaskState.Waiting;
|
---|
404 | } else
|
---|
405 | return DB.TaskState.Failed;
|
---|
406 | }
|
---|
407 | #endregion
|
---|
408 |
|
---|
409 | #region Permission
|
---|
410 | public static DT.Permission ToDto(DB.Permission source) {
|
---|
411 | if (source == DB.Permission.Full) {
|
---|
412 | return Permission.Full;
|
---|
413 | } else if (source == DB.Permission.NotAllowed) {
|
---|
414 | return Permission.NotAllowed;
|
---|
415 | } else if (source == DB.Permission.Read) {
|
---|
416 | return Permission.Read;
|
---|
417 | } else
|
---|
418 | return Permission.NotAllowed;
|
---|
419 | }
|
---|
420 |
|
---|
421 | public static DB.Permission ToEntity(DT.Permission source) {
|
---|
422 | if (source == DT.Permission.Full) {
|
---|
423 | return DB.Permission.Full;
|
---|
424 | } else if (source == DT.Permission.NotAllowed) {
|
---|
425 | return DB.Permission.NotAllowed;
|
---|
426 | } else if (source == DT.Permission.Read) {
|
---|
427 | return DB.Permission.Read;
|
---|
428 | } else
|
---|
429 | return DB.Permission.NotAllowed;
|
---|
430 | }
|
---|
431 | #endregion
|
---|
432 |
|
---|
433 | #region Command
|
---|
434 | public static DT.Command? ToDto(DB.Command? source) {
|
---|
435 | if (source.HasValue) {
|
---|
436 | if (source.Value == DB.Command.Abort) {
|
---|
437 | return Command.Abort;
|
---|
438 | } else if (source.Value == DB.Command.Pause) {
|
---|
439 | return Command.Pause;
|
---|
440 | } else if (source.Value == DB.Command.Stop) {
|
---|
441 | return Command.Stop;
|
---|
442 | } else
|
---|
443 | return Command.Pause;
|
---|
444 | }
|
---|
445 | return null;
|
---|
446 | }
|
---|
447 |
|
---|
448 | public static DB.Command? ToEntity(DT.Command? source) {
|
---|
449 | if (source.HasValue) {
|
---|
450 | if (source == DT.Command.Abort) {
|
---|
451 | return DB.Command.Abort;
|
---|
452 | } else if (source == DT.Command.Pause) {
|
---|
453 | return DB.Command.Pause;
|
---|
454 | } else if (source == DT.Command.Stop) {
|
---|
455 | return DB.Command.Stop;
|
---|
456 | } else
|
---|
457 | return DB.Command.Pause;
|
---|
458 | } else
|
---|
459 | return null;
|
---|
460 | }
|
---|
461 | #endregion
|
---|
462 |
|
---|
463 | #region CpuArchiteture
|
---|
464 | public static DT.CpuArchitecture ToDto(DB.CpuArchitecture source) {
|
---|
465 | if (source == DB.CpuArchitecture.x64) {
|
---|
466 | return CpuArchitecture.x64;
|
---|
467 | } else if (source == DB.CpuArchitecture.x86) {
|
---|
468 | return CpuArchitecture.x86;
|
---|
469 | } else
|
---|
470 | return CpuArchitecture.x86;
|
---|
471 | }
|
---|
472 |
|
---|
473 | public static DB.CpuArchitecture ToEntity(DT.CpuArchitecture source) {
|
---|
474 | if (source == DT.CpuArchitecture.x64) {
|
---|
475 | return DB.CpuArchitecture.x64;
|
---|
476 | } else if (source == DT.CpuArchitecture.x86) {
|
---|
477 | return DB.CpuArchitecture.x86;
|
---|
478 | } else
|
---|
479 | return DB.CpuArchitecture.x86;
|
---|
480 | }
|
---|
481 | #endregion
|
---|
482 |
|
---|
483 | #region SlaveState
|
---|
484 | public static DT.SlaveState ToDto(DB.SlaveState source) {
|
---|
485 | if (source == DB.SlaveState.Calculating) {
|
---|
486 | return SlaveState.Calculating;
|
---|
487 | } else if (source == DB.SlaveState.Idle) {
|
---|
488 | return SlaveState.Idle;
|
---|
489 | } else if (source == DB.SlaveState.Offline) {
|
---|
490 | return SlaveState.Offline;
|
---|
491 | } else
|
---|
492 | return SlaveState.Offline;
|
---|
493 | }
|
---|
494 |
|
---|
495 | public static DB.SlaveState ToEntity(DT.SlaveState source) {
|
---|
496 | if (source == DT.SlaveState.Calculating) {
|
---|
497 | return DB.SlaveState.Calculating;
|
---|
498 | } else if (source == DT.SlaveState.Idle) {
|
---|
499 | return DB.SlaveState.Idle;
|
---|
500 | } else if (source == DT.SlaveState.Offline) {
|
---|
501 | return DB.SlaveState.Offline;
|
---|
502 | } else
|
---|
503 | return DB.SlaveState.Offline;
|
---|
504 | }
|
---|
505 | #endregion
|
---|
506 | }
|
---|
507 | }
|
---|