public static void FixContinueWatchingGroupFilter_20160406() { // 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 gf in lockedGFs) { if (gf.GroupFilterName.Equals(Constants.GroupFilterName.ContinueWatching, StringComparison.InvariantCultureIgnoreCase)) { gf.FilterType = (int)GroupFilterType.ContinueWatching; repFilters.Save(gf); } } } } }
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); } }
public void UpdateGroupFilters() { AnimeGroupRepository repGroups = new AnimeGroupRepository(); AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); GroupFilterRepository repGrpFilter = new GroupFilterRepository(); List <GroupFilter> gfs = repGrpFilter.GetAll(); List <AnimeGroup> allGrps = repGroups.GetAllTopLevelGroups(); // No Need of subgroups List <AnimeSeries> allSeries = repSeries.GetAll(); foreach (GroupFilter gf in gfs) { bool change = false; foreach (AnimeGroup grp in allGrps) { Contract_AnimeGroup cgrp = grp.GetUserContract(this.JMMUserID); change |= gf.CalculateGroupFilterGroups(cgrp, Contract, JMMUserID); } foreach (AnimeSeries ser in allSeries) { Contract_AnimeSeries cser = ser.GetUserContract(this.JMMUserID); change |= gf.CalculateGroupFilterSeries(cser, Contract, JMMUserID); } if (change) { repGrpFilter.Save(gf); } } }
public void DeleteFromFilters() { GroupFilterRepository repo = new GroupFilterRepository(); foreach (GroupFilter gf in repo.GetAll()) { bool change = false; if (gf.SeriesIds.ContainsKey(JMMUserID)) { if (gf.SeriesIds[JMMUserID].Contains(AnimeSeriesID)) { gf.SeriesIds[JMMUserID].Remove(AnimeSeriesID); change = true; } } if (change) { repo.Save(gf); } } }
private static void CreateInitialGroupFilters() { // group filters GroupFilterRepository repFilters = new GroupFilterRepository(); GroupFilterConditionRepository repGFC = new GroupFilterConditionRepository(); if (repFilters.GetAll().Count() > 0) { return; } Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture); // Favorites GroupFilter gf = new GroupFilter(); gf.GroupFilterName = JMMServer.Properties.Resources.Filter_Favorites; gf.ApplyToSeries = 0; gf.BaseCondition = 1; gf.Locked = 0; gf.FilterType = (int)GroupFilterType.UserDefined; GroupFilterCondition gfc = new GroupFilterCondition(); gfc.ConditionType = (int)GroupFilterConditionType.Favourite; gfc.ConditionOperator = (int)GroupFilterOperator.Include; gfc.ConditionParameter = ""; gf.Conditions.Add(gfc); gf.EvaluateAnimeGroups(); gf.EvaluateAnimeSeries(); repFilters.Save(gf); // 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; gfc = new GroupFilterCondition(); gfc.ConditionType = (int)GroupFilterConditionType.MissingEpisodesCollecting; gfc.ConditionOperator = (int)GroupFilterOperator.Include; gfc.ConditionParameter = ""; gf.Conditions.Add(gfc); gf.EvaluateAnimeGroups(); gf.EvaluateAnimeSeries(); repFilters.Save(gf); // 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; gfc = new GroupFilterCondition(); gfc.ConditionType = (int)GroupFilterConditionType.SeriesCreatedDate; gfc.ConditionOperator = (int)GroupFilterOperator.LastXDays; gfc.ConditionParameter = "10"; gf.Conditions.Add(gfc); gf.EvaluateAnimeGroups(); gf.EvaluateAnimeSeries(); repFilters.Save(gf); // 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; gfc = new GroupFilterCondition(); gfc.ConditionType = (int)GroupFilterConditionType.AirDate; gfc.ConditionOperator = (int)GroupFilterOperator.LastXDays; gfc.ConditionParameter = "30"; gf.Conditions.Add(gfc); gf.EvaluateAnimeGroups(); gf.EvaluateAnimeSeries(); repFilters.Save(gf); // 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; gfc = new GroupFilterCondition(); gfc.ConditionType = (int)GroupFilterConditionType.CompletedSeries; gfc.ConditionOperator = (int)GroupFilterOperator.Include; gfc.ConditionParameter = ""; gf.Conditions.Add(gfc); gfc = new GroupFilterCondition(); gfc.ConditionType = (int)GroupFilterConditionType.HasUnwatchedEpisodes; gfc.ConditionOperator = (int)GroupFilterOperator.Exclude; gfc.ConditionParameter = ""; gf.Conditions.Add(gfc); gfc = new GroupFilterCondition(); gfc.ConditionType = (int)GroupFilterConditionType.UserVotedAny; gfc.ConditionOperator = (int)GroupFilterOperator.Exclude; gfc.ConditionParameter = ""; gf.Conditions.Add(gfc); gf.EvaluateAnimeGroups(); gf.EvaluateAnimeSeries(); repFilters.Save(gf); // 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; gfc = new GroupFilterCondition(); gfc.ConditionType = (int)GroupFilterConditionType.EpisodeWatchedDate; gfc.ConditionOperator = (int)GroupFilterOperator.LastXDays; gfc.ConditionParameter = "10"; gf.Conditions.Add(gfc); gf.EvaluateAnimeGroups(); gf.EvaluateAnimeSeries(); repFilters.Save(gf); // 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; gfc = new GroupFilterCondition(); gfc.ConditionType = (int)GroupFilterConditionType.AssignedTvDBOrMovieDBInfo; gfc.ConditionOperator = (int)GroupFilterOperator.Exclude; gfc.ConditionParameter = ""; gf.Conditions.Add(gfc); gf.EvaluateAnimeGroups(); gf.EvaluateAnimeSeries(); repFilters.Save(gf); }
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; 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 = "Missing Episodes"; gf.ApplyToSeries = 0; gf.BaseCondition = 1; 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 = "Newly Added Series"; gf.ApplyToSeries = 0; gf.BaseCondition = 1; 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 = "Newly Airing Series"; gf.ApplyToSeries = 0; gf.BaseCondition = 1; 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 = "Votes Needed"; gf.ApplyToSeries = 0; gf.BaseCondition = 1; 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 = "Recently Watched"; gf.ApplyToSeries = 0; gf.BaseCondition = 1; 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 = "TvDB/MovieDB Link Missing"; gf.ApplyToSeries = 0; gf.BaseCondition = 1; 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); }