Exemple #1
0
        public SPListItem Get(Guid listId, SPListItemGetOptions options)
        {
            var cacheId  = GetCacheId(listId, options);
            var listItem = (SPListItem)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process);

            if (listItem != null)
            {
                return(listItem);
            }

            listItem = listItemService.Get(listId, options);
            cacheService.Put(cacheId, listItem, CacheScope.Context | CacheScope.Process, new[] { Tag(listId) }, CacheTimeOut);
            return(listItem);
        }
        public Document Get(Guid libraryId, DocumentGetOptions options)
        {
            var cacheId  = GetCacheId(libraryId, options);
            var document = (Document)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process);

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

                document = new Document(listItemService.Get(libraryId, options));
                cacheService.Put(cacheId, document, CacheScope.Context | CacheScope.Process, new[] { Tag(libraryId) }, CacheTimeOut);
            }
            return(document);
        }
        public static Guid GetItemUniqueId(this IListItemService listItemService, string token, Guid listId)
        {
            if (string.IsNullOrEmpty(token))
            {
                return(Guid.Empty);
            }

            SPListItem listItem;

            // Try get item by incremental id
            int lookupId;

            if (int.TryParse(token, out lookupId) &&
                (listItem = listItemService.Get(listId, new ItemGetQuery(lookupId))) != null)
            {
                listItemService.Add(listId, new ItemImportQuery(listItem.ContentId));
                return(listItem.UniqueId);
            }

            return(Guid.Empty);
        }