Exemplo n.º 1
0
        public ListItemCollection GetItems(Caml.View spView, ListItemCollectionPosition position)
        {
            var list = GetList();

            if (list != null)
            {
                var items = list.GetItems(new CamlQuery()
                {
                    ViewXml = spView.ToString(true), ListItemCollectionPosition = position
                });
                items.Context.Load(items, item => item.Include(i => i.EffectiveBasePermissions));
                items.Context.Load(items, item => item.ListItemCollectionPosition);
                return(items);
            }
            return(null);
        }
Exemplo n.º 2
0
        public ListItemCollection GetItems(Caml.View spView, ListItemCollectionPosition position, bool countOnly, bool fieldValuesAsText)
        {
            if (_args == null || spView == null)
            {
                return(null);
            }

            string folderUrl = string.IsNullOrWhiteSpace(this._args.FolderUrl)
                ? null
                : new Uri(string.Concat(this._args.Context.SiteUrl.TrimEnd('/'), "/", string.IsNullOrEmpty(_args.ListUrl) ? "" : $"{_args.ListUrl.Trim('/')}/", (!string.IsNullOrEmpty(_args.ListUrl) ? this._args.FolderUrl.Replace(_args.ListUrl, "") : this._args.FolderUrl).TrimStart('/'))).LocalPath;
            var list = GetList();

            //if (list == null)
            //{
            //    Check.NotNull(list, nameof(List));
            //}
            //if (spView == null)
            //{
            //    Check.NotNull(spView, nameof(Caml.View));
            //}
            if (list != null && spView != null)
            {
                var items = list.GetItems(new CamlQuery()
                {
                    DatesInUtc = true, FolderServerRelativeUrl = folderUrl, ViewXml = spView.ToString(true), ListItemCollectionPosition = position
                });
                if (countOnly)
                {
                    items.Context.Load(items, item => item.ListItemCollectionPosition, item => item.Include(i => i.Id));
                    return(items);
                }
                else
                {
                    if (_args.IncludeItemPermissions)
                    {
                        items.Context.Load(items, item => item.Include(i => i.EffectiveBasePermissions));
                    }
                    if (/*fieldValuesAsText*/ false)
                    {
                        //BUG: NOT working!
                        items.Context.Load(items, item => item.ListItemCollectionPosition, item => item.Include(i => i.FieldValuesAsText));
                    }
                    else
                    {
                        items.Context.Load(items, item => item.ListItemCollectionPosition);
                    }
                    return(items);
                }
            }
            return(null);
        }