public Database(string projectName, RDBMS rdbms, IConfiguration configuration, ILogger <Database> logger) { this.projectName = projectName; this.rdbms = rdbms; this.configuration = configuration; this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); database = GetDatabase(rdbms); connectionString = GetConnectionStringFromConfig(connectionStringName); connectionStringMaster = GetConnectionStringFromConfig(connectionStringMasterName); }
private IDB GetDatabase(RDBMS rdbms) { if (rdbms == RDBMS.Postgres) { return(new DBPostgresBL()); } else { throw new Exception($"{rdbms} not supported"); } }
public DBFolders(string projectName, RDBMS databaseType, ILogger logger) { ProjectName = projectName; CurrentRDBMSRootFolder = databaseType.ToString(); if (!Directory.Exists(PathToScripts)) { throw new ApplicationException($"Folder { PathToScripts } with custom scripts does not exist."); } // Example: "[ApplicationName.Database]\Scripts\Postgres\": Postgres folder contains createDB or version folders with scripts. ProcessProjectDirectory(logger, projectName, PathToScripts); }
/// <summary> /// 获取关系型数据库系统提供者 /// </summary> /// <param name="rdbms"><see cref="RDBMS"/>关系型数据库提供者</param> /// <returns>关系型数据库提供者驱动</returns> public static string GetRdbmsProvider(RDBMS rdbms) { switch (rdbms) { case RDBMS.MSSQL: return MSSQL; case RDBMS.Oracle: return Oracle; case RDBMS.MySql: return MySql; case RDBMS.SQLite: return SQLite; default: throw new InvalidOperationException("No found the RDBMS."); } }
public StartupChecker(INodeRepository nodeRepository, IRpcClientFactory rpcClientFactory, IMinerId minerId, IBlockParser blockParser, ICreateDB createDB, INotificationsHandler notificationsHandler, ILogger <StartupChecker> logger, IConfiguration configuration) { this.rpcClientFactory = rpcClientFactory ?? throw new ArgumentNullException(nameof(rpcClientFactory)); this.nodeRepository = nodeRepository ?? throw new ArgumentNullException(nameof(nodeRepository)); this.logger = logger ?? throw new ArgumentException(nameof(logger)); this.blockParser = blockParser ?? throw new ArgumentException(nameof(blockParser)); this.createDB = createDB ?? throw new ArgumentException(nameof(createDB)); this.minerId = minerId ?? throw new ArgumentException(nameof(nodeRepository)); this.notificationsHandler = notificationsHandler ?? throw new ArgumentException(nameof(notificationsHandler)); rdbms = RDBMS.Postgres; }
/// <summary> /// 获取关系型数据库系统提供者 /// </summary> /// <param name="rdbms"><see cref="RDBMS"/>关系型数据库提供者</param> /// <returns>关系型数据库提供者驱动</returns> public static string GetRdbmsProvider(RDBMS rdbms) { switch (rdbms) { case RDBMS.MSSQL: return(MSSQL); case RDBMS.Oracle: return(Oracle); case RDBMS.MySql: return(MySql); case RDBMS.SQLite: return(SQLite); default: throw new InvalidOperationException("No found the RDBMS."); } }
public void AddBuilder(RDBMS rdbms, IConnectionBuilder builder) { _builders.Add(rdbms, builder); }
public IConnectionBuilder GetBuilder(RDBMS rdbms) { return(_builders[rdbms]); }
/// <summary> /// 初始化一个新的<c>Rdbms</c>实例。 /// 对 用户名 和 密码 会采用 AES 方式加密 /// </summary> /// <param name="name">给定的名称</param> /// <param name="description">相关描述</param> /// <param name="server">服务器实例(数据源)</param> /// <param name="catalog">数据库实例</param> /// <param name="userId">用户</param> /// <param name="password">用户密码</param> /// <param name="readOnly">数据库是否是只读</param> /// <param name="rdbms"><see cref="RDBMS"/>关系型数据库</param> public Rdbms(string name, string description, string server, string catalog, string userId, string password, bool readOnly, RDBMS rdbms) : this(name, description, server, catalog, userId, password, readOnly, RdbmsProvider.GetRdbmsProvider(rdbms)) { }
public bool DatabaseExists(string projectName, RDBMS rdbms) { return(new Database(projectName, rdbms, this.configuration, this.logger).DatabaseExists()); }
public bool DoCreateDB(string projectName, RDBMS rdbms, out string errorMessage, out string errorMessageShort) { // expected db scripts hierarchy: [ApplicationName.Database]\Scripts\Postgres\ DisplayScriptFolderOrder(projectName, rdbms); return(new Database(projectName, rdbms, this.configuration, this.logger).CreateDatabase(out errorMessage, out errorMessageShort)); }
private void DisplayScriptFolderOrder(string projectName, RDBMS rdbms) { DBFolders dbFolders = new DBFolders(projectName, rdbms, logger); dbFolders.WriteFolderNames(logger); }