我正在使用下面的代码批量更新共享点列表项,并试图弄清楚我是否也可以使用批量更新来更新项目的内容类型。这适用于 Sharepoint 2010,我只能使用 Web 服务。我无法在任何地方找到一个例子。
public static void UpdateListItems(string SiteURL, string ListName, int[] ItemIDs, List<string> FieldNames, List<object> Values)
{
using (ListsSoapClient ls = GetListSoapClient(SiteURL))
{
XDocument xDoc = new XDocument(new XElement("Batch"));
xDoc.Root.Add(new XAttribute("OnError", "Continue"));
xDoc.Root.Add(new XAttribute("PreCalc", "TRUE"));
int ID = 0;
for (int i = 0; i < ItemIDs.Count(); i++)
{
ID++;
XElement xMethod = new XElement("Method",
new XAttribute("ID", ID),
new XAttribute("Cmd", "Update"),
new XElement("Field",
new XAttribute("Name", "ID"),
ItemIDs[i]
)
);
for (int j = 0; j < FieldNames.Count(); j++)
{
xMethod.Add(new XElement("Field",
new XAttribute("Name", Functions.SPFieldName(FieldNames[j])),
Values[j]
)
);
}
xDoc.Root.Add(xMethod);
}
ls.UpdateListItems(ListName, xDoc.Root);
}
}