GetTVGuideChannelsForGroup() public method

Gets a list of tv channels sorted by their group
public GetTVGuideChannelsForGroup ( int groupID ) : List
groupID int
return List
示例#1
0
    private List<Channel> GetChannelListByGroup()
    {
      int idGroup = TVHome.Navigator.CurrentGroup.IdGroup;

      if (_tvGroupChannelListCache == null)
      {
        _tvGroupChannelListCache = new Dictionary<int, List<Channel>>();
      }

      List<Channel> channels = null;
      if (_tvGroupChannelListCache.TryGetValue(idGroup, out channels))  //already in cache ? then return it.      
      {
        Log.Debug("TvMiniGuide: GetChannelListByGroup returning cached version of channels.");
        return channels;
      }
      else //not in cache, fetch it and update cache, then return.
      {
        TvBusinessLayer layer = new TvBusinessLayer();
        List<Channel> tvChannelList = layer.GetTVGuideChannelsForGroup(idGroup);

        if (tvChannelList != null)
        {
          Log.Debug("TvMiniGuide: GetChannelListByGroup caching channels from DB.");
          _tvGroupChannelListCache.Add(idGroup, tvChannelList);
          return tvChannelList;
        }
      }
      return new List<Channel>();
    }
    private void UpdateChannelStatesForUsers()
    {
      TvBusinessLayer layer = new TvBusinessLayer();

      //System.Diagnostics.Debugger.Launch();
      // this section makes sure that all users are updated in regards to channel states.      
      ChannelStates channelStates = new ChannelStates(layer, this);

      if (channelStates != null)
      {
        IList<ChannelGroup> groups = ChannelGroup.ListAll();

        // populating _tvChannelListGroups is only done once as is therefor cached.
        if (_tvChannelListGroups == null)
        {
          foreach (ChannelGroup group in groups)
          {
            // we will only update user created groups, since it will often have fewer channels than "all channels"
            // going into "all channels" group in mini EPG will always be slower.
            if (group.GroupName.Equals(TvConstants.TvGroupNames.AllChannels))
              continue;

            if (_tvChannelListGroups == null)
            {
              _tvChannelListGroups = layer.GetTVGuideChannelsForGroup(group.IdGroup);
            }
            else
            {
              IList<Channel> tvChannelList = layer.GetTVGuideChannelsForGroup(group.IdGroup);

              foreach (Channel ch in tvChannelList)
              {
                bool exists = _tvChannelListGroups.Exists(delegate(Channel c) { return c.IdChannel == ch.IdChannel; });
                if (!exists)
                {
                  _tvChannelListGroups.Add(ch);
                }
              }
            }
          }
        }

        channelStates.SetChannelStates(_cards, _tvChannelListGroups, true, this);
      }
    }
示例#3
0
    protected override void GetChannels(bool refresh)
    {
      if (refresh || _channelList == null)
      {
        if (_channelList != null)
        {
          if (_channelList.Count < _channelCount)
          {
            _previousChannelCount = _channelList.Count;
          }
          else
          {
            _previousChannelCount = _channelCount;
          }
        }
        _channelList = new List<GuideChannel>();
      }

      if (_channelList.Count == 0)
      {
        try
        {
          if (TVHome.Navigator.CurrentGroup != null)
          {
            TvBusinessLayer layer = new TvBusinessLayer();
            IList<Channel> channels = layer.GetTVGuideChannelsForGroup(TVHome.Navigator.CurrentGroup.IdGroup);
            foreach (Channel chan in channels)
            {
              GuideChannel tvGuidChannel = new GuideChannel();
              tvGuidChannel.channel = chan;

              if (tvGuidChannel.channel.VisibleInGuide && tvGuidChannel.channel.IsTv)
              {
                if (_showChannelNumber)
                {

                  if (_byIndex)
                  {
                    tvGuidChannel.channelNum = _channelList.Count + 1;
                  }
                  else
                  {
                    tvGuidChannel.channelNum = chan.ChannelNumber;
                  }
                }
                tvGuidChannel.strLogo = GetChannelLogo(tvGuidChannel.channel.DisplayName);
                _channelList.Add(tvGuidChannel);
              }
            }
          }
        }
        catch { }

        if (_channelList.Count == 0)
        {
          GuideChannel tvGuidChannel = new GuideChannel();
          tvGuidChannel.channel = new Channel(false, true, 0, DateTime.MinValue, false,
                                              DateTime.MinValue, 0, true, "", GUILocalizeStrings.Get(911), 10000);
          for (int i = 0; i < 10; ++i)
          {
            _channelList.Add(tvGuidChannel);
          }
        }
      }
    }
    /// <summary>
    /// Fetches all channel states for a specific group
    /// </summary>
    /// <param name="idGroup"></param>    
    /// <param name="user"></param>        
    public Dictionary<int, ChannelState> GetAllChannelStatesForGroup(int idGroup, IUser user)
    {
      if (idGroup < 1)
      {
        return null;
      }

      if (user == null)
      {
        return null;
      }

      TvBusinessLayer layer = new TvBusinessLayer();
      IList<Channel> tvChannelList = layer.GetTVGuideChannelsForGroup(idGroup);

      if (tvChannelList == null || tvChannelList.Count == 0)
        return null;

      Dictionary<int, ChannelState> channelStatesList = new Dictionary<int, ChannelState>();
      ChannelStates channelStates = new ChannelStates(layer, this);

      if (channelStates != null)
      {
        channelStatesList = channelStates.GetChannelStates(_cards, tvChannelList, ref user, true, this);
      }

      return channelStatesList;
    }