示例#1
0
        public static SharepointObject Read(SharepointSession session, ObjectId id)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            SharepointSiteId sharepointSiteId = id as SharepointSiteId;

            if (sharepointSiteId == null)
            {
                throw new ArgumentException("id");
            }
            if (sharepointSiteId is SharepointDocumentLibraryItemId)
            {
                return(SharepointDocumentLibraryItem.Read(session, sharepointSiteId));
            }
            if (sharepointSiteId is SharepointListId)
            {
                return(SharepointList.Read(session, sharepointSiteId));
            }
            throw new ObjectNotFoundException(sharepointSiteId, Strings.ExObjectNotFound(sharepointSiteId.ToString()));
        }
示例#2
0
        public new static SharepointDocumentLibraryItem Read(SharepointSession session, ObjectId objectId)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (objectId == null)
            {
                throw new ArgumentNullException("objectId");
            }
            SharepointDocumentLibraryItemId itemId = objectId as SharepointDocumentLibraryItemId;

            if (itemId == null)
            {
                throw new ArgumentException("objectId");
            }
            if (itemId.UriFlags != UriFlags.SharepointDocument && itemId.UriFlags != UriFlags.SharepointFolder)
            {
                throw new ArgumentException("objectId");
            }
            if (session.Uri != itemId.SiteUri)
            {
                throw new ObjectNotFoundException(itemId, Strings.ExObjectMovedOrDeleted(itemId.ToString()));
            }
            if (itemId.Cache != null && itemId.Cache.Value.Key == session.Identity.Name)
            {
                if (itemId.UriFlags == UriFlags.SharepointFolder)
                {
                    return(new SharepointDocumentLibraryFolder(itemId, session, itemId.Cache.Value.Value));
                }
                if (itemId.UriFlags == UriFlags.SharepointDocument)
                {
                    return(new SharepointDocument(itemId, session, itemId.Cache.Value.Value));
                }
            }
            return(Utils.DoSharepointTask <SharepointDocumentLibraryItem>(session.Identity, itemId, itemId, false, Utils.MethodType.Read, delegate
            {
                XmlNode nodeForItem = SharepointDocumentLibraryItem.GetNodeForItem(session, itemId);
                if (nodeForItem != null)
                {
                    SharepointList sharepointList = SharepointList.Read(session, new SharepointListId(itemId.ListName, itemId.SiteUri, null, UriFlags.SharepointDocumentLibrary));
                    itemId.Cache = new KeyValuePair <string, XmlNode>?(new KeyValuePair <string, XmlNode>(session.Identity.Name, nodeForItem));
                    itemId.CultureInfo = sharepointList.GetRegionalSettings();
                    if (itemId.UriFlags == UriFlags.SharepointFolder)
                    {
                        return new SharepointDocumentLibraryFolder(itemId, session, itemId.Cache.Value.Value);
                    }
                    if (itemId.UriFlags == UriFlags.SharepointDocument)
                    {
                        return new SharepointDocument(itemId, session, itemId.Cache.Value.Value);
                    }
                }
                throw new ObjectNotFoundException(itemId, Strings.ExObjectNotFound(itemId.ToString()));
            }));
        }
        public new static SharepointDocumentLibrary Read(SharepointSession session, ObjectId listId)
        {
            if (listId == null)
            {
                throw new ArgumentNullException("listId");
            }
            SharepointListId sharepointListId = listId as SharepointListId;

            if (sharepointListId == null)
            {
                throw new ArgumentException("listId");
            }
            if (sharepointListId.UriFlags != UriFlags.SharepointDocumentLibrary)
            {
                throw new ArgumentNullException("listId");
            }
            return((SharepointDocumentLibrary)SharepointList.Read(session, sharepointListId));
        }
示例#4
0
        internal CultureInfo GetRegionalSettings()
        {
            if (this.HasRegionalSettings)
            {
                return(this.CultureInfo);
            }
            SharepointListId sharepointListId = (SharepointListId)base.Id;
            SharepointListId listId           = new SharepointListId(sharepointListId.ListName, sharepointListId.SiteUri, null, sharepointListId.UriFlags);
            SharepointList   sharepointList   = SharepointList.Read(this.Session, listId);

            if (!sharepointList.HasRegionalSettings)
            {
                throw new CorruptDataException(this, Strings.ExCorruptRegionalSetting);
            }
            this.CultureInfo             = sharepointList.GetRegionalSettings();
            sharepointListId.CultureInfo = this.CultureInfo;
            return(this.CultureInfo);
        }
示例#5
0
 internal static ITableView InternalGetView(QueryFilter query, SortBy[] sortBy, DocumentLibraryQueryOptions queryOptions, PropertyDefinition[] propsToReturn, SharepointSession session, SharepointListId listId)
 {
     EnumValidator.ThrowIfInvalid <DocumentLibraryQueryOptions>(queryOptions, "queryOptions");
     if (propsToReturn == null)
     {
         throw new ArgumentNullException("propsToReturn");
     }
     if (propsToReturn.Length == 0)
     {
         throw new ArgumentException("propsToReturn");
     }
     return(Utils.DoSharepointTask <ArrayTableView>(session.Identity, new SharepointListId(listId.ListName, listId.SiteUri, listId.CultureInfo, UriFlags.SharepointList), listId, true, Utils.MethodType.GetView, delegate
     {
         XmlNode xmlNode = null;
         using (Lists lists = new Lists(listId.SiteUri.ToString()))
         {
             lists.Credentials = CredentialCache.DefaultCredentials;
             XmlNode query2 = null;
             QueryFilter queryFilter = null;
             if (queryOptions == DocumentLibraryQueryOptions.Files)
             {
                 queryFilter = new ComparisonFilter(ComparisonOperator.Equal, SharepointDocumentLibraryItemSchema.FileSystemObjectType, 0);
             }
             else if (queryOptions == DocumentLibraryQueryOptions.Folders)
             {
                 queryFilter = new ComparisonFilter(ComparisonOperator.Equal, SharepointDocumentLibraryItemSchema.FileSystemObjectType, 1);
             }
             if (query != null && queryFilter != null)
             {
                 query = new AndFilter(new QueryFilter[]
                 {
                     queryFilter,
                     query
                 });
             }
             else if (queryFilter != null)
             {
                 query = queryFilter;
             }
             if (query != null)
             {
                 query2 = SharepointHelpers.GenerateQueryCAML(query);
             }
             XmlNode viewFields = SharepointHelpers.GenerateViewFieldCAML(SharepointDocumentSchema.Instance, SharepointDocumentSchema.Instance.AllProperties.Keys);
             if (listId.CultureInfo == null)
             {
                 SharepointList sharepointList = SharepointList.Read(session, listId);
                 listId.CultureInfo = sharepointList.GetRegionalSettings();
             }
             SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId = listId as SharepointDocumentLibraryItemId;
             XmlNode queryOptions2;
             if (sharepointDocumentLibraryItemId != null)
             {
                 queryOptions2 = SharepointHelpers.GenerateQueryOptionsXml(sharepointDocumentLibraryItemId.ItemHierarchy);
             }
             else
             {
                 queryOptions2 = SharepointHelpers.GenerateQueryOptionsXml(null);
             }
             xmlNode = lists.GetListItems(listId.ListName, null, query2, viewFields, Utils.GetViewMaxRows.ToString(), queryOptions2);
         }
         List <object[]> list = new List <object[]>();
         foreach (object obj in xmlNode.SelectNodes("/rs:data/z:row", SharepointHelpers.SharepointNamespaceManager))
         {
             XmlNode xmlNode2 = (XmlNode)obj;
             object[] valuesFromCAMLView = SharepointHelpers.GetValuesFromCAMLView(SharepointDocumentSchema.Instance, xmlNode2, listId.CultureInfo, new PropertyDefinition[]
             {
                 SharepointDocumentLibraryItemSchema.FileSystemObjectType,
                 SharepointDocumentLibraryItemSchema.ID,
                 SharepointDocumentLibraryItemSchema.EncodedAbsoluteUri
             });
             int num = 0;
             int num2 = num + 1;
             int num3 = num2 + 1;
             bool flag = valuesFromCAMLView[num] is bool && (bool)valuesFromCAMLView[num];
             UriFlags uriFlags = flag ? UriFlags.SharepointFolder : UriFlags.SharepointDocument;
             Uri uri = (Uri)valuesFromCAMLView[num3];
             List <string> list2 = new List <string>();
             for (int i = listId.SiteUri.Segments.Length; i < uri.Segments.Length; i++)
             {
                 list2.Add(Uri.UnescapeDataString(uri.Segments[i]));
             }
             SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId2 = new SharepointDocumentLibraryItemId((string)valuesFromCAMLView[num2], listId.ListName, listId.SiteUri, listId.CultureInfo, uriFlags, list2);
             sharepointDocumentLibraryItemId2.Cache = new KeyValuePair <string, XmlNode>?(new KeyValuePair <string, XmlNode>(session.Identity.Name, xmlNode2));
             object[] valuesFromCAMLView2 = SharepointHelpers.GetValuesFromCAMLView(SharepointDocumentSchema.Instance, xmlNode2, listId.CultureInfo, propsToReturn);
             object obj2 = null;
             for (int j = 0; j < propsToReturn.Length; j++)
             {
                 if (((DocumentLibraryPropertyDefinition)propsToReturn[j]).PropertyId == DocumentLibraryPropertyId.Id)
                 {
                     valuesFromCAMLView2[j] = sharepointDocumentLibraryItemId2;
                 }
                 else if (propsToReturn[j] == SharepointDocumentSchema.VersionControl)
                 {
                     if (obj2 == null)
                     {
                         string text = SharepointHelpers.GetValuesFromCAMLView(SharepointDocumentSchema.Instance, xmlNode2, listId.CultureInfo, new PropertyDefinition[]
                         {
                             SharepointDocumentSchema.CheckedOutUserId
                         })[0] as string;
                         object obj3 = SharepointHelpers.GetValuesFromCAMLView(SharepointDocumentSchema.Instance, xmlNode2, listId.CultureInfo, new PropertyDefinition[]
                         {
                             SharepointDocumentSchema.VersionId
                         })[0];
                         if (obj3 is int && !flag)
                         {
                             obj2 = new VersionControl(!string.IsNullOrEmpty(text), text, (int)obj3);
                         }
                         else
                         {
                             obj2 = new PropertyError(propsToReturn[j], PropertyErrorCode.NotFound);
                         }
                     }
                     valuesFromCAMLView2[j] = obj2;
                 }
             }
             list.Add(valuesFromCAMLView2);
         }
         return new ArrayTableView(null, sortBy, propsToReturn, list);
     }));
 }
示例#6
0
        private static SharepointList GetListSpecifics(Uri uri, SharepointSession session, out ClassifyResult result)
        {
            SharepointList sharepointList = null;
            int            num            = 0;

            result = null;
            foreach (object[] array in session.GetView(ListBaseType.Any, new PropertyDefinition[]
            {
                DocumentLibrarySchema.Id
            }).GetRows(int.MaxValue))
            {
                SharepointList sharepointList2 = SharepointList.Read(session, (ObjectId)array[0]);
                Uri            uri2            = sharepointList2.Uri;
                int            num2            = 0;
                int            num3            = session.Uri.Segments.Length;
                while (num3 < uri2.Segments.Length && num3 < uri.Segments.Length && string.Compare(uri.Segments[num3].TrimEnd(new char[]
                {
                    '/',
                    '\\'
                }), uri2.Segments[num3].TrimEnd(new char[]
                {
                    '/',
                    '\\'
                }), StringComparison.CurrentCultureIgnoreCase) == 0)
                {
                    num3++;
                    num2++;
                }
                if (num2 > num)
                {
                    sharepointList = sharepointList2;
                    num            = num2;
                }
                else if (num2 == num)
                {
                    sharepointList = null;
                }
            }
            if (sharepointList == null)
            {
                result = new ClassifyResult(uri, ClassificationError.ObjectNotFound);
            }
            else if (sharepointList.ItemType == SharepointItemType.List)
            {
                result = new ClassifyResult(sharepointList.Id, uri, UriFlags.SharepointList);
            }
            else if (!uri.Query.Contains("&RootFolder=") && !uri.Query.Contains("?RootFolder="))
            {
                Uri uri3 = sharepointList.Uri;
                if (string.Compare(uri.AbsolutePath, uri3.AbsolutePath, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    result = new ClassifyResult(sharepointList.Id, uri, UriFlags.SharepointDocumentLibrary);
                }
                else if (uri.Segments.Length == uri3.Segments.Length)
                {
                    for (int j = 0; j < uri.Segments.Length - 1; j++)
                    {
                        if (string.Compare(uri3.Segments[j], uri.Segments[j], StringComparison.OrdinalIgnoreCase) != 0)
                        {
                            return(sharepointList);
                        }
                    }
                    if (LinkClassifier.CheckIfLinkExists(uri, null))
                    {
                        result = new ClassifyResult(sharepointList.Id, uri, UriFlags.SharepointDocumentLibrary);
                    }
                    else
                    {
                        result = new ClassifyResult(uri, ClassificationError.ObjectNotFound);
                    }
                }
            }
            return(sharepointList);
        }