Beispiel #1
0
        private IMBotMessage DoShowChannelsCommand(IMBotConversation conversation, IList <string> arguments)
        {
            if (arguments.Count == 0)
            {
                return(new IMBotMessage("Group name or number missing.", IMBotMessage.ErrorColor));
            }

            using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
            {
                List <ChannelGroup> groups = GetAllGroups(tvSchedulerAgent, GetChannelType(conversation));

                ChannelGroup group = null;

                int index;
                if (int.TryParse(arguments[0], out index))
                {
                    if (index < 1 || index > groups.Count)
                    {
                        return(new IMBotMessage("Unknown group number.", IMBotMessage.ErrorColor));
                    }
                    group = groups[index - 1];
                }
                else
                {
                    foreach (ChannelGroup channelGroup in groups)
                    {
                        if (channelGroup.GroupName.Equals(arguments[0], StringComparison.CurrentCultureIgnoreCase))
                        {
                            group = channelGroup;
                            break;
                        }
                    }
                    if (group == null)
                    {
                        return(new IMBotMessage("Unknown group name.", IMBotMessage.ErrorColor));
                    }
                }

                Channel[] channels = tvSchedulerAgent.GetChannelsInGroup(group.ChannelGroupId, true);

                StringBuilder replyText = new StringBuilder();
                replyText.AppendFormat("Channels in {0}:", group.GroupName);

                foreach (Channel channel in channels)
                {
                    replyText.AppendLine();
                    replyText.AppendFormat("{0,3} {1}",
                                           channel.LogicalChannelNumber.HasValue ? channel.LogicalChannelNumber.Value.ToString() : "-",
                                           channel.DisplayName);
                }

                return(new IMBotMessage(replyText.ToString(), true)
                {
                    Footer = "Use 'show guide <number | name> [day-number]' to see the channel guide."
                });
            }
        }
Beispiel #2
0
 private void RefreshChannelsInGroup(SchedulerServiceAgent tvSchedulerAgent, ChannelType channelType)
 {
     try
     {
         if (_currentChannelGroup != null)
         {
             _navigatorChannels[channelType].Channels = new List <Channel>(
                 tvSchedulerAgent.GetChannelsInGroup(_currentChannelGroup.ChannelGroupId, true));
         }
         else
         {
             _navigatorChannels[channelType].Channels = new List <Channel>();
         }
         _navigatorChannels[channelType].ChannelsByNumber.Clear();
         _navigatorChannels[channelType].GroupsByChannelNumber.Clear();
     }
     catch (Exception ex)
     {
         Log.Error("ChannelNavigator: Error in RefreshChannelsInGroup - {0}", ex.Message);
     }
 }
 private void RefreshChannelsInGroup(SchedulerServiceAgent tvSchedulerAgent, ChannelType channelType)
 {
     try
     {
         if (_currentChannelGroup != null)
         {
             _navigatorChannels[channelType].Channels = new List<Channel>(
                 tvSchedulerAgent.GetChannelsInGroup(_currentChannelGroup.ChannelGroupId, true));
         }
         else
         {
             _navigatorChannels[channelType].Channels = new List<Channel>();
         }
         _navigatorChannels[channelType].ChannelsByNumber.Clear();
         _navigatorChannels[channelType].GroupsByChannelNumber.Clear();
     }
     catch (Exception ex)
     {
         Log.Error("ChannelNavigator: Error in RefreshChannelsInGroup - {0}", ex.Message);
     }
 }
 private Channel FindChannelInGroupByNumber(SchedulerServiceAgent tvSchedulerAgent, Guid channelGroupId, int channelNr)
 {
     return FindChannelByNumber(new List<Channel>(tvSchedulerAgent.GetChannelsInGroup(channelGroupId, true)), channelNr);
 }
Beispiel #5
0
        private IMBotMessage DoShowChannelsCommand(IMBotConversation conversation, IList<string> arguments)
        {
            if (arguments.Count == 0)
            {
                return new IMBotMessage("Group name or number missing.", IMBotMessage.ErrorColor);
            }

            using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
            {
                List<ChannelGroup> groups = GetAllGroups(tvSchedulerAgent, GetChannelType(conversation));

                ChannelGroup group = null;

                int index;
                if (int.TryParse(arguments[0], out index))
                {
                    if (index < 1 || index > groups.Count)
                    {
                        return new IMBotMessage("Unknown group number.", IMBotMessage.ErrorColor);
                    }
                    group = groups[index - 1];
                }
                else
                {
                    foreach (ChannelGroup channelGroup in groups)
                    {
                        if (channelGroup.GroupName.Equals(arguments[0], StringComparison.CurrentCultureIgnoreCase))
                        {
                            group = channelGroup;
                            break;
                        }
                    }
                    if (group == null)
                    {
                        return new IMBotMessage("Unknown group name.", IMBotMessage.ErrorColor);
                    }
                }

                Channel[] channels = tvSchedulerAgent.GetChannelsInGroup(group.ChannelGroupId, true);

                StringBuilder replyText = new StringBuilder();
                replyText.AppendFormat("Channels in {0}:", group.GroupName);

                foreach (Channel channel in channels)
                {
                    replyText.AppendLine();
                    replyText.AppendFormat("{0,3} {1}",
                        channel.LogicalChannelNumber.HasValue ? channel.LogicalChannelNumber.Value.ToString() : "-",
                        channel.DisplayName);
                }

                return new IMBotMessage(replyText.ToString(), true)
                {
                    Footer = "Use 'show guide <number | name> [day-number]' to see the channel guide."
                };
            }
        }
Beispiel #6
0
        private void GetChannels(bool refresh)
        {
            if (refresh || _channelList == null)
            {
                _channelList = new List<GuideBaseChannel>();
            }

            if (_channelList.Count == 0)
            {
                try
                {
                    using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
                    {
                        foreach (Channel chan in tvSchedulerAgent.GetChannelsInGroup(_model.CurrentChannelGroupId, true))
                        {
                            GuideBaseChannel tvGuidChannel = new GuideBaseChannel();
                            tvGuidChannel.channel = chan;

                            if (tvGuidChannel.channel.VisibleInGuide && tvGuidChannel.channel.ChannelType == _channelType)
                            {
                                if (_showChannelNumber)
                                {
                                    if (_byIndex)
                                    {
                                        tvGuidChannel.channelNum = _channelList.Count + 1;
                                    }
                                    else if (chan.LogicalChannelNumber.HasValue)
                                    {
                                        tvGuidChannel.channelNum = chan.LogicalChannelNumber.Value;
                                    }
                                }
                                tvGuidChannel.strLogo = GetChannelLogo(tvGuidChannel.channel);
                                _channelList.Add(tvGuidChannel);
                            }
                        }
                    }
                }
                catch { }

                if (_channelList.Count == 0)
                {
                    GuideBaseChannel tvGuidChannel = new GuideBaseChannel()
                    {
                        channel = new Channel()
                        {
                            DisplayName = Utility.GetLocalizedText(TextId.NoChannels),
                            VisibleInGuide = true
                        }
                    };
                    for (int i = 0; i < 10; ++i)
                    {
                        _channelList.Add(tvGuidChannel);
                    }
                }
            }
        }
Beispiel #7
0
 private Channel FindChannelInGroupByNumber(SchedulerServiceAgent tvSchedulerAgent, Guid channelGroupId, int channelNr)
 {
     return(FindChannelByNumber(new List <Channel>(tvSchedulerAgent.GetChannelsInGroup(channelGroupId, true)), channelNr));
 }