コード例 #1
0
        private void btnGenBLLDataDict_Click(object sender, EventArgs e)
        {
            if (false == Msg.AskQuestion("确认要生成吗?"))
            {
                return;
            }

            //创建参数对象
            Params4DataDictBLL param = new Params4DataDictBLL();

            param.BLL_Name       = txtBLL.Text;
            param.BLL_Namespace  = txtBllNamespace.Text;
            param.ConcretelyName = txtConcretelyName.Text;
            param.DAL_Name       = txtDAL.Text;
            param.ORM_Name       = txtORM.Text;
            param.UsingNamespace = txtUsingNamespace.Lines;

            //生成源码
            string code = new GenerateBLL().GenerateDataDictBLL(param);

            //显示代码
            if (chkPreviewBLL.Checked)
            {
                this.ShowCode(code);
            }

            //输出.cs文件
            if (chkExportToFileBLL.Checked)
            {
                string fileName = txtOutpup_BLL_DataDict.Text + txtBLL.Text + ".cs";
                File.WriteAllText(fileName, code, Encoding.UTF8);
                MessageBox.Show("输出文件:" + fileName);
            }
        }
コード例 #2
0
ファイル: GenerateBLL.cs プロジェクト: iot369/CSFramework
        /// <summary>
        /// 生成数据字典的业务层
        /// </summary>
        public string GenerateDataDictBLL(Params4DataDictBLL param)
        {
            StringBuilder builder = new StringBuilder();

            //.Net Framework的名字空间
            builder.AppendLine("using System;");
            builder.AppendLine("using System.Collections.Generic;");
            builder.AppendLine("using System.Text;");
            builder.AppendLine("using System.Data;");

            //引用的自定义名字空间
            foreach (string space in param.UsingNamespace)
            {
                builder.AppendLine("using " + space + ";");
            }

            //生成单元注释部分
            CreateComment(builder, param.ConcretelyName);

            builder.AppendLine("namespace " + param.BLL_Namespace);                          //当前业务层所在的名字空间
            builder.AppendLine("{");
            builder.AppendLine("    public class " + param.BLL_Name + " : bllBaseDataDict"); //基类
            builder.AppendLine("    {");
            builder.AppendLine("         public " + param.BLL_Name + "()");                  //构造器
            builder.AppendLine("         {");
            builder.AppendLine("             _KeyFieldName = " + param.ORM_Name + ".__KeyName; //主键字段");
            builder.AppendLine("             _SummaryTableName = " + param.ORM_Name + ".__TableName;//表名");
            builder.AppendLine("             _WriteDataLog = true;//是否保存日志");
            builder.AppendLine("             _DAL = new " + param.DAL_Name + "(Loginer.CurrentUser);//数据层的实例"); //返回数据层的实例
            builder.AppendLine("         }");
            builder.AppendLine("     }");
            builder.AppendLine("}");

            return(builder.ToString());
        }
コード例 #3
0
ファイル: GenerateBLL.cs プロジェクト: zzpgeorge/HH-Client-CS
        /// <summary>
        /// 生成数据字典的业务层
        /// </summary>
        public string GenerateDataDictBLL(Params4DataDictBLL param)
        {
            StringBuilder builder = new StringBuilder();

            //.Net Framework的名字空间
            builder.AppendLine("using System;");
            builder.AppendLine("using System.Collections.Generic;");
            builder.AppendLine("using System.Text;");
            builder.AppendLine("using System.Data;");

            //引用的自定义名字空间
            foreach (string space in param.UsingNamespace)
            {
                builder.AppendLine("using " + space + ";");
            }

            //生成单元注释部分
            CreateComment(builder, param.ConcretelyName);

            builder.AppendLine("namespace " + param.BLL_Namespace); //当前业务层所在的名字空间
            builder.AppendLine("{");
            builder.AppendLine("\r\n");
            builder.AppendLine("    public class " + param.BLL_Name + " : bllBaseDataDict"); //基类
            builder.AppendLine("    {");
            builder.AppendLine("         private IBridge_" + param.ConcretelyName + " _MyBridge = null;");
            builder.AppendLine("         public " + param.BLL_Name + "()"); //构造器
            builder.AppendLine("         {");
            builder.AppendLine("             _KeyFieldName = " + param.ORM_Name + ".__KeyName; //主键字段");
            builder.AppendLine("             _SummaryTableName = " + param.ORM_Name + ".__TableName;//表名");
            builder.AppendLine("             _WriteDataLog = true;//是否保存日志");
            builder.AppendLine("             _DataDictBridge = new " + param.DAL_Name + "(Loginer.CurrentUser);//数据层的实例"); //返回数据层的实例
            builder.AppendLine("             _MyBridge = this.CreateBridge();");
            builder.AppendLine("         }");
            builder.AppendLine("\r\n");
            builder.AppendLine("         private IBridge_" + param.ConcretelyName + " CreateBridge()");
            builder.AppendLine("         {");
            builder.AppendLine("             if (BridgeFactory.BridgeType == BridgeType.ADODirect)");
            builder.AppendLine("                    return new ADODirect_" + param.ConcretelyName + "().GetInstance();");
            builder.AppendLine("\r\n");
            builder.AppendLine("             if(BridgeFactory.BridgeType == BridgeType.WebService)");
            builder.AppendLine("                    return new WebService_" + param.ConcretelyName + "();");
            builder.AppendLine("                return null;");
            builder.AppendLine("          }");
            builder.AppendLine("");
            builder.AppendLine(@"           public DataTable FuzzySearch(string content)
        {
            return _MyBridge.FuzzySearch(content);
        }");
            builder.AppendLine("     }");
            builder.AppendLine("\r\n");

            builder.AppendLine("}");



            return(builder.ToString());
        }
コード例 #4
0
ファイル: GenerateBLL.cs プロジェクト: wuhuayun/JieLi_Cord
        /// <summary>
        /// 生成数据字典的业务层
        /// </summary>
        public string GenerateDataDictBLL(Params4DataDictBLL param)
        {
            StringBuilder builder = new StringBuilder();

            //.Net Framework的名字空间
            builder.AppendLine("using System;");
            builder.AppendLine("using System.Collections.Generic;");
            builder.AppendLine("using System.Text;");
            builder.AppendLine("using System.Data;");

            //引用的自定义名字空间
            foreach (string space in param.UsingNamespace)
                builder.AppendLine("using " + space + ";");

            //生成单元注释部分
            CreateComment(builder, param.ConcretelyName);

            builder.AppendLine("namespace " + param.BLL_Namespace); //当前业务层所在的名字空间
            builder.AppendLine("{");
            builder.AppendLine("    public class " + param.BLL_Name + " : bllBaseDataDict"); //基类
            builder.AppendLine("    {");
            builder.AppendLine("         public " + param.BLL_Name + "()"); //构造器
            builder.AppendLine("         {");
            builder.AppendLine("             _KeyFieldName = " + param.ORM_Name + ".__KeyName; //主键字段");
            builder.AppendLine("             _SummaryTableName = " + param.ORM_Name + ".__TableName;//表名");
            builder.AppendLine("             _WriteDataLog = true;//是否保存日志");
            builder.AppendLine("             _DAL = new " + param.DAL_Name + "(Loginer.CurrentUser);//数据层的实例"); //返回数据层的实例
            builder.AppendLine("         }");
            builder.AppendLine("     }");
            builder.AppendLine("}");

            return builder.ToString();
        }