예제 #1
0
        /// <summary>
        /// 全部生成
        /// </summary>
        private void GengerateAll()
        {
            var setHelper = new SettingHelper();

            setHelper.GetSetting();
            if (string.IsNullOrEmpty(setHelper.Output))
            {
                MessageBox.Show("请先设置代码的输出路径!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                var projProperty = new ProjectProperty();
                projProperty.ShowDialog();
                return;
            }
            var overwrite      = true;
            var codeOutPutPath = setHelper.Output;
            var codeMaker      = new PDMCodeMaker(this.xmlDocument, this.CompanyName, this.Project, this.Author, DateTime.Now.Year.ToString(), DateTime.Now.ToString("yyyy-MM-dd"), this.GetClassName(), "Manager", this.GetTableName(), this.GetDescription());

            overwrite = codeMaker.BuilderTable(codeOutPutPath, overwrite);
            overwrite = codeMaker.BuilderEntity(codeOutPutPath, overwrite);
            overwrite = codeMaker.BuilderManager(codeOutPutPath, overwrite);
            var fileName = codeOutPutPath + "\\" + this.Project + ".BizLogic\\IService\\" + "I" + this.GetClassName() + "Service.cs";

            this.GengerateIService(fileName);
            fileName = codeOutPutPath + "\\" + this.Project + ".BizLogic\\Service\\" + this.GetClassName() + "Service.cs";
            this.GenerateService(fileName);
            // 打开文件夹
            Process.Start(codeOutPutPath);
        }
예제 #2
0
        private void GenerateHtml()
        {
            var codeMaker = new PDMCodeMaker(this.xmlDocument, this.CompanyName, this.Project, this.Author, DateTime.Now.Year.ToString(), DateTime.Now.ToString("yyyy-MM-dd"), this.GetClassName(), string.Empty, this.GetTableName(), this.GetDescription());
            var bForm     = new BrowserForm(codeMaker.TableToHTML());
            var fileName  = this.GetTableName() + "(" + this.GetDescription() + ")";

            bForm.Name = fileName;
            PageUtility.AddSinglePage(bForm, fileName, mainfrm);
        }
예제 #3
0
        private void GenerateTableColumns(string outPutFile = "")
        {
            var codeMaker  = new PDMCodeMaker(this.xmlDocument, this.CompanyName, this.Project, this.Author, DateTime.Now.Year.ToString(), DateTime.Now.ToString("yyyy-MM-dd"), this.GetClassName(), "Table", this.GetTableName(), this.GetDescription());
            var codeString = codeMaker.DBSQL();

            if (string.IsNullOrEmpty(outPutFile))
            {
                var fileName = this.GetClassName() + "TableColumns.sql";
                var codeForm = new CodeView(codeString)
                {
                    FileName = fileName, Name = fileName
                };
                PageUtility.AddSinglePage(codeForm, fileName, mainfrm);
            }
            else
            {
                PDMCodeMaker.WriteCode(outPutFile, true, codeString);
            }
        }
예제 #4
0
        private void GenerateService(string outPutFile = "")
        {
            var file = Application.StartupPath + "\\Templates\\Service.cst";
            var code = CodeMakerLibary.GetTemplate(file);

            code = ReplaceAssemblyInfo(code);
            if (string.IsNullOrEmpty(outPutFile))
            {
                var fileName = this.GetClassName() + "Service.cs";
                var codeForm = new CodeView(code)
                {
                    FileName = fileName, Name = fileName
                };
                PageUtility.AddSinglePage(codeForm, fileName, mainfrm);
            }
            else
            {
                PDMCodeMaker.WriteCode(outPutFile, true, code);
            }
        }
예제 #5
0
        private void GengerateMvcEntity(string outPutFile = "")
        {
            var codeMaker = new PDMCodeMaker(this.xmlDocument, this.CompanyName, this.Project, this.Author, DateTime.Now.Year.ToString(), DateTime.Now.ToString("yyyy-MM-dd"), this.GetClassName(), "Entity", this.GetTableName(), this.GetDescription())
            {
                MVCEntity = true
            };
            var codeString = codeMaker.BuilderEntity();

            if (string.IsNullOrEmpty(outPutFile))
            {
                var fileName = this.GetClassName() + "Entity.cs";
                var codeForm = new CodeView(codeString)
                {
                    FileName = fileName, Name = fileName
                };
                //PageUtility.AddSinglePage(codeForm, fileName, mainfrm);
                PageUtility.AddTabPage(fileName, codeForm, mainfrm);
            }
            else
            {
                PDMCodeMaker.WriteCode(outPutFile, true, codeString);
            }
        }
예제 #6
0
        private void GenerateManager(string outPutFile = "")
        {
            //以模版方式生成
            //string file = Application.StartupPath + "\\Templates\\Manager.cst";
            //string code = CodeMakerLibary.GetTemplate(file);
            //code = ReplaceAssemblyInfo(code);

            var codeMaker  = new PDMCodeMaker(this.xmlDocument, this.CompanyName, this.Project, this.Author, DateTime.Now.Year.ToString(), DateTime.Now.ToString("yyyy-MM-dd"), this.GetClassName(), "Manager", this.GetTableName(), this.GetDescription());
            var codeString = codeMaker.BuilderManager(null);

            if (string.IsNullOrEmpty(outPutFile))
            {
                var fileName = this.GetClassName() + "Manager.Generate.cs";
                var codeForm = new CodeView(codeString)
                {
                    FileName = fileName, Name = fileName
                };
                PageUtility.AddSinglePage(codeForm, fileName, mainfrm);
            }
            else
            {
                PDMCodeMaker.WriteCode(outPutFile, true, codeString);
            }
        }
예제 #7
0
        //批量代码生成
        private void cmnuItemBatchGenerateAll_Click(object sender, EventArgs e)
        {
            if (tvPDObjectView.SelectedNode == null || tvPDObjectView.SelectedNode.Tag == null || string.IsNullOrEmpty(tvPDObjectView.SelectedNode.Tag.ToString()) || tvPDObjectView.SelectedNode.Tag.ToString() != this.TAGTABLES)
            {
                MessageBox.Show("请选择“数据表”节点进行代码的批量生成!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            var setHelper = new SettingHelper();

            setHelper.GetSetting();
            if (string.IsNullOrEmpty(setHelper.Output))
            {
                MessageBox.Show("请先设置代码的输出路径!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                var projProperty = new ProjectProperty();
                projProperty.ShowDialog();
                return;
            }
            var overwrite      = true;
            var codeOutPutPath = setHelper.Output;
            // 设置鼠标繁忙状态,并保留原先的状态
            var holdCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            mainfrm.InvokeSendStatusMessage("准备批量生成代码...");
            try
            {
                foreach (TreeNode node in this.tvPDObjectView.SelectedNode.Nodes)
                {
                    tvPDObjectView.SelectedNode = node;
                    var className   = node.Text.Split(',')[0].Replace("_", string.Empty);
                    var tableName   = node.Text.Split(',')[0];
                    var description = node.Text.Split(',')[1];
                    mainfrm.InvokeSendStatusMessage("当前处理对象:" + tableName);
                    if ((!string.IsNullOrEmpty(className)) && (!string.IsNullOrEmpty(this.ProductName)))
                    {
                        className = className.Replace(this.ProductName, string.Empty);
                    }

                    var codeMaker = new PDMCodeMaker(this.xmlDocument, this.CompanyName, this.Project, this.Author, DateTime.Now.Year.ToString(), DateTime.Now.ToString("yyyy-MM-dd"), className, "Manager", tableName, description);
                    overwrite = codeMaker.BuilderTable(codeOutPutPath, overwrite);
                    overwrite = codeMaker.BuilderEntity(codeOutPutPath, overwrite);
                    overwrite = codeMaker.BuilderManager(codeOutPutPath, overwrite);

                    var fileName = codeOutPutPath + "\\" + this.Project + ".BizLogic\\IService\\" + "I" + className + "Service.cs";
                    this.GengerateIService(fileName);
                    fileName = codeOutPutPath + "\\" + this.Project + ".BizLogic\\Service\\" + className + "Service.cs";
                    this.GenerateService(fileName);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteException(ex);
            }
            finally
            {
                // 设置鼠标默认状态,原来的光标状态
                this.Cursor = holdCursor;
                mainfrm.InvokeSendStatusMessage("就绪。");
                // 打开文件夹
                Process.Start(codeOutPutPath);
            }
        }