sqlserver2005的KPI展示控件开发详解
2008-11-24 10:10:40 来源:WEB开发网DataGridViewTrendColumn定义
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace KPIDisplayer
{
internal class DataGridViewTrendColumn : DataGridViewImageColumn
{
public DataGridViewTrendColumn()
{
CellTemplate = new DataGridViewTrendCell();
}
}
}
step3.取得analysis services 中的定义的KPI的信息和KPI的值。
/**//// <summary>
/// 展示结果
/// </summary>
public void Display()
{
AdomdConnection myKPIConnection = new AdomdConnection(_connectString);
_kpiDataSet = new KPIDataSet();
KPIDataSet.KPIModelRow kpiRow;
try
{
myKPIConnection.Open();
CubeDef myCubeDef = myKPIConnection.Cubes[this._cubeName];
AdomdCommand myKPICommand;
foreach (Kpi k in myCubeDef.Kpis)
{
myKPICommand = new AdomdCommand();
myKPICommand.Connection = myKPIConnection;
StringBuilder sb = new StringBuilder();
sb.Append("SELECT { ");
sb.Append("KPIValue("" + k.Name + ""), ");
sb.Append("KPIGoal("" + k.Name + ""), ");
sb.Append("KPIStatus("" + k.Name + ""), ");
sb.Append("KPITrend("" + k.Name + "")");
sb.Append("} ON COLUMNS FROM ["+this._cubeName+"]");
myKPICommand.CommandText = sb.ToString();
CellSet cellset = myKPICommand.ExecuteCellSet();
string kpiName = k.Name;
string kpiValue = cellset.Cells[0].FormattedValue;
string kpiGoal = cellset.Cells[1].FormattedValue;
string kpiStatus = cellset.Cells[2].FormattedValue;
string kpiTrend = cellset.Cells[3].FormattedValue;
string kpiStatusGraph = k.StatusGraphic;
string kpiTrendGraph = k.TrendGraphic;
kpiRow = this._kpiDataSet.KPIModel.NewKPIModelRow();
kpiRow.Name = kpiName;
kpiRow.Value = Convert.ToDecimal(kpiValue);
kpiRow.Goal = Convert.ToDecimal(kpiGoal);
kpiRow.Status = kpiStatusGraph + "," + kpiStatus;
kpiRow.Trend = kpiTrendGraph + "," + kpiTrend;
this._kpiDataSet.KPIModel.AddKPIModelRow(kpiRow);
}
}
catch (AdomdErrorResponseException myException)
{
MessageBox.Show(this, "连接Analysis Service服务器出错!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
catch (Exception ex)
{
MessageBox.Show(this, "未知错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
}
finally
{
myKPIConnection.Close();
}
step4.绑定到DataGridView。
this.kpiDataGridView1.DataSource = this._kpiDataSet.KPIModel;
step5.搞定,运行。
- ››sqlserver安装和简单的使用
- ››SqlServer触发器、存储过程和函数
- ››SQLServer建立交叉表查询
- ››SqlServer强制断开数据库连接的方法
- ››SQLServer 2005 海量数据解决方案
- ››SQLServer 2008数据库查看死锁、堵塞的SQL语句
- ››SqlServer 插入多条数据
- ››SQLServer 2008 R2导出的SQL文件中没有数据
- ››SQLSERVER通过游标查询两个数据表共有字段名组合成...
- ››sqlserver2008实现拼音首字母和随机n位数的生成
- ››SQLServer与Java数据类型对应表
- ››sqlserver的日常检查脚本归结
更多精彩
赞助商链接