コード例 #1
0
ファイル: OlapDemo.cs プロジェクト: windygu/Justin
        public static void Main1()
        {
            serverAnalysis = new Microsoft.AnalysisServices.Server();

            try
            {
                serverAnalysis.Connect("Data Source = " + strServerName);

                olap = new Olap();

                analysis.Database db = serverAnalysis.Databases.FindByName(strDataBaseName);

                if (db != null)
                {
                    db.Drop();
                }
                else
                {
                    db = serverAnalysis.Databases.Add(strDataBaseName);

                    db.Update();

                    olap.CreateDataSource(db, strName, strConnectionString);

                    olap.CreateDataSourceView(db, strName, strName);

                    olap.CreateGeographyDimension(db, strName);

                    olap.CreateCustomerDimension(db, strName);

                    olap.CreateCube(db, strName);
                }
            }

            catch (analysis.AmoException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #2
0
        private void CreateDatabase()
        {
            try
            {
                AppendLogLine("");
                AppendLogLine(string.Format("Creating a Analysis database: {0} ...", CbDbName));

                _CbServer.Update();
                if (_CbServer.Databases.Contains(CbDbName))
                {
                    AppendLogLine(string.Format("Analysis database: [{0}] already exists, drop it?.", CbDbName));

                    if (MessageBox.Show(string.Format("The Analysis database '{0} - {1}' already exists. Do you want to drop it?", CbServerName, CbDbName),
                                        "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        _CbDatabase = _CbServer.Databases.GetByName(CbDbName);
                        _CbDatabase.Drop();
                    }
                    else
                    {
                        throw new Exception(string.Format("The Analysis database '{0} - {1}' already exists, but user did not want to drop it. Aborting procedure.",
                                                          CbServerName, CbDbName));
                    }
                }

                _CbDatabase = new Database();
                //_CbServer.Databases.GetNewName(CbDbName)
                _CbDatabase = _CbServer.Databases.Add(CbDbName);
                //Save Database to the Analysis Services.
                _CbDatabase.Update();
            }
            catch (Exception ex)
            {
                AppendLogLine("Error in creating a analysis database. Error Message -> " + ex.Message);
                throw;
            }
        }