예제 #1
0
 /// <summary>
 /// Creates a new <see cref="SharePointListItem"/> instance.
 /// </summary>
 /// <param name="containingList">Containing list.</param>
 /// <param name="id">Id.</param>
 /// <param name="guid">Guid.</param>
 public SharePointListItem(SharePointList containingList, long id, Guid guid) : base(containingList.SiteURL)
 {
     this.id   = id;
     this.guid = guid;
     list      = containingList;
 }
예제 #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 LoadLists()
		{
			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;

						SharePointList subList = new SharePointList(siteUrl, name, path, new Guid(guid));
						subList.Credentials = Credentials;

						lists.Add(subList);
					}
				}
			}
			catch (WebException wex)
			{
				Console.WriteLine(wex.Message);
			}
			catch (SoapException ex)
			{
				Console.WriteLine(ex.Detail.ToString());
			}
		}
예제 #3
0
		/// <summary>
		/// Creates a new list in the current site.
		/// </summary>
		/// <param name="listName">Name of the list</param>
		/// <param name="listDescription">Description for the list</param>
		/// <param name="templateId">Template ID to use when creating the list. 100 is for custom
		/// list. For other types please refer to the SharePoint SDK</param>
		/// <returns>A new <see cref="SharePointList"/> object.</returns>
		public SharePointList CreateList(string listName, string listDescription, int templateId)
		{
			Lists lws = NewListsWebService();
			lws.AddList(listName, listDescription, templateId);
			XmlNode nodeList = lws.GetList(listName);
			Guid listGuid = new Guid(nodeList.Attributes["ID"].Value.ToString());
			
			string version = nodeList.Attributes["Version"].Value.ToString();
			string convertedListName = listName.Replace(" ", "%20");
			string listPath = siteUrl + "/Lists/" + convertedListName;
			
			SharePointList list = new SharePointList(siteUrl, listName, listPath, listGuid);
			list.Version = version;
			return list;
		}
예제 #4
0
		/// <summary>
		/// Creates a new <see cref="SharePointListItem"/> instance.
		/// </summary>
		/// <param name="containingList">Containing list.</param>
		/// <param name="id">Id.</param>
		/// <param name="guid">Guid.</param>
		public SharePointListItem(SharePointList containingList, long id, Guid guid) : base(containingList.SiteURL)
		{
			this.id = id;
			this.guid = guid;
			list = containingList;
		}