private void _refreshStatusBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { if (this.IsConnected) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { RefreshStatusResult result = new RefreshStatusResult(); result.ActiveRecordings = tvControlAgent.GetActiveRecordings(); result.LiveStreams = tvControlAgent.GetLiveStreams(); result.UpcomingRecording = tvControlAgent.GetNextUpcomingRecording(false); e.Result = result; } } }
private void RefreshBotPersonalMessage() { if (_messenger.Owner != null) { string message = "Idle"; PresenceStatus status = PresenceStatus.Online; using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { ActiveRecording[] activeRecordings = tvControlAgent.GetActiveRecordings(); if (activeRecordings.Length > 0) { message = "Recording"; status = PresenceStatus.Busy; } else { LiveStream[] liveStreams = tvControlAgent.GetLiveStreams(); if (liveStreams.Length > 0) { message = "Streaming"; status = PresenceStatus.Away; } else { UpcomingRecording upcomingRecording = tvControlAgent.GetNextUpcomingRecording(false); if (upcomingRecording != null) { message = "Waiting for next scheduled recording"; } } } } if (_messenger.Owner.PersonalMessage == null || _messenger.Owner.PersonalMessage.Message != message) { _messenger.Owner.PersonalMessage = new PersonalMessage(message); } if (_messenger.Owner.Status != status) { _messenger.Owner.Status = status; } } }
private IMBotMessage DoStatusCommand(IMBotConversation conversation, IList<string> arguments) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { bool fixedWidth = false; // Check if currently recording : ActiveRecording[] activeRecordings = tvControlAgent.GetActiveRecordings(); LiveStream[] liveStreams = tvControlAgent.GetLiveStreams(); UpcomingRecording upcomingRecording = tvControlAgent.GetNextUpcomingRecording(false); StringBuilder reply = new StringBuilder(); if (activeRecordings.Length > 0) { reply.Append("Currently recording:"); foreach (ActiveRecording activeRecording in activeRecordings) { PluginService pluginService = null; if (activeRecording.CardChannelAllocation != null) { pluginService = RecorderTunersCache.GetRecorderTunerById(activeRecording.CardChannelAllocation.RecorderTunerId); } reply.AppendLine(); Utility.AppendProgramDetails(reply, activeRecording.Program.Channel, activeRecording.Program); reply.AppendFormat(" [{0}]", pluginService == null ? "-" : pluginService.Name); } fixedWidth = true; if (liveStreams.Length > 0 || upcomingRecording != null) { reply.AppendLine(); } } if (liveStreams.Length > 0) { reply.Append("Currently streaming:"); foreach (LiveStream liveStream in liveStreams) { reply.AppendLine(); reply.AppendFormat("[{0}]", liveStream.Channel.DisplayName); } fixedWidth = true; if (upcomingRecording != null) { reply.AppendLine(); } } if (upcomingRecording != null) { if (reply.Length == 0) { reply.AppendLine("Idle, next scheduled recording:"); } else { reply.AppendLine("Next scheduled recording:"); } PluginService pluginService = null; if (upcomingRecording.CardChannelAllocation != null) { pluginService = RecorderTunersCache.GetRecorderTunerById(upcomingRecording.CardChannelAllocation.RecorderTunerId); } Utility.AppendProgramDetails(reply, upcomingRecording.Program.Channel, upcomingRecording.Program); reply.AppendFormat(" [{0}]", pluginService == null ? "-" : pluginService.Name); fixedWidth = true; } if (reply.Length == 0) { reply.Append("Idle"); } reply.AppendLine().AppendLine(); reply.Append("ARGUS TV Messenger " + Constants.ProductVersion + @", running on server \\").AppendLine(Dns.GetHostName()); reply.Append("http://www.argus-tv.com"); return new IMBotMessage(reply.ToString(), fixedWidth); } }
private void _refreshStatusBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { if (this.IsConnected) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { RefreshStatusResult result = new RefreshStatusResult(); result.ActiveRecordings = tvControlAgent.GetActiveRecordings(); result.LiveStreams = tvControlAgent.GetLiveStreams(); result.UpcomingRecording = tvControlAgent.GetNextUpcomingRecording(false); e.Result = result; } } }
private void RefreshBotPersonalMessage() { if (_messenger.Owner != null) { string message = "Idle"; PresenceStatus status = PresenceStatus.Online; using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { ActiveRecording[] activeRecordings = tvControlAgent.GetActiveRecordings(); if (activeRecordings.Length > 0) { message = "Recording"; status = PresenceStatus.Busy; } else { LiveStream[] liveStreams = tvControlAgent.GetLiveStreams(); if (liveStreams.Length > 0) { message = "Streaming"; status = PresenceStatus.Away; } else { UpcomingRecording upcomingRecording = tvControlAgent.GetNextUpcomingRecording(false); if (upcomingRecording != null) { message = "Waiting for next scheduled recording"; } } } } if (_messenger.Owner.PersonalMessage == null || _messenger.Owner.PersonalMessage.Message != message) { _messenger.Owner.PersonalMessage = new PersonalMessage(message); } if (_messenger.Owner.Status != status) { _messenger.Owner.Status = status; } } }
private IMBotMessage DoStatusCommand(IMBotConversation conversation, IList <string> arguments) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { bool fixedWidth = false; // Check if currently recording : ActiveRecording[] activeRecordings = tvControlAgent.GetActiveRecordings(); LiveStream[] liveStreams = tvControlAgent.GetLiveStreams(); UpcomingRecording upcomingRecording = tvControlAgent.GetNextUpcomingRecording(false); StringBuilder reply = new StringBuilder(); if (activeRecordings.Length > 0) { reply.Append("Currently recording:"); foreach (ActiveRecording activeRecording in activeRecordings) { PluginService pluginService = null; if (activeRecording.CardChannelAllocation != null) { pluginService = RecorderTunersCache.GetRecorderTunerById(activeRecording.CardChannelAllocation.RecorderTunerId); } reply.AppendLine(); Utility.AppendProgramDetails(reply, activeRecording.Program.Channel, activeRecording.Program); reply.AppendFormat(" [{0}]", pluginService == null ? "-" : pluginService.Name); } fixedWidth = true; if (liveStreams.Length > 0 || upcomingRecording != null) { reply.AppendLine(); } } if (liveStreams.Length > 0) { reply.Append("Currently streaming:"); foreach (LiveStream liveStream in liveStreams) { reply.AppendLine(); reply.AppendFormat("[{0}]", liveStream.Channel.DisplayName); } fixedWidth = true; if (upcomingRecording != null) { reply.AppendLine(); } } if (upcomingRecording != null) { if (reply.Length == 0) { reply.AppendLine("Idle, next scheduled recording:"); } else { reply.AppendLine("Next scheduled recording:"); } PluginService pluginService = null; if (upcomingRecording.CardChannelAllocation != null) { pluginService = RecorderTunersCache.GetRecorderTunerById(upcomingRecording.CardChannelAllocation.RecorderTunerId); } Utility.AppendProgramDetails(reply, upcomingRecording.Program.Channel, upcomingRecording.Program); reply.AppendFormat(" [{0}]", pluginService == null ? "-" : pluginService.Name); fixedWidth = true; } if (reply.Length == 0) { reply.Append("Idle"); } reply.AppendLine().AppendLine(); reply.Append("ARGUS TV Messenger " + Constants.ProductVersion + @", running on server \\").AppendLine(Dns.GetHostName()); reply.Append("http://www.argus-tv.com"); return(new IMBotMessage(reply.ToString(), fixedWidth)); } }