Ejemplo n.º 1
0
        }     //method

        public void CheckUpgradeDatabase(Database db)
        {
            //Invoke upgrade
            // Update db model
            if (db.Settings.UpgradeMode == DbUpgradeMode.Never)
            {
                ActivationLog.WriteMessage("Data source upgrade mode set to Never, skipping db upgrade.");
                return;
            }
            // upgrade
            var updateMgr   = new DbUpgradeManager(db, ActivationLog);
            var upgradeInfo = updateMgr.UpgradeDatabase(); //it might throw exception
            // _events.OnDataSourceStatusChanging(new DataSourceEventArgs(dataSource, DataSourceEventType.Connected));
        }
Ejemplo n.º 2
0
        public void RegisterDataSource(DataSource dataSource)
        {
            Util.CheckNotEmpty(dataSource.Name, "DataSource name may not be empty.");
            _app.SystemLog.Info("  Connecting to data source {0}.", dataSource.Name);
            //dataSource.Database.CheckConnectivity();
            lock (_lock) {
                var oldDs = LookupDataSource(dataSource.Name);
                if (oldDs != null)
                {
                    return;
                }
                //create copy, add to it, and then replace with interlock
                IDictionary <string, DataSource> newDict;
                if (_dataSources == null || _dataSources.Count == 0)
                {
                    newDict = new Dictionary <string, DataSource>(StringComparer.OrdinalIgnoreCase);
                }
                else
                {
                    newDict = new Dictionary <string, DataSource>(_dataSources, StringComparer.OrdinalIgnoreCase);
                }
                newDict.Add(dataSource.Name, dataSource);
                System.Threading.Interlocked.Exchange(ref _dataSources, newDict);
            }
            //Invoke upgrade
            _events.OnDataSourceStatusChanging(new DataSourceEventArgs(dataSource, DataSourceEventType.Connecting));
            // Update db model
            var db = dataSource.Database;

            if (db.Settings.UpgradeMode != DbUpgradeMode.Never)
            {
                var updateMgr   = new DbUpgradeManager(dataSource);
                var upgradeInfo = updateMgr.UpgradeDatabase();
                _app.CheckActivationErrors();
                ApplyPostUpgradeMigrations(upgradeInfo);
            }
            _events.OnDataSourceStatusChanging(new DataSourceEventArgs(dataSource, DataSourceEventType.Connected));
        }