Ejemplo n.º 1
0
        private IEpisodeTimeVO RefreshEpisodeItem <T>(IEpisodeTimeVO currentCachedItem) where T : IEpisodeTimeVO, IValueObject
        {
            DateTime serverDateTime = Service.ServerAPI.ServerDateTime;

            if (this.IsEpisodeItemActive(serverDateTime, currentCachedItem))
            {
                this.TrySetNextScheduledRefreshDate(serverDateTime, currentCachedItem.EndTime);
                return(currentCachedItem);
            }
            DateTime dateTime = DateTime.MaxValue;

            currentCachedItem = null;
            List <T> sortedEpisodeTimeVOList = this.GetSortedEpisodeTimeVOList <T>();
            int      i     = 0;
            int      count = sortedEpisodeTimeVOList.Count;

            while (i < count)
            {
                IEpisodeTimeVO episodeTimeVO = sortedEpisodeTimeVOList[i];
                if (this.IsEpisodeItemActive(serverDateTime, episodeTimeVO))
                {
                    currentCachedItem = episodeTimeVO;
                    this.TrySetNextScheduledRefreshDate(serverDateTime, currentCachedItem.EndTime);
                    return(currentCachedItem);
                }
                if (episodeTimeVO.StartTime > serverDateTime && episodeTimeVO.StartTime < dateTime)
                {
                    dateTime = episodeTimeVO.StartTime;
                }
                i++;
            }
            Service.Logger.Debug("Next Earliest Start Time: " + dateTime.ToString());
            this.TrySetNextScheduledRefreshDate(serverDateTime, dateTime);
            return(currentCachedItem);
        }
Ejemplo n.º 2
0
 private bool IsEpisodeItemActive(DateTime now, IEpisodeTimeVO vo)
 {
     return(vo != null && vo.StartTime <= now && vo.EndTime > now);
 }