Exemple #1
0
        public virtual Task <QueryResult <BaseItem> > GetItems(InternalItemsQuery query)
        {
            var user = query.User;

            Func <BaseItem, bool> filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager);

            IEnumerable <BaseItem> items;

            if (query.User == null)
            {
                items = query.Recursive
                   ? GetRecursiveChildren(filter)
                   : Children.Where(filter);
            }
            else
            {
                items = query.Recursive
                   ? GetRecursiveChildren(user, filter)
                   : GetChildren(user, true).Where(filter);
            }

            var result = PostFilterAndSort(items, query);

            return(Task.FromResult(result));
        }
        public QueryResult <BaseItem> QueryRecursive(InternalItemsQuery query)
        {
            var user = query.User;

            if (!query.ForceDirect && RequiresPostFiltering(query))
            {
                IEnumerable <BaseItem> items;
                Func <BaseItem, bool>  filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager);

                if (query.User == null)
                {
                    items = GetRecursiveChildren(filter);
                }
                else
                {
                    items = GetRecursiveChildren(user, query);
                }

                return(PostFilterAndSort(items, query, true, true));
            }

            if (!(this is UserRootFolder) && !(this is AggregateFolder))
            {
                query.ParentId = query.ParentId ?? Id;
            }

            return(LibraryManager.GetItemsResult(query));
        }
        protected virtual async Task <QueryResult <BaseItem> > GetItemsInternal(InternalItemsQuery query)
        {
            if (SourceType == SourceType.Channel)
            {
                try
                {
                    // Don't blow up here because it could cause parent screens with other content to fail
                    return(await ChannelManager.GetChannelItemsInternal(new ChannelItemQuery
                    {
                        ChannelId = ChannelId,
                        FolderId = Id.ToString("N"),
                        Limit = query.Limit,
                        StartIndex = query.StartIndex,
                        UserId = query.User.Id.ToString("N"),
                        SortBy = query.SortBy,
                        SortOrder = query.SortOrder
                    }, new Progress <double>(), CancellationToken.None));
                }
                catch
                {
                    // Already logged at lower levels
                    return(new QueryResult <BaseItem>());
                }
            }

            if (query.Recursive)
            {
                return(QueryRecursive(query));
            }

            var user = query.User;

            Func <BaseItem, bool> filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager);

            IEnumerable <BaseItem> items;

            if (query.User == null)
            {
                items = query.Recursive
                   ? GetRecursiveChildren(filter)
                   : Children.Where(filter);
            }
            else
            {
                items = query.Recursive
                   ? GetRecursiveChildren(user, query)
                   : GetChildren(user, true).Where(filter);
            }

            return(PostFilterAndSort(items, query, true, true));
        }
Exemple #4
0
        public override async Task <QueryResult <BaseItem> > GetItems(InternalItemsQuery query)
        {
            var user = query.User;
            Func <BaseItem, bool> filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager);

            if (query.Recursive)
            {
                var items = query.User.RootFolder.GetRecursiveChildren(query.User, filter);
                return(PostFilterAndSort(items, query));
            }

            var result = await UserViewManager.GetUserViews(new UserViewQuery
            {
                UserId = query.User.Id.ToString("N")
            }, CancellationToken.None).ConfigureAwait(false);

            return(PostFilterAndSort(result.Where(filter), query));
        }
Exemple #5
0
        protected override async Task <QueryResult <BaseItem> > GetItemsInternal(InternalItemsQuery query)
        {
            if (query.Recursive)
            {
                return(QueryRecursive(query));
            }

            var result = await UserViewManager.GetUserViews(new UserViewQuery
            {
                UserId      = query.User.Id.ToString("N"),
                PresetViews = query.PresetViews
            }, CancellationToken.None).ConfigureAwait(false);

            var user = query.User;
            Func <BaseItem, bool> filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager);

            return(PostFilterAndSort(result.Where(filter), query));
        }