Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/08/11 12:39:33 (14 years ago)
Author:
ascheibe
Message:

#1233 added Appointment/Schedule ws and dao methods

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  
    6464          target.StateLogs.Add(Convert.ToEntity(sl));
    6565        }
    66        
     66
    6767        //target.StateLogs.AddRange(source.StateLog.Select(x => Convert.ToEntity(x)).OrderBy(x => x.DateTime));
    6868        target.IsParentJob = source.IsParentJob;
     
    103103      if ((source != null) && (target != null)) {
    104104        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;
    105122      }
    106123    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs

    r5593 r5633  
    9494                    where resourceIds.Contains(ar.ResourceId)
    9595                       && ar.Job.State == JobState.Waiting
    96                        && ar.Job.IsParentJob 
     96                       && ar.Job.IsParentJob
    9797                       && (finished ? ar.Job.FinishWhenChildJobsFinished : !ar.Job.FinishWhenChildJobsFinished)
    9898                       && (from child in db.Jobs
     
    581581    }
    582582    #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
    583623  }
    584624}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Interfaces/IHiveDao.cs

    r5593 r5633  
    105105    void SetLastCleanup(DateTime datetime);
    106106    #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
    107116  }
    108117}
Note: See TracChangeset for help on using the changeset viewer.