Exemplo n.º 1
0
        public void Open()
        {
            if (_type == AdomdType.AnalysisServices)
            {
                _conn.Open();
            }
            else
            {
                void f() => _connExcel.Open();

                f();
            }
        }
Exemplo n.º 2
0
 public void Open()
 {
     if (_type == AdomdType.AnalysisServices)
     {
         _conn.Open();
     }
     else
     {
         ExcelAdoMdConnections.VoidDelegate f = delegate
         {
             _connExcel.Open();
         };
         f();
     }
 }
Exemplo n.º 3
0
        /*
         * Return mining results from query
         */
        public Microsoft.AnalysisServices.AdomdClient.AdomdDataReader GetMiningResults(string sQuery)
        {
            try
            {
                string sConnString = "Data Source=" + sServer + "; Initial Catalog=" + sCatalog;
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection objConn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(sConnString);
                objConn.Open();
                Microsoft.AnalysisServices.AdomdClient.AdomdCommand objCmd = objConn.CreateCommand();
                objCmd.CommandText = sQuery;

                /*
                 * "SELECT FLATTENED PredictHistogram(Generation) " +
                 * "FROM [Generation Trees] " +
                 * "NATURAL PREDICTION JOIN " +
                 * "( SELECT " +
                 * " (SELECT ’Cinemax’ AS Channel UNION " +
                 * " SELECT ’Showtime’ AS Channel) AS PayChannels " +
                 * ") AS T ";*/

                //Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objReader = objCmd.ExecuteReader();
                //Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter objDataAdaptor = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(objCmd);

                Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objDataReader = objCmd.ExecuteReader(CommandBehavior.CloseConnection);

                /*
                 * try
                 * {
                 *  for (int i = 0; i < objDataReader.FieldCount; i++)
                 *  {
                 *      Console.Write(objDataReader.GetName(i) + "\t");
                 *  }
                 *  Console.WriteLine();
                 *  while (objDataReader.Read())
                 *  {
                 *      for (int i = 0; i < objDataReader.FieldCount; i++)
                 *      {
                 *          object value = objDataReader.GetValue(i);
                 *          string strValue = (value == null) ?
                 *          string.Empty : value.ToString();
                 *          Console.Write(strValue + "\t");
                 *      }
                 *      Console.WriteLine();
                 *  }
                 * }
                 * finally
                 * {
                 *  objDataReader.Close();
                 * }
                 */

                return(objDataReader);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            return(null);
        }
        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();
        }
Exemplo n.º 5
0
        /*
         * Load mining viewer for the selected structure
         */
        private void LoadViewer()
        {
            if (DropDownListStructures.SelectedItem == null)
            {
                return;
            }

            // clear all the controls in order to avoid adding the same control twice
            PanelViewer.Controls.Clear();

            // define objects
            DMHtmlViewer objViewer = null;

            Microsoft.AnalysisServices.AdomdClient.MiningModel   objModel   = null;
            Microsoft.AnalysisServices.AdomdClient.MiningService objService = null;

            string sConnString = "Data Source=" + sServer + "; Initial Catalog=" + sCatalog;

            Microsoft.AnalysisServices.AdomdClient.AdomdConnection objConn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(sConnString);

            objConn.Open();
            objModel   = objConn.MiningModels[DropDownListStructures.SelectedItem.ToString()];
            objService = objConn.MiningServices[objModel.Algorithm];

            // switch mining service
            switch (objService.ViewerType)
            {
            case "Microsoft_Cluster_Viewer":
                objViewer = new DMClusterViewer();
                break;

            case "Microsoft_Tree_Viewer":
                objViewer = new DMDecisionTreeViewer();
                break;

            case "Microsoft_NaiveBayesian_Viewer":
                objViewer = new DMNaiveBayesViewer();
                break;

            default:
                // if none of the above then return
                return;
            }

            // init data for the current viewer type
            objViewer.Server   = sServer;
            objViewer.Database = sCatalog;
            objViewer.Model    = DropDownListStructures.SelectedItem.ToString();
            objViewer.DataBind();

            PanelViewer.Controls.Add(objViewer);
            PanelViewer.Visible = true;
        }
Exemplo n.º 6
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 { }
        }
Exemplo n.º 8
0
        private static void OpenAdomdClientConnection(object o)
        {
            ConnectAdomdClientInfo info = null;

            try
            {
                info = (ConnectAdomdClientInfo)o;
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection s = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(info.ConnectionString);
                s.Open();
                info.Server = s;
            }
            catch (Exception ex)
            {
                info.ex = ex;
            }
            finally
            {
                info.autoEvent.Set();
            }
        }
Exemplo n.º 9
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();
 }
Exemplo n.º 10
0
        /*
         * Load mining viewer for the selected structure
         */
        private void LoadViewer()
        {
            if (DropDownListStructures.SelectedItem == null)
                return;

            // clear all the controls in order to avoid adding the same control twice
            PanelViewer.Controls.Clear();

            // define objects
            DMHtmlViewer objViewer = null;
            Microsoft.AnalysisServices.AdomdClient.MiningModel objModel = null;
            Microsoft.AnalysisServices.AdomdClient.MiningService objService = null;

            string sConnString = "Data Source=" + sServer + "; Initial Catalog=" + sCatalog;
            Microsoft.AnalysisServices.AdomdClient.AdomdConnection objConn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(sConnString);

            objConn.Open();
            objModel = objConn.MiningModels[DropDownListStructures.SelectedItem.ToString()];
            objService = objConn.MiningServices[objModel.Algorithm];

            // switch mining service
            switch (objService.ViewerType)
            {
                case "Microsoft_Cluster_Viewer":
                    objViewer = new DMClusterViewer();
                    break;
                case "Microsoft_Tree_Viewer":
                    objViewer = new DMDecisionTreeViewer();
                    break;
                case "Microsoft_NaiveBayesian_Viewer":
                    objViewer = new DMNaiveBayesViewer();
                    break;
                default:
                    // if none of the above then return
                    return;
            }

            // init data for the current viewer type
            objViewer.Server = sServer;
            objViewer.Database = sCatalog;
            objViewer.Model = DropDownListStructures.SelectedItem.ToString();
            objViewer.DataBind();

            PanelViewer.Controls.Add(objViewer);
            PanelViewer.Visible = true;
        }
Exemplo n.º 11
0
 public void Open() => _conn.Open();
Exemplo n.º 12
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();
        }
Exemplo n.º 13
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();
 }
Exemplo n.º 14
0
        /*
         * Return mining results from query
         */
        public Microsoft.AnalysisServices.AdomdClient.AdomdDataReader GetMiningResults(string sQuery)
        {
            try
            {
                string sConnString = "Data Source=" + sServer + "; Initial Catalog=" + sCatalog;
                Microsoft.AnalysisServices.AdomdClient.AdomdConnection objConn = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection(sConnString);
                objConn.Open();
                Microsoft.AnalysisServices.AdomdClient.AdomdCommand objCmd = objConn.CreateCommand();
                objCmd.CommandText = sQuery;

                /*
                "SELECT FLATTENED PredictHistogram(Generation) " +
                "FROM [Generation Trees] " +
                "NATURAL PREDICTION JOIN " +
                "( SELECT " +
                " (SELECT ’Cinemax’ AS Channel UNION " +
                " SELECT ’Showtime’ AS Channel) AS PayChannels " +
                ") AS T ";*/

                //Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objReader = objCmd.ExecuteReader();
                //Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter objDataAdaptor = new Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter(objCmd);

                Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objDataReader = objCmd.ExecuteReader(CommandBehavior.CloseConnection);

                /*
                try
                {
                    for (int i = 0; i < objDataReader.FieldCount; i++)
                    {
                        Console.Write(objDataReader.GetName(i) + "\t");
                    }
                    Console.WriteLine();
                    while (objDataReader.Read())
                    {
                        for (int i = 0; i < objDataReader.FieldCount; i++)
                        {
                            object value = objDataReader.GetValue(i);
                            string strValue = (value == null) ?
                            string.Empty : value.ToString();
                            Console.Write(strValue + "\t");
                        }
                        Console.WriteLine();
                    }
                }
                finally
                {
                    objDataReader.Close();
                }
                */

                return objDataReader;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            return null;
        }
        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 { }
        }