- Timestamp:
- 03/08/11 12:39:33 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Convert.cs
r5526 r5633 64 64 target.StateLogs.Add(Convert.ToEntity(sl)); 65 65 } 66 66 67 67 //target.StateLogs.AddRange(source.StateLog.Select(x => Convert.ToEntity(x)).OrderBy(x => x.DateTime)); 68 68 target.IsParentJob = source.IsParentJob; … … 103 103 if ((source != null) && (target != null)) { 104 104 target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.JobId = source.JobId; target.SlaveId = source.SlaveId; target.State = source.State; target.UserId = source.UserId; 105 } 106 } 107 #endregion 108 109 #region Appointment 110 public static DT.Appointment ToDto(UptimeCalendar source) { 111 if (source == null) return null; 112 return new DT.Appointment { Id = source.UptimeCalendarId, AllDayEvent = source.AllDayEvent, EndDate = source.EndDate, Recurring = source.Recurring, RecurringId = source.RecurringId, ResourceId = source.ResourceId, StartDate = source.StartDate }; 113 } 114 public static UptimeCalendar ToEntity(DT.Appointment source) { 115 if (source == null) return null; 116 var entity = new UptimeCalendar(); ToEntity(source, entity); 117 return entity; 118 } 119 public static void ToEntity(DT.Appointment source, UptimeCalendar target) { 120 if ((source != null) && (target != null)) { 121 target.UptimeCalendarId = 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; 105 122 } 106 123 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs
r5593 r5633 94 94 where resourceIds.Contains(ar.ResourceId) 95 95 && ar.Job.State == JobState.Waiting 96 && ar.Job.IsParentJob 96 && ar.Job.IsParentJob 97 97 && (finished ? ar.Job.FinishWhenChildJobsFinished : !ar.Job.FinishWhenChildJobsFinished) 98 98 && (from child in db.Jobs … … 581 581 } 582 582 #endregion 583 584 #region AppointmentMethods 585 public Appointment GetAppointment(Guid id) { 586 using (var db = CreateContext()) { 587 return Convert.ToDto(db.UptimeCalendars.SingleOrDefault(x => x.UptimeCalendarId == id)); 588 } 589 } 590 591 public IEnumerable<Appointment> GetAppointments(Expression<Func<UptimeCalendar, bool>> predicate) { 592 using (var db = CreateContext()) { 593 return db.UptimeCalendars.Where(predicate).Select(x => Convert.ToDto(x)).ToArray(); 594 } 595 } 596 597 public Guid AddAppointment(Appointment dto) { 598 using (var db = CreateContext()) { 599 var entity = Convert.ToEntity(dto); 600 db.UptimeCalendars.InsertOnSubmit(entity); 601 db.SubmitChanges(); 602 return entity.UptimeCalendarId; 603 } 604 } 605 606 public void UpdateAppointment(Appointment dto) { 607 using (var db = CreateContext()) { 608 var entity = db.UptimeCalendars.FirstOrDefault(x => x.UptimeCalendarId == dto.Id); 609 if (entity == null) db.UptimeCalendars.InsertOnSubmit(Convert.ToEntity(dto)); 610 else Convert.ToEntity(dto, entity); 611 db.SubmitChanges(); 612 } 613 } 614 615 public void DeleteAppointment(Guid id) { 616 using (var db = CreateContext()) { 617 var entity = db.UptimeCalendars.FirstOrDefault(x => x.UptimeCalendarId == id); 618 if (entity != null) db.UptimeCalendars.DeleteOnSubmit(entity); 619 db.SubmitChanges(); 620 } 621 } 622 #endregion 583 623 } 584 624 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Interfaces/IHiveDao.cs
r5593 r5633 105 105 void SetLastCleanup(DateTime datetime); 106 106 #endregion 107 108 #region Appointment Methods 109 DT.Appointment GetAppointment(Guid id); 110 IEnumerable<DT.Appointment> GetAppointments(Expression<Func<UptimeCalendar, bool>> predicate); 111 Guid AddAppointment(DT.Appointment dto); 112 void UpdateAppointment(DT.Appointment dto); 113 void DeleteAppointment(Guid id); 114 #endregion 115 107 116 } 108 117 }
Note: See TracChangeset
for help on using the changeset viewer.