/*
         * Init checkbox fields to exclude the key attribute
         */
        void InitAttributeAndMeasures(string sQuery, GridView objGrid)
        {
            MiningManager objMiningManager = new MiningManager();

            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List <string> sAtributes = new List <string>();

            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value    = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sAtributes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            objGrid.DataSource = sAtributes;
            objGrid.DataBind();
        }
        /*
         * Init all cubes
         */
        private void InitCubes()
        {
            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT CUBE_NAME FROM $system.mdschema_cubes WHERE left(CUBE_NAME, 1) <> '$' AND len(BASE_CUBE_NAME) = 0";

            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List <string> sCubes = new List <string>();

            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value    = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListCubes.DataSource = sCubes;
            DropDownListCubes.DataBind();
        }
        /*
         * Init all dimension names into a listbox
         */
        private void InitDimensionNames()
        {
            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT DIMENSION_NAME FROM $system.mdschema_dimensions WHERE CUBE_NAME = '" +
                            DropDownListCubes.SelectedItem.Text + "'";

            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List <string> sCubes = new List <string>();

            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value    = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListDimensions.DataSource = sCubes;
            DropDownListDimensions.DataBind();
        }
        /*
         * Init all attributes
         */
        private void InitAttributes()
        {
            // clear current query
            DropDownListKey.DataSource = null;
            DropDownListKey.DataBind();

            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT HIERARCHY_NAME FROM $system.mdschema_hierarchies WHERE CUBE_NAME = '" +
                            DropDownListCubes.SelectedItem.Text + "' AND [DIMENSION_UNIQUE_NAME] = '[" +
                            DropDownListDimensions.SelectedItem.Text + "]'";

            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List <string> sCubes = new List <string>();

            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value    = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListKey.DataSource = sCubes;
            DropDownListKey.DataBind();

            // init input columns
            sQuery = "SELECT HIERARCHY_NAME FROM $system.mdschema_hierarchies WHERE CUBE_NAME = '" +
                     DropDownListCubes.SelectedItem.Text + "' AND [DIMENSION_UNIQUE_NAME] = '[" +
                     DropDownListDimensions.SelectedItem.Text + "]' AND HIERARCHY_NAME <> '" + DropDownListKey.SelectedItem.Text + "'";
            InitAttributeAndMeasures(sQuery, GridViewAttributes);

            // init measures
            sQuery = "SELECT MEASURE_NAME FROM $system.mdschema_measures WHERE CUBE_NAME = '" +
                     DropDownListCubes.SelectedItem.Text + "'";
            InitAttributeAndMeasures(sQuery, GridViewMeasures);
        }
        /*
         * Init all dimension names into a listbox
         */
        private void InitDimensionNames()
        {
            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT DIMENSION_NAME FROM $system.mdschema_dimensions WHERE CUBE_NAME = '" +
                DropDownListCubes.SelectedItem.Text + "'";
            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List<string> sCubes = new List<string>();
            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListDimensions.DataSource = sCubes;
            DropDownListDimensions.DataBind();
        }
        /*
         * Init all cubes
         */
        private void InitCubes()
        {
            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT CUBE_NAME FROM $system.mdschema_cubes WHERE left(CUBE_NAME, 1) <> '$' AND len(BASE_CUBE_NAME) = 0";
            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List<string> sCubes = new List<string>();
            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListCubes.DataSource = sCubes;
            DropDownListCubes.DataBind();
        }
        /*
         * Init all attributes
         */
        private void InitAttributes()
        {
            // clear current query
            DropDownListKey.DataSource = null;
            DropDownListKey.DataBind();

            MiningManager objMiningManager = new MiningManager();

            string sQuery = "SELECT HIERARCHY_NAME FROM $system.mdschema_hierarchies WHERE CUBE_NAME = '" +
                DropDownListCubes.SelectedItem.Text + "' AND [DIMENSION_UNIQUE_NAME] = '[" +
                DropDownListDimensions.SelectedItem.Text + "]'";
            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List<string> sCubes = new List<string>();

            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sCubes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            DropDownListKey.DataSource = sCubes;
            DropDownListKey.DataBind();

            // init input columns
            sQuery = "SELECT HIERARCHY_NAME FROM $system.mdschema_hierarchies WHERE CUBE_NAME = '" +
                DropDownListCubes.SelectedItem.Text + "' AND [DIMENSION_UNIQUE_NAME] = '[" +
                DropDownListDimensions.SelectedItem.Text + "]' AND HIERARCHY_NAME <> '" + DropDownListKey.SelectedItem.Text + "'";
            InitAttributeAndMeasures(sQuery, GridViewAttributes);

            // init measures
            sQuery = "SELECT MEASURE_NAME FROM $system.mdschema_measures WHERE CUBE_NAME = '" +
                DropDownListCubes.SelectedItem.Text + "'";
            InitAttributeAndMeasures(sQuery, GridViewMeasures);
        }
        /*
         * Init checkbox fields to exclude the key attribute
         */
        void InitAttributeAndMeasures(string sQuery, GridView objGrid)
        {
            MiningManager objMiningManager = new MiningManager();

            // display results
            Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetQueryResult(sQuery);

            List<string> sAtributes = new List<string>();
            try
            {
                while (objMiningData.Read())
                {
                    for (int i = 0; i < objMiningData.FieldCount; i++)
                    {
                        object value = objMiningData.GetValue(i);
                        string strValue = (value == null) ? string.Empty : value.ToString();
                        sAtributes.Add(strValue);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            objGrid.DataSource = sAtributes;
            objGrid.DataBind();
        }