public override void ProcessCommand()
        {
            SVR_GroupFilter gf = RepoFactory.GroupFilter.GetByID(GroupFilterID);

            if (gf == null)
            {
                return;
            }
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);
        }
Пример #2
0
        public ActionResult <List <Group> > PreviewFilterChanges(Filter.FullFilter filter)
        {
            SVR_GroupFilter gf = filter.ToServerModel();

            gf.CalculateGroupsAndSeries();

            if (!gf.GroupsIds.ContainsKey(User.JMMUserID))
            {
                return(new List <Group>());
            }
            return(gf.GroupsIds[User.JMMUserID].Select(a => RepoFactory.AnimeGroup.GetByID(a))
                   .Where(a => a != null).GroupFilterSort(gf).Select(a => new Group(HttpContext, a)).ToList());
        }
Пример #3
0
        public override void ProcessCommand()
        {
            if (GroupFilterID == 0)
            {
                RepoFactory.GroupFilter.CreateOrVerifyLockedFilters();
                return;
            }
            SVR_GroupFilter gf = RepoFactory.GroupFilter.GetByID(GroupFilterID);

            if (gf == null)
            {
                return;
            }
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);
        }
Пример #4
0
        public ActionResult <Filter> SaveFilter(Filter.FullFilter filter)
        {
            SVR_GroupFilter gf = null;

            if (filter.IDs.ID != 0)
            {
                gf = RepoFactory.GroupFilter.GetByID(filter.IDs.ID);
                if (gf == null)
                {
                    return(BadRequest("No Filter with ID"));
                }
            }
            gf = filter.ToServerModel(gf);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            return(new Filter(HttpContext, gf));
        }
Пример #5
0
        public ActionResult <Filter> SaveFilter(Filter.FullFilter body)
        {
            SVR_GroupFilter groupFilter = null;

            if (body.IDs.ID != 0)
            {
                groupFilter = RepoFactory.GroupFilter.GetByID(body.IDs.ID);
                if (groupFilter == null)
                {
                    return(NotFound(FilterNotFound));
                }
                if (groupFilter.Locked == 1)
                {
                    return(Forbid("Filter is Locked"));
                }
            }
            groupFilter = body.ToServerModel(groupFilter);
            groupFilter.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(groupFilter);

            return(new Filter(HttpContext, groupFilter));
        }
Пример #6
0
        private void CreateInitialGroupFilters()
        {
            // group filters

            if (RepoFactory.GroupFilter.GetAll().Any())
            {
                return;
            }

            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture);

            // Favorites
            SVR_GroupFilter gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_Favorites,
                ApplyToSeries   = 0,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            GroupFilterCondition gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.Favourite,
                ConditionOperator  = (int)GroupFilterOperator.Include,
                ConditionParameter = string.Empty
            };

            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            // Missing Episodes
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_MissingEpisodes,
                ApplyToSeries   = 0,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.MissingEpisodesCollecting,
                ConditionOperator  = (int)GroupFilterOperator.Include,
                ConditionParameter = string.Empty
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);


            // Newly Added Series
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_Added,
                ApplyToSeries   = 0,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.SeriesCreatedDate,
                ConditionOperator  = (int)GroupFilterOperator.LastXDays,
                ConditionParameter = "10"
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            // Newly Airing Series
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_Airing,
                ApplyToSeries   = 0,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.AirDate,
                ConditionOperator  = (int)GroupFilterOperator.LastXDays,
                ConditionParameter = "30"
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            // Votes Needed
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_Votes,
                ApplyToSeries   = 1,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.CompletedSeries,
                ConditionOperator  = (int)GroupFilterOperator.Include,
                ConditionParameter = string.Empty
            };
            gf.Conditions.Add(gfc);
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.HasUnwatchedEpisodes,
                ConditionOperator  = (int)GroupFilterOperator.Exclude,
                ConditionParameter = string.Empty
            };
            gf.Conditions.Add(gfc);
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.UserVotedAny,
                ConditionOperator  = (int)GroupFilterOperator.Exclude,
                ConditionParameter = string.Empty
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            // Recently Watched
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_RecentlyWatched,
                ApplyToSeries   = 0,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.EpisodeWatchedDate,
                ConditionOperator  = (int)GroupFilterOperator.LastXDays,
                ConditionParameter = "10"
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            // TvDB/MovieDB Link Missing
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_LinkMissing,
                ApplyToSeries   = 1, // This makes far more sense as applied to series
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.AssignedTvDBOrMovieDBInfo,
                ConditionOperator  = (int)GroupFilterOperator.Exclude,
                ConditionParameter = string.Empty
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);
        }
Пример #7
0
        private void CreateInitialGroupFilters()
        {
            // group filters
            // Do to DatabaseFixes, some filters may be made, namely directory filters
            // All, Continue Watching, Years, Seasons, Tags... 6 seems to be enough to tell for now
            // We can't just check the existence of anything specific, as the user can delete most of these
            if (RepoFactory.GroupFilter.GetTopLevel().Count() > 6)
            {
                return;
            }

            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Instance.Culture);

            // Favorites
            SVR_GroupFilter gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_Favorites,
                ApplyToSeries   = 0,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            GroupFilterCondition gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.Favourite,
                ConditionOperator  = (int)GroupFilterOperator.Include,
                ConditionParameter = string.Empty
            };

            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            // Missing Episodes
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_MissingEpisodes,
                ApplyToSeries   = 0,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.MissingEpisodesCollecting,
                ConditionOperator  = (int)GroupFilterOperator.Include,
                ConditionParameter = string.Empty
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);


            // Newly Added Series
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_Added,
                ApplyToSeries   = 0,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.SeriesCreatedDate,
                ConditionOperator  = (int)GroupFilterOperator.LastXDays,
                ConditionParameter = "10"
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            // Newly Airing Series
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_Airing,
                ApplyToSeries   = 0,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.AirDate,
                ConditionOperator  = (int)GroupFilterOperator.LastXDays,
                ConditionParameter = "30"
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            // Votes Needed
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_Votes,
                ApplyToSeries   = 1,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.CompletedSeries,
                ConditionOperator  = (int)GroupFilterOperator.Include,
                ConditionParameter = string.Empty
            };
            gf.Conditions.Add(gfc);
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.HasUnwatchedEpisodes,
                ConditionOperator  = (int)GroupFilterOperator.Exclude,
                ConditionParameter = string.Empty
            };
            gf.Conditions.Add(gfc);
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.UserVotedAny,
                ConditionOperator  = (int)GroupFilterOperator.Exclude,
                ConditionParameter = string.Empty
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            // Recently Watched
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_RecentlyWatched,
                ApplyToSeries   = 0,
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.EpisodeWatchedDate,
                ConditionOperator  = (int)GroupFilterOperator.LastXDays,
                ConditionParameter = "10"
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            // TvDB/MovieDB Link Missing
            gf = new SVR_GroupFilter
            {
                GroupFilterName = Commons.Properties.Resources.Filter_LinkMissing,
                ApplyToSeries   = 1, // This makes far more sense as applied to series
                BaseCondition   = 1,
                Locked          = 0,
                FilterType      = (int)GroupFilterType.UserDefined
            };
            gfc = new GroupFilterCondition
            {
                ConditionType      = (int)GroupFilterConditionType.AssignedTvDBOrMovieDBInfo,
                ConditionOperator  = (int)GroupFilterOperator.Exclude,
                ConditionParameter = string.Empty
            };
            gf.Conditions.Add(gfc);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);
        }