⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 builderframes3.cs

📁 通过数据库结构自动 生成三层结构代码,相当不错的一款软件
💻 CS
字号:
namespace LTP.CodeBuild
{
    using LTP.BuilderModel;
    using LTP.CodeHelper;
    using LTP.IBuilder;
    using LTP.IDBO;
    using LTP.Utility;
    using System;
    using System.Collections.Generic;

    public class BuilderFrameS3 : BuilderFrame
    {
        private IBuilderBLL ibll;
        private IBuilderDAL idal;
        private IBuilderDALTran idaltran;

        public BuilderFrameS3(IDbObject idbobj, string dbName, string nameSpace, string folder, string dbHelperName)
        {
            base.dbobj = idbobj;
            base._dbtype = idbobj.DbType;
            base.DbName = dbName;
            base.NameSpace = nameSpace;
            base.DbHelperName = dbHelperName;
            base.Folder = folder;
        }

        public BuilderFrameS3(IDbObject idbobj, string dbName, string tableName, string modelName, string bllName, string dalName, List<ColumnInfo> fieldlist, List<ColumnInfo> keys, string nameSpace, string folder, string dbHelperName)
        {
            base.dbobj = idbobj;
            base._dbtype = idbobj.DbType;
            base.DbName = dbName;
            base.TableName = tableName;
            base.ModelName = modelName;
            base.BLLName = bllName;
            base.DALName = dalName;
            base.NameSpace = nameSpace;
            base.DbHelperName = dbHelperName;
            base.Folder = folder;
            base.Fieldlist = fieldlist;
            base.Keys = keys;
            foreach (ColumnInfo info in keys)
            {
                base._key = info.ColumnName;
                base._keyType = info.TypeName;
                if (info.IsIdentity)
                {
                    base._key = info.ColumnName;
                    base._keyType = CodeCommon.DbTypeToCS(info.TypeName);
                    break;
                }
            }
        }

        public string GetBLLCode(string AssemblyGuid, bool Maxid, bool Exists, bool Add, bool Update, bool Delete, bool GetModel, bool GetModelByCache, bool List)
        {
            this.ibll = BuilderFactory.CreateBLLObj(AssemblyGuid);
            if (this.ibll == null)
            {
                return "请选择有效的业务层代码组件类型!";
            }
            this.ibll.set_Fieldlist(base.Fieldlist);
            this.ibll.set_Keys(base.Keys);
            this.ibll.set_NameSpace(base.NameSpace);
            this.ibll.set_Modelpath(base.Modelpath);
            this.ibll.set_ModelName(base.ModelName);
            this.ibll.set_BLLpath(base.BLLpath);
            this.ibll.set_BLLName(base.BLLName);
            this.ibll.set_Factorypath("");
            this.ibll.set_IDALpath("");
            this.ibll.set_IClass("");
            this.ibll.set_DALpath(this.DALpath);
            this.ibll.set_DALName(base.DALName);
            this.ibll.set_IsHasIdentity(base.IsHasIdentity);
            this.ibll.set_DbType(base.dbobj.DbType);
            return this.ibll.GetBLLCode(Maxid, Exists, Add, Update, Delete, GetModel, GetModelByCache, List);
        }

        public string GetDALCode(string AssemblyGuid, bool Maxid, bool Exists, bool Add, bool Update, bool Delete, bool GetModel, bool List, string procPrefix)
        {
            this.idal = BuilderFactory.CreateDALObj(AssemblyGuid);
            if (this.idal == null)
            {
                return "请选择有效的数据层代码组件类型!";
            }
            this.idal.set_DbObject(base.dbobj);
            this.idal.set_DbName(base.DbName);
            this.idal.set_TableName(base.TableName);
            this.idal.set_Fieldlist(base.Fieldlist);
            this.idal.set_Keys(base.Keys);
            this.idal.set_NameSpace(base.NameSpace);
            this.idal.set_Folder(base.Folder);
            this.idal.set_Modelpath(base.Modelpath);
            this.idal.set_ModelName(base.ModelName);
            this.idal.set_DALpath(this.DALpath);
            this.idal.set_DALName(base.DALName);
            this.idal.set_IDALpath("");
            this.idal.set_IClass("");
            this.idal.set_DbHelperName(base.DbHelperName);
            this.idal.set_ProcPrefix(procPrefix);
            return this.idal.GetDALCode(Maxid, Exists, Add, Update, Delete, GetModel, List);
        }

        public string GetDALCodeTran(string AssemblyGuid, bool Maxid, bool Exists, bool Add, bool Update, bool Delete, bool GetModel, bool List, string procPrefix, string tableNameParent, string tableNameSon, string modelNameParent, string modelNameSon, List<ColumnInfo> fieldlistParent, List<ColumnInfo> fieldlistSon, List<ColumnInfo> keysParent, List<ColumnInfo> keysSon, string DALNameParent, string DALNameSon)
        {
            this.idaltran = BuilderFactory.CreateDALTranObj(AssemblyGuid);
            if (this.idaltran == null)
            {
                return "请选择有效的数据层代码组件类型!";
            }
            this.idaltran.set_DbObject(base.dbobj);
            this.idaltran.set_DbName(base.DbName);
            this.idaltran.set_TableNameParent(tableNameParent);
            this.idaltran.set_TableNameSon(tableNameSon);
            this.idaltran.set_FieldlistParent(fieldlistParent);
            this.idaltran.set_FieldlistSon(fieldlistSon);
            this.idaltran.set_KeysParent(keysParent);
            this.idaltran.set_KeysSon(keysSon);
            this.idaltran.set_NameSpace(base.NameSpace);
            this.idaltran.set_Folder(base.Folder);
            this.idaltran.set_Modelpath(base.Modelpath);
            this.idaltran.set_ModelNameParent(modelNameParent);
            this.idaltran.set_ModelNameSon(modelNameSon);
            this.idaltran.set_DALpath(this.DALpath);
            this.idaltran.set_DALNameParent(DALNameParent);
            this.idaltran.set_DALNameSon(DALNameSon);
            this.idaltran.set_IDALpath("");
            this.idaltran.set_IClass("");
            this.idaltran.set_DbHelperName(base.DbHelperName);
            this.idaltran.set_ProcPrefix(procPrefix);
            return this.idaltran.GetDALCode(Maxid, Exists, Add, Update, Delete, GetModel, List);
        }

        public string GetModelCode()
        {
            LTP.BuilderModel.BuilderModel model = new LTP.BuilderModel.BuilderModel();
            model.ModelName = base.ModelName;
            model.NameSpace = base.NameSpace;
            model.Fieldlist = base.Fieldlist;
            model.Modelpath = base.Modelpath;
            return model.CreatModel();
        }

        public string GetModelCode(string tableNameParent, string modelNameParent, List<ColumnInfo> FieldlistP, string tableNameSon, string modelNameSon, List<ColumnInfo> FieldlistS)
        {
            if (modelNameParent == "")
            {
                modelNameParent = tableNameParent;
            }
            if (modelNameSon == "")
            {
                modelNameSon = tableNameSon;
            }
            StringPlus plus = new StringPlus();
            new StringPlus();
            new StringPlus();
            plus.AppendLine("using System;");
            plus.AppendLine("using System.Collections.Generic;");
            plus.AppendLine("namespace " + base.Modelpath);
            plus.AppendLine("{");
            BuilderModelT lt = new BuilderModelT();
            lt.ModelName = modelNameParent;
            lt.NameSpace = base.NameSpace;
            lt.Fieldlist = FieldlistP;
            lt.Modelpath = base.Modelpath;
            lt.ModelNameSon = modelNameSon;
            plus.AppendSpaceLine(1, "/// <summary>");
            plus.AppendSpaceLine(1, "/// 实体类" + modelNameParent + " 。(属性说明自动提取数据库字段的描述信息)");
            plus.AppendSpaceLine(1, "/// </summary>");
            plus.AppendSpaceLine(1, "public class " + modelNameParent);
            plus.AppendSpaceLine(1, "{");
            plus.AppendSpaceLine(2, "public " + modelNameParent + "()");
            plus.AppendSpaceLine(2, "{}");
            plus.AppendLine(lt.CreatModelMethodT());
            plus.AppendSpaceLine(1, "}");
            LTP.BuilderModel.BuilderModel model = new LTP.BuilderModel.BuilderModel();
            model.ModelName = modelNameSon;
            model.NameSpace = base.NameSpace;
            model.Fieldlist = FieldlistS;
            model.Modelpath = base.Modelpath;
            plus.AppendSpaceLine(1, "/// <summary>");
            plus.AppendSpaceLine(1, "/// 实体类" + modelNameSon + " 。(属性说明自动提取数据库字段的描述信息)");
            plus.AppendSpaceLine(1, "/// </summary>");
            plus.AppendSpaceLine(1, "public class " + modelNameSon);
            plus.AppendSpaceLine(1, "{");
            plus.AppendSpaceLine(2, "public " + modelNameSon + "()");
            plus.AppendSpaceLine(2, "{}");
            plus.AppendLine(model.CreatModelMethod());
            plus.AppendSpaceLine(1, "}");
            plus.AppendLine("}");
            plus.AppendLine("");
            return plus.ToString();
        }

        public string DALpath
        {
            get
            {
                string str = base.NameSpace + ".DAL";
                if (base.Folder.Trim() != "")
                {
                    str = str + "." + base.Folder;
                }
                return str;
            }
        }

        public string DALSpace
        {
            get
            {
                return (this.DALpath + "." + base.DALName);
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -