Share via


SPDataStore.CreateReportView Method

Saves a report 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 CreateReportView ( _
    listUrl As String, _
    reportView As ReportView _
) As ReportView
'Usage
Dim instance As SPDataStore
Dim listUrl As String
Dim reportView As ReportView
Dim returnValue As ReportView

returnValue = instance.CreateReportView(listUrl, _
    reportView)
public ReportView CreateReportView(
    string listUrl,
    ReportView reportView
)

Parameters

  • listUrl
    Type: System.String

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

  • reportView
    Type: Microsoft.PerformancePoint.Scorecards.ReportView

    The report object to save, which specifies values for the required Name property. For custom reports, reportView must also specify the SubTypeId property, and the value must match the subType attribute specified for the custom report in the web.config file for PerformancePoint Services in Microsoft SharePoint Server 2010.

Return Value

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

Implements

IBIMonitoringStore.CreateReportView(String, ReportView)

Examples

The following code example shows how to use a private method to create a report and to call CreateReportView(String, ReportView) to save it to the repository.

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

  • Configure your development environment and create a C# class library project in Visual Studio. For information about configuring a development environment, see Setting Up the Development Environment for SharePoint 2010 on Windows Vista, Windows 7, and Windows Server 2008.

  • Add the Microsoft.PerformancePoint.Scorecards.Client, Microsoft.PerformancePoint.Scorecards.ServerCommon, Microsoft.PerformancePoint.Scorecards.Store, and System.Drawing DLLs as references to your project. For more information about PerformancePoint Services in Microsoft SharePoint Server 2010 DLLs, see PerformancePoint Services DLLs Used in Development Scenarios.

  • Add the following using directives to your class.

    using Microsoft.PerformancePoint.Scorecards;
    using Microsoft.PerformancePoint.Scorecards.Analytics;
    using Microsoft.PerformancePoint.Scorecards.OlapReportViews;
    using Microsoft.PerformancePoint.Scorecards.Store;
    using System.Drawing;
    using System.Globalization;
    using System.IO;
    using System.Xml.Serialization;
    
// Create an analytic report view, based on the following parameters:
//   - reportName is the name for the report.
//   - listUrl is the server-relative URL of the list to save the report to. Example: 
//      "/BI Center/Lists/PerformancePoint Content" 
//   - ds is the data source to use for the report.
// This method returns the new report.
private ReportView CreateReport(string reportName, string listUrl, DataSource ds)
{
    if (String.IsNullOrEmpty(reportName))
        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 == ds)
        throw new ArgumentNullException("ds");

    ReportView newReport = new ReportView();
    newReport.Name.Text = reportName;
    newReport.Description.Text = "Created with the SDK.";

    // Define the report type as an Analytic Chart, which uses an MDX query.
    newReport.TypeName = ReportViewNames.AnalyticChart;

    // Create an OLAPReportViewData object, which is the core of an analytic view. This object will be serialized
    // into the report's CustomData property.
    OLAPReportViewData olapViewData = new OLAPReportViewData();
    olapViewData.QueryState = new QueryState();

    // Set up the data source in the query state so the "Revert to Design mode" option in
    // Dashboard Designer works correctly.
    olapViewData.QueryState.DataSourceLocation = ds.Location;

    // Use a QueryData object for MDX queries.
    olapViewData.QueryState.IsEnabled = false;

    // The OLAPQueryData object holds the data source location and the MDX query.
    olapViewData.QueryData = new OLAPQueryData();
    olapViewData.QueryData.DataSourceLocation = ds.Location;
    olapViewData.QueryData.TokenizedMDX = "SELECT HIERARCHIZE( { DESCENDANTS( [Date].[Calendar].[Calendar Year].&[2002], [Date].[Calendar].[Calendar Quarter] )," +
        "DESCENDANTS( [Date].[Calendar].[Calendar Year].&[2003], [Date].[Calendar].[Calendar Quarter] ) } ) ON COLUMNS, " +
        "{ [Customer].[Customer Geography].[All Customers].CHILDREN } ON ROWS " +
        "FROM [Direct Sales] WHERE ( [Measures].[Internet Gross Profit] ) " +
        "CELL PROPERTIES VALUE, FORMATTED_VALUE, CELL_ORDINAL, FONT_FLAGS, FORE_COLOR, BACK_COLOR";

    // Define chart settings.
    AnalyticChartReportViewData chartViewData = new AnalyticChartReportViewData();
    chartViewData.ChartType = AnalyticChartType.Line;
    chartViewData.BackgroundColor = Color.FloralWhite;

    // Serialize the chart settings into the ReportViewData property.
    XmlSerializer chartViewSerializer = new XmlSerializer(typeof(AnalyticChartReportViewData));
    StringBuilder buffer = new StringBuilder(1024);
    using (StringWriter sw = new StringWriter(buffer, CultureInfo.InvariantCulture))
    {
        chartViewSerializer.Serialize(sw, chartViewData);

    }
    olapViewData.ReportViewData = buffer.ToString();

    // Set the CustomData property to the serialized OLAPReportViewData object.
    newReport.CustomData = OLAPReportViewData.Serialize(olapViewData);

    // Set the filter's beginpoints and endpoints.
    newReport.InitBeginPoints();
    newReport.InitEndPoints();

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

See Also

Reference

SPDataStore Class

SPDataStore Members

Microsoft.PerformancePoint.Scorecards.Store Namespace

Other Resources

Create Report Extensions for PerformancePoint Services