先看代码:
private SPListWS.Lists _ws;private int _rowLimit = 100; //Add by spring yang ////// /// /// public void UpdateQARelateField(ListlistResults) { List listResultsPart = null; if (listResults != null && listResults.Count > 0) { for (int i = 0; i < listResults.Count / _rowLimit + 1; i++) { if (i == listResults.Count / _rowLimit) { listResultsPart = listResults.GetRange(i * _rowLimit, listResults.Count - i * _rowLimit); } else { listResultsPart = listResults.GetRange(i * _rowLimit, _rowLimit); } UpdateQARelateFieldLimit(listResultsPart); } } } private void UpdateQARelateFieldLimit(List listResults) { StringBuilder xml = new StringBuilder(); xml.Append(" "); foreach (SingleResultBE item in listResults) { if (!string.IsNullOrEmpty(item.ListItemId.ToString()) && (!string.IsNullOrEmpty(item.QARelate) || !string.IsNullOrEmpty(item.RelateBy))) { xml.Append(" "); //Get the Batch node XmlDocument doc = new XmlDocument(); doc.LoadXml(xml.ToString()); XmlNode batchNode = doc.SelectSingleNode("//Batch"); _logger.Log("Started batch update list Items' readonly fields"); XmlNode result = null; try { //Call the webservice result = _ws.UpdateListItems(Properties.ListName, batchNode); } catch (Exception ex) { //_logger.Log(String.Format("Error update Items. Exception: {0}. Stack Trace: {1}", ex.Message, ex.StackTrace)); } UpdateResultBE insertResult = new UpdateResultBE(result, Properties); if (Properties.IsNeedApprove) { this.ApproveItemsByInsertResult(insertResult); } }"); xml.Append(" "); } } xml.Append("" + item.ListItemId + " "); if (!string.IsNullOrEmpty(item.QARelate)) { xml.AppendFormat("", item.QARelate); } if (!string.IsNullOrEmpty(item.RelateBy)) { xml.AppendFormat(" ", item.RelateBy); } xml.Append("