- Timestamp:
- 07/08/15 15:51:32 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Converter.cs
r12584 r12691 150 150 #endregion 151 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 152 203 #region State 153 204 public static DT.TaskState ToDto(this DA.TaskState source) { … … 206 257 #endregion 207 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 208 401 #region Command 209 402 public static DT.Command? ToDto(this DA.Command? source) { … … 252 445 #endregion 253 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 254 506 } 255 507 }
Note: See TracChangeset
for help on using the changeset viewer.