/* * Execute custom query */ private void InitDataTable(string sQuery) { SQLMiningManager objMiningManager = new SQLMiningManager(); // clear node table GridViewDistribution.DataSource = null; GridViewDistribution.DataBind(); // display results Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetMiningResults(sQuery); if (objMiningData == null) { return; } DataTable objTable = new DataTable(); DataColumn myColumn = new DataColumn(); DataRow myRow = null; DataTable objSchemaTable = objMiningData.GetSchemaTable(); List <string> lMeta = new List <string>(); // init meta values for (int i = 0; i < objSchemaTable.Rows.Count; i++) { lMeta.Add(objSchemaTable.Rows[i][0].ToString()); } // add columns and column captions for (int i = 0; i < objMiningData.FieldCount; i++) { myColumn = new DataColumn(lMeta[i]); objTable.Columns.Add(myColumn); } // output the rows in the DataReader while (objMiningData.Read()) { // new row myRow = objTable.NewRow(); // set the row values for (int i = 0; i < objMiningData.FieldCount; i++) { myRow[i] = objMiningData[i]; } // add row to the table objTable.Rows.Add(myRow); } // close reader objMiningData.Close(); GridViewResults.DataSource = objTable; GridViewResults.DataBind(); // load the main table data Session.Add("queryMining", objTable); }
//private const string sServer = "localhost"; protected void Page_Load(object sender, EventArgs e) { try { // load existing mining structures if (!Page.IsPostBack) { LoadCustomization(); LoadExistingStructures(); InitCubes(); InitDimensionNames(); InitAttributes(); } // get from session if (Session != null) { // initial query data DataTable objTable = new DataTable(); if (Session["queryData"] != null) { objTable = (DataTable)Session["queryData"]; //GridViewData.DataSource = objTable; //GridViewData.DataBind(); // initialize column list //InitializeColumns(objTable); } // mining query data if (Session["queryMining"] != null) { objTable = (DataTable)Session["queryMining"]; GridViewResults.DataSource = objTable; GridViewResults.DataBind(); // load viewer for the current model LoadViewer(); } // node query data if (Session["queryNode"] != null) { objTable = (DataTable)Session["queryNode"]; GridViewDistribution.DataSource = objTable; GridViewDistribution.DataBind(); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } // register event DropDownListCubes.SelectedIndexChanged += new EventHandler(DropDownListCubes_SelectedIndexChanged); DropDownListDimensions.SelectedIndexChanged += new EventHandler(DropDownListDimensions_SelectedIndexChanged); DropDownListKey.SelectedIndexChanged += new EventHandler(DropDownListKey_SelectedIndexChanged); DropDownListAlgorithm.SelectedIndexChanged += new EventHandler(DropDownListAlgorithm_SelectedIndexChanged); }
/* * Show distribution node for selected row */ private void DisplayDistributionNode(string sNodeName) { SQLMiningManager objMiningManager = new SQLMiningManager(); string sQuery = "select NODE_DISTRIBUTION from [" + DropDownListStructures.SelectedItem.ToString() + "].CONTENT where NODE_NAME ='" + sNodeName + "'"; // display results Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetMiningResults(sQuery); // return for invalid data if (objMiningData == null) { return; } Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objNode = null; // output the rows in the DataReader while (objMiningData.Read()) { for (int j = 0; j < objMiningData.FieldCount; j++) { objNode = (Microsoft.AnalysisServices.AdomdClient.AdomdDataReader)objMiningData[j]; // table defines DataTable objTable = new DataTable(); DataColumn myColumn = new DataColumn(); DataRow myRow = null; // Get the node meta DataTable objSchemaTable = objNode.GetSchemaTable(); List <string> lMeta = new List <string>(); // init meta values for (int i = 0; i < objSchemaTable.Rows.Count; i++) { lMeta.Add(objSchemaTable.Rows[i][0].ToString()); } // add columns and column captions for (int i = 0; i < objNode.FieldCount; i++) { myColumn = new DataColumn(lMeta[i]); objTable.Columns.Add(myColumn); } // read the node while (objNode.Read()) { // new row myRow = objTable.NewRow(); // set the row values for (int i = 0; i < objNode.FieldCount; i++) { myRow[i] = objNode[i]; } // add row to the table objTable.Rows.Add(myRow); } // close reader objNode.Close(); GridViewDistribution.DataSource = objTable; GridViewDistribution.DataBind(); // hide viewer panel and show grid table GridViewDistribution.Visible = true; PanelViewer.Visible = false; // load the main table data Session.Add("queryNode", objTable); } } // close reader objMiningData.Close(); }