예제 #1
0
        //新建数据库实例
        private void Button16_Click(object sender, EventArgs e)
        {
            env = GetUIValue();
            Dao.Save(env);
            //var workDir = env.envPath + @"\tools\dbsetup\";
            //var cmd = workDir + "start-win.cmd";
            //var cmdexecutor = new CmdExecutor(cmd, workDir, "");

            //var env1 = GetUIValue();
            //string dbType = GetRegistDbType(env1);
            //var lastLine = string.Empty;
            //cmdexecutor.Execute(new string[] { "1", dbType, env1.dbHost, env1.dbPort, env1.dbName, env1.dbUserName, env1.dbPassword, "n" }, (s, ev) => {
            //    lastLine = ev.Data;
            //    if (ev.Data != null)
            //    {
            //        if (lastLine.Contains("新建数据库实例成功"))
            //        {
            //            SaveNode(ConfNode.Env, JToken.FromObject(env1));
            //            AddDBList();
            //        }
            //        AppendTextBoxText(tb_output, ev.Data);
            //        AppendTextBoxText(tb_output, "\n");
            //    }

            //}, (s, ev) => {
            //    AppendTextBoxText(tb_output, "命令执行完成");
            //});
        }
예제 #2
0
        private void SetUIValue(CloudEnv env)
        {
            tb_EnvPath.Text = env.envPath;
            if (env.dbHost == "x.gscloud.top")
            {
                rb_21.Checked = true;
            }
            else if (env.dbHost == "z.gscloud.top")
            {
                rb_35.Checked = true;
            }
            else if (env.dbHost == "127.0.0.1")
            {
                rb_localhost.Checked = true;
            }
            else
            {
                tb_host.Text = env.dbHost;
            }



            tb_dbPort.Text   = env.dbPort;
            tb_username.Text = env.dbUserName;
            tb_password.Text = env.dbPassword;
            tb_dbName.Text   = env.dbName;
        }
예제 #3
0
        private String GetDataImportDBType(CloudEnv e)
        {
            string dbType = "0";

            if (e.dbType == DbType.PgSQL)
            {
                dbType = "1";
            }
            else if (e.dbType == DbType.SQLServer)
            {
                dbType = "2";
            }
            else if (e.dbType == DbType.Oracle)
            {
                dbType = "3";
            }
            else if (e.dbType == DbType.DM)
            {
                dbType = "4";
            }
            else if (e.dbType == DbType.MySQL)
            {
                dbType = "0";
            }
            return(dbType);
        }
예제 #4
0
        //获取注册数据库的数据库类型
        private string GetRegistDbType(CloudEnv e = null)
        {
            var lenv = env;

            if (e != null)
            {
                lenv = e;
            }

            string dbType = "0";

            if (lenv.dbType == DbType.PgSQL)
            {
                dbType = "1";
            }
            else if (lenv.dbType == DbType.SQLServer)
            {
                dbType = "2";
            }
            else if (lenv.dbType == DbType.Oracle)
            {
                dbType = "3";
            }
            else if (lenv.dbType == DbType.DM)
            {
                dbType = "4";
            }
            else if (lenv.dbType == DbType.MySQL)
            {
                dbType = "0";
            }
            return(dbType);
        }
예제 #5
0
        private void LoadDefaultEnv()
        {
            env = Dao.GetDefaultEnv();
            var path = Environment.GetEnvironmentVariable("EnvPath");

            tb_EnvPath.Text  = env.envPath;
            tb_dbName.Text   = env.dbName;
            tb_username.Text = env.dbUserName;
            tb_password.Text = env.dbPassword;
            tb_dbPort.Text   = env.dbPort;
            SetRadioButton(env);
        }
예제 #6
0
        public static CloudEnv FromDict(Dictionary <String, object> dict)
        {
            var env = new CloudEnv();

            env.envPath    = Environment.GetEnvironmentVariable("EnvPath");
            env.dbHost     = dict["dbHost"].ToString();
            env.dbType     = GetDbType(dict["dbType"].ToString());
            env.dbName     = dict["dbName"].ToString();
            env.dbPassword = dict["dbPassword"].ToString();
            env.dbUserName = dict["dbUserName"].ToString();
            env.dbPort     = dict["dbPort"].ToString();
            return(env);
        }
예제 #7
0
        public static CloudEnv GetDefault()
        {
            var env = new CloudEnv();

            env.envPath    = @"E:\gscloud";
            env.dbHost     = @"z.gscloud.top";
            env.dbType     = DbType.PgSQL;
            env.dbName     = "b4";
            env.dbPassword = "******";
            env.dbUserName = "******";
            env.dbPort     = "5432";
            return(env);
        }
예제 #8
0
        private CloudEnv GetUIValue()
        {
            var uiEnv = new CloudEnv();

            var cb_dbType = groupBox1.Controls.OfType <RadioButton>()
                            .FirstOrDefault(r => r.Checked);
            var dbType = GetDBTypeByName(cb_dbType.Text);

            var cb_dbHost = grp_host.Controls.OfType <RadioButton>()
                            .FirstOrDefault(r => r.Checked);
            var dbHost = GetDBHostByName(cb_dbHost.Text);

            uiEnv.dbType     = dbType;
            uiEnv.dbHost     = dbHost;
            uiEnv.dbPort     = tb_dbPort.Text;
            uiEnv.dbName     = tb_dbName.Text;
            uiEnv.dbUserName = tb_username.Text;
            uiEnv.dbPassword = tb_password.Text;
            uiEnv.envPath    = tb_EnvPath.Text;

            return(uiEnv);
        }
예제 #9
0
 private void SetRadioButton(CloudEnv env)
 {
     //dbHost
     if (env.dbHost == "x.gscloud.top")
     {
         rb_21.Select();
     }
     else if (env.dbHost == "z.gscloud.top")
     {
         rb_35.Select();
     }
     else if (env.dbHost == "127.0.0.1")
     {
         rb_localhost.Select();
     }
     else
     {
         rb_otherHost.Select();
         tb_host.Text = env.dbHost;
     }
     //dbType
     if (env.dbType == DbType.DM)
     {
         rb_dm.Select();
     }
     else if (env.dbType == DbType.Oracle)
     {
         rb_ora.Select();
     }
     else if (env.dbType == DbType.SQLServer)
     {
         rb_sql.Select();
     }
     else
     {
         rb_pg.Select();
     }
 }
예제 #10
0
 private void RemoveDB(CloudEnv env)
 {
     Dao.DeleteEnv(env);
 }