Пример #1
0
 static void Main(string[] args)
 {
     //解决方案名称
     CodeBuilderManager.SolutionName = "Demo.Core3.0";
     //根命名空间
     CodeBuilderManager.RootNamespace = "EZNEW";
     //.NET版本
     CodeBuilderManager.NetVersion = CodeBuild.Net.NetVersion.netcore3_0;
     CodeBuilderManager.Run();
 }
Пример #2
0
        //生成代码
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string path = selectDialog.Text;

            if (string.IsNullOrEmpty(path))
            {
                MsgBox.Alert("请选择导出地址"); return;
            }
            //选中的表集合
            List <string> tableList = this.tables.GetCheckedTables();

            if (tableList.Count <= 0)
            {
                MsgBox.Alert("请至少选择表进行操作"); return;
            }
            //选中的模板
            List <TemplateEntity> templateList = this.template.GetCheckedFile();

            if (templateList.Count <= 0)
            {
                MsgBox.Alert("请至少选择代码模板进行操作"); return;
            }
            this.btnCreate.Enabled = false;
            this.btnCreate.Text    = "生成中...";
            Application.DoEvents();
            CodeBuilderManager builder = new CodeBuilderManager()
            {
                Project = Global.GetCurrentProject(),
                User    = Global.User
            };

            this.progressBar.Value   = 0;
            this.progressBar.Maximum = tableList.Count * templateList.Count;
            builder.OnProgress      += new Options.Common.ProgressHandler(builder_OnProgress);
            List <string> files = builder.ExportByTables(tableList, templateList, path);

            this.btnCreate.Enabled = true;
            this.btnCreate.Text    = "生成代码";
            if (builder.Error.Length > 0)
            {
                Utils.ShowErrorDialog(builder.Error.ToString());
            }
            else
            {
                string firstFileName = "";
                if (files.Count > 0)
                {
                    firstFileName = files[0];
                }
                if (MsgBox.Confirm("导出完毕,是否打开目录"))
                {
                    FileHelper.OpenPath(path, firstFileName);
                }
            }
        }