private void buildReport(string mdx, DataGridView dataGrid)
        {
            conn.Open();
            conn.ChangeDatabase("ProjectAnalysis");
            AdomdDataAdapter adapter = new AdomdDataAdapter(mdx, conn);
            DataSet          setin   = new DataSet();

            adapter.Fill(setin);
            dataGrid.DataSource = setin.Tables[0];

            foreach (DataColumn column in setin.Tables[0].Columns)
            {
                if (column.ColumnName.Contains("Дата"))
                {
                    String columnName = column.ColumnName;

                    System.Text.RegularExpressions.Match dateMatch = System.Text.RegularExpressions.Regex.Match(columnName, @"(?<year>\d{4})\-(?<month>\d{2})\-(?<day>\d{2})");
                    Int32    year   = Convert.ToInt32(dateMatch.Groups["year"].Value);
                    Int32    month  = Convert.ToInt32(dateMatch.Groups["month"].Value);
                    Int32    day    = Convert.ToInt32(dateMatch.Groups["day"].Value);
                    DateTime period = new DateTime(year, month, day);

                    column.ColumnName = period.ToString(DATEFORMAT);
                }
            }

            conn.Close();
        }
예제 #2
0
        //8
        public void ConnectToDB8()
        {
            AdomdConnection connection = new AdomdConnection(@"DataSource=" + serverName);

            try
            {
                connection.Open();
                connection.ChangeDatabase(DataBaseName8);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Исключение в процессе соединения с базой данных: " + ex.Message);
            }

            try
            {
                AdomdDataAdapter adapter = new AdomdDataAdapter(@"select " + columns + " on columns, "
                                                                + rows + " on rows FROM " + from + where, connection);
                DataSet set = new DataSet();
                adapter.Fill(set);
                dataGridViewReport.DataSource = set.Tables[0];
                connection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Исключение при формировании отчёта: " + ex.Message);
            }
        }
예제 #3
0
        /*       public void Open(string connectionString)
         *     {
         *         _adomdConn.Open(connectionString);
         *         if (ConnectionChanged!=null)
         *             ConnectionChanged(this,new EventArgs());
         *     }
         */

        public void ChangeDatabase(string database)
        {
            _currentDatabase = database;
            if (_adomdConn.State != ConnectionState.Open)
            {
                _adomdConn.Open();
            }
            //if (PowerBIFileName != string.Empty)
            //{
            //    _currentDatabase = PowerBIFileName;
            //    ADOTabularDatabase db = Database;
            //    _adomdConn.ChangeDatabase(db.Id);
            //}
            //else
            //{
            if (_adomdConn.Database != database)
            {
                _adomdConn.ChangeDatabase(database);
            }

            //}
            ConnectionChanged?.Invoke(this, new EventArgs());

            _spid = 0; // reset the spid to 0 so that it will get re-evaluated
                       // the PowerBI xmla endpoint sets the permissions to call DISCOVER_SESSIONS on a per data set basis
                       // depending on whether the user has admin access to the given data set
        }
 private void buttonBuildReport_Click(object sender, EventArgs e)
 {
     conn = new AdomdConnection(String.Format("provider=msolap;Data Source={0}", connectForm.nameServer));
     conn.Open();
     conn.ChangeDatabase("ProjectAnalysis");
     this.getFilterData();
     foreach (var empl in listEmployees)
     {
         comboBoxSelectEmpl.Items.Add(empl.ToString());
     }
     conn.Close();
 }
예제 #5
0
        /*       public void Open(string connectionString)
         *     {
         *         _adomdConn.Open(connectionString);
         *         if (ConnectionChanged!=null)
         *             ConnectionChanged(this,new EventArgs());
         *     }
         */

        public void ChangeDatabase(string database)
        {
            _currentDatabase = database;
            if (_adomdConn.State != ConnectionState.Open)
            {
                _adomdConn.Open();
            }
            //if (PowerBIFileName != string.Empty)
            //{
            //    _currentDatabase = PowerBIFileName;
            //    ADOTabularDatabase db = Database;
            //    _adomdConn.ChangeDatabase(db.Id);
            //}
            //else
            //{
            _adomdConn.ChangeDatabase(database);
            //}
            if (ConnectionChanged != null)
            {
                ConnectionChanged(this, new EventArgs());
            }
        }
예제 #6
0
 /// <summary>
 /// Changes the current database for an open MdxConnection.
 /// </summary>
 /// <param name="database">The name of the database to use instead of the current database.</param>
 public override void ChangeDatabase(string databaseName)
 {
     _connection.ChangeDatabase(databaseName);
 }