Class DatabaseConfigurator
Provides methods for creating or updating Repository or Umbraco database. This class is intended to be used by Repository Configuration and Dev Portal Configuration utilities.
Inheritance
Inherited Members
Namespace: Nevatech.Vsb.Repository.Services
Assembly: Nevatech.Vsb.Repository.dll
Syntax
public sealed class DatabaseConfigurator
Constructors
DatabaseConfigurator(String, String)
Initializes new instance with connection strings.
Declaration
public DatabaseConfigurator(string runtimeConnectionString, string systemMasterConnectionString)
Parameters
Type | Name | Description |
---|---|---|
System.String | runtimeConnectionString | Connection string to be used by runtime components (Repository and Agent). It must be fully populated and include credentials and database name. |
System.String | systemMasterConnectionString | Connection string with elevated access permissions to the database server. It must point to a default or Master database. |
Fields
DevPortalConnectionStringName
Gets connection string name in application configuration file that contains DevPortal database connection string.
Declaration
public const string DevPortalConnectionStringName = "umbracoDbDSN"
Field Value
Type | Description |
---|---|
System.String |
LatestDbVersion
The latest database version that does not require any schema updates.
Declaration
public static readonly Version LatestDbVersion
Field Value
Type | Description |
---|---|
System.Version |
MinimumSupportedDbVersion
The minimum database version supported by this tool.
Declaration
public static readonly Version MinimumSupportedDbVersion
Field Value
Type | Description |
---|---|
System.Version |
MonitoringConnectionStringName
Gets connection string name in application configuration file that contains Monitoring database connection string.
Declaration
public const string MonitoringConnectionStringName = "Nevatech.Vsb.Monitoring"
Field Value
Type | Description |
---|---|
System.String |
ProviderName
Name of the SQL Server database provider.
Declaration
public const string ProviderName = "System.Data.SqlClient"
Field Value
Type | Description |
---|---|
System.String |
RepositoryConnectionStringName
Gets connection string name in application configuration file that contains Repository database connection string.
Declaration
public const string RepositoryConnectionStringName = "Nevatech.Vsb.Repository"
Field Value
Type | Description |
---|---|
System.String |
Methods
CreateOrUpdateRepositoryDatabase()
Creates, upgrades, and populates the Repository database and its entities.
Declaration
public void CreateOrUpdateRepositoryDatabase()
CreateOrUpdateRepositoryDatabase(Boolean, Boolean, Boolean, String)
Creates, upgrades, and populates the Repository database and its entities.
Declaration
public void CreateOrUpdateRepositoryDatabase(bool configurationObjects, bool monitoringObjects, bool enableTablePartitioning = false, string collation = null)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | configurationObjects | Flag indicating that Configuration database objects must be created or updated. |
System.Boolean | monitoringObjects | Flag indicating that Monitoring database objects must be created or updated. |
System.Boolean | enableTablePartitioning | True to enable the monitoring tables partitioning, false otherwise. The default value is false. |
System.String | collation | The optional collation to use or null to use the default SQL Server collation. |
CreateOrUpdateSystemAdministrator(String, String, String, String)
Creates or updates the system administrator's account.
Declaration
public void CreateOrUpdateSystemAdministrator(string userName, string password, string friendlyName, string email)
Parameters
Type | Name | Description |
---|---|---|
System.String | userName | User login name. |
System.String | password | User password. |
System.String | friendlyName | User account friendly name. |
System.String | User's e-mail address. |
CreateSqlLoginAndUser(String, String, Boolean)
Creates a SQL login and user.
Declaration
public void CreateSqlLoginAndUser(string loginName, string password, bool isOwner = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | loginName | The SQL login name. |
System.String | password | The SQL login password. |
System.Boolean | isOwner | True to add user to the database 'db_owner' role, false otherwise. The default value is false. |
CreateWindowsLoginAndUser(String, Boolean)
Creates a Windows login and corresponding user.
Declaration
public void CreateWindowsLoginAndUser(string identityName, bool isOwner = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | identityName | Windows identity name. |
System.Boolean | isOwner | True to add user to the database 'dbo' role, false otherwise. The default value is false. |
EnsureDatabaseAccess(Boolean)
Creates an empty database, SQL Server login, and/or a database user specified in the runtime connection string.
Declaration
public void EnsureDatabaseAccess(bool allowToCreateDatabase = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | allowToCreateDatabase | Flag indicating that empty database can be created, if it does not exist yet. If False and database does not exist then exception will be thrown. |
GetCollation()
Gets the collation name of this database.
Declaration
public string GetCollation()
Returns
Type | Description |
---|---|
System.String | The collation name. |
GetDatabases()
Returns collection of names of the non-system databases.
Declaration
public Collection<string> GetDatabases()
Returns
Type | Description |
---|---|
System.Collections.ObjectModel.Collection<System.String> | Collection of names of the non-system databases. |
GetDatabases(String)
Returns collection of names of the non-system databases.
Declaration
public static Collection<string> GetDatabases(string systemMasterConnectionString)
Parameters
Type | Name | Description |
---|---|---|
System.String | systemMasterConnectionString | Connection string with elevated access permissions to the database server. It must point to a default or Master database. |
Returns
Type | Description |
---|---|
System.Collections.ObjectModel.Collection<System.String> | Collection of names of the non-system databases. |
GetServerType()
Returns the type of the current database server.
Declaration
public DatabaseServerType GetServerType()
Returns
Type | Description |
---|---|
DatabaseServerType | Type of the current database server. |
GetUmbracoDatabaseVersion(String)
Returns the current Umbraco database schema version.
Declaration
public static string GetUmbracoDatabaseVersion(string runtimeConnectionString)
Parameters
Type | Name | Description |
---|---|---|
System.String | runtimeConnectionString | Connection string that points to Umbraco database. It must be fully populated and include credentials and database name. |
Returns
Type | Description |
---|---|
System.String | The database schema version or "0.0.0.0", if version cannot be retrieved. |
IsSystemAdministrator()
Checks if the current administrative user has system administrator privileges on the target SQL server.
Declaration
public bool IsSystemAdministrator()
Returns
Type | Description |
---|---|
System.Boolean |
|
IsValidMonitoringDatabase()
Checks whether the current database connection represents a valid monitoring database.
Declaration
public bool IsValidMonitoringDatabase()
Returns
Type | Description |
---|---|
System.Boolean | True if the current database is valid Sentinet monitoring database, false otherwise. |
LoadConfigurationSettings(String)
Loads configuration settings from the database and sets the singleton Current instance.
Declaration
public static void LoadConfigurationSettings(string runtimeConnectionString)
Parameters
Type | Name | Description |
---|---|---|
System.String | runtimeConnectionString | Connection string to be used by runtime components (Repository and Agent). It must be fully populated and include credentials and database name. |
PatchUmbracoDatabase()
Patches Umbraco database.
Declaration
public void PatchUmbracoDatabase()
ReplicationFeatureInstalled()
Checks whether the replication feature is installed for this instance of SQL Server.
Declaration
public bool ReplicationFeatureInstalled()
Returns
Type | Description |
---|---|
System.Boolean | True if replication is installed, false otherwise. |
SaveConfigurationSettings()
Saves configuration settings from the singleton Current instance to the database.
Declaration
public void SaveConfigurationSettings()
SqlAgentRunning()
Checks whether SQL Server Agent service is running.
Declaration
public bool SqlAgentRunning()
Returns
Type | Description |
---|---|
System.Boolean | True if service is running, false otherwise. |
ValidateDatabaseVersion()
Ensures the target database version is compatible with the current installation and can be upgraded.
Declaration
public void ValidateDatabaseVersion()