Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
Saiba como criar o componente de editor de uma extensão de filtro personalizada para os Serviços PerformancePoint.
Cite editores de filtro personalizado para PerformancePoint Services.
Em PerformancePoint Services, editores de filtro personalizado permitem que os usuários definir propriedades em filtros personalizados. Os editores de filtros também têm de inicializar a propriedade BeginPoints de um filtro, que define o ponto inicial do filtro que contém valores de parâmetros para consumidores de tabelas de indicadores e relatórios. Para obter mais informações sobre requisitos de editor e a funcionalidade, consulte Editors for Custom PerformancePoint Services Objects.
Os procedimentos e os exemplos a seguir baseiam-se na classe SampleFilterEditor da amostra de objetos personalizados. O editor é um aplicativo web fina que permite que os usuários para modificar o nome e uma descrição do filtro e selecionar a fonte de dados subjacente. Para obter o código completo da classe, veja Exemplo de código: Criar, obter e atualizar filtros de Serviços PerformancePoint personalizados no SharePoint.
Recomendamos que você use o editor de amostra como um modelo. Mostra o exemplo como chamar objetos no PerformancePoint Services API, fornece objetos auxiliares que simplificam chama-se para operações de repositório (por exemplo, criando e atualizando objetos) e demonstra as práticas recomendadas para o desenvolvimento de PerformancePoint Services.
Criar e configurar a classe do editor de filtros personalizados PerformancePoint Services
Instalar PerformancePoint Services ou copie as DLLs que usa sua extensão (consulte a etapa 3) para o seu computador. Para obter mais informações, veja DLLs com Bibliotecas de Classes.
Em Visual Studio, crie uma biblioteca de classes c#. Se você criou uma biblioteca de classes para sua extensão, adicione uma nova classe c#.
Você deve entrar sua DLL com um nome forte. In addition, ensure that all assemblies referenced by your DLL have strong names. Para obter informações sobre como assinar uma assemblagem com um nome forte e como criar um par de chaves públicas/privadas, consulte Como: Criar um par de chaves públicas/privadas.
Adicione as seguintes DLLs como referências de assembly para o projeto:
- Microsoft.PerformancePoint.Scorecards.Client.dll
- Microsoft.PerformancePoint.Scorecards.ServerCommon.dll
- Microsoft.PerformancePoint.Scorecards.ServerRendering.dll
- Microsoft.PerformancePoint.Scorecards.Store.dll (usado pelo classes auxiliares)
- Microsoft.SharePoint.dll (usado pelo classes auxiliares)
O editor de amostra também contém referências de assembly System.Web.dll e System.Web.Services.dll. Dependendo da funcionalidade da sua extensão, outras referências de projeto podem ser necessárias.
Adicione as seguintes classes da amostra ao projeto. O editor usa essas classes auxiliares para interagir com o repositório de PerformancePoint Services:
- DataSourceConsumerHelper.cs
- ExtensionRepositoryHelper.cs
- FilterRepositoryHelper.cs
- IDataSourceConsumer.cs
Na sua classe de editor, adicione
usingdiretivas para os seguintes Serviços PerformancePoint espaços de nomes:- Microsoft.PerformancePoint.Scorecards
- Microsoft.PerformancePoint.Scorecards.ServerCommon
- Microsoft.PerformancePoint.Scorecards.ServerRendering
Dependendo da funcionalidade da sua extensão, outras diretivas using podem ser necessárias.
Herde a classe base que ofereça suporte a implementação do editor. Uma vez que o editor de filtros de exemplo é uma aplicação Web, herda da classe Página . Outras implementações podem derivar de classes base, como a classe UserControl ou WebPart .
Defina os controles que expõem as propriedades que você deseja que os usuários para exibir ou modificar. O editor de filtros de amostra primeiramente declara variáveis para a web controles de servidor que são definidos no componente de interface do usuário, que é uma página ASPX. O editor de amostra também define um controle de botão que permite aos usuários enviar alterações. Em seguida, o editor chama o método CreateChildControls() para disponibilizar os controlos na página.
Observação
[!OBSERVAçãO] O editor define a lógica de programação separadamente da interface do usuário. Instruções para criar o componente de interface do usuário do editor estão além do escopo desta documentação.
O editor de filtros de exemplo realiza as etapas 8 a 12 no método Page_Load. Page_Load também é usado para inicializar e validar variáveis e controles, preencher controles e salvar as informações de estado para os objetos de filtro e auxiliar personalizados.
Defina a propriedade AllowUnsafeUpdates comotrue. Isso permite que o editor de filtros gravar dados ao repositório sem usar as operações de POSTAGEM de formulário.
Recuperar os parâmetros da cadeia de consulta e defini-las como valores de variáveis locais, conforme mostrado no exemplo de código a seguir.
// 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];Observação
Para obter informações sobre os parâmetros da cadeia de consulta, veja Editores para Objetos de Serviços PerformancePoint Personalizados.
Recupere o objeto FilterRepositoryHelper, que é usado para fazer chamadas para o repositório, conforme mostrado no exemplo de código a seguir.
filterRepositoryHelper = new FilterRepositoryHelper();Defina o local de filtro com base no parâmetro de cadeia de caracteres de consulta, conforme mostrado no exemplo de código a seguir.
RepositoryLocation repositoryFilterLocation = RepositoryLocation.CreateFromUriString(itemLocation);Recuperar a operação para executar ( OpenItem ou CreateItem) da seqüência de consulta e, em seguida, recuperar ou criar o filtro personalizado.
- Para recuperar o filtro personalizado, use o método FilterRepositoryHelper.Get.
- Para criar o filtro personalizado, utilize o construtor Filter() e defina as propriedades Nome do filtro, RendererClassName e SubTypeId . SubTypeId é o identificador exclusivo do filtro e tem de corresponder ao atributo subType que especificar para o filtro personalizado no ficheiro Serviços PerformancePoint web.config. RendererClassName é o nome completamente qualificado da classe que define o controlo do servidor Web do compositor. Se não estiver definido no editor, este valor é predefinido para a classe de compositor especificada no ficheiro 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" }; }Observação
[!OBSERVAçãO] Por padrão, os usuários podem criar objetos personalizados de PerformancePoint Dashboard Designer somente. Para permitir que os utilizadores criem um objeto personalizado fora do Dashboard Designer, tem de adicionar um item de menu que envie um pedido CreateItem ao editor a partir do tipo de conteúdo no repositório. Para obter mais informações, consulte Editors for Custom PerformancePoint Services Objects.
Recupere a fonte de dados subjacente do filtro do repositório. O editor de filtros de amostra usa a propriedade FilterRepositoryHelper.DataSourceHelper para chamar o método DataSourceConsumerHelper.GetDataSource, que é usado para recuperar a fonte de dados por seu local no repositório. Isso é mostrado no exemplo de código a seguir.
if (!string.IsNullOrEmpty(filter.DataSourceLocation.ItemUrl)) { RepositoryLocation repositoryDatasourceLocation = RepositoryLocation.CreateFromUriString(filter.DataSourceLocation.ItemUrl); datasource = filterRepositoryHelper.DataSourceHelper.GetDataSource(repositoryDatasourceLocation); }Para habilitar usuários selecionar uma fonte de dados para o filtro, preencha o controle de seleção com fontes de dados de PerformancePoint Services. O método PopulateDataSourceDropDown no editor de filtro de exemplo chama o método DataSourceConsumerHelper.GetDataSourcesBySourceNames para recuperar as fontes de dados. Isso é mostrado no exemplo de código a seguir.
// 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 });O editor de filtros de exemplo obtém apenas dois tipos de origem de dados, mas pode modificar este método para suportar outros tipos de origens de dados ou para pedir ao utilizador o tipo de origem de dados a obter. Para referenciar uma origem de dados nativa de um determinado tipo, utilize a propriedade SourceName , que devolve um campo da classe DataSourceNames . Para referenciar uma origem de dados personalizada, utilize a propriedade SubTypeId da origem de dados, que é o mesmo valor que o atributo subType registado no ficheiro Serviços PerformancePoint web.config para a extensão da origem de dados.
Se modificar este método, tem de fazer a alteração correspondente no método GetDisplayDataInternal no fornecedor de dados do filtro de exemplo.
Defina o ponto de início do filtro, que é representado pela propriedade BeginPoints . Isso define a fonte dos valores de filtro e é necessário para habilitar o filtro enviar dados para scorecards e relatórios.
Crie um objeto ParameterDefinition . BeginPoints retorna um objeto de ParameterDefinitionCollection que contém apenas um objeto ParameterDefinition .
Para especificar o fornecedor de dados do filtro, defina a propriedade ParameterProviderId como o identificador exclusivo do fornecedor de dados. Este valor deve corresponder ao valor retornado pelo método de GetId() do provedor de dados.
Para especificar a origem dos identificadores de chave para os valores de filtro, defina a propriedade KeyColumn para a coluna na tabela de dados de apresentação que contém os identificadores de chave. O editor de filtros de amostra define essa propriedade como a coluna "Símbolo".
Para especificar a origem dos valores de apresentação para o controlo de filtro, defina a propriedade DisplayColumn para a coluna na tabela de dados de apresentação que contém os valores de apresentação. O editor de filtros de amostra define essa propriedade como a coluna "Símbolo".
Observação
A tabela de dados de apresentação é devolvida pela propriedade DisplayValues e é inicializada quando o fornecedor de dados de filtro chama o método GetDisplayDataInternal . Se a tabela de dados contém outras colunas, você pode definir outros mapeamentos de coluna para fornecer funcionalidade adicional.
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); }O editor de amostra define seu beginpoint no método VerifyFilter. Ele também usa VerifyFilter para verificar se as propriedades necessárias estão definidas e definir o modo de seleção, que é uma propriedade opcional.
Inicialize o filtro executando consulta do filtro e a recuperação de dados da fonte de dados. O método buttonOK_Click no editor de filtro de exemplo chama o método de FilterRepositoryHelper.GetParameterDisplayData para inicializar o filtro.
Observação
[!OBSERVAçãO] O editor deve chamar FilterRepositoryHelper.GetParameterDisplayData pelo menos uma vez antes de atualizar o objeto filter.
Atualize o filtro com alterações definida pelo usuário. O método buttonOK_Click no editor de filtro de amostra chama o método FilterRepositoryHelper.Update para atualizar as propriedades do filtro de Name , Description e DataSourceLocation no repositório. Além disso, buttonOK_Click é usado para validar o conteúdo dos controles e recuperar as informações de estado para o filtro personalizado e o objeto auxiliar.
Observação
Os utilizadores podem definir as propriedades Nome, Descrição e Proprietário (Responsável) de um objeto personalizado e eliminar objetos personalizados diretamente do dashboard Designer e do repositório Serviços PerformancePoint.
Exemplo de código: Criar, obter e atualizar filtros de Serviços PerformancePoint personalizados no SharePoint
O exemplo de código a seguir cria, recupera e atualiza os filtros personalizados. Este código é da classe code-behind do editor, que fornece a lógica de programação para controles que são definidos em uma página ASPX.
Antes de poder compilar este exemplo de código, tem de configurar o ambiente de desenvolvimento conforme descrito em Criar e configurar a classe de editor para um editor de filtros no Serviços PerformancePoint.
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) &&
(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 && null != dataSet.Tables[0])
{
listboxStocks.DataTextField = "Symbol";
listboxStocks.DataValueField = "Value";
listboxStocks.DataSource = dataSet.Tables[0];
listboxStocks.DataBind();
}
}
}
}
Próximas etapas
Depois de criar um editor de filtros (incluindo a respetiva interface de utilizador, se necessário) e um fornecedor de dados, implemente a extensão conforme descrito em Como: Registar Manualmente Serviços PerformancePoint Extensões.