Share via


SPDataStore.CreateScorecard - Méthode

Enregistre un objet de la carte de performance comme un 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 CreateScorecard ( _
    listUrl As String, _
    newElement As Scorecard _
) As Scorecard
'Utilisation
Dim instance As SPDataStore
Dim listUrl As String
Dim newElement As Scorecard
Dim returnValue As Scorecard

returnValue = instance.CreateScorecard(listUrl, _
    newElement)
public Scorecard CreateScorecard(
    string listUrl,
    Scorecard newElement
)

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.

Valeur renvoyée

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

Implémentations

IBIMonitoringStore.CreateScorecard(String, Scorecard)

Exemples

L'exemple de code suivant montre comment utiliser une méthode privée pour créer une carte de performance et d'appeler CreateScorecard(String, Scorecard) 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.Store;
    using System.Drawing;
    
// Create a scorecard that contains two KPIs, based on the following parameters:
//   - scorecardName is the name for the scorecard.
//   - listUrl is the server-relative URL of the list to save the scorecard to. Example: 
//      "/BI Center/lists/PerformancePoint Content"
//   - kpi1 is the first KPI.
//   - kpi2 is the second KPI.
// This method returns the new scorecard.
private Scorecard CreateScorecard(string scorecardName, string listUrl, Kpi kpi1, Kpi kpi2)
{
    if (String.IsNullOrEmpty(scorecardName))
        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 == kpi1)
        throw new ArgumentNullException("kpi1");
    if (null == kpi2)
        throw new ArgumentNullException("kpi2");

    // Create a reference to the global data store for convenience.
    SPDataStore globalStore = SPDataStore.GlobalDataStore;  
    List<string> actualHeaders = new List<string>();
    List<string> targetHeaders = new List<string>();

    Scorecard newScorecard = Scorecard.CreateNew();
    newScorecard.Name.Text = scorecardName;
    newScorecard.Description.Text = "Created with the SDK.";

    // Define the fonts and colors for the grid.
    Font scFont = new Font(FontFamily.GenericSansSerif, 9);
    newScorecard.ConfiguredView = ConfiguredView.CreateDefaultConfiguredView(
        scFont,
        Color.White,
        Color.Black,
        Color.LightSteelBlue,
        Color.Bisque,
        Color.DimGray);

    KpiCollection kpis = new KpiCollection();
    kpis.Add(kpi1);
    kpis.Add(kpi2);
    GridViewDefinition gvd = newScorecard.ConfiguredView.GridViewDefinition;

    foreach (Kpi includedKpi in kpis)
    {
        // Add the KPIs to the scorecard.
        GridHeaderItem rowItem = GridHeaderItem.CreateKpiHeader(includedKpi.Location);
        gvd.RootRowHeader.Children.Add(rowItem);

        // Find unique actuals.
        for (int i = 0; i < includedKpi.Actuals.Count; i++)
        {
            if (!actualHeaders.Contains(includedKpi.Actuals[i].Name.Text))
            {
        actualHeaders.Add(includedKpi.Actuals[i].Name.Text);
            }
        }

        // Find unique targets.
        for (int i = 0; i < includedKpi.Targets.Count; i++)
        {
            if (!targetHeaders.Contains(includedKpi.Targets[i].Name.Text))
            {
                targetHeaders.Add(includedKpi.Targets[i].Name.Text);
            }
        }
    }

    // Add the actual headings to the scorecard.
    foreach (string actualHeader in actualHeaders)
    {
        GridHeaderItem actualItem = GridHeaderItem.CreateActualHeader(actualHeader);
        gvd.RootColumnHeader.Children.Add(actualItem);
    }

    // Add the target headings to the scorecard.
    foreach (string targetHeader in targetHeaders)
    {
        GridHeaderItem targetItem = GridHeaderItem.CreateTargetHeader(targetHeader);
        gvd.RootColumnHeader.Children.Add(targetItem);
    }

    gvd.RootColumnHeader.LinkTreeFromRoot();
    gvd.RootRowHeader.LinkTreeFromRoot();

    // Call the CreateScorecard method to save the new scorecard to the specified list.
    // TODO: Handle exceptions from this call.
    return globalStore.CreateScorecard(listUrl, newScorecard);
}

Voir aussi

Référence

SPDataStore classe

SPDataStore - Membres

Microsoft.PerformancePoint.Scorecards.Store - Espace de noms