public PagedList <Document> List(Guid libraryId, DocumentListOptions options = null)
        {
            if (options == null)
            {
                options = new DocumentListOptions {
                    PageSize = DefaultPageSize
                };
            }

            if (string.IsNullOrEmpty(options.Url))
            {
                options.Url = GetUrl(libraryId);
            }

            var cacheId   = GetCacheId(libraryId, options);
            var documents = (PagedList <Document>)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process);

            if (documents == null)
            {
                var listItems = listItemService.List(libraryId, options);
                documents = new PagedList <Document>(listItems.Select(_ => new Document(_)))
                {
                    PageSize   = options.PageSize,
                    PageIndex  = options.PageIndex,
                    TotalCount = listItems.TotalCount
                };

                cacheService.Put(cacheId, documents, CacheScope.Context | CacheScope.Process, new[] { Tag(libraryId) }, CacheTimeOut);
            }
            return(documents);
        }
Пример #2
0
        public PagedList <SPListItem> List(Guid listId, SPListItemCollectionOptions options = null)
        {
            if (options == null)
            {
                options = new SPListItemCollectionOptions {
                    PageSize = DefaultPageSize
                };
            }

            var cacheId   = GetCacheId(listId, options);
            var listItems = (PagedList <SPListItem>)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process);

            if (listItems == null)
            {
                listItems = listItemService.List(listId, options);
                cacheService.Put(cacheId, listItems, CacheScope.Context | CacheScope.Process, new[] { Tag(listId) }, CacheTimeOut);
            }
            return(listItems);
        }