다음을 통해 공유


SPDataStore.CreateDashboard Method

Saves a dashboard object as a content type in a SharePoint list.

Namespace:  Microsoft.PerformancePoint.Scorecards.Store
Assembly:  Microsoft.PerformancePoint.Scorecards.Store (in Microsoft.PerformancePoint.Scorecards.Store.dll)

Syntax

'Declaration
Public Function CreateDashboard ( _
    listUrl As String, _
    dashboard As Dashboard _
) As Dashboard
'Usage
Dim instance As SPDataStore
Dim listUrl As String
Dim dashboard As Dashboard
Dim returnValue As Dashboard

returnValue = instance.CreateDashboard(listUrl, _
    dashboard)
public Dashboard CreateDashboard(
    string listUrl,
    Dashboard dashboard
)

Parameters

  • listUrl
    Type: System.String

    The server-relative URL of the SharePoint list to save the object to. Example: /BI Center/Lists/PerformancePoint Content.

Return Value

Type: Microsoft.PerformancePoint.Scorecards.Dashboard
The new object, which contains updated information such its location and version number.

Implements

IBIMonitoringStore.CreateDashboard(String, Dashboard)

Remarks

This method saves a dashboard object as a content type in a SharePoint list; it does not deploy the dashboard for viewing. Dashboards are deployed to SharePoint for viewing from PerformancePoint Dashboard Designer, and deployed dashboards are stored in separate document libraries.

Examples

The following code example shows how to use a private method to create a dashboard and to call CreateDashboard(String, Dashboard) to save it to the repository.

Before you can compile this code example, you must do the following:

// Create a dashboard that contains a scorecard and a report, based on the following parameters:
//   - dashboardName is the name for the dashboard.
//   - listUrl is the server-relative URL of the list to save the dashboard to. Example: 
//      "/BI Center/Lists/PerformancePoint Content"
//   - sc is a scorecard to add to the dashboard.
//   - report is a report to add to the dashboard.
// This method returns the new dashboard.
private Dashboard CreateDashboard(string dashboardName, string listUrl, Scorecard sc, ReportView report)
{
    if (String.IsNullOrEmpty(dashboardName))
        throw new ArgumentException("The name must not be null or empty.");
    if (String.IsNullOrEmpty(listUrl))
        throw new ArgumentException("The list URL must not be null or empty.");
    if (null == sc)
        throw new ArgumentNullException("sc");
    if (null == report)
        throw new ArgumentNullException("report");

    Dashboard newDashboard = Dashboard.CreateNew();
    newDashboard.Name.Text = dashboardName;
    newDashboard.Description.Text = "Created with the SDK.";

    // The dashboard has a single page with two zones.
    DashboardElementContainer page = new DashboardElementContainer();
    page.Guid = Guid.NewGuid();
    page.Orientation = LayoutOrientation.VerticalTopJustified;
    newDashboard.TemplateType = DashboardTemplateId.Rows2;
    for (int rowNumber = 1; rowNumber <= 2; rowNumber++)
    {
        DashboardElementContainer row = new DashboardElementContainer();
        row.Guid = Guid.NewGuid();
        row.Name.Text = String.Format("Row {0}", rowNumber);
        row.Height = new DashboardElementSize();
        row.Height.Units = System.Windows.Forms.SizeType.Percent;
        row.Height.Measurement = 50; // 50 percent
        row.Orientation = LayoutOrientation.HorizontalLeftJustified;

        DashboardItem newItem = new DashboardItem();
        newItem.Guid = Guid.NewGuid();
        newItem.Height.Measurement = 50;
        newItem.Height.Units = System.Windows.Forms.SizeType.Percent;
        FirstClassElement currentElement;
        if (rowNumber == 1)
        {
            // The scorecard in the first zone.
            currentElement = sc;
            newItem.AutoSizeHeight = true;
            newItem.AutoSizeWidth = true;
        }
        else
        {
            // The report view in the second zone.
            currentElement = report;
            newItem.AutoSizeHeight = false;
            newItem.AutoSizeWidth = false;
        }
        newItem.UnderlyingElementType = currentElement.GetType();
        newItem.UnderlyingElementLocation = currentElement.Location;
        row.DashboardElements.Add(newItem);
        page.DashboardElements.Add(row);
    }

    newDashboard.Pages.Add(page);

    // Call the CreateDashboard method to save the new dashboard to the specified list.
    // TODO: Handle exceptions from this call.
    return SPDataStore.GlobalDataStore.CreateDashboard(listUrl, newDashboard);
}

See Also

Reference

SPDataStore Class

SPDataStore Members

Microsoft.PerformancePoint.Scorecards.Store Namespace