Changeset 6229 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Convert.cs
- Timestamp:
- 05/17/11 18:29:41 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Convert.cs
r6006 r6229 213 213 CpuArchitecture = source.CpuArchitecture, 214 214 OperatingSystem = source.OperatingSystem, 215 LastHeartbeat = source.LastHeartbeat 215 LastHeartbeat = source.LastHeartbeat, 216 CpuUtilization = source.CpuUtilization 216 217 }; 217 218 } … … 236 237 target.OperatingSystem = source.OperatingSystem; 237 238 target.LastHeartbeat = source.LastHeartbeat; 239 target.CpuUtilization = source.CpuUtilization; 238 240 } 239 241 } … … 273 275 } 274 276 #endregion 277 278 #region Statistics 279 public static DT.Statistics ToDto(Statistics source) { 280 if (source == null) return null; 281 return new DT.Statistics { 282 Id = source.StatisticsId, 283 TimeStamp = source.Timestamp, 284 SlaveStatistics = source.SlaveStatistics.Select(x => Convert.ToDto(x)).ToArray(), 285 UserStatistics = source.UserStatistics.Select(x => Convert.ToDto(x)).ToArray() 286 }; 287 } 288 public static Statistics ToEntity(DT.Statistics source) { 289 if (source == null) return null; 290 var entity = new Statistics(); ToEntity(source, entity); 291 return entity; 292 } 293 public static void ToEntity(DT.Statistics source, Statistics target) { 294 if ((source != null) && (target != null)) { 295 target.StatisticsId = source.Id; 296 target.Timestamp = source.TimeStamp; 297 298 } 299 } 300 #endregion 301 302 #region SlaveStatistics 303 public static DT.SlaveStatistics ToDto(SlaveStatistics source) { 304 if (source == null) return null; 305 return new DT.SlaveStatistics { 306 Id = source.StatisticsId, 307 SlaveId = source.SlaveId, 308 Cores = source.Cores, 309 CpuUtilization = source.CpuUtilization, 310 FreeCores = source.FreeCores, 311 FreeMemory = source.FreeMemory, 312 Memory = source.Memory 313 }; 314 } 315 public static SlaveStatistics ToEntity(DT.SlaveStatistics source) { 316 if (source == null) return null; 317 var entity = new SlaveStatistics(); ToEntity(source, entity); 318 return entity; 319 } 320 public static void ToEntity(DT.SlaveStatistics source, SlaveStatistics target) { 321 if ((source != null) && (target != null)) { 322 target.StatisticsId = source.Id; 323 target.SlaveId = source.SlaveId; 324 target.Cores = source.Cores; 325 target.CpuUtilization = source.CpuUtilization; 326 target.FreeCores = source.FreeCores; 327 target.FreeMemory = source.FreeMemory; 328 target.Memory = source.Memory; 329 } 330 } 331 #endregion 332 333 #region UserStatistics 334 public static DT.UserStatistics ToDto(UserStatistics source) { 335 if (source == null) return null; 336 return new DT.UserStatistics { 337 Id = source.StatisticsId, 338 UserId = source.UserId, 339 UsedCores = source.UsedCores, 340 ExecutionTime = string.IsNullOrEmpty(source.ExecutionTime) ? TimeSpan.Zero : TimeSpan.Parse(source.ExecutionTime), 341 ExecutionTimeFinishedJobs = string.IsNullOrEmpty(source.ExecutionTimeFinishedJobs) ? TimeSpan.Zero : TimeSpan.Parse(source.ExecutionTimeFinishedJobs), 342 StartToEndTime = string.IsNullOrEmpty(source.StartToEndTime) ? TimeSpan.Zero : TimeSpan.Parse(source.StartToEndTime) 343 }; 344 } 345 public static UserStatistics ToEntity(DT.UserStatistics source) { 346 if (source == null) return null; 347 var entity = new UserStatistics(); ToEntity(source, entity); 348 return entity; 349 } 350 public static void ToEntity(DT.UserStatistics source, UserStatistics target) { 351 if ((source != null) && (target != null)) { 352 target.StatisticsId = source.Id; 353 target.UserId = source.UserId; 354 target.UsedCores = source.UsedCores; 355 target.ExecutionTime = source.ExecutionTime.ToString(); 356 target.ExecutionTimeFinishedJobs = source.ExecutionTimeFinishedJobs.ToString(); 357 target.StartToEndTime = source.StartToEndTime.ToString(); 358 } 359 } 360 #endregion 275 361 } 276 362 }
Note: See TracChangeset
for help on using the changeset viewer.