コード例 #1
0
        public void Close()
        {
            if (_type == AdomdType.AnalysisServices)
            {
                _conn.Close();
            }
            else
            {
                void f() => _connExcel.Close();

                f();
            }
        }
コード例 #2
0
 public void Close()
 {
     if (_type == AdomdType.AnalysisServices)
     {
         _conn.Close();
     }
     else
     {
         ExcelAdoMdConnections.VoidDelegate f = delegate
         {
             _connExcel.Close();
         };
         f();
     }
 }
コード例 #3
0
        private static void DynamicQueryParser(
            string serverAddress,
            string database,
            string UserId,
            string Password,
            string Query,
            bool outputToCsv)
        {
            string ConnectionString = @"Data Source=" + serverAddress + ";Initial catalog=" + database + ";User ID=" +
                                      UserId + ";Password="******";Persist Security Info=True;Impersonation Level=Impersonate";

            var query = Query;

            Console.WriteLine("About to connect to Analysis Services");
            Console.WriteLine("{0} Date Time \n", DateTime.Now.ToString());

            var adocon = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection();

            adocon.ConnectionString = ConnectionString;
            var table = new System.Data.DataTable();

            adocon.Open();
            Console.WriteLine("Successfully Connected to Analysis Services");
            Console.WriteLine("{0} Date Time \n", DateTime.Now.ToString());

            var adoadapter = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(query, adocon);

            adoadapter.Fill(table);
            var str = "";

            foreach (System.Data.DataRow row in table.Rows)
            {
                var cnt = row.ItemArray.Count();
                for (int i = 0; i < cnt; i++)
                {
                    if (i == (cnt - 1))
                    {
                        str += row.ItemArray[i].ToString() + "\n";
                    }
                    else
                    {
                        str += row.ItemArray[i].ToString() + ",";
                    }
                }
            }
            Console.WriteLine("Creating Stream Bytes");
            Console.WriteLine("{0} Date Time \n", DateTime.Now.ToString());

            byte[] bytes = Encoding.ASCII.GetBytes(str);
            Console.WriteLine("Successfully created Stream Bytes");
            Console.WriteLine("{0} Date Time \n", DateTime.Now.ToString());
            var connectionstring = ConfigurationManager.ConnectionStrings["BlobStorage"].ConnectionString;
            var dest             = ConfigurationManager.AppSettings["dest"];

            Task.Run(async() => await SaveTextAsBlobHelper(bytes, connectionstring)).Wait();
            adocon.Close();
            adocon.Dispose();
        }
コード例 #4
0
        public DataTable ForEachMeasureGroupInternal(string command, bool forEachPartition)
        {
            DataTable result = new DataTable();

            Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server();
            server.Connect("*");
            Database db = server.Databases.GetByName(Context.CurrentDatabaseName);

            foreach (Microsoft.AnalysisServices.Cube c in db.Cubes)
            {
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection conn = TimeoutUtility.ConnectAdomdClient("Data Source=" + server.Name + ";Initial Catalog=" + Context.CurrentDatabaseName + ";Cube=" + c.Name);

                foreach (Microsoft.AnalysisServices.MeasureGroup mg in c.MeasureGroups)
                {
                    if (forEachPartition)
                    {
                        foreach (Microsoft.AnalysisServices.Partition p in mg.Partitions)
                        {
                            //parameters don't appear to work with some DMV queries, so use string substitution
                            string sNewCommand = command;
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_NAME", db.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_ID", db.ID);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_NAME", c.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_ID", c.ID);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_NAME", mg.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_ID", mg.ID);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "PARTITION_NAME", p.Name);
                            sNewCommand = ReplaceParameterWithString(sNewCommand, "PARTITION_ID", p.ID);
                            Microsoft.AnalysisServices.AdomdClient.AdomdCommand cmd = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(sNewCommand, conn);
                            cmd.CommandTimeout = 0;
                            Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter adp = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(cmd);
                            TimeoutUtility.FillAdomdDataAdapter(adp, result);
                        }
                    }
                    else
                    {
                        //parameters don't appear to work with some DMV queries, so use string substitution
                        string sNewCommand = command;
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_NAME", db.Name);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "DATABASE_ID", db.ID);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_NAME", c.Name);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "CUBE_ID", c.ID);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_NAME", mg.Name);
                        sNewCommand = ReplaceParameterWithString(sNewCommand, "MEASUREGROUP_ID", mg.ID);
                        Microsoft.AnalysisServices.AdomdClient.AdomdCommand cmd = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand(sNewCommand, conn);
                        cmd.CommandTimeout = 0;
                        Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter adp = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(cmd);
                        TimeoutUtility.FillAdomdDataAdapter(adp, result);
                    }
                }

                conn.Close();
            }
            return(result);
        }
コード例 #5
0
        /*
         * Discover mining services; for future use
         */
        private void DiscoverServices()
        {
            Microsoft.AnalysisServices.AdomdClient.AdomdConnection connection = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection("Data Source=" + sServer + "; Initial Catalog=" + sCatalog);
            connection.Open();

            foreach (Microsoft.AnalysisServices.AdomdClient.MiningService ms in connection.MiningServices)
            {
                Console.WriteLine("Service: " + ms.Name);
                foreach (Microsoft.AnalysisServices.AdomdClient.MiningServiceParameter mp in ms.AvailableParameters)
                {
                    Console.WriteLine(" Parameter: " + mp.Name + " Default: " + mp.DefaultValue);
                }
            }
            connection.Close();
        }
        private void InitASSPLabel()
        {
            try
            {
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection conn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection("Data Source=" + lblServer.Text + ";Initial Catalog=" + lblDatabase.Text);
                conn.Open();

                bool bASSPExists = AggManager.AggregationPerformanceTester.ASSPExists(conn);
                if (bASSPExists)
                {
                    lblASSPInstallStatus.Text = "           version 1.3.5 or later is installed on the server so the file system cache will be cleared between each test.";
                }

                conn.Close();
            }
            catch { }
        }
コード例 #7
0
 public void SimplePredictionQuery()
 {
     Microsoft.AnalysisServices.AdomdClient.AdomdConnection connection = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection();
     connection.ConnectionString =
         "Data Source=localhost; Initial Catalog=Chapter 16";
     connection.Open();
     Microsoft.AnalysisServices.AdomdClient.AdomdCommand cmd = connection.CreateCommand();
     cmd.CommandText =
         "SELECT Predict(Generation) FROM [Generation Trees] " +
         "NATURAL PREDICTION JOIN " +
         "( SELECT " +
         " (SELECT ’Cinemax’ AS Channel UNION " +
         " SELECT ’Showtime’ AS Channel) AS PayChannels " +
         ") AS T ";
     // execute the command and display the prediction result
     Microsoft.AnalysisServices.AdomdClient.AdomdDataReader reader = cmd.ExecuteReader();
     if (reader.Read())
     {
         string predictedGeneration = reader.GetValue(0).ToString();
         Console.WriteLine(predictedGeneration);
     }
     reader.Close();
     connection.Close();
 }
コード例 #8
0
 public void Close() => _conn.Close();
コード例 #9
0
        /*
         * Discover mining services; for future use
         */
        private void DiscoverServices()
        {
            Microsoft.AnalysisServices.AdomdClient.AdomdConnection connection = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection("Data Source=" + sServer + "; Initial Catalog=" + sCatalog);
            connection.Open();

            foreach (Microsoft.AnalysisServices.AdomdClient.MiningService ms in connection.MiningServices)
            {
                Console.WriteLine("Service: " + ms.Name);
                foreach (Microsoft.AnalysisServices.AdomdClient.MiningServiceParameter mp in ms.AvailableParameters)
                {
                    Console.WriteLine(" Parameter: " + mp.Name + " Default: " + mp.DefaultValue);
                }
            }
            connection.Close();
        }
コード例 #10
0
 public void SimplePredictionQuery()
 {
     Microsoft.AnalysisServices.AdomdClient.AdomdConnection connection = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection();
     connection.ConnectionString =
     "Data Source=localhost; Initial Catalog=Chapter 16";
     connection.Open();
     Microsoft.AnalysisServices.AdomdClient.AdomdCommand cmd = connection.CreateCommand();
     cmd.CommandText =
     "SELECT Predict(Generation) FROM [Generation Trees] " +
     "NATURAL PREDICTION JOIN " +
     "( SELECT " +
     " (SELECT ’Cinemax’ AS Channel UNION " +
     " SELECT ’Showtime’ AS Channel) AS PayChannels " +
     ") AS T ";
     // execute the command and display the prediction result
     Microsoft.AnalysisServices.AdomdClient.AdomdDataReader reader = cmd.ExecuteReader();
     if (reader.Read())
     {
         string predictedGeneration = reader.GetValue(0).ToString();
         Console.WriteLine(predictedGeneration);
     }
     reader.Close();
     connection.Close();
 }
コード例 #11
0
        private void InitASSPLabel()
        {
            try
            {
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection conn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection("Data Source=" + lblServer.Text + ";Initial Catalog=" + lblDatabase.Text);
                conn.Open();

                bool bASSPExists = AggManager.AggregationPerformanceTester.ASSPExists(conn);
                if (bASSPExists)
                {
                    lblASSPInstallStatus.Text = "           version 1.3.5 or later is installed on the server so the file system cache will be cleared between each test.";
                }

                conn.Close();
            }
            catch { }
        }