public void RegisterDataSource(DataSource dataSource) { Util.CheckNotEmpty(dataSource.Name, "DataSource name may not be empty."); //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) newDict = new Dictionary<string, DataSource>(StringComparer.InvariantCultureIgnoreCase); else newDict = new Dictionary<string, DataSource>(_dataSources, StringComparer.InvariantCultureIgnoreCase); 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(); ApplyMigrations(upgradeInfo); } _events.OnDataSourceStatusChanging(new DataSourceEventArgs(dataSource, DataSourceEventType.Connected)); }
public DataSourceEventArgs(DataSource dataSource, DataSourceEventType eventType) { DataSource = dataSource; EventType = eventType; }
public DbUpgradeEventArgs(DataSource dataSource, DataSourceEventType eventType, List<DbUpgradeScript> scripts, DateTime startedOn, DateTime? completedOn, Exception exception = null, DbUpgradeScript failedScript = null) { DataSource = dataSource; Scripts = scripts; StartedOn = startedOn; CompletedOn = completedOn; Exception = exception; FailedScript = failedScript; }