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)。 SharePoint的任務(wù)列表中有一個(gè)字段叫做“分配對(duì)象”,就是為任務(wù)指派給某個(gè)用戶。該字段的數(shù)據(jù)類型是User型的。在拼Web Service更新命令的串時(shí),并不能像通常的字段一樣直接給一個(gè)用戶名做為值。 關(guān)于如何使用SharePoint提供的WebService進(jìn)行列表的增刪改,可以參考這里。 下面是該欄的相關(guān)信息:
?有一點(diǎn)是肯定的,那就是一定是以字符串的方式來傳值的。經(jīng)過對(duì)列表項(xiàng)的架構(gòu)xml的分析,發(fā)現(xiàn)了這個(gè)字符串的格式為 “UserID;#UserName”。 那么,只需要在調(diào)用UpdateListItem之前調(diào)用另一個(gè)獲取用戶信息的WebService先得到這些信息就可以順利實(shí)現(xiàn)對(duì)包含該類型字段的列表項(xiàng)進(jìn)行更新了。 下面是示例的代碼,在vs2005中調(diào)試通過。其中引用了兩個(gè)SharePoint的WebService.。分別是 Lists Service Web引用Url:http://Server_Name/[sites/][Site_Name/]_vti_bin/Lists.asmx 文件夾名稱:LabDb Users and Groups Service Web引用Url:http://Server_Name/[sites/][Site_Name/]_vti_bin/UserGroup.asmx 文件夾名稱:LabUser using?System.Collections.Generic; using?System.Text; using?System.Xml; namespace?ConsoleTestUpdate { ????class?Program ????{ ????????static?void?Main(string[]?args) ????????{ ????????????LabDb.Lists?listService?=?new?LabDb.Lists(); ????????????LabUser.UserGroup?userService?=?new?LabUser.UserGroup(); ????????????userService.Credentials?=?listService.Credentials?=?System.Net.CredentialCache.DefaultCredentials; ????????????string?UserID?=?""; ????????????string?UserName?=?""; ????????????try ????????????{ ????????????????XmlNode?ndUserInfo?=?userService.GetUserInfo("lab\\sunmoonfire"); ????????????????UserID?=?ndUserInfo.ChildNodes[0].Attributes["ID"].Value.ToString(); ????????????????UserName=?ndUserInfo.ChildNodes[0].Attributes["Name"].Value.ToString(); ???????????????? ????????????} ????????????catch?{?} ????????????if?((UserID?!=?null?&&?UserID?!=?"")?&&?(UserName?!=?""?&&?UserName?!=?null)) ????????????{ ????????????????string?strBatch?=?" ???????????????????????????????" ???????????????????????????????" ???????????????????????????????UserID?+?";#"?+?UserName?+?""; ????????????????XmlDocument?xmlDoc?=?new?System.Xml.XmlDocument(); ????????????????System.Xml.XmlElement?elBatch?=?xmlDoc.CreateElement("Batch"); ????????????????elBatch.SetAttribute("OnError",?"Continue"); ????????????????elBatch.InnerXml?=?strBatch; ????????????????try ????????????????{ ????????????????????XmlNode?ndReturn?=?listService.UpdateListItems("任務(wù)",?elBatch); ????????????????????//XmlNode?ndReturn?=?listService.GetListItems("任務(wù)",null,null,null,null,null);??????//查看返回的列表項(xiàng)的結(jié)構(gòu),用于分析串的組成 ????????????????????Console.WriteLine(ndReturn.OuterXml); ??????? ????????????????} ????????????????catch?(Exception?ex) ????????????????{ ????????????????????Console.WriteLine(ex.Message); ????????????????} ????????????} ????????????else ????????????{ ????????????????Console.WriteLine("bad?parameter"); ????????????} ????????????Console.Read(); ????????} ????} } Sharepoint 可以幫助企業(yè)用戶輕松完成日常工作。 |
溫馨提示:喜歡本站的話,請收藏一下本站!