public override bool Equals(object obj) { if (base.Equals(obj)) { SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId = (SharepointDocumentLibraryItemId)obj; return sharepointDocumentLibraryItemId.ItemId == base.ItemId; } return false; }
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())); })); }
internal static XmlNode GetNodeForItem(SharepointSession session, SharepointDocumentLibraryItemId itemId) { XmlNode result; using (Lists lists = new Lists(session.Uri.ToString())) { lists.Credentials = CredentialCache.DefaultCredentials; XmlNode query = SharepointHelpers.GenerateQueryCAML(new ComparisonFilter(ComparisonOperator.Equal, SharepointDocumentLibraryItemSchema.ID, itemId.ItemId)); XmlNode queryOptions = SharepointHelpers.GenerateQueryOptionsXml(itemId.ParentDirectoryStructure); XmlNode viewFields = SharepointHelpers.GenerateViewFieldCAML(SharepointDocumentSchema.Instance, SharepointDocumentSchema.Instance.AllProperties.Keys); XmlNode listItems = lists.GetListItems(itemId.ListName, null, query, viewFields, "2", queryOptions); XmlNodeList xmlNodeList = listItems.SelectNodes("/rs:data/z:row", SharepointHelpers.SharepointNamespaceManager); result = ((xmlNodeList.Count == 1) ? xmlNodeList[0] : null); } return(result); }
public new static SharepointDocumentLibraryFolder Read(SharepointSession session, ObjectId objectId) { if (session == null) { throw new ArgumentNullException("session"); } if (objectId == null) { throw new ArgumentNullException("objectId"); } SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId = objectId as SharepointDocumentLibraryItemId; if (sharepointDocumentLibraryItemId == null) { throw new ArgumentException("objectId"); } if (sharepointDocumentLibraryItemId.UriFlags != UriFlags.SharepointFolder) { throw new ArgumentException("objectId"); } return((SharepointDocumentLibraryFolder)SharepointDocumentLibraryItem.Read(session, objectId)); }
public new static SharepointDocument Read(SharepointSession session, ObjectId id) { if (session == null) { throw new ArgumentNullException("session"); } if (id == null) { throw new ArgumentNullException("id"); } SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId = id as SharepointDocumentLibraryItemId; if (sharepointDocumentLibraryItemId == null) { throw new ArgumentException("id"); } if (sharepointDocumentLibraryItemId.UriFlags != UriFlags.SharepointDocument) { throw new ArgumentException("id"); } return((SharepointDocument)SharepointDocumentLibraryItem.Read(session, id)); }
public List <KeyValuePair <string, Uri> > GetHierarchy() { SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId = base.Id as SharepointDocumentLibraryItemId; List <KeyValuePair <string, Uri> > list = new List <KeyValuePair <string, Uri> >(sharepointDocumentLibraryItemId.ItemHierarchy.Count); if (sharepointDocumentLibraryItemId.SiteUri.Segments.Length > 1) { list.Add(new KeyValuePair <string, Uri>(sharepointDocumentLibraryItemId.SiteUri.Segments[sharepointDocumentLibraryItemId.SiteUri.Segments.Length - 1], sharepointDocumentLibraryItemId.SiteUri)); } else { list.Add(new KeyValuePair <string, Uri>(sharepointDocumentLibraryItemId.SiteUri.Host, sharepointDocumentLibraryItemId.SiteUri)); } UriBuilder uriBuilder = new UriBuilder(sharepointDocumentLibraryItemId.SiteUri); for (int i = 0; i < sharepointDocumentLibraryItemId.ItemHierarchy.Count - 1; i++) { uriBuilder.Path = uriBuilder.Path + "/" + sharepointDocumentLibraryItemId.ItemHierarchy[i]; list.Add(new KeyValuePair <string, Uri>(sharepointDocumentLibraryItemId.ItemHierarchy[i], uriBuilder.Uri)); } return(list); }
public Stream GetDocument() { return(Utils.DoSharepointTask <Stream>(this.Session.Identity, base.Id, (SharepointSiteId)base.Id, true, Utils.MethodType.GetStream, delegate { Stream stream = null; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(this.Uri); httpWebRequest.KeepAlive = false; httpWebRequest.Headers.Set("Pragma", "no-cache"); httpWebRequest.Headers.Set("Depth", "0"); httpWebRequest.ContentType = "text/xml"; httpWebRequest.ContentLength = 0L; httpWebRequest.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); stream = httpWebResponse.GetResponseStream(); bool flag = false; try { SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId = (SharepointDocumentLibraryItemId)base.Id; XmlNode nodeForItem = SharepointDocumentLibraryItem.GetNodeForItem(this.Session, sharepointDocumentLibraryItemId); SharepointDocument sharepointDocument = new SharepointDocument(sharepointDocumentLibraryItemId, this.Session, nodeForItem); if (sharepointDocument.VersionControl.TipVersion != this.VersionControl.TipVersion) { throw new DocumentModifiedException(base.Id, this.Uri.ToString()); } flag = true; } finally { if (!flag) { stream.Dispose(); stream = null; } } return stream; })); }
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); })); }
internal SharepointDocumentLibraryFolder(SharepointDocumentLibraryItemId id, SharepointSession session, XmlNode dataCache) : base(id, session, dataCache, SharepointFolderSchema.Instance) { }
private static ClassifyResult ClassifySharepointLink(Uri uri, WindowsIdentity authenticatedUser) { WindowsImpersonationContext windowsImpersonationContext = null; ClassifyResult classifyResult = null; ClassifyResult result; try { windowsImpersonationContext = Utils.ImpersonateUser(authenticatedUser); Uri siteAddress = LinkClassifier.GetSiteAddress(uri, out classifyResult); if (classifyResult != null) { result = classifyResult; } else { SharepointSession session = SharepointSession.Open(new SharepointSiteId(siteAddress, UriFlags.Sharepoint), new WindowsPrincipal(authenticatedUser)); SharepointList listSpecifics = LinkClassifier.GetListSpecifics(uri, session, out classifyResult); if (classifyResult != null) { result = classifyResult; } else { IList <string> itemHierarchy = LinkClassifier.GetItemHierarchy(uri, listSpecifics); if (itemHierarchy.Count < 2) { Uri uri2 = listSpecifics.Uri; bool flag = false; if (itemHierarchy.Count == 0 || string.Compare(itemHierarchy[0].TrimEnd(new char[] { '/', '\\' }), Uri.UnescapeDataString(uri2.Segments[siteAddress.Segments.Length].TrimEnd(new char[] { '/', '\\' })), StringComparison.OrdinalIgnoreCase) != 0) { flag = true; } if (!flag) { result = new ClassifyResult(listSpecifics.Id, uri, UriFlags.SharepointDocumentLibrary); } else { result = new ClassifyResult(uri, ClassificationError.ObjectNotFound); } } else { string propertyValue = itemHierarchy[itemHierarchy.Count - 1]; itemHierarchy.RemoveAt(itemHierarchy.Count - 1); SharepointListId sharepointListId = (SharepointListId)listSpecifics.Id; SharepointDocumentLibraryItemId listId = new SharepointDocumentLibraryItemId("-1", sharepointListId.ListName, sharepointListId.SiteUri, listSpecifics.GetRegionalSettings(), UriFlags.SharepointFolder, itemHierarchy); ComparisonFilter query = new ComparisonFilter(ComparisonOperator.Equal, SharepointDocumentLibraryItemSchema.Name, propertyValue); PropertyDefinition[] propsToReturn = new PropertyDefinition[] { SharepointDocumentLibraryItemSchema.ID, SharepointDocumentLibraryItemSchema.FileSystemObjectType }; object[][] rows = SharepointDocumentLibraryFolder.InternalGetView(query, null, DocumentLibraryQueryOptions.FoldersAndFiles, propsToReturn, session, listId).GetRows(2); if (rows.Length == 1) { result = new ClassifyResult((DocumentLibraryObjectId)rows[0][0], uri, ((DocumentLibraryObjectId)rows[0][0]).UriFlags); } else { result = new ClassifyResult(uri, ClassificationError.ObjectNotFound); } } } } } catch (SoapException) { result = new ClassifyResult(uri, ClassificationError.ConnectionFailed); } catch (ObjectNotFoundException) { result = new ClassifyResult(uri, ClassificationError.ObjectNotFound); } catch (AccessDeniedException) { result = new ClassifyResult(uri, ClassificationError.AccessDenied); } catch (WebException ex) { result = LinkClassifier.GetClassificationResultFromWebException(uri, ex); } catch { Utils.UndoContext(ref windowsImpersonationContext); throw; } finally { Utils.UndoContext(ref windowsImpersonationContext); } return(result); }
internal SharepointDocumentLibraryItem(SharepointDocumentLibraryItemId id, SharepointSession session, XmlNode dataCache, Schema schema) : base(id, session, dataCache, schema) { this.CultureInfo = id.CultureInfo; }