public ListItemCollection GetListItems(string listName, string viewName, string query, IEnumerable <string> viewFields, bool splitMetaInfo, int rowLimit, QueryOptions queryOptions) { if (String.IsNullOrEmpty(listName)) { throw new ArgumentNullException("listName"); } XmlDocument viewDoc = new XmlDocument(); XmlElement viewFieldsNode = viewDoc.CreateElement("ViewFields"); if (splitMetaInfo) { viewFieldsNode.SetAttribute("Properties", "TRUE"); } foreach (string field in viewFields) { XmlElement fieldRef = viewDoc.CreateElement("FieldRef"); fieldRef.SetAttribute("Name", field); viewFieldsNode.AppendChild(fieldRef); } XmlDocument queryDoc = null; if (!String.IsNullOrEmpty(query)) { queryDoc = new XmlDocument(); queryDoc.LoadXml(query); } XmlNode response = listService.GetListItems( listName, viewName, queryDoc, viewFieldsNode, rowLimit.ToString(), queryOptions.GetCamlQueryOptions(), null); return(response.GetXElement().GetCamlListItems()); }
public ChangeBatch GetListItemChangesSinceToken( string listName, string viewName, string query, IEnumerable <string> viewFields, bool splitMetaInfo, int rowLimit, QueryOptions queryOptions, string changeToken) { if (String.IsNullOrEmpty(listName)) { throw new ArgumentNullException("listName"); } XmlDocument viewDoc = new XmlDocument(); XmlElement viewFieldsNode = viewDoc.CreateElement("ViewFields"); if (splitMetaInfo) { viewFieldsNode.SetAttribute("Properties", "TRUE"); } foreach (string field in viewFields) { XmlElement fieldRef = viewDoc.CreateElement("FieldRef"); fieldRef.SetAttribute("Name", field); viewFieldsNode.AppendChild(fieldRef); } XmlDocument queryDoc = null; if (!String.IsNullOrEmpty(query)) { queryDoc = new XmlDocument(); queryDoc.LoadXml(query); } XmlNode response = listService.GetListItemChangesSinceToken( listName, viewName, queryDoc, viewFieldsNode, rowLimit.ToString(), queryOptions.GetCamlQueryOptions(), changeToken, null); ChangeBatch batch = response.GetXElement().GetCamlChangeBatch(); // catch the case where no changes in list returns the same token if (batch.ChangeLog.Count == 0 && batch.NextChangeBatch == changeToken) { // re-query with empty token in order to get the very latest change token // and avoid token expiration XmlNode dummyResponse = listService.GetListItemChangesSinceToken( listName, viewName, queryDoc, viewFieldsNode, "10", queryOptions.GetCamlQueryOptions(), null, null); ChangeBatch batch2 = response.GetXElement().GetCamlChangeBatch(); batch.ChangeLog.NextLastChangeToken = batch2.ChangeLog.NextLastChangeToken; } return(batch); }