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 static bool IsRecordingProgram(TvDatabase.Program program, out TvDatabase.Schedule recordingSchedule, bool filterCanceledRecordings) { recordingSchedule = null; IList <TvDatabase.Schedule> schedules = TvDatabase.Schedule.ListAll(); foreach (TvDatabase.Schedule schedule in schedules) { if (schedule.Canceled != TvDatabase.Schedule.MinSchedule || (filterCanceledRecordings && schedule.IsSerieIsCanceled(schedule.GetSchedStartTimeForProg(program), program.IdChannel))) { continue; } if (schedule.IsManual && schedule.IdChannel == program.IdChannel && schedule.EndTime >= program.EndTime) { TvDatabase.Schedule manual = schedule.Clone(); manual.ProgramName = program.Title; manual.EndTime = program.EndTime; manual.StartTime = program.StartTime; if (manual.IsRecordingProgram(program, filterCanceledRecordings)) { recordingSchedule = schedule; return(true); } } else if (schedule.IsRecordingProgram(program, filterCanceledRecordings)) { recordingSchedule = schedule; return(true); } } return(false); }
private void CheckEpsiodesForRecording(Schedule schedule, TvDatabase.Program program) { if (!schedule.DoesUseEpisodeManagement) return; //check how many episodes we got while (true) { IList<Recording> recordings = Recording.ListAll(); List<Recording> episodes = GetEpisodes(program.Title, recordings); if (episodes.Count <= schedule.MaxAirings) return; Recording oldestEpisode = GetOldestEpisode(episodes); if (oldestEpisode == null) return; Log.Write("diskmanagement: Delete episode {0} {1} {2} {3}", oldestEpisode.ReferencedChannel(), oldestEpisode.Title, oldestEpisode.StartTime.ToLongDateString(), oldestEpisode.StartTime.ToLongTimeString()); // Delete the file from disk and the recording entry from the database. bool result = RecordingFileHandler.DeleteRecordingOnDisk(oldestEpisode.FileName); if (result) { oldestEpisode.Delete(); } } }
public void OnScheduleEnded(string recordingFilename, Schedule recording, TvDatabase.Program program) { Log.Write("diskmanagement: recording {0} ended. type:{1} max episodes:{2}", program.Title, (ScheduleRecordingType)recording.ScheduleType, recording.MaxAirings); CheckEpsiodesForRecording(recording, program); }
public override Task <bool> EditScheduleAsync(ISchedule schedule, IChannel channel = null, string title = null, DateTime?from = null, DateTime?to = null, ScheduleRecordingType?recordingType = null, int?preRecordInterval = null, int?postRecordInterval = null, string directory = null, int?priority = null) { try { ServiceRegistration.Get <ILogger>().Debug("Editing schedule {0} on channel {1} for {2}, {3} till {4}, type {5}", schedule.ScheduleId, channel.ChannelId, title, from, to, recordingType); TvDatabase.Schedule tvSchedule = TvDatabase.Schedule.Retrieve(schedule.ScheduleId); tvSchedule.IdChannel = channel.ChannelId; if (title != null) { tvSchedule.ProgramName = title; } if (from != null) { tvSchedule.StartTime = from.Value; } if (to != null) { tvSchedule.EndTime = to.Value; } if (recordingType != null) { ScheduleRecordingType scheduleRecType = recordingType.Value; tvSchedule.ScheduleType = (int)scheduleRecType; } if (preRecordInterval != null) { tvSchedule.PreRecordInterval = preRecordInterval.Value; } if (postRecordInterval != null) { tvSchedule.PostRecordInterval = postRecordInterval.Value; } if (directory != null) { tvSchedule.Directory = directory; } if (priority != null) { tvSchedule.Priority = priority.Value; } tvSchedule.Persist(); _tvControl.OnNewSchedule(); // I don't think this is needed, but doesn't hurt either return(Task.FromResult(true)); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Warn(String.Format("Failed to edit schedule {0}", schedule.ScheduleId), ex); return(Task.FromResult(false)); } }
public override bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule) { TvDatabase.Schedule tvSchedule = _tvBusiness.AddSchedule(channel.ChannelId, "Manual", from, to, (int)ScheduleRecordingType.Once); tvSchedule.PreRecordInterval = Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value); tvSchedule.PostRecordInterval = Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value); tvSchedule.Persist(); _tvControl.OnNewSchedule(); schedule = tvSchedule.ToSchedule(); return(true); }
public override async Task <AsyncResult <ISchedule> > CreateScheduleByTimeAsync(IChannel channel, DateTime from, DateTime to, ScheduleRecordingType recordingType) { await _initComplete.Task; TvDatabase.Schedule tvSchedule = new TvDatabase.Schedule(channel.ChannelId, "Manual", from, to); tvSchedule.ScheduleType = (int)recordingType; tvSchedule.PreRecordInterval = Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value); tvSchedule.PostRecordInterval = Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value); tvSchedule.Persist(); _tvControl.OnNewSchedule(); var schedule = tvSchedule.ToSchedule(); return(new AsyncResult <ISchedule>(true, schedule)); }
public static bool CreateProgram(TvDatabase.Program program, int scheduleType, out ISchedule currentSchedule) { ServiceRegistration.Get <ILogger>().Debug("SlimTvService3.CreateProgram: program = {0}", program.ToString()); TvDatabase.Schedule schedule; TvDatabase.Schedule saveSchedule = null; TvBusinessLayer layer = new TvBusinessLayer(); if (IsRecordingProgram(program, out schedule, false)) // check if schedule is already existing { ServiceRegistration.Get <ILogger>().Debug("SlimTvService3.CreateProgram - series schedule found ID={0}, Type={1}", schedule.IdSchedule, schedule.ScheduleType); ServiceRegistration.Get <ILogger>().Debug(" - schedule= {0}", schedule.ToString()); if (schedule.IsSerieIsCanceled(schedule.GetSchedStartTimeForProg(program), program.IdChannel)) { // Delete the cancelled schedule. saveSchedule = schedule; schedule = new TvDatabase.Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime) { PreRecordInterval = saveSchedule.PreRecordInterval, PostRecordInterval = saveSchedule.PostRecordInterval, ScheduleType = (int)ScheduleRecordingType.Once }; } } else { ServiceRegistration.Get <ILogger>().Debug("SlimTvService3.CreateProgram - no series schedule"); // No series schedule => create it schedule = new TvDatabase.Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime) { PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value), PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value), ScheduleType = scheduleType }; } if (saveSchedule != null) { ServiceRegistration.Get <ILogger>().Debug("SlimTvService3.CreateProgram - UnCancelSerie at {0}", program.StartTime); saveSchedule.UnCancelSerie(program.StartTime, program.IdChannel); saveSchedule.Persist(); currentSchedule = saveSchedule.ToSchedule(); } else { ServiceRegistration.Get <ILogger>().Debug("SlimTvService3.CreateProgram - create schedule = {0}", schedule.ToString()); schedule.Persist(); currentSchedule = schedule.ToSchedule(); } return(currentSchedule != null); }
public bool AddScheduleAdvanced(int idChannel, string programName, DateTime startTime, DateTime endTime, int scheduleType, int preRecordInterval, int postRecordInterval, string directory, int keepMethod) { if (!ConnectToDatabase()) return false; Schedule sched = new Schedule(idChannel, programName, startTime, endTime); // using negative numbers instead of null because non-primitive types (which a Nullable<int> is) and SOAP don't mix easily sched.PreRecordInterval = preRecordInterval < 0 ? Int32.Parse(GetSetting("preRecordInterval", "5").Value) : preRecordInterval; sched.PostRecordInterval = postRecordInterval < 0 ? Int32.Parse(GetSetting("postRecordInterval", "5").Value) : postRecordInterval; sched.ScheduleType = scheduleType; sched.Directory = directory; sched.KeepMethod = keepMethod; sched.Persist(); RemoteControl.Instance.OnNewSchedule(); return true; }
public bool AddSchedule(int channelId, String programName, DateTime startTime, DateTime endTime, int scheduleType, Int32 priority, Int32 keepmethod, DateTime keepdate, Int32 preRecordInterval, Int32 postRecordInterval) { try { TvBusinessLayer layer = new TvBusinessLayer(); TvDatabase.Schedule s = new TvDatabase.Schedule(channelId, programName, startTime, endTime); if (scheduleType < 0) { s.ScheduleType = (int)TvDatabase.ScheduleRecordingType.Once; } else { s.ScheduleType = scheduleType; } if (priority != -1) { s.Priority = priority; } if (keepmethod != -1) { s.KeepMethod = keepmethod; s.KeepDate = keepdate; } if ((preRecordInterval < 0) && (postRecordInterval < 0)) { //Use the settings from Mediaportal s.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value); s.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value); } else { // Use the settings from XBMC s.PreRecordInterval = preRecordInterval; s.PostRecordInterval = postRecordInterval; } s.Persist(); RemoteControl.Instance.OnNewSchedule(); return true; } catch { return false; } }
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 override Task <AsyncResult <ISchedule> > CreateScheduleDetailedAsync(IChannel channel, string title, DateTime from, DateTime to, ScheduleRecordingType recordingType, int preRecordInterval, int postRecordInterval, string directory, int priority) { TvDatabase.Schedule tvSchedule = _tvBusiness.AddSchedule(channel.ChannelId, title, from, to, (int)recordingType); tvSchedule.PreRecordInterval = preRecordInterval >= 0 ? preRecordInterval : Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value); tvSchedule.PostRecordInterval = postRecordInterval >= 0 ? postRecordInterval : Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value); if (!String.IsNullOrEmpty(directory)) { tvSchedule.Directory = directory; } if (priority >= 0) { tvSchedule.Priority = priority; } tvSchedule.Persist(); _tvControl.OnNewSchedule(); var schedule = tvSchedule.ToSchedule(); return(Task.FromResult(new AsyncResult <ISchedule>(true, schedule))); }
public void CopyTimeShiftFile(object itemlist, Recording rec, Schedule newSchedule) { try { ThreadStart ts = delegate() { TsCopier(itemlist, rec, newSchedule); }; Thread _CopyTimeShiftFile; _CopyTimeShiftFile = new Thread(ts); _CopyTimeShiftFile.Priority = ThreadPriority.Lowest; _CopyTimeShiftFile.IsBackground = true; _CopyTimeShiftFile.Start(); } catch (Exception ex) { Log.Error("TsCopier exception: {0}", ex); return; } }
/// <summary> /// constructor /// </summary> /// <param name="schedule">Schedule of this recording</param> /// <param name="channel">Channel on which the recording is done</param> /// <param name="endTime">Date/Time the recording should start without pre-record interval</param> /// <param name="endTime">Date/Time the recording should stop with post record interval</param> /// <param name="isSerie">Is serie recording</param> /// /// public RecordingDetail(Schedule schedule, Channel channel, DateTime endTime, bool isSerie) { _user = UserFactory.CreateSchedulerUser(schedule.IdSchedule); /*User.Name = string.Format("scheduler{0}", schedule.IdSchedule); User.CardId = -1; User.SubChannel = -1; User.IsAdmin = true; User.Priority = UserFactory.SCHEDULER_PRIORITY;*/ _schedule = schedule; _channel = channel; _endTime = endTime; _program = null; _isSerie = isSerie; DateTime startTime = DateTime.MinValue; if (isSerie) { DateTime now = DateTime.Now.AddMinutes(schedule.PreRecordInterval); startTime = new DateTime(now.Year, now.Month, now.Day, schedule.StartTime.Hour, schedule.StartTime.Minute, 0); } else { startTime = schedule.StartTime; } _program = schedule.ReferencedChannel().GetProgramAt(startTime); //no program? then treat this as a manual recording if (_program == null) { _program = new TvDatabase.Program(0, DateTime.Now, endTime, "manual", "", "", TvDatabase.Program.ProgramState.None, System.Data.SqlTypes.SqlDateTime.MinValue.Value, string.Empty, string.Empty, string.Empty, string.Empty, -1, string.Empty, 0); } }
public static void StartRecordingSchedule(Channel channel, bool manual) { TvBusinessLayer layer = new TvBusinessLayer(); TvServer server = new TvServer(); if (manual) // until manual stop { Schedule newSchedule = new Schedule(channel.IdChannel, GUILocalizeStrings.Get(413) + " (" + channel.DisplayName + ")", DateTime.Now, DateTime.Now.AddDays(1)); newSchedule.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value); newSchedule.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value); newSchedule.Persist(); server.OnNewSchedule(); } else // current program { // lets find any canceled episodes that match this one we want to create, if found uncancel it. Schedule existingParentSchedule = Schedule.RetrieveSeries(channel.IdChannel, channel.CurrentProgram.Title, channel.CurrentProgram.StartTime, channel.CurrentProgram.EndTime); if (existingParentSchedule != null) { foreach (CanceledSchedule cancelSched in existingParentSchedule.ReferringCanceledSchedule()) { if (cancelSched.CancelDateTime == channel.CurrentProgram.StartTime) { existingParentSchedule.UnCancelSerie(channel.CurrentProgram.StartTime, channel.CurrentProgram.IdChannel); server.OnNewSchedule(); return; } } } // ok, no existing schedule found with matching canceled schedules found. proceeding to add the schedule normally Schedule newSchedule = new Schedule(channel.IdChannel, channel.CurrentProgram.Title, channel.CurrentProgram.StartTime, channel.CurrentProgram.EndTime); newSchedule.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value); newSchedule.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value); newSchedule.Persist(); server.OnNewSchedule(); } GUIMessage msgManualRecord = new GUIMessage(GUIMessage.MessageType.GUI_MSG_MANUAL_RECORDING_STARTED, 0, 0, 0, 0, 0, null); GUIWindowManager.SendMessage(msgManualRecord); }
/// <summary> /// GetWakeupTime determines the wakeup time for a Schedule when no guide data is present /// Note that this obviously only works for the following ScheduleRecordingsType's: /// - Once /// - Daily /// - Weekends /// - WorkingDays /// - Weekly /// </summary> /// <param name="schedule">Schedule to determine next wakeup time for</param> /// <returns>DateTime indicating the wakeup time for this Schedule</returns> private static DateTime GetWakeupTime(Schedule schedule) { ScheduleRecordingType type = (ScheduleRecordingType)schedule.ScheduleType; DateTime now = DateTime.Now; DateTime start = new DateTime(now.Year, now.Month, now.Day, schedule.StartTime.Hour, schedule.StartTime.Minute, schedule.StartTime.Second); DateTime stop = new DateTime(now.Year, now.Month, now.Day, schedule.EndTime.Hour, schedule.EndTime.Minute, schedule.EndTime.Second); switch (type) { case ScheduleRecordingType.Once: return schedule.StartTime.AddMinutes(-schedule.PreRecordInterval); case ScheduleRecordingType.Daily: // if schedule was already due today, then run tomorrow if (now > stop.AddMinutes(schedule.PostRecordInterval)) start = start.AddDays(1); return start.AddMinutes(-schedule.PreRecordInterval); case ScheduleRecordingType.Weekends: // check if it's a weekend currently if (WeekEndTool.IsWeekend(now.DayOfWeek)) { // check if schedule has been due already today if (now > stop.AddMinutes(schedule.PostRecordInterval)) { // if so, add appropriate days to wakeup time start = WeekEndTool.IsFirstWeekendDay(now.DayOfWeek) ? start.AddDays(1) : start.AddDays(6); } } else { // it's not a weekend so calculate number of days to add to current time int days = (int)WeekEndTool.FirstWeekendDay - (int)now.DayOfWeek; start = start.AddDays(days); } return start.AddMinutes(-schedule.PreRecordInterval); case ScheduleRecordingType.WorkingDays: // check if current time is in weekend; if so add appropriate number of days if (now.DayOfWeek == WeekEndTool.FirstWeekendDay) start = start.AddDays(2); else if (now.DayOfWeek == WeekEndTool.SecondWeekendDay) start = start.AddDays(1); else { // current time is on a working days; check if schedule has already been due if (now > stop.AddMinutes(schedule.PostRecordInterval)) { // schedule has been due, so add appropriate number of days start = now.DayOfWeek < (WeekEndTool.FirstWeekendDay - 1) ? start.AddDays(1) : start.AddDays(3); } } return start.AddMinutes(-schedule.PreRecordInterval); case ScheduleRecordingType.Weekly: // check if current day of week is same as schedule's day of week if (now.DayOfWeek == schedule.StartTime.DayOfWeek) { // check if schedule has been due if (now > stop.AddMinutes(schedule.PostRecordInterval)) { // schedule has been due, so record again next week start = start.AddDays(7); } } else { // current day of week isn't schedule's day of week, so // add appropriate number of days if (now.DayOfWeek < schedule.StartTime.DayOfWeek) { // schedule is due this week int days = schedule.StartTime.DayOfWeek - now.DayOfWeek; start = start.AddDays(days); } else { // schedule should start next week int days = 7 - (now.DayOfWeek - schedule.StartTime.DayOfWeek); start = start.AddDays(days); } } return start.AddMinutes(-schedule.PreRecordInterval); } // other recording types cannot be determined manually (every time on ...) return DateTime.MaxValue; }
private WebScheduledRecording GetScheduledRecording(Schedule schedule, DateTime date) { // ignore schedules that don't even match the date we are checking for ScheduleRecordingType type = (ScheduleRecordingType)schedule.ScheduleType; if ((type == ScheduleRecordingType.Weekends && !(date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday)) || (type == ScheduleRecordingType.WorkingDays && (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday)) || (type == ScheduleRecordingType.Weekly && schedule.StartTime.DayOfWeek != date.DayOfWeek) || (type == ScheduleRecordingType.Once && schedule.StartTime.Date != date.Date) || (type == ScheduleRecordingType.WeeklyEveryTimeOnThisChannel && schedule.StartTime.Date != date.Date)) return null; // retrieve some data var channel = Channel.Retrieve(schedule.IdChannel); WebScheduledRecording recording = new WebScheduledRecording(); recording.ScheduleId = schedule.IdSchedule; // first check all types that do not require any EPG matching ScheduleRecordingType[] noEpgTypes = { ScheduleRecordingType.Daily, ScheduleRecordingType.Weekends, ScheduleRecordingType.WorkingDays, ScheduleRecordingType.Weekly, ScheduleRecordingType.Once }; if (noEpgTypes.Contains(type)) { recording.ChannelId = channel.IdChannel; recording.ChannelName = channel.DisplayName; recording.StartTime = schedule.StartTime; recording.EndTime = schedule.EndTime; var matchingPrograms = _tvBusiness.GetPrograms(channel, schedule.StartTime, schedule.EndTime); recording.ProgramId = matchingPrograms.Any() ? matchingPrograms.First().IdProgram : 0; recording.Title = matchingPrograms.Any() ? matchingPrograms.First().Title : schedule.ProgramName; return recording; } // all schedule types which reach this far match a program in the EPG IList<Program> programs = type == ScheduleRecordingType.WeeklyEveryTimeOnThisChannel || type == ScheduleRecordingType.EveryTimeOnThisChannel ? _tvBusiness.GetPrograms(channel, date.Date, date.Date.Add(TimeSpan.FromDays(1))) : _tvBusiness.GetPrograms(date.Date, date.Date.Add(TimeSpan.FromDays(1))); var program = programs.FirstOrDefault(x => x.Title == schedule.ProgramName && (x.StartTime > DateTime.Now || date.Date < DateTime.Today)); if (program == null) return null; // set properties from the program and channel of the program channel = program.ReferencedChannel(); recording.ChannelId = channel.IdChannel; recording.ChannelName = channel.DisplayName; recording.StartTime = program.StartTime; recording.EndTime = program.EndTime; recording.ProgramId = program.IdProgram; recording.Title = program.Title; return recording; }
public IList<Schedule> GetRecordingTimes(Schedule rec) { DateTime startTime = DateTime.Now; DateTime endTime = startTime.AddDays(_days); IList<Program> programs = Schedule.GetProgramsForSchedule(rec); IList<Schedule> recordings = recordings = AddProgramsToSchedulesList(rec, programs); return recordings; }
private void OnPostRecordInterval() { Schedule rec = currentSchedule; if (currentSchedule == null && !IsRecordingProgram(CurrentProgram, out rec, false)) { return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.ShowQuickNumbers = false; dlg.SetHeading(GUILocalizeStrings.Get(1445)); //pre-record foreach (int interval in RecordingIntervalValues) { if (interval == 1) { if (interval == _postRec) { dlg.Add(String.Format("{0} {1}", interval, GUILocalizeStrings.Get(3003) + " (" + GUILocalizeStrings.Get(886) + ")")); // minute (default) } else { dlg.Add(String.Format("{0} {1}", interval, GUILocalizeStrings.Get(3003))); // minute } } else { if (interval == _postRec) { dlg.Add(String.Format("{0} {1}", interval, GUILocalizeStrings.Get(3004) + " (" + GUILocalizeStrings.Get(886) + ")")); // minutes (default) } else { dlg.Add(String.Format("{0} {1}", interval, GUILocalizeStrings.Get(3004))); // minutes } } } if (rec.PostRecordInterval < 0) { dlg.SelectedLabel = 0; } else if (RecordingIntervalValues.IndexOf(rec.PostRecordInterval) == -1) { RecordingIntervalValues.IndexOf(_postRec); // select default if the value is not part of the list } else { dlg.SelectedLabel = RecordingIntervalValues.IndexOf(rec.PostRecordInterval); } dlg.DoModal(GetID); if (dlg.SelectedLabel < 0) { return; } rec.PostRecordInterval = RecordingIntervalValues[dlg.SelectedLabel]; rec.Persist(); currentSchedule = rec; Schedule assocSchedule = Schedule.RetrieveSpawnedSchedule(rec.IdSchedule, rec.StartTime); if (assocSchedule != null) { assocSchedule.PostRecordInterval = rec.PostRecordInterval; assocSchedule.Persist(); } } Update(); }
public static void CreateProgram(Program program, int scheduleType, int dialogId) { Log.Debug("TVProgramInfo.CreateProgram: program = {0}", program.ToString()); Schedule schedule; Schedule saveSchedule = null; TvBusinessLayer layer = new TvBusinessLayer(); if (IsRecordingProgram(program, out schedule, false)) // check if schedule is already existing { Log.Debug("TVProgramInfo.CreateProgram - series schedule found ID={0}, Type={1}", schedule.IdSchedule, schedule.ScheduleType); Log.Debug(" - schedule= {0}", schedule.ToString()); //schedule = Schedule.Retrieve(schedule.IdSchedule); // get the correct informations if (schedule.IsSerieIsCanceled(schedule.GetSchedStartTimeForProg(program), program.IdChannel)) { //lets delete the cancelled schedule. saveSchedule = schedule; schedule = new Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime); schedule.PreRecordInterval = saveSchedule.PreRecordInterval; schedule.PostRecordInterval = saveSchedule.PostRecordInterval; schedule.ScheduleType = (int)ScheduleRecordingType.Once; // needed for layer.GetConflictingSchedules(...) } } else { Log.Debug("TVProgramInfo.CreateProgram - no series schedule"); // no series schedule => create it schedule = new Schedule(program.IdChannel, program.Title, program.StartTime, program.EndTime); schedule.PreRecordInterval = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value); schedule.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value); schedule.ScheduleType = scheduleType; } // check if this program is conflicting with any other already scheduled recording IList conflicts = layer.GetConflictingSchedules(schedule); Log.Debug("TVProgramInfo.CreateProgram - conflicts.Count = {0}", conflicts.Count); TvServer server = new TvServer(); bool skipConflictingEpisodes = false; if (conflicts.Count > 0) { TVConflictDialog dlg = (TVConflictDialog)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_TVCONFLICT); if (dlg != null) { dlg.Reset(); dlg.SetHeading(GUILocalizeStrings.Get(879)); // "recording conflict" foreach (Schedule conflict in conflicts) { Log.Debug("TVProgramInfo.CreateProgram: Conflicts = " + conflict); GUIListItem item = new GUIListItem(conflict.ProgramName); item.Label2 = GetRecordingDateTime(conflict); Channel channel = Channel.Retrieve(conflict.IdChannel); if (channel != null && !string.IsNullOrEmpty(channel.DisplayName)) { item.Label3 = channel.DisplayName; } else { item.Label3 = conflict.IdChannel.ToString(); } item.TVTag = conflict; dlg.AddConflictRecording(item); } dlg.ConflictingEpisodes = (scheduleType != (int)ScheduleRecordingType.Once); dlg.DoModal(dialogId); switch (dlg.SelectedLabel) { case 0: // Skip new Recording { Log.Debug("TVProgramInfo.CreateProgram: Skip new recording"); return; } case 1: // Don't record the already scheduled one(s) { Log.Debug("TVProgramInfo.CreateProgram: Skip old recording(s)"); foreach (Schedule conflict in conflicts) { Program prog = new Program(conflict.IdChannel, conflict.StartTime, conflict.EndTime, conflict.ProgramName, "-", "-", Program.ProgramState.None, DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1, string.Empty, -1); CancelProgram(prog, Schedule.Retrieve(conflict.IdSchedule), dialogId); } break; } case 2: // keep conflict { Log.Debug("TVProgramInfo.CreateProgram: Keep Conflict"); break; } case 3: // Skip for conflicting episodes { Log.Debug("TVProgramInfo.CreateProgram: Skip conflicting episode(s)"); skipConflictingEpisodes = true; break; } default: // Skipping new Recording { Log.Debug("TVProgramInfo.CreateProgram: Default => Skip new recording"); return; } } } } if (saveSchedule != null) { Log.Debug("TVProgramInfo.CreateProgram - UnCancleSerie at {0}", program.StartTime); saveSchedule.UnCancelSerie(program.StartTime, program.IdChannel); //saveSchedule.UnCancelSerie(); saveSchedule.Persist(); currentSchedule = saveSchedule; } else { Log.Debug("TVProgramInfo.CreateProgram - create schedule = {0}", schedule.ToString()); schedule.Persist(); if (currentSchedule == null || (currentSchedule.ScheduleType > 0 && schedule.ScheduleType != (int)ScheduleRecordingType.Once)) { currentSchedule = schedule; } } if (skipConflictingEpisodes) { List<Schedule> episodes = layer.GetRecordingTimes(schedule); foreach (Schedule episode in episodes) { if (DateTime.Now > episode.EndTime) { continue; } if (episode.IsSerieIsCanceled(episode.StartTime, program.IdChannel)) { continue; } foreach (Schedule conflict in conflicts) { if (episode.IsOverlapping(conflict)) { Log.Debug("TVProgramInfo.CreateProgram - skip episode = {0}", episode.ToString()); CanceledSchedule canceledSchedule = new CanceledSchedule(schedule.IdSchedule, program.IdChannel, episode.StartTime); canceledSchedule.Persist(); } } } } server.OnNewSchedule(); }
private static void ResetCurrentScheduleAndProgram() { currentProgram = initialProgram; currentSchedule = null; }
// Add schedules for importing from xml public Schedule AddSchedule(int idChannel, string programName, DateTime startTime, DateTime endTime, int scheduleType) { Schedule schedule = GetSchedule(idChannel, programName, startTime, endTime, scheduleType); if (schedule != null) { return schedule; } Schedule newSchedule = new Schedule(idChannel, programName, startTime, endTime); return newSchedule; }
public List<Schedule> GetRecordingTimes(Schedule rec) { return GetRecordingTimes(rec, 10); }
public List<Schedule> GetConflictingSchedules(Schedule rec) { Log.Info("GetConflictingSchedules: Schedule = " + rec); List<Schedule> conflicts = new List<Schedule>(); IList<Schedule> schedulesList = Schedule.ListAll(); IList<Card> cards = Card.ListAll(); if (cards.Count == 0) { return conflicts; } Log.Info("GetConflictingSchedules: Cards.Count = {0}", cards.Count); List<Schedule>[] cardSchedules = new List<Schedule>[cards.Count]; for (int i = 0; i < cards.Count; i++) { cardSchedules[i] = new List<Schedule>(); } // GEMX: Assign all already scheduled timers to cards. Assume that even possibly overlapping schedulues are ok to the user, // as he decided to keep them before. That's why they are in the db foreach (Schedule schedule in schedulesList) { List<Schedule> episodes = GetRecordingTimes(schedule); foreach (Schedule episode in episodes) { if (DateTime.Now > episode.EndTime) { continue; } if (episode.IsSerieIsCanceled(episode.StartTime)) { continue; } List<Schedule> overlapping; AssignSchedulesToCard(episode, cardSchedules, out overlapping); } } List<Schedule> newEpisodes = GetRecordingTimes(rec); foreach (Schedule newEpisode in newEpisodes) { if (DateTime.Now > newEpisode.EndTime) { continue; } if (newEpisode.IsSerieIsCanceled(newEpisode.StartTime)) { continue; } List<Schedule> overlapping; if (!AssignSchedulesToCard(newEpisode, cardSchedules, out overlapping)) { Log.Info("GetConflictingSchedules: newEpisode can not be assigned to a card = " + newEpisode); conflicts.AddRange(overlapping); } } return conflicts; }
private static bool AssignSchedulesToCard(Schedule schedule, List<Schedule>[] cardSchedules, out List<Schedule> overlappingSchedules) { overlappingSchedules = new List<Schedule>(); Log.Info("AssignSchedulesToCard: schedule = " + schedule); IList<Card> cards = Card.ListAll(); bool assigned = false; int count = 0; foreach (Card card in cards) { if (card.Enabled && card.canViewTvChannel(schedule.IdChannel)) { // checks if any schedule assigned to this cards overlaps current parsed schedule bool free = true; foreach (Schedule assignedSchedule in cardSchedules[count]) { Log.Info("AssignSchedulesToCard: card {0}, ID = {1} has schedule = " + assignedSchedule, count, card.IdCard); bool hasOverlappingSchedule = schedule.IsOverlapping(assignedSchedule); if (hasOverlappingSchedule) { bool isSameTransponder = (schedule.isSameTransponder(assignedSchedule) && card.supportSubChannels); if (!isSameTransponder) { overlappingSchedules.Add(assignedSchedule); Log.Info("AssignSchedulesToCard: overlapping with " + assignedSchedule + " on card {0}, ID = {1}", count, card.IdCard); free = false; break; } } } if (free) { Log.Info("AssignSchedulesToCard: free on card {0}, ID = {1}", count, card.IdCard); cardSchedules[count].Add(schedule); assigned = true; break; } } count++; } if (!assigned) { return false; } return true; }
private static string GetRecordingDateTime(Schedule rec) { return String.Format("{0} {1} - {2}", Utils.GetShortDayString(rec.StartTime), rec.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), rec.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); }
public List<Schedule> GetRecordingTimes(Schedule rec, int days) { TvBusinessLayer layer = new TvBusinessLayer(); List<Schedule> recordings = new List<Schedule>(); DateTime dtDay = DateTime.Now; if (rec.ScheduleType == (int)ScheduleRecordingType.Once) { recordings.Add(rec); return recordings; } if (rec.ScheduleType == (int)ScheduleRecordingType.Daily) { for (int i = 0; i < days; ++i) { Schedule recNew = rec.Clone(); recNew.ScheduleType = (int)ScheduleRecordingType.Once; recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute, 0); if (rec.EndTime.Day > rec.StartTime.Day) { dtDay = dtDay.AddDays(1); } recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0); if (rec.EndTime.Day > rec.StartTime.Day) { dtDay = dtDay.AddDays(-1); } recNew.Series = true; if (recNew.StartTime >= DateTime.Now) { if (rec.IsSerieIsCanceled(recNew.StartTime)) { recNew.Canceled = recNew.StartTime; } recordings.Add(recNew); } dtDay = dtDay.AddDays(1); } return recordings; } if (rec.ScheduleType == (int)ScheduleRecordingType.WorkingDays) { for (int i = 0; i < days; ++i) { if (WeekEndTool.IsWorkingDay(dtDay.DayOfWeek)) { Schedule recNew = rec.Clone(); recNew.ScheduleType = (int)ScheduleRecordingType.Once; recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute, 0); if (rec.EndTime.Day > rec.StartTime.Day) { dtDay = dtDay.AddDays(1); } recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0); if (rec.EndTime.Day > rec.StartTime.Day) { dtDay = dtDay.AddDays(-1); } recNew.Series = true; if (rec.IsSerieIsCanceled(recNew.StartTime)) { recNew.Canceled = recNew.StartTime; } if (recNew.StartTime >= DateTime.Now) { recordings.Add(recNew); } } dtDay = dtDay.AddDays(1); } return recordings; } if (rec.ScheduleType == (int)ScheduleRecordingType.Weekends) { IList<Program> progList = layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, rec.ReferencedChannel()); foreach (Program prog in progList) { if ((rec.IsRecordingProgram(prog, false)) && (WeekEndTool.IsWeekend(prog.StartTime.DayOfWeek))) { Schedule recNew = rec.Clone(); recNew.ScheduleType = (int)ScheduleRecordingType.Once; recNew.StartTime = prog.StartTime; recNew.EndTime = prog.EndTime; recNew.Series = true; if (rec.IsSerieIsCanceled(recNew.StartTime)) { recNew.Canceled = recNew.StartTime; } recordings.Add(recNew); } } return recordings; } if (rec.ScheduleType == (int)ScheduleRecordingType.Weekly) { for (int i = 0; i < days; ++i) { if ((dtDay.DayOfWeek == rec.StartTime.DayOfWeek) && (dtDay.Date >= rec.StartTime.Date)) { Schedule recNew = rec.Clone(); recNew.ScheduleType = (int)ScheduleRecordingType.Once; recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.StartTime.Hour, rec.StartTime.Minute, 0); if (rec.EndTime.Day > rec.StartTime.Day) { dtDay = dtDay.AddDays(1); } recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, rec.EndTime.Hour, rec.EndTime.Minute, 0); if (rec.EndTime.Day > rec.StartTime.Day) { dtDay = dtDay.AddDays(-1); } recNew.Series = true; if (rec.IsSerieIsCanceled(recNew.StartTime)) { recNew.Canceled = recNew.StartTime; } if (recNew.StartTime >= DateTime.Now) { recordings.Add(recNew); } } dtDay = dtDay.AddDays(1); } return recordings; } IList<Program> programs; if (rec.ScheduleType == (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel) { //Log.Debug("get {0} {1} EveryTimeOnThisChannel", rec.ProgramName, rec.ReferencedChannel().Name); programs = layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, rec.ReferencedChannel()); foreach (Program prog in programs) { // dtDay.DayOfWeek == rec.StartTime.DayOfWeek // Log.Debug("BusinessLayer.cs Program prog in programs WeeklyEveryTimeOnThisChannel: {0} {1} prog.StartTime.DayOfWeek == rec.StartTime.DayOfWeek {2} == {3}", rec.ProgramName, rec.ReferencedChannel().Name, prog.StartTime.DayOfWeek, rec.StartTime.DayOfWeek); if (prog.StartTime.DayOfWeek == rec.StartTime.DayOfWeek && rec.IsRecordingProgram(prog, false)) { Schedule recNew = rec.Clone(); recNew.ScheduleType = (int)ScheduleRecordingType.Once; recNew.IdChannel = prog.IdChannel; recNew.StartTime = prog.StartTime; recNew.EndTime = prog.EndTime; recNew.Series = true; if (rec.IsSerieIsCanceled(recNew.StartTime)) { recNew.Canceled = recNew.StartTime; } recordings.Add(recNew); //Log.Debug("BusinessLayer.cs Added Recording WeeklyEveryTimeOnThisChannel: {0} {1} prog.StartTime.DayOfWeek == rec.StartTime.DayOfWeek {2} == {3}", rec.ProgramName, rec.ReferencedChannel().Name, prog.StartTime.DayOfWeek, rec.StartTime.DayOfWeek); } } return recordings; } programs = rec.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnThisChannel ? layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, rec.ReferencedChannel()) : layer.SearchMinimalPrograms(dtDay, dtDay.AddDays(days), rec.ProgramName, null); foreach (Program prog in programs) { if (rec.IsRecordingProgram(prog, false)) { Schedule recNew = rec.Clone(); recNew.ScheduleType = (int)ScheduleRecordingType.Once; recNew.IdChannel = prog.IdChannel; recNew.StartTime = prog.StartTime; recNew.EndTime = prog.EndTime; recNew.Series = true; if (rec.IsSerieIsCanceled(rec.GetSchedStartTimeForProg(prog), prog.IdChannel)) { recNew.Canceled = recNew.StartTime; } recordings.Add(recNew); } } return recordings; }
private static bool StopRecAndDeleteEntireSchedule(Schedule schedule, Schedule parentSchedule, DateTime canceledStartTime) { int idChannel = schedule.IdChannel; CancelEpisode(canceledStartTime, parentSchedule, idChannel); TvServer server = new TvServer(); bool wasRecStopped = StopRecording(schedule); bool wasDeleted = DeleteEntireOrOnceSchedule(schedule, parentSchedule); server.OnNewSchedule(); return wasRecStopped || wasDeleted; }
private static void CancelProgram(Program program, Schedule schedule, int dialogId) { Log.Debug("TVProgammInfo.CancelProgram - programm = {0}", program.ToString()); Log.Debug(" - schedule = {0}", schedule.ToString()); Log.Debug(" ProgramID = {0} ScheduleID = {1}", program.IdProgram, schedule.IdSchedule); bool deleteEntireSched = false; if (schedule.ScheduleType == (int)ScheduleRecordingType.Once) { TVUtil.DeleteRecAndSchedWithPrompt(schedule, program.IdChannel); ResetCurrentScheduleAndProgram(schedule); return; } if ((schedule.ScheduleType == (int)ScheduleRecordingType.Daily) || (schedule.ScheduleType == (int)ScheduleRecordingType.Weekends) || (schedule.ScheduleType == (int)ScheduleRecordingType.Weekly) || (schedule.ScheduleType == (int)ScheduleRecordingType.WorkingDays) || (schedule.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnEveryChannel) || (schedule.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnThisChannel) || (schedule.ScheduleType == (int) ScheduleRecordingType.WeeklyEveryTimeOnThisChannel)) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { Log.Error("TVProgramInfo.CancelProgram: ERROR no GUIDialogMenu found !!!!!!!!!!"); return; } dlg.Reset(); dlg.SetHeading(TVUtil.GetDisplayTitle(program)); if (anyUpcomingEpisodesRecording) { dlg.AddLocalizedString(981); //Cancel this show } dlg.AddLocalizedString(982); //Delete this entire schedule dlg.DoModal(dialogId); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedId) { case 981: //delete specific series break; case 982: //Delete entire recording deleteEntireSched = true; break; } if (deleteEntireSched) { TVUtil.DeleteRecAndEntireSchedWithPrompt(schedule, program.StartTime); ResetCurrentScheduleAndProgram(schedule); } else { TVUtil.DeleteRecAndSchedWithPrompt(schedule, program); } } }
private static bool DeleteEntireOrOnceSchedule(Schedule schedule, Schedule parentSchedule) { //is the schedule recording, then stop it now. bool wasDeleted = false; try { bool isRec = TvDatabase.Schedule.IsScheduleRecording(schedule.IdSchedule); bool isOnce = IsScheduleTypeOnce(parentSchedule.IdSchedule); if (parentSchedule != null) { wasDeleted = DeleteSchedule(parentSchedule.IdSchedule); } if (schedule != null) { wasDeleted = DeleteSchedule(schedule.IdSchedule); } } catch (Exception) { //consume ex } return wasDeleted; }
private static void ResetCurrentScheduleAndProgram(Schedule schedule) { if ( currentSchedule == null || ( currentSchedule != null && (currentSchedule.ScheduleType == 0 || (currentSchedule.ScheduleType > 0 && schedule.ScheduleType > 0)) )) { ResetCurrentScheduleAndProgram(); } }
private static bool CancelEpisode(DateTime cancelStartTime, Schedule scheduleToCancel, int idChannel) { bool episodeCanceled = false; if (scheduleToCancel != null) { //create the canceled schedule to prevent the schedule from restarting again. // we only create cancelled recordings on series type schedules Schedule sched2cancel = Schedule.Retrieve(scheduleToCancel.IdSchedule); bool isOnce = IsScheduleTypeOnce(scheduleToCancel.IdSchedule); if (!isOnce) { DateTime cancel = cancelStartTime; int IdForScheduleToCancel = scheduleToCancel.IdSchedule; CanceledSchedule canceledSchedule = new CanceledSchedule(IdForScheduleToCancel, idChannel, cancel); canceledSchedule.Persist(); episodeCanceled = true; } } return episodeCanceled; }
private void OnKeep() { Schedule rec = currentSchedule; if (currentSchedule == null && !IsRecordingProgram(CurrentProgram, out rec, false)) { return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(1042); dlg.AddLocalizedString(1043); //Until watched dlg.AddLocalizedString(1044); //Until space needed dlg.AddLocalizedString(1045); //Until date dlg.AddLocalizedString(1046); //Always switch (rec.KeepMethod) { case (int)KeepMethodType.UntilWatched: dlg.SelectedLabel = 0; break; case (int)KeepMethodType.UntilSpaceNeeded: dlg.SelectedLabel = 1; break; case (int)KeepMethodType.TillDate: dlg.SelectedLabel = 2; break; case (int)KeepMethodType.Always: dlg.SelectedLabel = 3; break; } dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedId) { case 1043: rec.KeepMethod = (int)KeepMethodType.UntilWatched; break; case 1044: rec.KeepMethod = (int)KeepMethodType.UntilSpaceNeeded; break; case 1045: rec.KeepMethod = (int)KeepMethodType.TillDate; dlg.Reset(); dlg.ShowQuickNumbers = false; dlg.SetHeading(1045); for (int iDay = 1; iDay <= 100; iDay++) { DateTime dt = CurrentProgram.StartTime.AddDays(iDay); dlg.Add(dt.ToLongDateString()); } TimeSpan ts = (rec.KeepDate - CurrentProgram.StartTime); int days = (int)ts.TotalDays; if (days >= 100) { days = 30; } dlg.SelectedLabel = days - 1; dlg.DoModal(GetID); if (dlg.SelectedLabel < 0) { return; } rec.KeepDate = CurrentProgram.StartTime.AddDays(dlg.SelectedLabel + 1); break; case 1046: rec.KeepMethod = (int)KeepMethodType.Always; break; } rec.Persist(); currentSchedule = rec; TvServer server = new TvServer(); server.OnNewSchedule(); }
private static void GetParentAndSpawnSchedule(ref Schedule schedule, out Schedule parentSchedule) { parentSchedule = schedule.ReferencedSchedule(); if (parentSchedule == null) { parentSchedule = schedule; Schedule spawn = Schedule.RetrieveSpawnedSchedule(parentSchedule.IdSchedule, parentSchedule.StartTime); if (spawn != null) { schedule = spawn; } } }
public static bool IsRecordingProgram(Program program, out Schedule recordingSchedule, bool filterCanceledRecordings) { recordingSchedule = null; IList<Schedule> schedules = Schedule.ListAll(); foreach (Schedule schedule in schedules) { if (schedule.Canceled != Schedule.MinSchedule || (filterCanceledRecordings && schedule.IsSerieIsCanceled(schedule.GetSchedStartTimeForProg(program), program.IdChannel))) { continue; } if (schedule.IsManual && schedule.IdChannel == program.IdChannel && schedule.EndTime >= program.EndTime) { Schedule manual = schedule.Clone(); manual.ProgramName = TVUtil.GetDisplayTitle(program); manual.EndTime = program.EndTime; manual.StartTime = program.StartTime; if (manual.IsRecordingProgram(program, filterCanceledRecordings)) { recordingSchedule = schedule; return true; } } else if (schedule.IsRecordingProgram(program, filterCanceledRecordings)) { recordingSchedule = schedule; return true; } } return false; }
private static bool IsValidSchedule(Schedule schedule) { if (schedule == null) { return false; } int scheduleId = schedule.IdSchedule; if (scheduleId < 1) { return false; } return true; }
private void OnSetQuality() { Schedule rec = currentSchedule; if (currentSchedule == null && !IsRecordingProgram(CurrentProgram, out rec, false)) { return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(882); dlg.ShowQuickNumbers = true; dlg.AddLocalizedString(968); dlg.AddLocalizedString(965); dlg.AddLocalizedString(966); dlg.AddLocalizedString(967); VIDEOENCODER_BITRATE_MODE _newBitRate = rec.BitRateMode; switch (_newBitRate) { case VIDEOENCODER_BITRATE_MODE.NotSet: dlg.SelectedLabel = 0; break; case VIDEOENCODER_BITRATE_MODE.ConstantBitRate: dlg.SelectedLabel = 1; break; case VIDEOENCODER_BITRATE_MODE.VariableBitRateAverage: dlg.SelectedLabel = 2; break; case VIDEOENCODER_BITRATE_MODE.VariableBitRatePeak: dlg.SelectedLabel = 3; break; } dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedLabel) { case 0: // Not Set _newBitRate = VIDEOENCODER_BITRATE_MODE.NotSet; break; case 1: // CBR _newBitRate = VIDEOENCODER_BITRATE_MODE.ConstantBitRate; break; case 2: // VBR _newBitRate = VIDEOENCODER_BITRATE_MODE.VariableBitRateAverage; break; case 3: // VBR Peak _newBitRate = VIDEOENCODER_BITRATE_MODE.VariableBitRatePeak; break; } rec.BitRateMode = _newBitRate; rec.Persist(); currentSchedule = rec; dlg.Reset(); dlg.SetHeading(882); dlg.ShowQuickNumbers = true; dlg.AddLocalizedString(968); // NotSet dlg.AddLocalizedString(886); //Default dlg.AddLocalizedString(993); // Custom dlg.AddLocalizedString(893); //Portable dlg.AddLocalizedString(883); //Low dlg.AddLocalizedString(884); //Medium dlg.AddLocalizedString(885); //High QualityType _newQuality = rec.QualityType; switch (_newQuality) { case QualityType.NotSet: dlg.SelectedLabel = 0; break; case QualityType.Default: dlg.SelectedLabel = 1; break; case QualityType.Custom: dlg.SelectedLabel = 2; break; case QualityType.Portable: dlg.SelectedLabel = 3; break; case QualityType.Low: dlg.SelectedLabel = 4; break; case QualityType.Medium: dlg.SelectedLabel = 5; break; case QualityType.High: dlg.SelectedLabel = 6; break; } dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedLabel) { case 0: // Default _newQuality = QualityType.Default; break; case 1: // Custom _newQuality = QualityType.Custom; break; case 2: // Protable _newQuality = QualityType.Portable; break; case 3: // Low _newQuality = QualityType.Low; break; case 4: // Medium _newQuality = QualityType.Medium; break; case 5: // High _newQuality = QualityType.High; break; } rec.QualityType = _newQuality; rec.Persist(); currentSchedule = rec; } Update(); }
private static bool StopRecording(Schedule schedule) { bool stoppedRec = false; bool isRec = TvDatabase.Schedule.IsScheduleRecording(schedule.IdSchedule); if (isRec) { TvServer server = new TvServer(); server.StopRecordingSchedule(schedule.IdSchedule); stoppedRec = true; } return stoppedRec; }