First cut at a service method that returns unlimited documents from a library, in chunks.
git-svn-id: https://svn.apache.org/repos/asf/manifoldcf/integration/sharepoint-2010/trunk@1364381 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webservice/MCPermissions.cs b/webservice/MCPermissions.cs
index 1a9f9f3..7d379ab 100644
--- a/webservice/MCPermissions.cs
+++ b/webservice/MCPermissions.cs
@@ -88,8 +88,58 @@
[WebMethod(Description = "Returns the list of contents of a library without interference from administrator-set limits.")]
public XmlNode GetListItems(string listName, string startRow, string rowLimit)
{
- // MHL - add code that lists items and allows paging through the results using startRow and rowLimit
- return null;
+ XmlNode retVal = null;
+
+ try
+ {
+ uint startRowParam = Convert.ToUInt32(startRow);
+ uint rowLimitParam = Convert.ToUInt32(rowLimit);
+
+ using (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb)
+ {
+
+ oWebsiteRoot.Lists.IncludeRootFolder = true;
+ SPList oList = oWebsiteRoot.Lists[listName];
+
+ SPQuery listQuery = new SPQuery();
+ listQuery.QueryThrottleMode = SPQueryThrottleOption.Override;
+ listQuery.RowLimit = startRowParam + rowLimitParam;
+
+ SPListItemCollection collListItems = oList.GetItems(listQuery);
+
+ XmlDocument doc = new XmlDocument();
+ retVal = doc.CreateElement("GetListItems",
+ "http://schemas.microsoft.com/sharepoint/soap/directory/");
+ XmlNode getListItemsNode = doc.CreateElement("GetListItemsResponse");
+
+ uint counter = 0;
+ foreach (SPListItem oListItem in collListItems)
+ {
+ if (counter >= startRowParam)
+ {
+ XmlNode resultNode = doc.CreateElement("GetListItemsResult");
+ XmlAttribute idAttribute = doc.CreateAttribute("ID");
+ idAttribute.Value = Convert.ToString(oListItem.ID);
+ resultNode.Attributes.Append(idAttribute);
+ getListItemsNode.AppendChild(resultNode);
+ }
+ counter++;
+ }
+
+ retVal.AppendChild(getListItemsNode);
+ }
+ }
+ catch (SoapException soapEx)
+ {
+ throw soapEx;
+ }
+ catch (Exception ex)
+ {
+ EventLog.WriteEntry("MCPermissions.asmx", ex.Message);
+ throw RaiseException(ex.Message, "1010", ex.Source);
+ }
+
+ return retVal;
}
#endregion