예제 #1
0
        /// <summary>
        /// Returns a dictionary of row label to value retrieved from a query (command) applied to a cube (CubeInfo).
        /// </summary>
        /// <param name="cubeInfo"></param>
        /// <param name="command"></param>
        /// <returns></returns>
        public Dictionary <string, double> GetSlicedMeasureData(CubeInfo cubeInfo, string command)
        {
            Dictionary <string, double> datalist = new Dictionary <string, double>();

            string connection = cubeInfo.getStandardConnectionString();

            try
            {
                using (AdomdConnection conn = new AdomdConnection(connection))
                {
                    conn.Open();

                    using (AdomdCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = command;

                        using (AdomdDataReader result = cmd.ExecuteReader())
                        {
                            while (result.Read())
                            {
                                string label = "";
                                if (!result.IsDBNull(0))
                                {
                                    label = result[0].ToString();
                                }
                                double value = 0;
                                if (!result.IsDBNull(2))
                                {
                                    value = result.GetDouble(2);
                                }

                                datalist.Add(label, value);
                            }
                        }
                    }
                    conn.Close();
                }
            }
            catch (AdomdErrorResponseException aere)
            {
                Utility.WriteToConsole(string.Format(Constants.invalid, aere.Message), 100);
            }

            return(datalist);
        }