public static ExternalDatabaseServer CreateNewExternalServer(ICatalogueRepository repository, PermissableDefaults defaultToSet, IPatcher patcher) { CreatePlatformDatabase createPlatform = new CreatePlatformDatabase(patcher); createPlatform.ShowDialog(); if (!string.IsNullOrWhiteSpace(createPlatform.DatabaseConnectionString)) { SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(createPlatform.DatabaseConnectionString); var newServer = new ExternalDatabaseServer(repository, builder.InitialCatalog, patcher); newServer.Server = builder.DataSource; newServer.Database = builder.InitialCatalog; //if there is a username/password if (!builder.IntegratedSecurity) { newServer.Password = builder.Password; newServer.Username = builder.UserID; } newServer.SaveToDatabase(); if (defaultToSet != PermissableDefaults.None) { repository.GetServerDefaults().SetDefault(defaultToSet, newServer); } return(newServer); } return(null); }
public static ExternalDatabaseServer CreateNewExternalServer(ICatalogueRepository repository, PermissableDefaults defaultToSet, IPatcher patcher) { CreatePlatformDatabase createPlatform = new CreatePlatformDatabase(patcher); createPlatform.ShowDialog(); var db = createPlatform.DatabaseCreatedIfAny; if (db != null) { var newServer = new ExternalDatabaseServer(repository, db.GetRuntimeName(), patcher); newServer.SetProperties(db); if (defaultToSet != PermissableDefaults.None) { repository.GetServerDefaults().SetDefault(defaultToSet, newServer); } return(newServer); } return(null); }