SPWeb.GetUsageData 方法 (SPUsageReportType, SPUsagePeriodType, Int32, DateTime)

Gets a table that contains information about the usage of a website based on the specified report type, time interval, number of columns to display, and last day to display.

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public Function GetUsageData ( _
    itemType As SPUsageReportType, _
    periodType As SPUsagePeriodType, _
    numColsToDisplay As Integer, _
    lastDayToDisplay As DateTime _
) As DataTable
用法
Dim instance As SPWeb
Dim itemType As SPUsageReportType
Dim periodType As SPUsagePeriodType
Dim numColsToDisplay As Integer
Dim lastDayToDisplay As DateTime
Dim returnValue As DataTable

returnValue = instance.GetUsageData(itemType, _
    periodType, numColsToDisplay, lastDayToDisplay)
public DataTable GetUsageData(
    SPUsageReportType itemType,
    SPUsagePeriodType periodType,
    int numColsToDisplay,
    DateTime lastDayToDisplay
)

参数

  • numColsToDisplay
    类型:System.Int32

    A 32-bit integer that specifies the number of columns to return in the table.

  • lastDayToDisplay
    类型:System.DateTime

    A System.DateTime value that specifies the most recent day to represent in the information that is returned. The value that is passed in this parameter must specify a time that is greater than or equal to the last time usage processing was run for the site.

返回值

类型:System.Data.DataTable
A System.Data.DataTable object that contains the information.

备注

The GetUsageData method returns undefined results when invalid parameters are passed (for example, a date from 100 years ago). If the value passed in the numColsToDisplay parameter is out of range, 31 columns are returned.

This 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 12 columns of information about the usage of a site, starting from yesterday.

This example also assumes the presence of a DataGrid control.

Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Site_Name")
    Dim dateValue As System.DateTime = System.DateTime.Today
    dateValue = dateValue.AddDays(- 1)

    DataGrid1.DataSource = webSite.GetUsageData(SPUsageReportType.user, SPUsagePeriodType.day, 12, dateValue)

    DataGrid1.DataBind()
End Using
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
    System.DateTime dtValue = System.DateTime.Today;
    dtValue = dtValue.AddDays(-1);
    DataGrid1.DataSource = 
        oWebsite.GetUsageData(SPUsageReportType.user, SPUsagePeriodType.day, 
        12, dtValue);
    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.

另请参阅

引用

SPWeb 类

SPWeb 成员

GetUsageData 重载

Microsoft.SharePoint 命名空间