Esempio n. 1
0
        public static IEnumerable <FilteredCollection> GetAllRuntimes(List <TitleFilter> filters)
        {
            int maxRuntime = int.MaxValue;

            if (filters != null && filters.Count != 0 && filters.Exists(f => f.FilterType == TitleFilterType.Runtime))
            {
                // get the max runtime value to query titles for which is
                // going to be our most restrictive filter
                maxRuntime = filters.Where(a => a.FilterType == TitleFilterType.Runtime).Min(a => TitleConfig.RuntimeFilterStringToInt(a.FilterText) - 30);
            }

            IEnumerable <short> runtimes = from t in GetFilteredTitlesWrapper(filters)
                                           where t.Runtime.HasValue && t.Runtime <= maxRuntime
                                           select t.Runtime.Value;

            int longestRuntime = runtimes.DefaultIfEmpty().Max();

            IEnumerable <TitleConfig.NumericRange> runtimeRange = (longestRuntime < TitleConfig.MAX_RUNTIME)
                                                                    ? TitleConfig.RUNTIME_RANGE.AsQueryable().Where(r => longestRuntime + 30 > r.End)
                                                                    : TitleConfig.RUNTIME_RANGE;

            return(from d in runtimes
                   from r in runtimeRange
                   where d >= r.Start && d <= r.End
                   group r by r.End into g
                   orderby g.Key ascending
                   select new FilteredCollection()
            {
                Name = TitleConfig.RuntimeToFilterString(g.Key), Count = g.Count()
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Applys the date added filter
        /// </summary>
        /// <param name="titles"></param>
        /// <param name="dateAdded"></param>
        /// <returns></returns>
        private static IQueryable <Title> ApplyDateAddedFilter(IQueryable <Title> titles, string dateAdded)
        {
            int days = TitleConfig.DateAddedFilterStringToInt(dateAdded);

            if (days == 0)
            {
                return(from t in titles
                       where t.DateAdded != null && ((TimeSpan)(DateTime.Now - t.DateAdded)).Days <= days
                       select t);
            }
            else if (days == -1)
            {
                return(from t in titles
                       where t.DateAdded != null && ((TimeSpan)(DateTime.Now - t.DateAdded)).Days > TitleConfig.MAX_DATE_ADDED
                       select t);
            }
            else
            {
                int minDate = 0;

                // the min time is the previous index
                for (int x = 0; x < TitleConfig.ADDED_FILTER_DATE.Length; x++)
                {
                    if (TitleConfig.ADDED_FILTER_DATE[x] == days)
                    {
                        minDate = TitleConfig.ADDED_FILTER_DATE[x - 1];
                        break;
                    }
                }

                return(from t in titles
                       where t.DateAdded != null && ((TimeSpan)(DateTime.Now - t.DateAdded)).Days <= days && ((TimeSpan)(DateTime.Now - t.DateAdded)).Days > minDate
                       select t);
            }
        }
Esempio n. 3
0
        public CtrlSetting()
        {
            InitializeComponent();

            this.systemConfig        = SystemConfig.ReadConfig();
            this.titleConfig         = TitleConfig.ReadConfig();
            this.subtitleConfig      = SubtitleConfig.ReadConfig();
            this.scrollTextConfig    = ScrollTextConfig.ReadConfig();
            this.lotteryButtonConfig = LotteryButtonConfig.ReadConfig();
            this.lotteryBoxConfig    = LotteryBoxConfig.ReadConfig();
        }
Esempio n. 4
0
        public static IEnumerable <FilteredCollection> GetAllDateAdded(List <TitleFilter> filters)
        {
            IEnumerable <int> days = from t in GetFilteredTitlesWrapper(filters)
                                     where t.DateAdded.HasValue
                                     select(int)(DateTime.Now - t.DateAdded.Value).TotalDays;

            return(from d in days
                   from r in TitleConfig.DATE_ADDED_RANGE
                   where d >= r.Start && d < r.End
                   group r by r.End into g
                   orderby g.Key ascending
                   select new FilteredCollection()
            {
                Name = TitleConfig.DaysToFilterString(g.Key), Count = g.Count()
            });
        }
Esempio n. 5
0
        /// <summary>
        /// Returns all the titles that have a specific runtime
        /// </summary>
        /// <param name="titles"></param>
        /// <param name="runtime"></param>
        /// <returns></returns>
        private static IQueryable <Title> ApplyRuntimeFilter(IQueryable <Title> titles, string runtime)
        {
            int maxTime = TitleConfig.RuntimeFilterStringToInt(runtime);

            if (maxTime != -1)
            {
                return(from t in titles
                       where t.Runtime <= maxTime
                       select t);
            }
            else
            {
                return(from t in titles
                       where t.Runtime > TitleConfig.MAX_RUNTIME
                       select t);
            }
        }