SharePoint發(fā)行版本有SharePoint2003、SharePoint2007、Sharepoint 2010、SharePoint2013和SharePoint2016。SharePoint提供了功能強(qiáng)大的團(tuán)隊(duì)協(xié)作環(huán)境,使得組織能夠在整個(gè)組織內(nèi)部實(shí)現(xiàn)整合、組織、查找和提供 SharePoint站點(diǎn)。 異構(gòu)應(yīng)用訪問SharePoint的文檔庫或列表時(shí),使用WebService的方式再恰當(dāng)不過了。有朋友問我如何在dotNet Framework 3.0下的應(yīng)用程序中控制SharePoint 2003中的列表項(xiàng)。想一想類似的場(chǎng)景應(yīng)該比較常見,所以寫了下面的demo。以下的代碼在VS2005中測(cè)試通過。 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的唯一標(biāo)識(shí),如果有多個(gè)Method就都列在下面 //Cmd的類型有:New,Update,Delete。分別對(duì)應(yīng)增加,刪除,更新 "New"+ // //ID在增加操作時(shí)只是個(gè)唯一標(biāo)記,可以隨便指定,并不對(duì)應(yīng)到實(shí)際 //listitem的ID。但在刪除和更新時(shí)就必須是實(shí)際的ID了,因?yàn)橐窟@個(gè)來唯一指定一條記錄 "Smf"+ ""; XmlDocument xmlDoc = new XmlDocument(); XmlElement elBatch = xmlDoc.CreateElement("Batch"); //Batch元素下面的這些Attribue是可選的 elBatch.SetAttribute("OnError", "Continue"); //指定出錯(cuò)后是返回還是繼續(xù)下一步 elBatch.SetAttribute("ListVersion","1"); //指定列表的版本 elBatch.SetAttribute("ViewName", "654446D3-8E70-4483-B2B6-F87329EAC2D9"); //指定所操作的列表視圖GUID elBatch.InnerXml = strBatch; XmlNode ndReturn = listService.UpdateListItems("Contracts", elBatch); //在名為Contracts的聯(lián)系人列表中增加一條記錄
Console.WriteLine(ndReturn.OuterXml); } } }
Sharepoint 可以幫助企業(yè)用戶輕松完成日常工作。
|