This sample is written in C# and use SQL Server 2005 beta 2 and a beta version of the .Net Framework 2.0. It show how, with ADOMD.Net, you can retreive KPI that are defined in Analysis Services 2005.
1) reference the namespace for ADOMD:
using
2) Build your connection string and connect to Analysis Services
string
AdomdConnection myKPIConnection;
CubeDef myCubeDef;
myConnectionString = "Data Source=" + @myOlapServer + ";Catalog=\"" + @myOlapDatabase + "\"";
myKPIConnection =
myKPIConnection.Open();
myCubeDef = myKPIConnection.Cubes[myCube];
3) Build the command and query the Olap database :
AdomdCommand myKPICommand;
{
myKPICommand =
myKPICommand.Connection = myKPIConnection;
myKPICommand.CommandText = "SELECT { strtomember(@Value), strtomember(@Goal), strtomember(@Status), strtomember(@Trend) } ON COLUMNS FROM [" +myCubeDef.Name + "]";
myKPICommand.Parameters.Clear();
myKPICommand.Parameters.Add(
CellSet cellset = myKPICommand.ExecuteCellSet();
Response.Write("<td><font face=arial size=3><img src=\"images\\kpi_icon.gif\"></td>");
Response.Write("<td align=right><font face=arial size=3>" + kpiValue + "</td>");
Response.Write("<td align=right><font face=arial size=3>" + kpiGoal + "</td>");
Response.Write("<td><center><img src=" + myGraphicFileInfo.GetKpiImage(k.StatusGraphic, Convert.ToDouble(cellset.Cells[2].Value)) + "></center></td>");
if (k.Description != null && k.Description != "")
Response.Write("<td><center><img src=images\\info.gif title=\"" + k.Description + "\"></center></td>");
Response.Write("<td></td>");
Response.Write("</tr>");
}
4) the query return a status graphic, and a value, now you have to retreive which graphic you should display, this is the goals of the method myGraphicFileInfo.GetKpiImage(k.StatusGraphic, Convert.ToDouble(cellset.Cells[2].Value), and this is the source of this methode :
///
public
InitializeGraphicFileInfo();
graphicFiles =
graphicFiles.Add("Standard Arrow",
graphicFiles.Add("XP Arrow",
graphicFiles.Add("Status Arrow - Ascending",
graphicFiles.Add("Status Arrow - Descending",
graphicFiles.Add("Traffic Light - Single",
graphicFiles.Add("Traffic Light - Multiple",
graphicFiles.Add("Road Signs",
graphicFiles.Add("Gauge - Ascending",
graphicFiles.Add("Gauge - Descending",
graphicFiles.Add("Thermometer",
graphicFiles.Add("Cylinder",
graphicFiles.Add("Smiley Face",
GraphicFileInformation graphicFile = (GraphicFileInformation)graphicFiles[graphicName];
fileNumber = 0;
fileNumber = graphicFile.LastFileNumber;
Last week I worked with a customer who wanted to give users the ability to create and subscribe to alerts
PingBack from http://boxing.247blogging.info/?p=3049
PingBack from http://boxing.247blogging.info/?p=3178
One of the more publicized features of Analysis Services 2005 is the intrinsic support for the KPIs (for
项目中要从Web端根据维护的参数在Cube中创建KPI,查了一天多资料,只查到MSDN中有一个