예제 #1
0
        public void Execute(CutoffUnmetEpisodeSearchCommand message)
        {
            var monitored = message.Monitored;

            var pagingSpec = new PagingSpec <Episode>
            {
                Page          = 1,
                PageSize      = 100000,
                SortDirection = SortDirection.Ascending,
                SortKey       = "Id"
            };

            if (message.SeriesId.HasValue)
            {
                var seriesId = message.SeriesId.Value;
                pagingSpec.FilterExpressions.Add(v => v.SeriesId == seriesId);
            }

            if (monitored)
            {
                pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Series.Monitored == true);
            }
            else
            {
                pagingSpec.FilterExpressions.Add(v => v.Monitored == false || v.Series.Monitored == false);
            }

            var episodes    = _episodeCutoffService.EpisodesWhereCutoffUnmet(pagingSpec).Records.ToList();
            var queue       = _queueService.GetQueue().Where(q => q.Episode != null).Select(q => q.Episode.Id);
            var cutoffUnmet = episodes.Where(e => !queue.Contains(e.Id)).ToList();

            SearchForEpisodes(cutoffUnmet, monitored, message.Trigger == CommandTrigger.Manual);
        }
예제 #2
0
        public void Execute(CutoffUnmetEpisodeSearchCommand message)
        {
            Expression <Func <Episode, bool> > filterExpression;

            if (message.SeriesId.HasValue)
            {
                filterExpression = v =>
                                   v.SeriesId == message.SeriesId.Value &&
                                   v.Monitored == true &&
                                   v.Series.Monitored == true;
            }

            else
            {
                filterExpression = v =>
                                   v.Monitored == true &&
                                   v.Series.Monitored == true;
            }

            var pagingSpec = new PagingSpec <Episode>
            {
                Page          = 1,
                PageSize      = 100000,
                SortDirection = SortDirection.Ascending,
                SortKey       = "Id"
            };

            pagingSpec.FilterExpressions.Add(filterExpression);

            var episodes = _episodeCutoffService.EpisodesWhereCutoffUnmet(pagingSpec).Records.ToList();

            var queue   = _queueService.GetQueue().Where(q => q.Episode != null).Select(q => q.Episode.Id);
            var missing = episodes.Where(e => !queue.Contains(e.Id)).ToList();

            SearchForMissingEpisodes(missing, message.Trigger == CommandTrigger.Manual);
        }