Exemplo n.º 1
0
        // execute SSAS/OLAP command and return a R language compliant dataframe script representing the result data.
        static string SSASConnectAndExec(string mdx)
        {
            AdomdConnection conn = new AdomdConnection(_connStr);
            //  string mdx = "SELECT {[Measures].[Page Views],[Measures].[Daily Unique Visitors]} ON 0,{[Dim Date].[Month].[Month]} ON ROWS FROM [Hearst POC];";
            AdomdCommand     cmd = new AdomdCommand(mdx, conn);
            AdomdDataAdapter da  = new AdomdDataAdapter(cmd);
            DataTable        dt  = new DataTable();

            try
            {
                conn.Open();
            }
            catch (AdomdException e)
            {
                Console.WriteLine(">> Failed to open SSAS Connection");
                log.Error("Failed to open SSAS connection for " + _connStr, e);
                return(null);
            }

            try
            {
                da.Fill(dt);
            }
            catch (AdomdException e)
            {
                Console.WriteLine(">> Failed to fill the datatable");
                log.Error("Failed to fill datatable for query " + mdx, e);
                return(null);
            }

            // Clean up ado.net objects
            da.Dispose();
            conn.Close();

            // process datatable and create R language compliant dataframe object as script
            return(DataTableToRDataFrame(dt));
        }
Exemplo n.º 2
0
        // execute SSAS/OLAP command and return a R language compliant dataframe script representing the result data.
        static string SSASConnectAndExec(string mdx)
        {
            AdomdConnection conn = new AdomdConnection(_connStr);
            //  string mdx = "SELECT {[Measures].[Page Views],[Measures].[Daily Unique Visitors]} ON 0,{[Dim Date].[Month].[Month]} ON ROWS FROM [Hearst POC];";
            AdomdCommand cmd = new AdomdCommand(mdx, conn);
            AdomdDataAdapter da = new AdomdDataAdapter(cmd);
            DataTable dt = new DataTable();

            try
            {
                conn.Open();
            }
            catch (AdomdException e)
            {
                Console.WriteLine(">> Failed to open SSAS Connection");
                log.Error("Failed to open SSAS connection for " + _connStr, e);
                return null;
            }

            try
            {
                da.Fill(dt);
            }
            catch (AdomdException e)
            {
                Console.WriteLine(">> Failed to fill the datatable");
                log.Error("Failed to fill datatable for query " + mdx, e);
                return null;
            }

            // Clean up ado.net objects
            da.Dispose();
            conn.Close();

            // process datatable and create R language compliant dataframe object as script
            return DataTableToRDataFrame(dt);
        }