Changeset 7916 for trunk/sources/HeuristicLab.Services.Hive/3.3/Convert.cs
- Timestamp:
- 05/29/12 14:04:59 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.Hive/3.3/Convert.cs
r7857 r7916 200 200 #endregion 201 201 202 #region Resource 203 public static DT.Resource ToDto(DB.Resource source) { 204 if (source == null) return null; 205 return new DT.Resource { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval, OwnerUserId = source.OwnerUserId }; 206 } 207 public static DB.Resource ToEntity(DT.Resource source) { 208 if (source == null) return null; 209 var entity = new DB.Resource(); ToEntity(source, entity); 210 return entity; 211 } 212 public static void ToEntity(DT.Resource source, DB.Resource target) { 213 if ((source != null) && (target != null)) { 214 target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval; target.OwnerUserId = source.OwnerUserId; 215 } 216 } 217 #endregion 218 219 #region SlaveGroup 220 public static DT.SlaveGroup ToDto(DB.SlaveGroup source) { 221 if (source == null) return null; 222 return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval, OwnerUserId = source.OwnerUserId }; 223 } 224 public static DB.SlaveGroup ToEntity(DT.SlaveGroup source) { 225 if (source == null) return null; 226 var entity = new DB.SlaveGroup(); ToEntity(source, entity); 227 return entity; 228 } 229 public static void ToEntity(DT.SlaveGroup source, DB.SlaveGroup target) { 230 if ((source != null) && (target != null)) { 231 target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval; target.OwnerUserId = source.OwnerUserId; 232 } 233 } 234 #endregion 235 202 236 #region Slave 203 237 public static DT.Slave ToDto(DB.Slave source) { … … 219 253 CpuUtilization = source.CpuUtilization, 220 254 HbInterval = source.HbInterval, 221 IsDisposable = source.IsDisposable 255 IsDisposable = source.IsDisposable, 256 OwnerUserId = source.OwnerUserId 222 257 }; 223 258 } … … 245 280 target.HbInterval = source.HbInterval; 246 281 target.IsDisposable = source.IsDisposable; 247 } 248 } 249 #endregion 250 251 #region SlaveGroup 252 public static DT.SlaveGroup ToDto(DB.SlaveGroup source) { 253 if (source == null) return null; 254 return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval }; 255 } 256 public static DB.SlaveGroup ToEntity(DT.SlaveGroup source) { 257 if (source == null) return null; 258 var entity = new DB.SlaveGroup(); ToEntity(source, entity); 259 return entity; 260 } 261 public static void ToEntity(DT.SlaveGroup source, DB.SlaveGroup target) { 262 if ((source != null) && (target != null)) { 263 target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval; 264 } 265 } 266 #endregion 267 268 #region Resource 269 public static DT.Resource ToDto(DB.Resource source) { 270 if (source == null) return null; 271 return new DT.Resource { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId, HbInterval = source.HbInterval }; 272 } 273 public static DB.Resource ToEntity(DT.Resource source) { 274 if (source == null) return null; 275 var entity = new DB.Resource(); ToEntity(source, entity); 276 return entity; 277 } 278 public static void ToEntity(DT.Resource source, DB.Resource target) { 279 if ((source != null) && (target != null)) { 280 target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId; target.HbInterval = source.HbInterval; 281 } 282 } 283 #endregion 284 285 #region Statistics 286 public static DT.Statistics ToDto(DB.Statistics source) { 287 if (source == null) return null; 288 return new DT.Statistics { 289 Id = source.StatisticsId, 290 TimeStamp = source.Timestamp, 291 SlaveStatistics = source.SlaveStatistics.Select(x => Convert.ToDto(x)).ToArray(), 292 UserStatistics = source.UserStatistics.Select(x => Convert.ToDto(x)).ToArray() 293 }; 294 } 295 public static DB.Statistics ToEntity(DT.Statistics source) { 296 if (source == null) return null; 297 var entity = new DB.Statistics(); ToEntity(source, entity); 298 return entity; 299 } 300 public static void ToEntity(DT.Statistics source, DB.Statistics target) { 301 if ((source != null) && (target != null)) { 302 target.StatisticsId = source.Id; 303 target.Timestamp = source.TimeStamp; 304 282 target.OwnerUserId = source.OwnerUserId; 283 } 284 } 285 #endregion 286 287 #region ResourcePermission 288 public static DT.ResourcePermission ToDto(DB.ResourcePermission source) { 289 if (source == null) return null; 290 return new DT.ResourcePermission { ResourceId = source.ResourceId, GrantedUserId = source.GrantedUserId, GrantedByUserId = source.GrantedByUserId }; 291 } 292 public static DB.ResourcePermission ToEntity(DT.ResourcePermission source) { 293 if (source == null) return null; 294 var entity = new DB.ResourcePermission(); ToEntity(source, entity); 295 return entity; 296 } 297 public static void ToEntity(DT.ResourcePermission source, DB.ResourcePermission target) { 298 if ((source != null) && (target != null)) { 299 target.ResourceId = source.ResourceId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId; 305 300 } 306 301 } … … 334 329 target.FreeMemory = source.FreeMemory; 335 330 target.Memory = source.Memory; 331 } 332 } 333 #endregion 334 335 #region Statistics 336 public static DT.Statistics ToDto(DB.Statistics source) { 337 if (source == null) return null; 338 return new DT.Statistics { 339 Id = source.StatisticsId, 340 TimeStamp = source.Timestamp, 341 SlaveStatistics = source.SlaveStatistics.Select(x => Convert.ToDto(x)).ToArray(), 342 UserStatistics = source.UserStatistics.Select(x => Convert.ToDto(x)).ToArray() 343 }; 344 } 345 public static DB.Statistics ToEntity(DT.Statistics source) { 346 if (source == null) return null; 347 var entity = new DB.Statistics(); ToEntity(source, entity); 348 return entity; 349 } 350 public static void ToEntity(DT.Statistics source, DB.Statistics target) { 351 if ((source != null) && (target != null)) { 352 target.StatisticsId = source.Id; 353 target.Timestamp = source.TimeStamp; 354 336 355 } 337 356 }
Note: See TracChangeset
for help on using the changeset viewer.