Ejemplo n.º 1
0
        /// <summary>
        /// Loads up the collection for document libraries and lists
        /// in a site and creates objects to represent each library and list
        /// so we can refer to them later without having
        /// to call additional web services.
        /// </summary>
        public void LoadDocumentLibraries()
        {
            Lists ws = NewListsWebService();

            try
            {
                XmlNode listNodes = ws.GetListCollection();
                foreach (XmlNode list in listNodes)
                {
                    string serverTemplate = list.Attributes["ServerTemplate"].Value;
                    if (serverTemplate == "101")
                    {
                        string url  = list.Attributes["DefaultViewUrl"].Value;
                        string path = "/";

                        if (url != "")
                        {
                            string   delimStr  = "/";
                            char[]   delimiter = delimStr.ToCharArray();
                            string[] arr       = url.Split(delimiter);
                            path = arr[arr.Length - 3];
                        }

                        string name = list.Attributes["Title"].Value;
                        string guid = list.Attributes["ID"].Value;

                        SharePointDocLib docLib = new SharePointDocLib(siteUrl, name, path, new Guid(guid));
                        docLib.Credentials = Credentials;

                        docLibs.Add(docLib);
                    }
                }
            }
            catch (WebException wex)
            {
                Console.WriteLine(wex.Message);
            }
            catch (SoapException ex)
            {
                Console.WriteLine(ex.Detail.ToString());
            }
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Loads up the collection for document libraries and lists
		/// in a site and creates objects to represent each library and list
		/// so we can refer to them later without having
		/// to call additional web services.
		/// </summary>
		public void LoadDocumentLibraries()
		{
			Lists ws = NewListsWebService();
			try
			{
				XmlNode listNodes = ws.GetListCollection();
				foreach(XmlNode list in listNodes)
				{
					string serverTemplate = list.Attributes["ServerTemplate"].Value;
					if(serverTemplate == "101")
					{
						string url = list.Attributes["DefaultViewUrl"].Value;
						string path = "/";

						if(url != "")
						{
							string delimStr = "/";
							char[] delimiter = delimStr.ToCharArray();
							string[] arr = url.Split(delimiter);
							path = arr[arr.Length - 3];
						}

						string name = list.Attributes["Title"].Value;
						string guid = list.Attributes["ID"].Value;

						SharePointDocLib docLib = new SharePointDocLib(siteUrl, name, path, new Guid(guid));
						docLib.Credentials = Credentials;
						
						docLibs.Add(docLib);
					}
				}
			}
			catch (WebException wex)
			{
				Console.WriteLine(wex.Message);
			}
			catch (SoapException ex)
			{
				Console.WriteLine(ex.Detail.ToString());
			}
		}