SharePoint發行版本有SharePoint2003、SharePoint2007、Sharepoint 2010、SharePoint2013和SharePoint2016。SharePoint提供了功能強大的團隊協作環境,使得組織能夠在整個組織內部實現整合、組織、查找和提供 SharePoint站點。 SharePoint的任務列表中有一個字段叫做“分配對象”,就是為任務指派給某個用戶。該字段的數據類型是User型的。在拼Web Service更新命令的串時,并不能像通常的字段一樣直接給一個用戶名做為值。 關于如何使用SharePoint提供的WebService進行列表的增刪改,可以參考這里。 下面是該欄的相關信息:
?有一點是肯定的,那就是一定是以字符串的方式來傳值的。經過對列表項的架構xml的分析,發現了這個字符串的格式為 “UserID;#UserName”。 那么,只需要在調用UpdateListItem之前調用另一個獲取用戶信息的WebService先得到這些信息就可以順利實現對包含該類型字段的列表項進行更新了。 下面是示例的代碼,在vs2005中調試通過。其中引用了兩個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("任務",?elBatch); ????????????????????//XmlNode?ndReturn?=?listService.GetListItems("任務",null,null,null,null,null);??????//查看返回的列表項的結構,用于分析串的組成 ????????????????????Console.WriteLine(ndReturn.OuterXml); ??????? ????????????????} ????????????????catch?(Exception?ex) ????????????????{ ????????????????????Console.WriteLine(ex.Message); ????????????????} ????????????} ????????????else ????????????{ ????????????????Console.WriteLine("bad?parameter"); ????????????} ????????????Console.Read(); ????????} ????} } Sharepoint 可以幫助企業用戶輕松完成日常工作。 |
溫馨提示:喜歡本站的話,請收藏一下本站!