Esempio n. 1
0
 public WebCount GetChannelCount(int groupId)
 {
     return(new WebCount()
     {
         Count = _tvBusiness.GetTVGuideChannelsForGroup(groupId).Count
     });
 }
Esempio n. 2
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>());
        }
Esempio n. 3
0
 public override bool GetProgramsGroup(IChannelGroup channelGroup, DateTime from, DateTime to, out IList <IProgram> programs)
 {
     programs = new List <IProgram>();
     if (channelGroup.ChannelGroupId < 0)
     {
         foreach (var channel in _tvBusiness.GetRadioGuideChannelsForGroup(-channelGroup.ChannelGroupId))
         {
             CollectionUtils.AddAll(programs, _tvBusiness.GetPrograms(TvDatabase.Channel.Retrieve(channel.IdChannel), from, to).Select(p => p.ToProgram()));
         }
     }
     else
     {
         foreach (var channel in _tvBusiness.GetTVGuideChannelsForGroup(channelGroup.ChannelGroupId))
         {
             CollectionUtils.AddAll(programs, _tvBusiness.GetPrograms(TvDatabase.Channel.Retrieve(channel.IdChannel), from, to).Select(p => p.ToProgram()));
         }
     }
     return(programs.Count > 0);
 }
Esempio n. 4
0
        public bool GetProgramsGroup(IChannelGroup channelGroup, DateTime from, DateTime to, out IList <IProgram> programs)
        {
#if TVE3
            programs = new List <IProgram>();
            foreach (var channel in _tvBusiness.GetTVGuideChannelsForGroup(channelGroup.ChannelGroupId))
            {
                CollectionUtils.AddAll(programs, _tvBusiness.GetPrograms(TvDatabase.Channel.Retrieve(channel.IdChannel), from, to).Select(p => p.ToProgram()));
            }
#else
            IProgramService      programService      = GlobalServiceProvider.Instance.Get <IProgramService>();
            IChannelGroupService channelGroupService = GlobalServiceProvider.Instance.Get <IChannelGroupService>();

            var channels = channelGroupService.GetChannelGroup(channelGroup.ChannelGroupId).GroupMaps.Select(groupMap => groupMap.Channel);
            IDictionary <int, IList <Program> > programEntities = programService.GetProgramsForAllChannels(from, to, channels);

            programs = programEntities.Values.SelectMany(x => x).Select(p => p.ToProgram()).Distinct(ProgramComparer.Instance).ToList();
#endif
            return(programs.Count > 0);
        }
Esempio n. 5
0
        public override async Task <AsyncResult <IList <IProgram> > > GetProgramsGroupAsync(IChannelGroup channelGroup, DateTime from, DateTime to)
        {
            await _initComplete.Task;

            var programs = new List <IProgram>();

            if (channelGroup.ChannelGroupId < 0)
            {
                foreach (var channel in _tvBusiness.GetRadioGuideChannelsForGroup(-channelGroup.ChannelGroupId))
                {
                    CollectionUtils.AddAll(programs, _tvBusiness.GetPrograms(TvDatabase.Channel.Retrieve(channel.IdChannel), from, to).Select(p => GetProgram(p)));
                }
            }
            else
            {
                foreach (var channel in _tvBusiness.GetTVGuideChannelsForGroup(channelGroup.ChannelGroupId))
                {
                    CollectionUtils.AddAll(programs, _tvBusiness.GetPrograms(TvDatabase.Channel.Retrieve(channel.IdChannel), from, to).Select(p => GetProgram(p)));
                }
            }
            var success = programs.Count > 0;

            return(new AsyncResult <IList <IProgram> >(success, programs));
        }
Esempio n. 6
0
 private IEnumerable <Channel> GetChannels(int?groupId, WebSortField?sort, WebSortOrder?order)
 {
     return(groupId == null ?
            (IEnumerable <Channel>)Channel.ListAll().Where(ch => ch.IsTv).OrderBy(ch => sort == WebSortField.User ? ch.SortOrder : 1, order) :
            (IEnumerable <Channel>)_tvBusiness.GetTVGuideChannelsForGroup(groupId.Value));
 }