public override async Task <bool> RemoveScheduleAsync(ISchedule schedule) { await _initComplete.Task; TvDatabase.Schedule tvSchedule = TvDatabase.Schedule.Retrieve(schedule.ScheduleId); // Already deleted somewhere else? if (tvSchedule == null) { return(true); } _tvControl.StopRecordingSchedule(tvSchedule.IdSchedule); // delete canceled schedules first foreach (var cs in CanceledSchedule.ListAll().Where(x => x.IdSchedule == tvSchedule.IdSchedule)) { cs.Remove(); } try { // can fail if "StopRecordingSchedule" already deleted the entry TvDatabase.Schedule.ResetProgramStates(tvSchedule.IdSchedule); tvSchedule.Remove(); } catch { } _tvControl.OnNewSchedule(); // I don't think this is needed, but doesn't hurt either return(true); }
public WebBoolResult DeleteSchedule(int scheduleId) { // TODO: the workflow in this method doesn't make any sense at all try { Schedule schedule = Schedule.Retrieve(scheduleId); // first cancel all of the episodes of this program for this schedule foreach (Program program in Program.ListAll().Where(program => program.Title == schedule.ProgramName)) { if (schedule.IsRecordingProgram(program, true)) { CanceledSchedule canceledSchedule = new CanceledSchedule(schedule.IdSchedule, program.IdChannel, program.StartTime); canceledSchedule.Persist(); _tvControl.OnNewSchedule(); } } // now remove existing CanceledSchedule for this schedule foreach (CanceledSchedule canceled in CanceledSchedule.ListAll().Where(canceled => canceled.IdSchedule == schedule.IdSchedule)) { canceled.Remove(); } schedule.Remove(); _tvControl.OnNewSchedule(); return(true); } catch (Exception ex) { Log.Warn(String.Format("Failed to delete schedule {0}", scheduleId), ex); return(false); } }
/// <summary> /// Removes every cancled schedule. /// </summary> /// <param name="refFillList">The schedules list.</param> /// <returns></returns> private void removeCanceledSchedules(IList <Schedule> refFillList) { IList <CanceledSchedule> canceledList = CanceledSchedule.ListAll(); foreach (CanceledSchedule canceled in canceledList) { foreach (Schedule sched in refFillList) { if ((canceled.IdSchedule == sched.IdSchedule) && (canceled.CancelDateTime == sched.StartTime)) { refFillList.Remove(sched); break; } } } }
public override bool RemoveSchedule(ISchedule schedule) { TvDatabase.Schedule tvSchedule = TvDatabase.Schedule.Retrieve(schedule.ScheduleId); // Already deleted somewhere else? if (tvSchedule == null) { return(true); } _tvControl.StopRecordingSchedule(tvSchedule.IdSchedule); // delete canceled schedules first foreach (var cs in CanceledSchedule.ListAll().Where(x => x.IdSchedule == tvSchedule.IdSchedule)) { cs.Remove(); } tvSchedule.Remove(); _tvControl.OnNewSchedule(); // I don't think this is needed, but doesn't hurt either return(true); }
public bool RemoveSchedule(ISchedule schedule) { #if TVE3 TvDatabase.Schedule tvSchedule = TvDatabase.Schedule.Retrieve(schedule.ScheduleId); _tvControl.StopRecordingSchedule(tvSchedule.IdSchedule); // delete canceled schedules first foreach (var cs in CanceledSchedule.ListAll().Where(x => x.IdSchedule == tvSchedule.IdSchedule)) { cs.Remove(); } tvSchedule.Remove(); _tvControl.OnNewSchedule(); // I don't think this is needed, but doesn't hurt either #else IScheduleService scheduleService = GlobalServiceProvider.Instance.Get <IScheduleService>(); if (scheduleService == null) { return(false); } scheduleService.DeleteSchedule(schedule.ScheduleId); #endif return(true); }
public WebBoolResult DeleteSchedule(int scheduleId) { try { Log.Debug("Deleting schedule with id {0}", scheduleId); Schedule schedule = Schedule.Retrieve(scheduleId); _tvControl.StopRecordingSchedule(schedule.IdSchedule); // delete canceled schedules first foreach (var cs in CanceledSchedule.ListAll().Where(x => x.IdSchedule == schedule.IdSchedule)) { cs.Remove(); } schedule.Remove(); _tvControl.OnNewSchedule(); // I don't think this is needed, but doesn't hurt either return(true); } catch (Exception ex) { Log.Warn(String.Format("Failed to delete schedule {0}", scheduleId), ex); return(false); } }