private void _refreshProgramsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { RefreshProgramsResult result = null; //DateTime startTime = DateTime.Now; if (this.IsConnected) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { result = new RefreshProgramsResult(); result.AllUpcomingRecordings = tvControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.Recordings, true); result.ActiveRecordings = tvControlAgent.GetActiveRecordings(); result.LiveStreams = tvControlAgent.GetLiveStreams(); result.UpcomingRecordings = new UpcomingOrActiveProgramsList(result.AllUpcomingRecordings); result.UpcomingRecordings.RemoveActiveRecordings(result.ActiveRecordings); } } //Utility.EnsureMinimumTime(startTime, 250); e.Result = result; }
private IMBotMessage DoShowUpcomingCommand(IMBotConversation conversation, ScheduleType type) { if (type == ScheduleType.Recording) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { UpcomingRecording[] upcomingRecordings = tvControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.Recordings, false); StringBuilder replyText = new StringBuilder(); if (upcomingRecordings.Length > 0) { int index = 0; foreach (UpcomingRecording upcomingRecording in upcomingRecordings) { if (replyText.Length > 0) { replyText.AppendLine(); } PluginService pluginService = null; if (upcomingRecording.CardChannelAllocation != null) { pluginService = RecorderTunersCache.GetRecorderTunerById(upcomingRecording.CardChannelAllocation.RecorderTunerId); } replyText.AppendFormat("{0,3}» ", ++index); Utility.AppendProgramDetails(replyText, upcomingRecording.Program.Channel, upcomingRecording.Program); replyText.AppendFormat(" [{0}]", pluginService == null ? "-" : pluginService.Name); } conversation.Session[SessionKey.Programs] = new Session.Programs(upcomingRecordings); return new IMBotMessage(replyText.ToString(), true) { Footer = "Use 'cancel', 'uncancel' or 'delete schedule' with <number>." }; } } } else { using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent()) { UpcomingProgram[] upcomingPrograms = tvSchedulerAgent.GetAllUpcomingPrograms(type, false); StringBuilder replyText = new StringBuilder(); if (upcomingPrograms.Length > 0) { int index = 0; foreach (UpcomingProgram upcomingProgram in upcomingPrograms) { if (replyText.Length > 0) { replyText.AppendLine(); } replyText.AppendFormat("{0,3}» ", ++index); Utility.AppendProgramDetails(replyText, upcomingProgram.Channel, upcomingProgram); } conversation.Session[SessionKey.Programs] = new Session.Programs(upcomingPrograms); return new IMBotMessage(replyText.ToString(), true) { Footer = "Use 'record', 'cancel', 'uncancel' or 'delete schedule' with <number>." }; } } } return new IMBotMessage("There are no upcoming " + type.ToString().ToLowerInvariant() + "s."); }
private void _refreshProgramsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { RefreshProgramsResult result = null; //DateTime startTime = DateTime.Now; if (this.IsConnected) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { result = new RefreshProgramsResult(); result.AllUpcomingRecordings = tvControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.Recordings, true); result.ActiveRecordings = tvControlAgent.GetActiveRecordings(); result.LiveStreams = tvControlAgent.GetLiveStreams(); result.UpcomingRecordings = new UpcomingOrActiveProgramsList(result.AllUpcomingRecordings); result.UpcomingRecordings.RemoveActiveRecordings(result.ActiveRecordings); } } //Utility.EnsureMinimumTime(startTime, 250); e.Result = result; }
internal static bool HasUpcomingRecording(Guid channelId, GuideProgram program, out UpcomingRecording upcomingRecording) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { upcomingRecording = null; Guid upcomingProgramId = program.GetUniqueUpcomingProgramId(channelId); UpcomingRecording[] upcomingRecordings = tvControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.All, true); foreach (UpcomingRecording recording in upcomingRecordings) { if (recording.Program.UpcomingProgramId == upcomingProgramId) { upcomingRecording = recording; return true; } } return false; } }
private IMBotMessage DoShowUpcomingCommand(IMBotConversation conversation, ScheduleType type) { if (type == ScheduleType.Recording) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { UpcomingRecording[] upcomingRecordings = tvControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.Recordings, false); StringBuilder replyText = new StringBuilder(); if (upcomingRecordings.Length > 0) { int index = 0; foreach (UpcomingRecording upcomingRecording in upcomingRecordings) { if (replyText.Length > 0) { replyText.AppendLine(); } PluginService pluginService = null; if (upcomingRecording.CardChannelAllocation != null) { pluginService = RecorderTunersCache.GetRecorderTunerById(upcomingRecording.CardChannelAllocation.RecorderTunerId); } replyText.AppendFormat("{0,3}» ", ++index); Utility.AppendProgramDetails(replyText, upcomingRecording.Program.Channel, upcomingRecording.Program); replyText.AppendFormat(" [{0}]", pluginService == null ? "-" : pluginService.Name); } conversation.Session[SessionKey.Programs] = new Session.Programs(upcomingRecordings); return(new IMBotMessage(replyText.ToString(), true) { Footer = "Use 'cancel', 'uncancel' or 'delete schedule' with <number>." }); } } } else { using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent()) { UpcomingProgram[] upcomingPrograms = tvSchedulerAgent.GetAllUpcomingPrograms(type, false); StringBuilder replyText = new StringBuilder(); if (upcomingPrograms.Length > 0) { int index = 0; foreach (UpcomingProgram upcomingProgram in upcomingPrograms) { if (replyText.Length > 0) { replyText.AppendLine(); } replyText.AppendFormat("{0,3}» ", ++index); Utility.AppendProgramDetails(replyText, upcomingProgram.Channel, upcomingProgram); } conversation.Session[SessionKey.Programs] = new Session.Programs(upcomingPrograms); return(new IMBotMessage(replyText.ToString(), true) { Footer = "Use 'record', 'cancel', 'uncancel' or 'delete schedule' with <number>." }); } } } return(new IMBotMessage("There are no upcoming " + type.ToString().ToLowerInvariant() + "s.")); }