Compartir a través de


Crear editores de filtros para PerformancePoint Services en SharePoint

Aprenda a crear el componente de edición de una extensión de filtro personalizada para PerformancePoint Services.

¿Qué son los editores de filtros personalizados para PerformancePoint Services?

En PerformancePoint Services, los editores de filtros personalizados permiten a los usuarios establecer propiedades para los filtros personalizados. Los editores de filtros también deben inicializar la propiedad BeginPoints de un filtro, que define el punto inicial del filtro que contiene los valores de parámetro para los consumidores de cuadros de mandos y de informes. Para más información sobre los requisitos y las funciones de los editores, vea Editores para objetos personalizados de PerformancePoint Services.

Los siguientes procedimientos y ejemplos se basan en la clase SampleFilterEditor del ejemplo de objetos personalizados. El editor es una aplicación web ligera que permite a los usuarios modificar el nombre y la descripción del filtro, y seleccionar el origen de datos subyacente. Para obtener el código completo de la clase, vea Ejemplo de código: Crear, recuperar y actualizar filtros de PerformancePoint Services personalizados en SharePoint.

Se recomienda usar el editor de ejemplo como plantilla. El ejemplo muestra cómo llamar a objetos en la API de PerformancePoint Services, proporciona objetos auxiliares que simplifican llamadas para operaciones de repositorio (como la creación y actualización de objetos) y muestra los procedimientos recomendados para el desarrollo de PerformancePoint Services.

Creación y configuración de la clase de editor para los filtros personalizados de PerformancePoint Services

  1. Instale PerformancePoint Services o copie las DLL que usa la extensión (vea el paso 3) en el equipo. Para obtener más información, vea ARCHIVOS DLL con bibliotecas de clases.

  2. En Visual Studio, cree una biblioteca de clases C#. Si ya creó una biblioteca de clases para la extensión, agregue una nueva clase C#.

    Debe firmar el DLL con un nombre seguro. Además, asegúrese de que todos los ensamblados a los que su DLL hace referencia tengan nombres seguros. Para obtener información sobre cómo firmar un ensamblado con un nombre seguro y cómo crear un par de claves pública y privada, vea How to: Create a public/private key pair.

  3. Agregue las siguientes DLL como referencias de ensamblado al proyecto:

    • Microsoft.PerformancePoint.Scorecards.Client.dll
    • Microsoft.PerformancePoint.Scorecards.ServerCommon.dll
    • Microsoft.PerformancePoint.Scorecards.ServerRendering.dll
    • Microsoft.PerformancePoint.Scorecards.Store.dll (usada por clases auxiliares)
    • Microsoft.SharePoint.dll (usada por clases auxiliares)

    El editor de ejemplo también contiene referencias de ensamblado a System.Web.dll y System.Web.Services.dll. De acuerdo con la función de la extensión, es posible que se necesiten otras referencias de proyecto.

  4. Agregue las siguientes clases del ejemplo al proyecto. El editor usa estas clases de aplicaciones auxiliares para interactuar con el repositorio de PerformancePoint Services:

    • DataSourceConsumerHelper.cs
    • ExtensionRepositoryHelper.cs
    • FilterRepositoryHelper.cs
    • IDataSourceConsumer.cs
  5. En la clase de editor, agregue using directivas para los siguientes espacios de nombres de PerformancePoint Services:

    • Microsoft.PerformancePoint.Scorecards
    • Microsoft.PerformancePoint.Scorecards.ServerCommon
    • Microsoft.PerformancePoint.Scorecards.ServerRendering

    De acuerdo con la función de la extensión, es posible que se necesiten otras directivas using.

  6. Herede de la clase base que admite la implementación del editor. Dado que el editor de filtros de ejemplo es una aplicación web, hereda de la clase Page . Otras implementaciones pueden derivar de clases base, como la clase UserControl o la clase WebPart .

  7. Defina los controles que exponen las propiedades que desea que los usuarios vean o modifiquen. En primer lugar, el editor de filtros de ejemplo declara variables para los controles de servidor web que se definen en el componente de la interfaz de usuario, que es una página ASPX. El editor de ejemplo también define un control de botón que permite a los usuarios enviar los cambios. A continuación, el editor llama al método CreateChildControls() para que los controles estén disponibles en la página.

    Nota:

    [!NOTA] El editor define la lógica de programación independientemente de la interfaz de usuario. Las instrucciones para crear el componente de interfaz de usuario del editor están fuera del ámbito de esta documentación.

    El editor de filtros de ejemplo lleva a cabo los pasos 8 a 12 en el método Page_Load. Page_Load también se usa para inicializar y validar variables y controles, rellenar controles, y guardar la información de estado de los objetos auxiliares y los filtros personalizados.

  8. Establezca la propiedad AllowUnsafeUpdates en true. Esto permite que el editor de filtros escriba datos en el repositorio sin usar las operaciones POST de un formulario.

  9. Recupere los parámetros de la cadena de consulta y establézcalos como valores para las variables locales, como se muestra en el siguiente ejemplo de código.

    // The URL of the site collection that contains the PerformancePoint Services repository.
    string server = Request.QueryString[ClickOnceLaunchKeys.SiteCollectionUrl];
    
    // The location of the filter in the repository.
    string itemLocation = Request.QueryString[ClickOnceLaunchKeys.ItemLocation];
    
    // The operation to perform: OpenItem or CreateItem.
    string action = Request.QueryString[ClickOnceLaunchKeys.LaunchOperation];
    

    Nota:

    Para obtener información sobre los parámetros de cadena de consulta, vea Editores para objetos de PerformancePoint Services personalizados.

  10. Recupere el objeto FilterRepositoryHelper, que se usa para hacer llamadas al repositorio, como se muestra en el siguiente ejemplo de código.

    filterRepositoryHelper = new FilterRepositoryHelper();
    
  11. Establezca la ubicación del filtro en función del parámetro de cadena de consulta, como se muestra en el siguiente ejemplo de código.

    RepositoryLocation repositoryFilterLocation = RepositoryLocation.CreateFromUriString(itemLocation);
    
  12. Recupere la operación que se llevará a cabo ( OpenItem o CreateItem) de la cadena de consulta y, después, recupere o cree el filtro personalizado.

    • Para recuperar el filtro personalizado, use el método FilterRepositoryHelper.Get.
    • Para crear el filtro personalizado, use el constructor Filter() y defina las propiedades Name , RendererClassName y SubTypeId del filtro. SubTypeId es el identificador único del filtro y debe coincidir con el atributo subType que se especifica para el filtro personalizado en el archivo web.config de PerformancePoint Services. RendererClassName es el nombre completo de la clase que define el control de servidor web del representador. Si no está definido en el editor, el valor predeterminado es la clase del representador especificada en el archivo web.config.
    if (ClickOnceLaunchValues.OpenItem.Equals(action, StringComparison.OrdinalIgnoreCase))
    {
      // Use the repository-helper object to retrieve the filter.
      filter = filterRepositoryHelper.Get(repositoryFilterLocation);
      if (filter == null)
      {
        displayError("Could not retrieve the filter for editing.");
        return;
      }
    }
    else if (ClickOnceLaunchValues.CreateItem.Equals(action, StringComparison.OrdinalIgnoreCase))
    {
      filter = new Filter
      {
        RendererClassName = typeof(MultiSelectTreeViewControl).AssemblyQualifiedName,
        SubTypeId = "SampleFilter"
      };
    }
    

    Nota:

    [!NOTA] De forma predeterminada, los usuarios solo pueden crear objetos personalizados desde el Diseñador de paneles de PerformancePoint. Para permitir que los usuarios creen un objeto personalizado fuera del Diseñador de paneles, debe agregar un elemento de menú que envíe una solicitud CreateItem al editor desde el tipo de contenido del repositorio. Para más información, vea Editores para objetos personalizados de PerformancePoint Services.

  13. Recupere el origen de datos subyacente del filtro desde el repositorio. El editor de filtros de ejemplo usa la propiedad FilterRepositoryHelper.DataSourceHelper para llamar al método DataSourceConsumerHelper.GetDataSource, que se usa para recuperar el origen de datos según la ubicación que tiene en el repositorio. Esto se muestra en el siguiente ejemplo de código.

    if (!string.IsNullOrEmpty(filter.DataSourceLocation.ItemUrl))
    {
      RepositoryLocation repositoryDatasourceLocation = RepositoryLocation.CreateFromUriString(filter.DataSourceLocation.ItemUrl);
      datasource = filterRepositoryHelper.DataSourceHelper.GetDataSource(repositoryDatasourceLocation);
    }
    
  14. Para permitir que los usuarios seleccionen un origen de datos para el filtro, rellene el control de selección con orígenes de datos de PerformancePoint Services. El método PopulateDataSourceDropDown, en el editor de filtros de ejemplo, llama al método DataSourceConsumerHelper.GetDataSourcesBySourceNames para recuperar los orígenes de datos. Esto se muestra en el siguiente ejemplo de código.

    // The parameter contains the default server-relative URL to the PerformancePoint Data Connections Library.
    // Edit this value if you are not using the default path. A leading forward slash may not be needed.
    ICollection dataSourceCollection =
    
    filterRepositoryHelper.DataSourceHelper.GetDataSourcesBySourceNames
        ("/BICenter/Data%20Connections%20for%20PerformancePoint/",
             new[] { "WSTabularDataSource", DataSourceNames.ExcelWorkbook });
    

    El editor de filtros de ejemplo recupera solo dos tipos de orígenes de datos, pero puede modificar este método para admitir otros tipos de orígenes de datos o para preguntar al usuario qué tipo de origen de datos desea recuperar. Para hacer referencia a un origen de datos nativo de un tipo determinado, use la propiedad SourceName , que devuelve un campo de la clase DataSourceNames . Para hacer referencia a un origen de datos personalizado, use la propiedad SubTypeId del origen de datos, que tiene el mismo valor que el atributo subType registrado en el archivo web.config de PerformancePoint Services para la extensión de origen de datos.

    Si modifica este método, debe realizar el cambio correspondiente en el método GetDisplayDataInternal en el proveedor de datos del filtro de ejemplo.

  15. Defina el punto inicial del filtro, que se representa mediante la propiedad BeginPoints . Esto define el origen de los valores del filtro y es necesario para permitir que el filtro envíe datos a los cuadros de mandos e informes.

    1. Cree un objeto ParameterDefinition . BeginPoints devuelve un objeto ParameterDefinitionCollection que contiene solo un objeto ParameterDefinition .

    2. Para especificar el proveedor de datos del filtro, establezca la propiedad ParameterProviderId en el identificador único del proveedor de datos. Este valor debe coincidir con el valor devuelto por el método GetId() del proveedor de datos.

    3. Para especificar el origen de los identificadores de clave para los valores de filtro, establezca la propiedad KeyColumn en la columna de la tabla de datos para mostrar que contiene los identificadores de clave. El editor de filtros de ejemplo define esta propiedad como la columna "Symbol".

    4. Para especificar el origen de los valores de visualización para el control de filtro, establezca la propiedad DisplayColumn en la columna de la tabla de datos para mostrar que contiene los valores para mostrar. El editor de filtros de ejemplo define esta propiedad como la columna "Symbol".

      Nota:

      La tabla de datos para mostrar la devuelve la propiedad DisplayValues y se inicializa cuando el proveedor de datos de filtro llama al método GetDisplayDataInternal . Si la tabla de datos contiene otras columnas, puede definir otras asignaciones de columna para proporcionar funciones adicionales.

    if (0 == filter.BeginPoints.Count)
    {
      ParameterDefinition paramDef = new ParameterDefinition();
    
      // Reference the data provider.
      paramDef.ParameterProviderId = "SampleFilterDataProvider";
      paramDef.DefaultPostFormula = string.Empty;
    
      // Specify the column that contains the key identifiers and the column
      // that contains the display values. The sample uses the same column
      // for both purposes.
      // These values must match the structure of the data table that is
      // returned by the ParameterDefinition.DisplayValues property.
    
      paramDef.KeyColumn = "Symbol";
      paramDef.DisplayColumn = "Symbol";
    
      // You can use this property to store custom information for this filter.
      paramDef.CustomDefinition = string.Empty;
    
      filter.BeginPoints.Add(paramDef);
    }
    

    El editor de ejemplo define su punto inicial en el método VerifyFilter. También usa VerifyFilter para comprobar si se establecieron las propiedades obligatorias y para definir el modo de selección, que es una propiedad opcional.

  16. Para inicializar el filtro, ejecute la consulta del filtro y recupere datos del origen. El método buttonOK_Click, en el editor de filtros de ejemplo, llama al método FilterRepositoryHelper.GetParameterDisplayData para inicializar el filtro.

    Nota:

    [!NOTA] El editor debe llamar a FilterRepositoryHelper.GetParameterDisplayData al menos una vez antes de actualizar el objeto del filtro.

  17. Actualice el filtro con los cambios definidos por el usuario. El método buttonOK_Click, en el editor de filtros de ejemplo, llama al método FilterRepositoryHelper.Update para actualizar las propiedades Name , Description y DataSourceLocation del filtro en el repositorio. Además, se usa buttonOK_Click para validar el contenido de los controles y recuperar la información de estado del objeto auxiliar y el filtro personalizado.

    Nota:

    Los usuarios pueden establecer las propiedades Name , Description y Owner (Person Responsible) de un objeto personalizado y eliminar objetos personalizados directamente desde el Diseñador de paneles y el repositorio de PerformancePoint Services.

Ejemplo de código: Creación, recuperación y actualización de filtros de PerformancePoint Services personalizados en SharePoint

En el siguiente ejemplo de código, se crean, recuperan y actualizan filtros personalizados. Este código pertenece a la clase de código subyacente del editor, que proporciona la lógica de programación para los controles que se definen en una página ASPX.

Para poder compilar este ejemplo de código, debe configurar el entorno de desarrollo como se describe en Creación y configuración de la clase de editor para un editor de filtros en PerformancePoint Services.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.PerformancePoint.Scorecards;
using Microsoft.PerformancePoint.Scorecards.ServerCommon;
using Microsoft.PerformancePoint.Scorecards.ServerRendering;

namespace Microsoft.PerformancePoint.SDK.Samples.SampleFilter
{

    // Represents the class that defines the sample filter editor.
    public class SampleFilterEditor : Page
    {

        // Declare private variables for the ASP.NET controls defined in the user interface.
        // The sample's user interface is an ASPX page that defines the controls in HTML.
        private TextBox textboxName;
        private TextBox textboxDescription;
        private Label labelErrorMessage;
        private DropDownList dropdownlistDataSource;
        private Button buttonOK;
        private ListBox listboxStocks;

        // Make the controls available to this class.
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            if (null == textboxName)
                textboxName = FindControl("textboxName") as TextBox;
            if (null == textboxDescription)
                textboxDescription = FindControl("textboxDescription") as TextBox;
            if (null == dropdownlistDataSource)
                dropdownlistDataSource = FindControl("dropdownlistDataSource") as DropDownList;
            if (null == labelErrorMessage)
                labelErrorMessage = FindControl("labelErrorMessage") as Label;
            if (null==buttonOK)
                buttonOK = FindControl("buttonOK") as Button;
            if (null==listboxStocks)
                listboxStocks = FindControl("listboxStocks") as ListBox;
        }

        // Handles the Load event of the Page control.
        // Methods that use a control variable should call the Control.EnsureChildControls
        // method before accessing the variable for the first time.
        protected void Page_Load(object sender, EventArgs e)
        {

            // Required to enable custom report and filter editors to
            // write data to the repository.
            ServerUtils.AllowUnsafeUpdates = true;

            // Initialize controls the first time the page loads only.
            if (!IsPostBack)
            {
                EnsureChildControls();
                FilterRepositoryHelper filterRepositoryHelper = null;
                try
                {

                    // Get information from the query string parameters.
                    string server = Request.QueryString[ClickOnceLaunchKeys.SiteCollectionUrl];
                    string itemLocation = Request.QueryString[ClickOnceLaunchKeys.ItemLocation];
                    string action = Request.QueryString[ClickOnceLaunchKeys.LaunchOperation];

                    // Validate the query string parameters.
                    if (string.IsNullOrEmpty(server) ||
                        string.IsNullOrEmpty(itemLocation) ||
                        string.IsNullOrEmpty(action))
                    {
                        displayError("Invalid URL.");
                        return;
                    }

                    // Retrieve the repository-helper object.
                    filterRepositoryHelper =
                        new FilterRepositoryHelper();

                    // Set the filter location.
                    RepositoryLocation repositoryFilterLocation = RepositoryLocation.CreateFromUriString(itemLocation);

                    Filter filter;
                    DataSource datasource = null;

                    // Retrieve or create the filter object, depending on the operation
                    // passed in the query string (OpenItem or CreateItem).
                    if (ClickOnceLaunchValues.OpenItem.Equals(action, StringComparison.OrdinalIgnoreCase))
                    {

                        // Retrieve the filter object by using the repository-helper object.
                        filter = filterRepositoryHelper.Get(repositoryFilterLocation);
                        if (filter == null)
                        {
                            displayError("Could not retrieve the filter for editing.");
                            return;
                        }

                    }
                    else if (ClickOnceLaunchValues.CreateItem.Equals(action, StringComparison.OrdinalIgnoreCase))
                    {

                        // Create a filter.
                        // CreateItem requests can be sent from a SharePoint list, but
                        // you must create a custom menu item to send the request.
                        // Dashboard Designer can send edit requests only.
                        filter = new Filter
                            {

                                // Specify the class that defines the renderer
                                // web server control. The sample filter uses a native
                                // PerformancePoint Services renderer.
                                // Defaults to the value specified in the web.config file
                                RendererClassName = typeof(MultiSelectTreeViewControl).AssemblyQualifiedName,

                                // Specify the unique identifier for the filter.
                                // The SubTypeId property must match the
                                // subType attribute in the web.config file.
                                SubTypeId = "SampleFilter"
                            };
                    }
                    else
                    {
                        displayError("Invalid Action.");
                        return;
                    }

                    VerifyFilter(filter);

                    // Retrieve filter's underlying data source.
                    if (!string.IsNullOrEmpty(filter.DataSourceLocation.ItemUrl))
                    {
                        RepositoryLocation repositoryDatasourceLocation =
                            RepositoryLocation.CreateFromUriString(filter.DataSourceLocation.ItemUrl);
                        datasource =

                            // Gets a PerformancePoint Services data source by using the
                            // DataSourceHelper property to call the
                            // DataSourceConsumerHelper.GetDataSource method.
                            filterRepositoryHelper.DataSourceHelper.GetDataSource(repositoryDatasourceLocation);
                    }

                    // Save the original filter and helper objects across page postbacks.
                    ViewState["action"] = action;
                    ViewState["filter"] = filter;
                    ViewState["filterrepositoryhelper"] = filterRepositoryHelper;
                    ViewState["itemlocation"] = itemLocation;

                    // Populate the child controls.
                    textboxName.Text = filter.Name.ToString();
                    textboxDescription.Text = filter.Description.ToString();

                    // Populate the dropdownlistDataSource control with data sources of specific
                    // types from the PerformancePoint Services repository.
                    // This method looks up the passed data source in the data sources
                    // that are registered in the web.config file.
                    // Although the sample retrieves data sources of two specific types,
                    // you can modify it to prompt the user for a data source type.
                    PopulateDataSourceDropDown(datasource);

                    // Call the SelectedIndexChanged event directly to populate the
                    // listbox control with preview data.
                    dropdownlistDataSource_SelectedIndexChanged(null, null);
                }
                catch (Exception ex)
                {
                    displayError("An error has occurred. Please contact your administrator for more information.");
                    if (filterRepositoryHelper != null)
                    {
                        // Add the exception detail to the server event log.
                        filterRepositoryHelper.HandleException(ex);
                    }
                }
            }
        }

        // Handles the SelectedIndexChanged event of the dropdownlistDataSource control.
        protected void dropdownlistDataSource_SelectedIndexChanged(object sender, EventArgs e)
        {
            EnsureChildControls();

            // Check if a valid data source is selected.
            if (null != dropdownlistDataSource.SelectedItem &&
                !string.IsNullOrEmpty(dropdownlistDataSource.SelectedItem.Text))
            {
                // Retrieve the data source object.
                FilterRepositoryHelper filterRepositoryHelper =
                    (FilterRepositoryHelper)ViewState["filterrepositoryhelper"];
                string selectedDataSourceItemUrl = dropdownlistDataSource.SelectedItem.Value;

                RepositoryLocation repositoryDatasourceLocation =
                    RepositoryLocation.CreateFromUriString(selectedDataSourceItemUrl);
                DataSource datasource = filterRepositoryHelper.DataSourceHelper.GetDataSource(repositoryDatasourceLocation);
                ViewState["datasource"] = datasource;

                // Populate the listboxStocks control with the preview data for the selected
                // data source.
                PopulateListBoxData(datasource);
            }
            else
            {
                ClearStocksListBox();
            }
        }

        // Clears the listboxStocks control.
        // The sample filter works with a web service that provides stock information.
        private void ClearStocksListBox()
        {
            listboxStocks.DataSource = null;
            listboxStocks.DataBind();
            listboxStocks.Items.Clear();
        }

        // Handles the Click event of the buttonOK control.
        protected void buttonOK_Click(object sender, EventArgs e)
        {
            EnsureChildControls();

            // Verify that the controls contain values.
            if (string.IsNullOrEmpty(textboxName.Text))
            {
                labelErrorMessage.Text = "A filter name is required.";
                return;
            }
            if (dropdownlistDataSource.SelectedIndex == 0)
            {
                labelErrorMessage.Text = "A data source is required.";
                return;
            }

            // Clear any pre-existing error message.
            labelErrorMessage.Text = string.Empty;

            // Retrieve the filter, data source, and helper objects from view state.
            string action = (string)ViewState["action"];
            string itemLocation = (string) ViewState["itemlocation"];
            Filter filter = (Filter)ViewState["filter"];
            DataSource datasource = (DataSource)ViewState["datasource"];
            FilterRepositoryHelper filterRepositoryHelper = (FilterRepositoryHelper)ViewState["filterrepositoryhelper"];

            // Update the filter object with form changes.
            filter.Name.Text = textboxName.Text;
            filter.Description.Text = textboxDescription.Text;
            filter.DataSourceLocation = datasource.Location;
            foreach (ParameterDefinition parameterDefinition in filter.BeginPoints)
            {
                parameterDefinition.DisplayName = filter.Name.Text;
            }

            // Initialize the filter. This method runs the filter's query and retrieves preview data.
            filterRepositoryHelper.GetParameterDisplayData(ref filter);

            // Save the filter object to the PerformancePoint Services repository.
            try
            {
                filter.Validate();

                if (ClickOnceLaunchValues.CreateItem.Equals(action,StringComparison.OrdinalIgnoreCase))
                {
                    Filter newFilter = filterRepositoryHelper.Create(
                        string.IsNullOrEmpty(filter.Location.ItemUrl) ? itemLocation : filter.Location.ItemUrl, filter);
                    ViewState["filter"] = newFilter;
                    ViewState["action"] = ClickOnceLaunchValues.OpenItem;
                }
                else
                {
                    filterRepositoryHelper.Update(filter);
                }
            }
            catch (Exception ex)
            {
                displayError("An error has occurred. Please contact your administrator for more information.");
                if (filterRepositoryHelper != null)
                {

                    // Add the exception detail to the server event log.
                    filterRepositoryHelper.HandleException(ex);
                }
            }
        }

        // Displays the error string in the labelErrorMessage label.
        void displayError(string msg)
        {
            EnsureChildControls();

            labelErrorMessage.Text = msg;

            // Disable the OK button because the page is in an error state.
            buttonOK.Enabled = false;
            return;
        }

        // Verifies that the properties for the filter object are set.
        static void VerifyFilter(Filter filter)
        {

            if (null != filter)
            {

                // Verify that all required properties are set.
                if (string.IsNullOrEmpty(filter.SubTypeId))
                {

                    // This value must match the subType attribute specified
                    // in the web.config file.
                    filter.SubTypeId = "SampleFilter";
                }

                if (string.IsNullOrEmpty(filter.RendererClassName))
                {
                    filter.RendererClassName = typeof (MultiSelectTreeViewControl).AssemblyQualifiedName;
                }

                // Define the BeginPoints property so the filter can send a parameter value to
                // scorecards and reports.
                // The value must be from the KeyColumn of the display
                // DataTable object, which is defined in the data provider. The data table is
                // returned by the FilterRepositoryHelper.GetParameterDisplayData method.
                // A filter has one beginpoint only, and it is represented by a
                // ParameterDefinition object. The ParameterDefinition object defines how
                // the filter accesses the data.
                if (0 == filter.BeginPoints.Count)
                {
                    ParameterDefinition paramDef = new ParameterDefinition
                                                       {
                                                           // This value must match the value returned
                                                           // by the data provider's GetId method.
                                                           ParameterProviderId = "SampleFilterDataProvider",

                                                           // Reference the data provider.
                                                           DefaultPostFormula = string.Empty,

                                                           // Specify the column that contains
                                                           // the key identifiers and the column
                                                           // that contains the display values.
                                                           // The sample uses the same column
                                                           // for both purposes.
                                                           // These values must match the structure
                                                           // of the data table that is returned
                                                           // by the ParameterDefinition.DisplayValues property.
                                                           KeyColumn = "Symbol",
                                                           DisplayColumn = "Symbol",

                                                           // You can use this property to store
                                                           // extra information for this filter.
                                                           CustomDefinition = string.Empty
                                                       };
                    filter.BeginPoints.Add(paramDef);
                }

                // Set optional properties. The renderer can return multiple values.
                filter.SelectionMode = FilterSelectionMode.MultiSelect;
            }
        }

        // Populates the dropdownlistDataSource control.
        void PopulateDataSourceDropDown(DataSource filterDataSource)
        {
            EnsureChildControls();

            FilterRepositoryHelper filterRepositoryHelper =
                (FilterRepositoryHelper)ViewState["filterrepositoryhelper"];

            // Retrieve data sources from the repository by using the DataSourceHelper
            // property to call the DataSourceConsumerHelper object.
            // If you modify the types of data source to retrieve, you must make the corresponding
            // change in the filter's data provider.
            // The parameter contains the default server-relative URL to the PerformancePoint Data Connections Library.
            // Edit this value if you are not using the default path. A leading forward slash may not be needed.
            ICollection dataSourceCollection = filterRepositoryHelper.DataSourceHelper.GetDataSourcesBySourceNames("/BICenter/Data%20Connections%20for%20PerformancePoint/",
                new[] { "WSTabularDataSource", DataSourceNames.ExcelWorkbook });
            if (null == dataSourceCollection)
            {
                displayError("No available data sources were found.");
                return;
            }

            // Create a list of name/value pairs for the dropdownlistDataSource control.
            var dataSources = new List<KeyValuePair<string, string>>();
            int selectedIndex = 0;
            int i = 1;
            dataSources.Add(new KeyValuePair<string, string>(string.Empty, string.Empty));

            foreach (DataSource ds in dataSourceCollection)
            {
                dataSources.Add(new KeyValuePair<string, string>(ds.Name.Text, ds.Location.ItemUrl));

                // Check if the entry is the originally selected data source.
                if ((filterDataSource != null) &amp;&amp;
                    (string.Compare(ds.Name.Text, filterDataSource.Name.Text) == 0))
                {
                    selectedIndex = i;
                }
                ++i;
            }

            dropdownlistDataSource.DataSource = dataSources;
            dropdownlistDataSource.DataTextField = "Key";
            dropdownlistDataSource.DataValueField = "Value";
            dropdownlistDataSource.DataBind();
            dropdownlistDataSource.SelectedIndex = selectedIndex;
        }


        // Populate the list box data.
        void PopulateListBoxData(DataSource datasource)
        {
            EnsureChildControls();

            ClearStocksListBox();

            FilterRepositoryHelper filterRepositoryHelper =
                (FilterRepositoryHelper)ViewState["filterrepositoryhelper"];

            // Retrieve the first 100 rows of the preview data from the data source
            DataSet dataSet = filterRepositoryHelper.DataSourceHelper.GetDataSet(100, datasource);

            if (null != dataSet &amp;&amp; null != dataSet.Tables[0])
            {
                listboxStocks.DataTextField = "Symbol";
                listboxStocks.DataValueField = "Value";
                listboxStocks.DataSource = dataSet.Tables[0];
                listboxStocks.DataBind();
            }
        }
    }
}

Pasos siguientes

Después de crear un editor de filtros (incluida su interfaz de usuario, si es necesario) y un proveedor de datos, implemente la extensión como se describe en How to: Manually Register PerformancePoint Services Extensions.

Vea también