public static IQueryable <T> WhereMatchFilter <T>(this IQueryable <T> query, AdvancedSearchFilter filter) where T : ISongLink { if (filter == null) { return(query); } switch (filter.FilterType) { case AdvancedFilterType.ArtistType: { var param = EnumVal <ArtistType> .Parse(filter.Param); return(WhereSongHasArtistWithType(query, param)); } case AdvancedFilterType.HasMultipleVoicebanks: { return(query.Where(s => s.Song.AllArtists.Count(a => !a.IsSupport && ArtistHelper.VoiceSynthesizerTypes.Contains(a.Artist.ArtistType)) > 1)); } case AdvancedFilterType.HasPublishDate: { return(query.WhereSongHasPublishDate(!filter.Negate)); } case AdvancedFilterType.Lyrics: { var any = filter.Param == AdvancedSearchFilter.Any; var languageCodes = !any ? (filter.Param ?? string.Empty).Split(',') : null; return(WhereSongHasLyrics(query, languageCodes, any)); } } return(query); }
/// <summary> /// This method retrieves the list of users using the specified SearchFilter durin /// the last number of days from the date that this is called on. /// </summary> /// <param name="day">The number of days to go back on and check to see what users /// were created during this time frame.</param> /// <returns></returns> public List <ADUser> GetUsersByCriteria(AdvancedSearchFilter filter, DateTime day) { List <ADUser> users = new List <ADUser>(); using (PrincipalContext context = new PrincipalContext(ContextType.Domain, ServerName, null, ContextOptions.Negotiate, ServiceUser, ServicePassword)) { using (ADUser userFilter = new ADUser(context)) { switch (filter) { case AdvancedSearchFilter.DateCreated: userFilter.MyAdvancedFilters.CreatedInTheLastDays(day, MatchType.GreaterThanOrEquals); break; case AdvancedSearchFilter.WhenChanged: userFilter.MyAdvancedFilters.WhenChangedInLastDays(day, MatchType.GreaterThanOrEquals); break; default: break; } using (PrincipalSearcher searcher = new PrincipalSearcher(userFilter)) { ((DirectorySearcher)searcher.GetUnderlyingSearcher()).PageSize = 1000; var searchResults = searcher.FindAll().ToList(); foreach (Principal user in searchResults) { ADUser usr = user as ADUser; // We are filtering out users who don't have a first name // Though this has the issue of filtering out accounts if (String.IsNullOrEmpty(usr.GivenName)) { continue; } users.Add(usr); } } } } return(users.OrderByDescending(u => u.WhenChanged).ToList()); }
public static IQueryable <Album> WhereMatchFilter(this IQueryable <Album> query, AdvancedSearchFilter filter) { switch (filter.FilterType) { case AdvancedFilterType.ArtistType: { var param = EnumVal <ArtistType> .Parse(filter.Param); return(WhereArtistHasType(query, param)); } case AdvancedFilterType.NoCoverPicture: { return(query.Where(a => a.CoverPictureMime == null || a.CoverPictureMime == string.Empty)); } case AdvancedFilterType.HasStoreLink: { return(query.WhereHasLinkWithCategory(WebLinkCategory.Commercial)); } case AdvancedFilterType.WebLink: { return(query.WhereHasLink <Album, AlbumWebLink>(filter.Param)); } } return(query); }
public static IQueryable <T> WhereAlbumMatchFilter <T>(this IQueryable <T> query, AdvancedSearchFilter filter) where T : IAlbumLink { if (filter == null) { return(query); } switch (filter.FilterType) { case AdvancedFilterType.ArtistType: { var param = EnumVal <ArtistType> .Parse(filter.Param); return(WhereAlbumHasArtistWithType(query, param)); } case AdvancedFilterType.NoCoverPicture: { return(query.Where(a => a.Album.CoverPictureMime == null || a.Album.CoverPictureMime == string.Empty)); } case AdvancedFilterType.HasStoreLink: { return(query.WhereAlbumHasLinkWithCategory(WebLinkCategory.Commercial)); } case AdvancedFilterType.HasTracks: { return(query.Where(a => filter.Negate != a.Album.AllSongs.Any(s => s.Song == null || !s.Song.Deleted))); } } return(query); }
public static IQueryable <Song> WhereMatchFilter(this IQueryable <Song> query, AdvancedSearchFilter filter) { if (filter == null) { return(query); } switch (filter.FilterType) { case AdvancedFilterType.ArtistType: { var param = EnumVal <ArtistType> .Parse(filter.Param); return(WhereArtistHasType(query, param)); } case AdvancedFilterType.HasAlbum: return(filter.Negate ? query.Where(s => !s.AllAlbums.Any()) : query.Where(s => s.AllAlbums.Any())); case AdvancedFilterType.HasMultipleVoicebanks: { return(query.Where(s => s.AllArtists.Count(a => !a.IsSupport && ArtistHelper.VoiceSynthesizerTypes.Contains(a.Artist.ArtistType)) > 1)); } case AdvancedFilterType.HasPublishDate: { return(query.WhereHasPublishDate(!filter.Negate)); } case AdvancedFilterType.Lyrics: { var any = filter.Param == AdvancedSearchFilter.Any; var languageCodes = !any ? (filter.Param ?? string.Empty).Split(',') : null; return(WhereHasLyrics(query, languageCodes, any)); } case AdvancedFilterType.LyricsContent: { return(query.WhereHasLyricsContent(filter.Param)); } case AdvancedFilterType.HasOriginalMedia: { return(query.Where(s => filter.Negate != s.PVs.PVs.Any(pv => !pv.Disabled && pv.PVType == PVType.Original))); } case AdvancedFilterType.HasMedia: { return(query.Where(s => filter.Negate != s.PVs.PVs.Any())); } case AdvancedFilterType.WebLink: { return(query.WhereHasLink <Song, SongWebLink>(filter.Param)); } } return(query); }
public static IQueryable <Artist> WhereMatchFilter(this IQueryable <Artist> query, AdvancedSearchFilter filter) { switch (filter.FilterType) { case AdvancedFilterType.HasUserAccount: { return(query.Where(a => a.OwnerUsers.Any())); } case AdvancedFilterType.RootVoicebank: { return(filter.Negate ? query.Where(a => a.BaseVoicebank != null) : query.Where(a => ArtistHelper.VoiceSynthesizerTypes.Contains(a.ArtistType) && a.BaseVoicebank == null)); } case AdvancedFilterType.VoiceProvider: { var param = EnumVal <ArtistType> .ParseSafe(filter.Param, ArtistType.Unknown); return(param == ArtistType.Unknown ? query.Where(a => a.AllMembers.Any(m => m.LinkType == ArtistLinkType.VoiceProvider)) : query.Where(a => a.AllMembers.Any(m => m.LinkType == ArtistLinkType.VoiceProvider && m.Member.ArtistType == param))); } case AdvancedFilterType.WebLink: { return(query.WhereHasLink <Artist, ArtistWebLink>(filter.Param)); } } return(query); }