快捷搜索:

SharePoint SPListWS.Lists 调用数据量过大时报错的处理

先看代码:

private SPListWS.Lists _ws;

private int _rowLimit = 100;

//Add by spring yang

//////

//////

public void UpdateQARelateField(List listResults){

List listResultsPart = null;

if (listResults != null && listResults.Count > 0){

for (int i = 0; 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(" + item.ListItemId + "\" Cmd=\"Update\">");xml.Append("" + item.ListItemId + "");

if (!string.IsNullOrEmpty(item.QARelate)){

xml.AppendFormat("", item.QARelate);}

if (!string.IsNullOrEmpty(item.RelateBy)){

xml.AppendFormat("", item.RelateBy);}

xml.Append("");}

}

xml.Append("");

//Get the Batch nodeXmlDocument 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);

}}

您可能还会对下面的文章感兴趣: