internal SharepointList(SharepointListId listId, SharepointSession session, XmlNode dataCache) : base(listId, session, dataCache, SharepointListSchema.Instance) { if (listId.CultureInfo != null) { this.CultureInfo = listId.CultureInfo; return; } if (dataCache.ChildNodes.Count > 0) { foreach (object obj in dataCache.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; if (xmlNode.Name == "RegionalSettings") { using (IEnumerator enumerator2 = xmlNode.GetEnumerator()) { while (enumerator2.MoveNext()) { object obj2 = enumerator2.Current; XmlNode xmlNode2 = (XmlNode)obj2; if (xmlNode2.Name == "Locale") { try { this.CultureInfo = CultureInfo.GetCultureInfo(int.Parse(xmlNode2.InnerText)); listId.CultureInfo = this.CultureInfo; } catch (FormatException) { throw new CorruptDataException(this, Strings.ExCorruptRegionalSetting); } catch (ArgumentException) { throw new CorruptDataException(this, Strings.ExCorruptRegionalSetting); } } } break; } } } if (this.CultureInfo == null) { throw new CorruptDataException(this, Strings.ExCorruptRegionalSetting); } } }
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)); }
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); }
public SharepointDocumentLibraryItem Read(ObjectId objectId, params PropertyDefinition[] propsToReturn) { if (objectId == null) { throw new ArgumentNullException("objectId"); } SharepointItemId sharepointItemId = objectId as SharepointItemId; SharepointListId sharepointListId = base.Id as SharepointListId; if (sharepointItemId == null) { throw new ArgumentException("objectId as SharepointItemId"); } if (sharepointItemId.ListName != sharepointListId.ListName || sharepointItemId.SiteUri != sharepointListId.SiteUri) { throw new ObjectNotFoundException(objectId, Strings.ExObjectNotFound(objectId.ToString())); } return(SharepointDocumentLibraryItem.Read(this.Session, objectId)); }
public List <KeyValuePair <string, Uri> > GetHierarchy() { SharepointListId sharepointListId = base.Id as SharepointListId; List <KeyValuePair <string, Uri> > list = new List <KeyValuePair <string, Uri> >(1); if (sharepointListId.SiteUri.Segments.Length > 1) { list.Add(new KeyValuePair <string, Uri>(sharepointListId.SiteUri.Segments[sharepointListId.SiteUri.Segments.Length - 1].TrimEnd(new char[] { '/', '\\' }), sharepointListId.SiteUri)); } else { list.Add(new KeyValuePair <string, Uri>(sharepointListId.SiteUri.Host, sharepointListId.SiteUri)); } return(list); }
public new static SharepointList Read(SharepointSession session, ObjectId listId) { if (session == null) { throw new ArgumentNullException("session"); } if (listId == null) { throw new ArgumentNullException("listId"); } SharepointListId spListId = listId as SharepointListId; if (spListId == null) { throw new ArgumentException("listId"); } if (spListId.SiteUri != session.Uri) { throw new ObjectNotFoundException(listId, Strings.ExObjectNotFound(listId.ToString())); } if ((spListId.UriFlags & UriFlags.SharepointList) != UriFlags.SharepointList && (spListId.UriFlags & UriFlags.SharepointDocumentLibrary) != UriFlags.SharepointDocumentLibrary) { throw new ArgumentException("listId"); } if (spListId.Cache != null && spListId.Cache.Value.Key == session.Identity.Name) { return(SharepointList.ReadHelper(spListId.Cache.Value.Value, session, spListId)); } return(Utils.DoSharepointTask <SharepointList>(session.Identity, spListId, spListId, false, Utils.MethodType.Read, delegate { using (Lists lists = new Lists(session.Uri.ToString())) { new List <Result <SharepointList> >(); XmlNode xmlNode = lists.GetListAndView(spListId.ListName, null).SelectSingleNode("/sp:List", SharepointHelpers.SharepointNamespaceManager); if (xmlNode != null) { return SharepointList.ReadHelper(xmlNode, session, spListId); } } throw new ObjectNotFoundException(spListId, Strings.ExObjectNotFound(spListId.ToString())); })); }
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); })); }
private ITableView InternalGetView(ListBaseType listBaseType, PredefinedListType predefinedListType, SortBy[] sortBy, params PropertyDefinition[] propsToReturn) { if (propsToReturn == null) { throw new ArgumentNullException("propsToReturn"); } if (propsToReturn.Length == 0) { throw new ArgumentException("propsToReturn"); } EnumValidator.ThrowIfInvalid <ListBaseType>(listBaseType, "listBaseType"); EnumValidator.ThrowIfInvalid <PredefinedListType>(predefinedListType, "listBaseType"); if (listBaseType != ListBaseType.Any && predefinedListType != PredefinedListType.Any) { throw new ArgumentException("listBaseType && predefinedListType"); } return(Utils.DoSharepointTask <ArrayTableView>(this.Identity, this.Id, (SharepointSiteId)this.Id, true, Utils.MethodType.GetView, delegate { List <object[]> list = new List <object[]>(); ArrayTableView result; using (Lists lists = new Lists(this.Uri.ToString())) { lists.Credentials = CredentialCache.DefaultCredentials; foreach (object obj in lists.GetListCollection().SelectNodes("/sp:List", SharepointHelpers.SharepointNamespaceManager)) { XmlNode xmlNode = (XmlNode)obj; object[] valuesFromCAMLView = SharepointHelpers.GetValuesFromCAMLView(SharepointListSchema.Instance, xmlNode, null, new PropertyDefinition[] { SharepointListSchema.ID, SharepointListSchema.ListType, SharepointListSchema.PredefinedListType, SharepointListSchema.IsHidden }); int num = 0; int num2 = num + 1; int num3 = num2 + 1; int num4 = num3 + 1; string text = valuesFromCAMLView[num] as string; if (text != null && valuesFromCAMLView[num2] is int && valuesFromCAMLView[num3] is int && valuesFromCAMLView[num4] is bool && !(bool)valuesFromCAMLView[num4]) { ListBaseType listBaseType2 = (ListBaseType)valuesFromCAMLView[num2]; PredefinedListType predefinedListType2 = (PredefinedListType)valuesFromCAMLView[num3]; if ((listBaseType == ListBaseType.Any || listBaseType == listBaseType2) && (predefinedListType == PredefinedListType.Any || predefinedListType == predefinedListType2)) { SharepointListId sharepointListId; if (listBaseType2 == ListBaseType.DocumentLibrary) { sharepointListId = new SharepointListId(text, this.Uri, null, UriFlags.SharepointDocumentLibrary); } else { sharepointListId = new SharepointListId(text, this.Uri, null, UriFlags.SharepointList); } sharepointListId.Cache = new KeyValuePair <string, XmlNode>?(new KeyValuePair <string, XmlNode>(this.Identity.Name, xmlNode)); object[] valuesFromCAMLView2 = SharepointHelpers.GetValuesFromCAMLView(SharepointListSchema.Instance, xmlNode, null, propsToReturn); for (int i = 0; i < propsToReturn.Length; i++) { DocumentLibraryPropertyDefinition documentLibraryPropertyDefinition = propsToReturn[i] as DocumentLibraryPropertyDefinition; if (documentLibraryPropertyDefinition != null) { if (documentLibraryPropertyDefinition.PropertyId == DocumentLibraryPropertyId.Id) { valuesFromCAMLView2[i] = sharepointListId; } else if (documentLibraryPropertyDefinition.PropertyId == DocumentLibraryPropertyId.Uri) { Uri uri = SharepointHelpers.GetValuesFromCAMLView(SharepointListSchema.Instance, xmlNode, null, new PropertyDefinition[] { SharepointListSchema.DefaultViewUri })[0] as Uri; if (uri != null) { valuesFromCAMLView2[i] = new UriBuilder(sharepointListId.SiteUri.Scheme, sharepointListId.SiteUri.Host, sharepointListId.SiteUri.Port, uri.ToString()).Uri; } } } } list.Add(valuesFromCAMLView2); } } } result = new ArrayTableView(null, sortBy, propsToReturn, list); } return result; })); }
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 SharepointDocumentLibrary(SharepointListId siteId, SharepointSession session, XmlNode dataCache) : base(siteId, session, dataCache) { }
private static SharepointList ReadHelper(XmlNode node, SharepointSession session, SharepointListId spListId) { object[] valuesFromCAMLView = SharepointHelpers.GetValuesFromCAMLView(SharepointListSchema.Instance, node, null, new PropertyDefinition[] { SharepointListSchema.Name, SharepointListSchema.ListType, SharepointListSchema.PredefinedListType }); ListBaseType listBaseType = (ListBaseType)valuesFromCAMLView[1]; spListId.Cache = new KeyValuePair <string, XmlNode>?(new KeyValuePair <string, XmlNode>(session.Identity.Name, node)); if (listBaseType == ListBaseType.DocumentLibrary) { return(new SharepointDocumentLibrary(spListId, session, node)); } return(new SharepointList(spListId, session, node)); }