SharePoint發行版本有SharePoint2003、SharePoint2007、Sharepoint 2010、SharePoint2013和SharePoint2016。SharePoint提供了功能強大的團隊協作環境,使得組織能夠在整個組織內部實現整合、組織、查找和提供 SharePoint站點。 異構應用訪問SharePoint的文檔庫或列表時,使用WebService的方式再恰當不過了。有朋友問我如何在dotNet Framework 3.0下的應用程序中控制SharePoint 2003中的列表項。想一想類似的場景應該比較常見,所以寫了下面的demo。以下的代碼在VS2005中測試通過。 using System; using System.Xml; using System.Collections.Generic; using System.Text; namespace ConsoleDemo { class Program { static void Main(string[] args) { try { test(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("END"); Console.Read(); } private static void test() { LabPortal.Lists listService = new ConsoleDemo.LabPortal.Lists(); listService.Credentials = System.Net.CredentialCache.DefaultCredentials; string strBatch = ""+ // //ID是Method的唯一標識,如果有多個Method就都列在下面 //Cmd的類型有:New,Update,Delete。分別對應增加,刪除,更新 "New"+ // //ID在增加操作時只是個唯一標記,可以隨便指定,并不對應到實際 //listitem的ID。但在刪除和更新時就必須是實際的ID了,因為要靠這個來唯一指定一條記錄 "Smf"+ ""; XmlDocument xmlDoc = new XmlDocument(); XmlElement elBatch = xmlDoc.CreateElement("Batch"); //Batch元素下面的這些Attribue是可選的 elBatch.SetAttribute("OnError", "Continue"); //指定出錯后是返回還是繼續下一步 elBatch.SetAttribute("ListVersion","1"); //指定列表的版本 elBatch.SetAttribute("ViewName", "654446D3-8E70-4483-B2B6-F87329EAC2D9"); //指定所操作的列表視圖GUID elBatch.InnerXml = strBatch; XmlNode ndReturn = listService.UpdateListItems("Contracts", elBatch); //在名為Contracts的聯系人列表中增加一條記錄
Console.WriteLine(ndReturn.OuterXml); } } }
Sharepoint 可以幫助企業用戶輕松完成日常工作。
|