Share via


SPDataStore.CreateReportView - Méthode

Enregistre un objet report en tant que type de contenu dans une liste SharePoint.

Espace de noms :  Microsoft.PerformancePoint.Scorecards.Store
Assembly :  Microsoft.PerformancePoint.Scorecards.Store (dans Microsoft.PerformancePoint.Scorecards.Store.dll)

Syntaxe

'Déclaration
Public Function CreateReportView ( _
    listUrl As String, _
    reportView As ReportView _
) As ReportView
'Utilisation
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
)

Paramètres

  • listUrl
    Type : System.String

    L'URL relative de serveur de la liste SharePoint pour enregistrer l'objet. Exemple : /BI Center/Lists/PerformancePoint Content.

  • reportView
    Type : Microsoft.PerformancePoint.Scorecards.ReportView

    Objet report à enregistrer, qui spécifie les valeurs de la propriété requise Name . Pour les rapports personnalisés, reportView doit également spécifier la propriété SubTypeId , et la valeur doit correspondre à l'attribut subType spécifiée pour le rapport personnalisé dans le fichier web.config pour PerformancePoint Services dans SharePoint Server 2013.

Valeur renvoyée

Type : Microsoft.PerformancePoint.Scorecards.ReportView
Le nouvel objet, qui contient des informations mises à jour ce son numéro de version et d'emplacement.

Implémentations

IBIMonitoringStore.CreateReportView(String, ReportView)

Exemples

L'exemple de code suivant montre comment utiliser une méthode privée pour créer un rapport et d'appeler CreateReportView(String, ReportView) pour l'enregistrer dans le référentiel.

Pour pouvoir compiler cet exemple de code, vous procédez comme suit :

  • Configurer votre environnement de développement et créer un projet de bibliothèque de classes c# dans Visual Studio. Pour plus d'informations sur la configuration d'un environnement de développement, voir Configurer un environnement de développement général pour SharePoint 2013.

  • En tant que références à votre projet, ajoutez le Microsoft.PerformancePoint.Scorecards.Client, Microsoft.PerformancePoint.Scorecards.ServerCommon, Microsoft.PerformancePoint.Scorecards.Store et fichiers DLL System.Drawing. Pour plus d'informations sur PerformancePoint Services DLL, voir PerformancePoint Services DLLs Used in Development Scenarios.

  • Ajoutez les directives using suivantes à votre classe.

    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);
}

Voir aussi

Référence

SPDataStore classe

SPDataStore - Membres

Microsoft.PerformancePoint.Scorecards.Store - Espace de noms

Autres ressources

How to: Create report editors for PerformancePoint Services

How to: Create report renderers for PerformancePoint Services