示例#1
0
        private static void CreateContinueWatchingGroupFilter()
        {
            // group filters
            GroupFilterRepository          repFilters = new GroupFilterRepository();
            GroupFilterConditionRepository repGFC     = new GroupFilterConditionRepository();

            using (var session = JMMService.SessionFactory.OpenSession())
            {
                // check if it already exists
                List <GroupFilter> lockedGFs = repFilters.GetLockedGroupFilters(session);

                if (lockedGFs != null)
                {
                    // if it already exists we can leave
                    foreach (GroupFilter gfTemp in lockedGFs)
                    {
                        if (gfTemp.FilterType == (int)GroupFilterType.ContinueWatching)
                        {
                            return;
                        }
                    }

                    // the default value when the column was added to the database was '1'
                    // this is only needed for users of a migrated database
                    foreach (GroupFilter gfTemp in lockedGFs)
                    {
                        if (gfTemp.GroupFilterName.Equals(Constants.GroupFilterName.ContinueWatching, StringComparison.InvariantCultureIgnoreCase) &&
                            gfTemp.FilterType != (int)GroupFilterType.ContinueWatching)
                        {
                            FixContinueWatchingGroupFilter_20160406();
                            return;
                        }
                    }
                }

                GroupFilter gf = new GroupFilter();
                gf.GroupFilterName = Constants.GroupFilterName.ContinueWatching;
                gf.Locked          = 1;
                gf.SortingCriteria = "4;2";           // by last watched episode desc
                gf.ApplyToSeries   = 0;
                gf.BaseCondition   = 1;               // all
                gf.FilterType      = (int)GroupFilterType.ContinueWatching;

                repFilters.Save(gf);

                GroupFilterCondition gfc = new GroupFilterCondition();
                gfc.ConditionType      = (int)GroupFilterConditionType.HasWatchedEpisodes;
                gfc.ConditionOperator  = (int)GroupFilterOperator.Include;
                gfc.ConditionParameter = "";
                gfc.GroupFilterID      = gf.GroupFilterID;
                repGFC.Save(gfc);

                gfc = new GroupFilterCondition();
                gfc.ConditionType      = (int)GroupFilterConditionType.HasUnwatchedEpisodes;
                gfc.ConditionOperator  = (int)GroupFilterOperator.Include;
                gfc.ConditionParameter = "";
                gfc.GroupFilterID      = gf.GroupFilterID;
                repGFC.Save(gfc);
            }
        }
示例#2
0
        private static void CreateInitialGroupFilters()
        {
            // group filters
            GroupFilterRepository          repFilters = new GroupFilterRepository();
            GroupFilterConditionRepository repGFC     = new GroupFilterConditionRepository();

            if (repFilters.GetAll().Count() > 0)
            {
                return;
            }

            // Favorites
            GroupFilter gf = new GroupFilter();

            gf.GroupFilterName = "Favorites";
            gf.ApplyToSeries   = 0;
            gf.BaseCondition   = 1;
            gf.Locked          = 0;
            gf.FilterType      = (int)GroupFilterType.UserDefined;

            repFilters.Save(gf);

            GroupFilterCondition gfc = new GroupFilterCondition();

            gfc.ConditionType      = (int)GroupFilterConditionType.Favourite;
            gfc.ConditionOperator  = (int)GroupFilterOperator.Include;
            gfc.ConditionParameter = "";
            gfc.GroupFilterID      = gf.GroupFilterID;
            repGFC.Save(gfc);



            // Missing Episodes
            gf = new GroupFilter();
            gf.GroupFilterName = JMMServer.Properties.Resources.Filter_MissingEpisodes;
            gf.ApplyToSeries   = 0;
            gf.BaseCondition   = 1;
            gf.Locked          = 0;
            gf.FilterType      = (int)GroupFilterType.UserDefined;

            repFilters.Save(gf);

            gfc = new GroupFilterCondition();
            gfc.ConditionType      = (int)GroupFilterConditionType.MissingEpisodesCollecting;
            gfc.ConditionOperator  = (int)GroupFilterOperator.Include;
            gfc.ConditionParameter = "";
            gfc.GroupFilterID      = gf.GroupFilterID;
            repGFC.Save(gfc);

            // Newly Added Series
            gf = new GroupFilter();
            gf.GroupFilterName = JMMServer.Properties.Resources.Filter_Added;
            gf.ApplyToSeries   = 0;
            gf.BaseCondition   = 1;
            gf.Locked          = 0;
            gf.FilterType      = (int)GroupFilterType.UserDefined;

            repFilters.Save(gf);

            gfc = new GroupFilterCondition();
            gfc.ConditionType      = (int)GroupFilterConditionType.SeriesCreatedDate;
            gfc.ConditionOperator  = (int)GroupFilterOperator.LastXDays;
            gfc.ConditionParameter = "10";
            gfc.GroupFilterID      = gf.GroupFilterID;
            repGFC.Save(gfc);

            // Newly Airing Series
            gf = new GroupFilter();
            gf.GroupFilterName = JMMServer.Properties.Resources.Filter_Airing;
            gf.ApplyToSeries   = 0;
            gf.BaseCondition   = 1;
            gf.Locked          = 0;
            gf.FilterType      = (int)GroupFilterType.UserDefined;

            repFilters.Save(gf);

            gfc = new GroupFilterCondition();
            gfc.ConditionType      = (int)GroupFilterConditionType.AirDate;
            gfc.ConditionOperator  = (int)GroupFilterOperator.LastXDays;
            gfc.ConditionParameter = "30";
            gfc.GroupFilterID      = gf.GroupFilterID;
            repGFC.Save(gfc);

            // Votes Needed
            gf = new GroupFilter();
            gf.GroupFilterName = JMMServer.Properties.Resources.Filter_Votes;
            gf.ApplyToSeries   = 0;
            gf.BaseCondition   = 1;
            gf.Locked          = 0;
            gf.FilterType      = (int)GroupFilterType.UserDefined;

            repFilters.Save(gf);

            gfc = new GroupFilterCondition();
            gfc.ConditionType      = (int)GroupFilterConditionType.CompletedSeries;
            gfc.ConditionOperator  = (int)GroupFilterOperator.Include;
            gfc.ConditionParameter = "";
            gfc.GroupFilterID      = gf.GroupFilterID;
            repGFC.Save(gfc);

            gfc = new GroupFilterCondition();
            gfc.ConditionType      = (int)GroupFilterConditionType.HasUnwatchedEpisodes;
            gfc.ConditionOperator  = (int)GroupFilterOperator.Exclude;
            gfc.ConditionParameter = "";
            gfc.GroupFilterID      = gf.GroupFilterID;
            repGFC.Save(gfc);

            gfc = new GroupFilterCondition();
            gfc.ConditionType      = (int)GroupFilterConditionType.UserVotedAny;
            gfc.ConditionOperator  = (int)GroupFilterOperator.Exclude;
            gfc.ConditionParameter = "";
            gfc.GroupFilterID      = gf.GroupFilterID;
            repGFC.Save(gfc);

            // Recently Watched
            gf = new GroupFilter();
            gf.GroupFilterName = JMMServer.Properties.Resources.Filter_RecentlyWatched;
            gf.ApplyToSeries   = 0;
            gf.BaseCondition   = 1;
            gf.Locked          = 0;
            gf.FilterType      = (int)GroupFilterType.UserDefined;

            repFilters.Save(gf);

            gfc = new GroupFilterCondition();
            gfc.ConditionType      = (int)GroupFilterConditionType.EpisodeWatchedDate;
            gfc.ConditionOperator  = (int)GroupFilterOperator.LastXDays;
            gfc.ConditionParameter = "10";
            gfc.GroupFilterID      = gf.GroupFilterID;
            repGFC.Save(gfc);

            // TvDB/MovieDB Link Missing
            gf = new GroupFilter();
            gf.GroupFilterName = JMMServer.Properties.Resources.Filter_LinkMissing;
            gf.ApplyToSeries   = 0;
            gf.BaseCondition   = 1;
            gf.Locked          = 0;
            gf.FilterType      = (int)GroupFilterType.UserDefined;

            repFilters.Save(gf);

            gfc = new GroupFilterCondition();
            gfc.ConditionType      = (int)GroupFilterConditionType.AssignedTvDBOrMovieDBInfo;
            gfc.ConditionOperator  = (int)GroupFilterOperator.Exclude;
            gfc.ConditionParameter = "";
            gfc.GroupFilterID      = gf.GroupFilterID;
            repGFC.Save(gfc);
        }