Freigeben über


SPDataStore.CreateFilter-Methode

Speichert ein Filterobjekt als Inhaltstyp in einer SharePoint-Liste.

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

Syntax

'Declaration
Public Function CreateFilter ( _
    listUrl As String, _
    filter As Filter _
) As Filter
'Usage
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
)

Parameter

  • listUrl
    Typ: System.String

    Die serverrelative URL der SharePoint-Liste um das Objekt zu speichern. Beispiel: /BI Center/Lists/PerformancePoint Content.

  • filter
    Typ: Microsoft.PerformancePoint.Scorecards.Filter

    Das Filter-Objekt zu speichern, das Werte für die erforderlichen Name Eigenschaft angibt. Für benutzerdefinierte Filter filter müssen auch die SubTypeId -Eigenschaft angeben, und der Wert muss das subType -Attribut für den benutzerdefinierten Filter in der Datei web.config für die PerformancePoint-Dienste in SharePoint Server 2013angegebenen übereinstimmen.

Rückgabewert

Typ: Microsoft.PerformancePoint.Scorecards.Filter
Das neue Objekt, das enthält aktualisierte Informationen so ihre Nummer und Version.

Implementiert

IBIMonitoringStore.CreateFilter(String, Filter)

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie Sie eine private Methode verwenden, um einen Filter zu erstellen und Aufrufen von CreateFilter(String, Filter) , um sie im Repository zu speichern.

Bevor Sie dieses Codebeispiel kompilieren können, müssen Sie Folgendes tun:

  • Konfigurieren Sie die Entwicklungsumgebung, und erstellen Sie ein C#-Klassenbibliotheksprojekt in Visual Studio. Informationen zum Konfigurieren einer Entwicklungsumgebung finden Sie unter Einrichten einer allgemeinen Entwicklungsumgebung für SharePoint 2013.

  • Fügen Sie die Microsoft.PerformancePoint.Scorecards.Client, Microsoft.PerformancePoint.Scorecards.ServerCommon, Microsoft.PerformancePoint.Scorecards.Store und Microsoft.SharePoint-DLLs als Verweise auf das Projekt Visual Studio . Weitere Informationen zu PerformancePoint-Dienste DLLs finden Sie unter PerformancePoint Services DLLs Used in Development Scenarios.

  • Fügen Sie die folgenden using Direktiven zu Ihrer Klasse.

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

Siehe auch

Referenz

SPDataStore Klasse

SPDataStore-Member

Microsoft.PerformancePoint.Scorecards.Store-Namespace

Weitere Ressourcen

How to: Create filter editors for PerformancePoint Services

How to: Create filter data providers for PerformancePoint Services