![]() |
#1 |
Участник
|
mscrmblog: Getting total document count for a SharePoint site
Источник: http://mscrmblog.net/2013/11/07/gett...arepoint-site/
============== I had a customer wanting to find out the total number of documents under a site. Quickly came up with a Webservice method that ran a query on all the lists on the site to get a total count. Run this from a ribbon or in your custom web app solution in SharePoint [WebMethod] public string GetDocumentCount(string webUrl) { var DocumentCountTxt = new StringBuilder(); try { int totalItems = 0; string siteName = ""; using (var site = new SPSite(webUrl)) { using (SPWeb web = site.OpenWeb()) { siteName = web.Title; var query = new SPQuery(); query.ViewAttributes = "Scope='Recursive'"; foreach (SPList list in web.Lists) { totalItems += list.GetItems(query).Count; } } } DocumentCountTxt.Append(String.Format("Found a total of {0} Documents In '{1}'", totalItems, siteName)); } catch (Exception ex) { DocumentCountTxt.Append(String.Format("An Error has occured: {0}", ex.Message)); } return DocumentCountTxt.ToString(); } Источник: http://mscrmblog.net/2013/11/07/gett...arepoint-site/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|