Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private void GengerateTable(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.BuilderTable();

            if (string.IsNullOrEmpty(outPutFile))
            {
                var fileName = this.GetClassName() + "Table.cs";
                var codeForm = new CodeView(codeString)
                {
                    FileName = fileName, Name = fileName
                };
                PageUtility.AddSinglePage(codeForm, fileName, mainfrm);
            }
            else
            {
                PDMCodeMaker.WriteCode(outPutFile, true, codeString);
            }
        }
Ejemplo n.º 3
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);
            }
        }