Ejemplo n.º 1
0
        public override NewDatabaseParameters GetNewParameters(SqlProduct product, string id)
        {
            NewDatabaseParameters parametes = base.GetNewParameters(product, id);

            switch (product)
            {
            case SqlProduct.SqlServer:
                parametes.DbName        = null;
                parametes.Engine        = RDSEngin.sqlserver_ee.ToString().Replace('_', '-');
                parametes.EngineVersion = GetSqlServerEnginVersion();
                return(parametes);

            case SqlProduct.MySql:
                parametes.Engine        = RDSEngin.MySQL.ToString();
                parametes.EngineVersion = GetMySQLEnginVersion();
                return(parametes);

            case SqlProduct.Postgre:
                parametes.Engine        = RDSEngin.postgres.ToString();
                parametes.EngineVersion = GetPostgreSQLEnginVersion();
                return(parametes);

            case SqlProduct.Oracle:
                parametes.Engine        = RDSEngin.oracle_ee.ToString().Replace('_', '-');
                parametes.EngineVersion = GetOracleEnginVersion();
                parametes.DbName        = "ORCL";
                return(parametes);
            }
            return(null);
        }
Ejemplo n.º 2
0
        private string GetCreateNewSchemaAndUserSql(NewDatabaseParameters newDbParameters)
        {
            string sql = string.Format(@"CREATE  DATABASE IF NOT EXISTS `{0}` CharSet=utf8mb4;
                            CREATE USER '{1}'@'%'  IDENTIFIED BY  '{2}';
                            GRANT ALL ON `{0}`.* TO '{1}'@'%';", newDbParameters.DbName, newDbParameters.Username, newDbParameters.Password);

            return(sql);
        }
Ejemplo n.º 3
0
        public virtual NewDatabaseParameters GetNewParameters(SqlProduct product, string id)
        {
            AppId = id ?? string.Empty;
            NewDatabaseParameters parameters = GetNewBaseParameters();

            parameters.Port = GetDefaultProductPort(product);
            return(parameters);
        }
Ejemplo n.º 4
0
        public void CreateNewSystemSchemaAndUser(string connectionString, NewDatabaseParameters newDbParameters)
        {
            string sql = GetCreateNewSchemaAndUserSql(newDbParameters);

            using (System.Data.IDbConnection connection = ConnectionStringHelper.GetConnection(connectionString))
            {
                CreateSchemaAndUser(sql, connection);
            }
        }
Ejemplo n.º 5
0
        public void CreateNewSchemaAndUser(SqlProduct sqlProduct, out string server, out int port, NewDatabaseParameters newDbParameters, string sampleApp)
        {
            string sql = GetCreateNewSchemaAndUserSql(newDbParameters);

            if (!string.IsNullOrEmpty(sampleApp))
            {
                string scriptFileName = Maps.GetDeploymentPath(string.Format("Sql/SampleApp/{0}.sql", sampleApp));

                System.IO.FileInfo file = new System.IO.FileInfo(scriptFileName);
                if (!file.Exists)
                {
                    Maps.Instance.DuradosMap.Logger.Log("myAppConnectionController", "Post", "CreateNewSchemaAndUser", "Sample app file do not exists", null, 1, "Sample app file do not exists", DateTime.Now);
                    throw new Exception("Sample app file do not exists");
                }
                string script = file.OpenText().ReadToEnd();
                sql += script.Replace("__DB__Name__", newDbParameters.DbName);
            }

            using (System.Data.IDbConnection connection = GetExternalAvailableInstanceConnection(sqlProduct, out server, out port))
            {
                CreateSchemaAndUser(sql, connection);
            }
        }