SharePoint 2010 - 以编程方式使用 Web 分析报告






2.50/5 (2投票s)
通过开箱即用的 DLL(类)捕获 Web 分析报告。
引言
最近我被要求以编程方式从 Microsoft SharePoint 2010 中获取 Web 分析报告数据。据我搜索,所有答案都与从数据库中获取数据有关,而本文我将不会关注这种方法,而是使用与 Web 分析报告相关的开箱即用的类。 代码全部使用 C# 语言编写。
背景
您需要安装 VS2010 和 SHAREPOINT 2010。
使用代码
要使用 Web 分析报告数据,我们需要显式引用以下动态链接库(简称 dll)
Microsoft.Office.Server.WebAnalytics
Microsoft.Office.Server.WebAnalytics.UI
有一个名为 AnalyticsReportFunction 的方法,它可以获取所有数据。 这是获取数据的核心代码
Microsoft.Office.Server.WebAnalytics.Reporting.AnalyticsReportFunction a =
new Microsoft.Office.Server.WebAnalytics.Reporting.AnalyticsReportFunction();
foreach (AggregationLevel itm in Enum.GetValues(typeof(AggregationLevel)))
{
lstRepLevel.Items.Add(new ListItem(itm.ToString(), itm.ToString()));
}
foreach (ReportType itm in Enum.GetValues(typeof(ReportType)))
{
lstRepTypes.Items.Add(new ListItem(itm.ToString(), itm.ToString()));
}
object[,] res = a.GetWebAnalyticsReportData(TxtSiteUrl.Text, reportLevel,reportType,DateTime.Parse(txtFromDate.Text),
DateTime.Parse(txtToDate.Text));
祝一切顺利。