为 Microsoft Business Scorecard Manager 2005 构建自定义报告视图
本文档是一份初稿,在发布此处所述软件的最终商业版本之前可能会做重大改动。本文档所包含的信息代表了 Microsoft Corporation 在发布之日对所讨论问题的看法。因为 Microsoft 必须顺应不断变化的市场条件,故不应将本文档理解为 Microsoft 一方的承诺,Microsoft 不保证所给出的信息在发布之日以后仍保持准确性。
本白皮书仅供参考。Microsoft 对本文档中的信息不做任何明示或暗示的保证。
遵守所有适用的版权法是用户的责任。除版权法规定的权利外,未经 Microsoft Corporation 的明确书面许可,不得以任何形式、任何手段(电子、机械、影印、录制或其他方式)或出于任何目的复制、传播本文档的任何部分,也不得将其存入或引入检索系统。
Microsoft 可能拥有本文档主题涉及到的专利、专利使用、商标、版权或其他知识产权。除非在 Microsoft 的任何书面许可协议中有明确的表示,否则提供本文档并不表示授权您使用这些专利、商标、版权或其他知识产权。
© 2005 Microsoft Corporation。保留所有权利。
本文档中所例举的公司、组织、产品、域名、电子邮件地址、徽标、人员、地点和事件纯属虚构。与任何真实的公司、组织、产品、域名、电子邮件地址、徽标、人员、地点或事件均不相关,也不应推断出任何关联性。
Microsoft、MSDN 和 Office 徽标是 Microsoft Corporation 在美国和/或其他国家(地区)的注册商标或商标。
简介 4
关于自定义报告视图 4
创建示例自定义报告视图 4
创建配置组件 4
使用配置组件 7
创建 Web 组件 9
使用 Web 组件 11
Microsoft® Office Business Scorecard Manager 2005 的一个核心功能是能够以报告视图的形式将异类报告与记分卡或 KPI 关联起来。这些报告提供补充数据和其他工具以帮助决策者分析绩效信息并根据这些信息制定决策。Business Scorecard Manager 支持多种报告视图,包括 Office Web 组件 (OWC)、PivotCharts®、PivotTables®、电子表格、基于 Microsoft SQL Server™ Reporting Services 的报表、记分卡视图和网页。此外,开发人员和第三方独立软件供应商 (ISV) 可以构建基于 .NET 的自定义报告视图类型,这些视图类型可与 Business Scorecard Manager 进行无缝集成。本文说明以下内容:
● 关于自定义报告视图。
● 创建示例自定义报告视图,包括:
● 创建配置组件。
● 使用配置组件。
● 创建 Web 组件。
● 使用 Web 组件。
要创建自定义报告视图,必须构建以下两个组件:
1. 由 Business Scorecard Builder 托管的配置组件。
2. 用于显示自定义报告视图的 Web 组件,由基于 Microsoft Windows SharePoint® Services 或基于 Microsoft Office SharePoint Portal Server 的网页托管。
配置组件是派生自 CustomReportViewWinControlBase 类的 Windows® Forms 用户控件。该组件显示于 Business Scorecard Builder 的报告视图编辑器中,用户可使用它来配置自定义报告视图。自定义报告视图 Web 组件由基于 Windows SharePoint Services 或 SharePoint Portal Server 的网页上的报告视图 Web 部件托管。
本部分说明创建示例自定义报告视图的步骤。将构建一个可将记分卡的当前状态和选择信息显示到屏幕上的组件。
创建示例自定义报告视图的第一步是创建配置组件。报告视图的配置窗格将显示一个可用于将数据传递到 Web 组件的文本框,以及一个用于测试验证检查是否在运行的复选框。还要添加一些控件,以设置首选高度、首选宽度以及报告视图组,如图 1 所示(组表示可用于在基于 Windows SharePoint Services 或 SharePoint Portal Server 的网站上的报告视图 Web 部件中显示报告视图的物理区域)。
图 1
完成的示例配置组件
下面是配置组件的示例代码:
using System;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;
using Microsoft.PerformanceManagement.Scorecards.Client;
using Microsoft.PerformanceManagement.Scorecards.Extensions;
namespace CustomReportViewSample
{
///
/// Sample custom Report View authoring control
///
public class SampleCustomReportViewWinControl : CustomReportViewWinControlBase
{
CustomReportView customReportView;
CheckBox validate = new CheckBox();
TextBox customDataTextBox = new TextBox();
ErrorProvider validationErrorProvider = new ErrorProvider();
ComboBox groupComboBox = new ComboBox();
TextBox preferredHeight = new TextBox();
TextBox preferredWidth = new TextBox();
const int MaxReportViewZones = 30;
public SampleCustomReportViewWinControl()
{
// Add the custom data control
Label label = new Label();
label.Left = 10;
label.Top = 10;
label.Text = "&Custom Data:";
label.Height = label.PreferredHeight;
label.Width = label.PreferredWidth;
this.Controls.Add(label);
customDataTextBox.Left = 10;
customDataTextBox.Top = label.Bottom + 10;
customDataTextBox.Height = 50;
customDataTextBox.Width = 200;
customDataTextBox.Multiline = true;
this.Controls.Add(customDataTextBox);
// Add the pass-validation control
validate.Left = 10;
validate.Top = customDataTextBox.Bottom + 10;
validate.Height = 50;
validate.Width = 200;
validate.Text = "Pass &validation";
validate.Checked = true;
this.Controls.Add(validate);
// Add the preferred height control
Label preferredHeightLabel = new Label();
preferredHeightLabel.Top = validate.Bottom + 10;
this.Controls.Add(preferredHeightLabel);
preferredHeightLabel.Text = "Preferred &height:";
preferredHeightLabel.TextAlign = ContentAlignment.MiddleRight;
preferredHeight.Top = preferredHeightLabel.Top;
preferredHeight.Left = preferredHeightLabel.Right + 5;
preferredHeight.Width = 40;
this.Controls.Add(preferredHeight);
preferredHeight.Name = "preferredHeight";
preferredHeight.MaxLength = 5;
// Add the preferred width control
Label preferredWidthLabel = new Label();
preferredWidthLabel.Top = preferredHeightLabel.Bottom + 10;
this.Controls.Add(preferredWidthLabel);
preferredWidthLabel.Text = "Preferred &width:";
preferredWidthLabel.TextAlign = ContentAlignment.MiddleRight;
preferredWidth.Top = preferredWidthLabel.Top;
preferredWidth.Left = preferredWidthLabel.Right + 5;
preferredWidth.Width = 40;
this.Controls.Add(preferredWidth);
preferredWidth.Name = "preferredWidth";
preferredWidth.MaxLength = 5;
// Add the group drop down
Label groupLabel = new Label();
groupLabel.Top = preferredWidthLabel.Bottom + 10;
this.Controls.Add(groupLabel);
groupLabel.Text = "&Group:";
groupLabel.TextAlign = ContentAlignment.MiddleRight;
for (int i=1; i<=MaxReportViewZones; i++)
{
groupComboBox.Items.Add(i);
}
groupComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
groupComboBox.Left = groupLabel.Right + 5;
groupComboBox.Top = groupLabel.Top;
groupComboBox.Height = groupComboBox.PreferredHeight;
groupComboBox.Width = 40;
this.Controls.Add(groupComboBox);
}
public override void SetCustomReportView(
CustomReportView customReportView)
{
this.customReportView = customReportView;
customDataTextBox.Text = customReportView.Data;
if (customReportView.PreferredHeight > 0)
preferredHeight.Text =
customReportView.PreferredHeight.ToString();
if (customReportView.PreferredWidth > 0)
preferredWidth.Text = customReportView.PreferredWidth.ToString();
if (customReportView.Zone >= 0 &&
customReportView.Zone < groupComboBox.Items.Count)
groupComboBox.SelectedIndex = customReportView.Zone;
else
groupComboBox.SelectedIndex = 0;
}
public override string GetCustomType()
{
return "SampleCustomReportView";
}
public override string GetDisplayName()
{
return "Custom Report View Sample";
}
public override bool ValidateData()
{
if (!validate.Checked)
{
// This check is just to demonstrate the validation mechanism
// In actual code, you would validate your custom data here
this.validationErrorProvider.SetError(
this.validate,
"This box must be checked");
}
return validate.Checked;
}
public override void UpdateData()
{
// Update data from UI
customReportView.Data = customDataTextBox.Text;
if (preferredHeight.Text.Length > 0)
customReportView.PreferredHeight = int.Parse(
preferredHeight.Text);
else
customReportView.PreferredHeight = int.MinValue;
if (preferredWidth.Text.Length > 0)
customReportView.PreferredWidth = int.Parse(preferredWidth.Text);
else
customReportView.PreferredWidth = int.MinValue;
customReportView.Zone = groupComboBox.SelectedIndex;
}
}
}
要使用配置组件,必须先对该组件进行注册。然后在 Business Scorecard Builder 中验证该组件是否已准备就绪。
使用配置组件
1. 在运行 Business Scorecard Builder 的服务器的全局程序集缓存 (GAC) 中注册配置组件。若要在 GAC 中注册配置组件,请在命令提示符后运行以下命令:
gacutil /f /i CustomReportViewSample.dll
2. 使用 Business Scorecard Builder 注册配置组件。若要执行此操作,请在 pmbuilder.exe 所在的文件夹中(默认情况下,此程序安装在 \Program Files\Microsoft Office Business Scorecard Manager 2005\Builder 中)创建一个名为 pmbuilder.exe.config 的新配置文件。作为示例报告视图扩展内容的配置文件具有以下内容:
构建自定义报告视图时,必须将程序集引用值和 PublicKeyToken 值更改为您的程序集的相应值。
3. 注册该组件以后,可以验证它是否已准备就绪。打开 Business Scorecard Builder,然后打开一个新工作区。
4. 在“工作区浏览器”中,单击任一记分卡或 KPI。
5. 在该窗口右窗格的“报告视图”选项卡上单击“添加”。将打开“创建报告视图”向导。
6. 单击“新建定义”,然后单击“下一步”。
7. 在“报告视图类型”下拉列表中,所创建的自定义报告视图目前显示在可用报告视图的列表中,如图 2 所示。
图 2
自定义报告视图类型选择
自定义报告视图配置窗格的用户界面 (UI) 包含一个可输入任意字符串的文本框和一个可测试验证界面的复选框。清除通过验证复选框会导致 Business Scorecard Builder 在用户单击“确定”时显示错误。自定义数据文本框的内容将被传递给自定义报告视图。在实际操作中,可以使用 CustomData 属性将配置数据传递给视图控件,例如序列化对象的表单。
本部分说明如何构建自定义报告视图的查看时组件,该组件用于将内容在基于 Windows SharePoint Services 或 SharePoint Portal Server 的网页上呈现给用户。在此示例中,将显示所有有用的状态数据,这些数据在运行时可用于该控件。这些数据(如图 3 所示)包括:
1. 在创作组件中设置的自定义数据。
2. 链接的记分卡。
3. 选定的记分卡视图。
4. 选定的记分卡节点(KpiGroup 对象)。
5. 选定的实际值或目标值(KpiMeasure 对象)。
7. 活动的页面筛选器。
8. 选定单元格的行部分。
9. 选定单元格的列部分。
图 3
示例自定义报告视图 Web 控件
图 4 说明 KPIGroupID、KPIMeasureID 和 Column 部分是如何随着用户所选单元格的不同而变化的。
图 4
选择单元格后的示例自定义报告视图 Web 组件
自定义报告视图的 Web 组件是从 CustomReportViewControlBase 类派生的。下面是报告视图 Web 组件的示例代码:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using Microsoft.PerformanceManagement.Scorecards.Extensions;
using Microsoft.PerformanceManagement.Scorecards.Client;
namespace CustomReportViewSample
{
///
/// A sample custom report view control
///
public class SampleCustomReportViewControl : CustomReportViewControlBase
{
///
/// Render this control to the output parameter specified.
///
/// The HTML writer to write out to
protected override void Render(HtmlTextWriter output)
{
// Show the context information available to the control
output.Write("
Custom Data: " + HttpUtility.HtmlEncode(this.CustomData));
output.Write("
Scorecard Name: " + HttpUtility.HtmlEncode(this.ContextData.Scorecard.Name.Text));
output.Write("
Scorecard View Name: " + HttpUtility.HtmlEncode(this.ContextData.ConfiguredView.Name.Text));
output.Write("
selected KpiGroupId: " + HttpUtility.HtmlEncode(this.ContextData.SelectedKpiGroupId.ToString()));
output.Write("
selected KpiMeasureId: " + HttpUtility.HtmlEncode(this.ContextData.SelectedKpiMeasureId.ToString()));
output.Write("
Active page filters:");
output.Write(GetMemberCollectionHtml(this.ContextData.PageFilters));
output.Write("
Column slices of the selected cell:");
output.Write(GetMemberCollectionHtml(this.ContextData.ColumnSlices));
output.Write("
Row slices of the selected cell:");
output.Write(GetMemberCollectionHtml(this.ContextData.RowSlices));
}
private string GetMemberCollectionHtml(MemberCollection members)
{
string html = "";
foreach (Member member in members)
{
html += "
" + HttpUtility.HtmlEncode(member.UniqueName);
}
return html;
}
}
}
显示自定义报告视图之前,必须在服务器的 GAC 中以及基于 Windows SharePoint Services 或 SharePoint Portal Server 的网站的 web.config 文件中注册 Web 组件扩展内容。
使用 Web 组件
1. 在运行 Business Scorecard Manager Server 的服务器的全局程序集缓存 (GAC) 中注册 Web 组件。若要在 GAC 中进行注册,请在命令提示符后运行以下命令:
gacutil /f /i CustomReportViewSample.dll
2. 该示例在单个程序集中同时包含配置控件和 Web 控件。若要使用 Business Scorecard Manager Server 注册该组件,必须编辑基于 Windows SharePoint Services 或 SharePoint Portal Server 的网站的 web.config 文件,该网站将托管记分卡视图页面。如下面的代码示例所示,在
Then, add a
构建自定义报告视图时,必须将程序集引用值和 PublicKeyToken 值更改为您的程序集的相应值。
此时,您将能够看到新示例报告视图 Web 组件与其他报告视图一并显示在网页上。
¥29.8
¥9.9
¥59.8