Share via


SPDataStore.CreateFilter - Méthode

Enregistre un objet filter sous la forme d'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 CreateFilter ( _
    listUrl As String, _
    filter As Filter _
) As Filter
'Utilisation
Dim instance As SPDataStore
Dim listUrl As String
Dim filter As Filter
Dim returnValue As Filter

returnValue = instance.CreateFilter(listUrl, _
    filter)
public Filter CreateFilter(
    string listUrl,
    Filter filter
)

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.

  • filter
    Type : Microsoft.PerformancePoint.Scorecards.Filter

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

Valeur renvoyée

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

Implémentations

IBIMonitoringStore.CreateFilter(String, Filter)

Exemples

L'exemple de code suivant montre comment utiliser une méthode privée pour créer un filtre et d'appeler CreateFilter(String, Filter) 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.

  • Ajoutez les DLL Microsoft.SharePoint, Microsoft.PerformancePoint.Scorecards.ServerCommon, des Microsoft.PerformancePoint.Scorecards.Store et Microsoft.PerformancePoint.Scorecards.Client en tant que références à votre projet Visual Studio . 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;
    
// Create a member selection filter that uses the Adventure Works sample cube.
//   - filterName is the name for the filter.
//   - listUrl is the server-relative URL of the list to save the filter to. Example: 
//      "/BI Center/Lists/PerformancePoint Content"
//   - ds is the data source to use for the filter.
// This method returns the new filter.
private Filter CreateMemberSelectionFilter(string filterName, string listUrl, DataSource ds)
{
    if (String.IsNullOrEmpty(filterName))
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");

    Filter newFilter = Filter.CreateNew();
    newFilter.Name.Text = filterName;
    newFilter.Description.Text = "Created with the SDK.";
    newFilter.DataSourceLocation = ds.Location;
    newFilter.SubTypeId = ParameterTemplateId.MemberSelection;

    // Define the filter visualization as a multi-select tree.
    newFilter.SelectionMode = FilterSelectionMode.MultiSelect;
    newFilter.Visualization = FilterVisualization.MultiSelectTree.ToString();

    // The parameter definition defines the filter type and query.
    ParameterDefinition parameterDef = new ParameterDefinition();
    newFilter.BeginPoints.Add(parameterDef);
    parameterDef.DisplayName = newFilter.Name.Text;
    parameterDef.DefaultPostFormula = Constants.PostFormulaSourceColumnMoniker;

    // The ParameterProviderId property must match the name of a provider registered in
    // the CustomParameterDataProviders section of the PerformancePoint Services web.config file.
    // The default path to the web.config file is 
    // %ProgramFiles%\Microsoft Office Servers\14.0\WebServices\PpsMonitoringServer.
    parameterDef.ParameterProviderId = "MemberParameterDataProvider";

    // Define the how members are selected from the cube. This type of filter
    // uses MemberParameterDefinition.
    // Selection definitions used by other types of filters are ParameterDefinition,
    // MdxParameterDefinition, and NamedSetParameterDefinition.
    MemberParameterDefinition customDefinition = new MemberParameterDefinition();

    // Create a filter on the Customer Geography dimension.
    // One method is to create a Dimension object manually by hard-coding 
    // the name, as follows.
    customDefinition.Dimension = new Dimension("Customer Geography",
        "[Customer].[Customer Geography]", 
        "Customer Geography Dimension");

    // But as a best practice, you should get the full dimension definition
    // from the cube. This enables full editing within Dashboard Designer.
    // This code assumes it is running on the front-end Web server (for example,
    // in a Web Part), so it uses the service application proxy to call the
    // service application on the back-end server.
    // TODO: Handle exceptions from this call.
    Cube filterCube = BIMonitoringServiceApplicationProxy.Default.GetCube(ds.Location);
    if (filterCube != null)
    {
        try
        {
            customDefinition.Dimension = filterCube.Dimensions["[Customer].[Customer Geography]"];
}
        catch (Exception)
        {
            // TODO: Add error handling.
        }
    }

    // For the filter, use Australia, France, and their child elements.
    Member aus = new Member("[Customer].[Customer Geography].[Country].&[Australia]")
    {
        Caption = "Australia",
        LevelName = "[Customer].[Customer Geography].[Country]"
    };
    Member france = new Member("[Customer].[Customer Geography].[Country].&[France]")
    {
        Caption = "France",
        LevelName = "[Customer].[Customer Geography].[Country]"
    };
    Member ausChildren = (Member) aus.Clone();
    ausChildren.MemberType = MemberType.Operation;
    ausChildren.LevelDepth = 1;
    ausChildren.MemberOperation = new MemberOperationChildren();

    Member franceChildren = (Member) france.Clone();
    franceChildren.MemberType = MemberType.Operation;
    franceChildren.LevelDepth = 1;
    franceChildren.MemberOperation = new MemberOperationChildren();

    customDefinition.Members.Add(aus);
    customDefinition.Members.Add(france);
    customDefinition.Members.Add(ausChildren);
    customDefinition.Members.Add(franceChildren);

    // Define France and Australia as the default selections.
    customDefinition.DefaultMembers.Add(aus);
    customDefinition.DefaultMembers.Add(france);

    parameterDef.CustomDefinition = MemberParameterDefinition.Serialize(customDefinition);

    // Call the service application to get the display data definition.
    // TODO: Handle exceptions from this call.
    System.Data.DataTable dt = 
        BIMonitoringServiceApplicationProxy.Default.GetParameterDisplayData(
            RepositoryLocation.Empty(), 
            newFilter.BeginPoints[0], 
            ds.Location, 
            null);

    if (dt != null)
    {
        parameterDef.DisplayValues = dt.Clone();
        parameterDef.DisplayValues.Rows.Clear();
    }
    else
    {
        // TODO: Add error handling.
    }

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

Voir aussi

Référence

SPDataStore classe

SPDataStore - Membres

Microsoft.PerformancePoint.Scorecards.Store - Espace de noms

Autres ressources

How to: Create filter editors for PerformancePoint Services

How to: Create filter data providers for PerformancePoint Services