Example #1
0
 void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     Log(e.Exception);
     MsgBox.ShowExceptionMessage(e.Exception);
 }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!CheckGoEnvironment())
            {
                if (MsgBox.ShowQuestionMessage("检测到未安装GO环境!是否查看帮助?") == DialogResult.Yes)
                {
                    Help.ShowHelp(this, "https://jingyan.baidu.com/article/d2b1d102cbac775c7f37d477.html");
                }
                return;
            }

            if (!CheckBeeEnvironment())
            {
                if (MsgBox.ShowQuestionMessage("检测到未安装Bee工具!是否查看帮助?") == DialogResult.Yes)
                {
                    CmdHelper.CreateBat(Config.TEMP_BAT_FILENAME, "go get -u github.com/astaxie/beego \r\ngo get -u github.com/beego/bee");
                    CmdHelper.RunApp(Config.TEMP_BAT_FILENAME, ProcessWindowStyle.Normal, GOPATH);
                    Help.ShowHelp(this, "https://beego.me/quickstart");
                }
                ;
                return;
            }

            if (string.IsNullOrEmpty(cmbDatabase.Text))
            {
                MsgBox.Show("请选择数据库!");
                return;
            }

            if (string.IsNullOrEmpty(txtProjectName.Text.Trim()))
            {
                MsgBox.Show("请输入项目名称!");
                return;
            }

            if (string.IsNullOrEmpty(GOROOT))
            {
                MsgBox.Show("请先在选项中设置GOROOT环境变量!");
                return;
            }

            if (string.IsNullOrEmpty(GOPATH))
            {
                MsgBox.Show("请先在选项中设置GOPATH环境变量!");
                return;
            }

            if (currentDatabase.Parent.DbProvider.DatabaseType != DatabaseType.MySql)
            {
                MsgBox.Show("该数据库不是MySql,不支持该操作!");
                this.Close();
                return;
            }

            if (rbWebProject.Checked)
            {
                if (listBox2.Items.Count == 0)
                {
                    MsgBox.Show("请选择要生成的表!");
                    return;
                }
            }

            codePath = GOPATH + (GOPATH.EndsWith(@"\") ? "src" : @"\src") + @"\" + txtProjectName.Text.Trim();
            if (Directory.Exists(codePath))
            {
                OpenDirectory(string.Format("文件夹“{0}”已经存在,是否立即打开?", codePath));
                this.Close();
                return;
            }

            SetBtnDisable();
            backgroundWorkerGenerate.RunWorkerAsync();
        }