SPWeb.GetUsageData 方法 (SPUsageReportType, SPUsagePeriodType)
Gets a table that contains information about the usage of a website, based on the specified report type and time interval.
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Function GetUsageData ( _
itemType As SPUsageReportType, _
periodType As SPUsagePeriodType _
) As DataTable
用法
Dim instance As SPWeb
Dim itemType As SPUsageReportType
Dim periodType As SPUsagePeriodType
Dim returnValue As DataTable
returnValue = instance.GetUsageData(itemType, _
periodType)
public DataTable GetUsageData(
SPUsageReportType itemType,
SPUsagePeriodType periodType
)
参数
itemType
类型:Microsoft.SharePoint.Administration.SPUsageReportTypeAn SPUsageReportType value that specifies the type of report to be created.
periodType
类型:Microsoft.SharePoint.Administration.SPUsagePeriodTypeAn SPUsagePeriodType value that specifies the time interval to use in the information that is returned.
返回值
类型:System.Data.DataTable
A System.Data.DataTable object that contains the information.
备注
The GetUsageData method returns only 2000 records from the usage data for the site, while the GetUsageBlob method of Remote Procedure Call (RPC) protocol returns all usage data.
示例
The following code example populates a DataGrid control with information about the number of hits by type of browser that a website received during the last month.
This example requires using directives (Imports in Microsoft Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Administration namespaces.
The example assumes the presence of a DataGrid control.
Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Site_Name")
DataGrid1.DataSource = webSite.GetUsageData(SPUsageReportType.browser, SPUsagePeriodType.lastMonth)
DataGrid1.DataBind()
End Using
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
DataGrid1.DataSource =
oWebsite.GetUsageData(SPUsageReportType.browser, SPUsagePeriodType.lastMonth);
DataGrid1.DataBind();
}
备注
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.