示例#1
0
        /// <summary>
        /// 生成完整Model类
        /// </summary>
        public string CreatModel()
        {
            StringPlus strclass = new StringPlus();

            strclass.AppendLine("using System;");
            strclass.AppendLine("namespace " + Modelpath);
            strclass.AppendLine("{");
            strclass.AppendSpaceLine(1, "/// <summary>");
            if (TableDescription.Length > 0)
            {
                strclass.AppendSpaceLine(1, "/// " + TableDescription.Replace("\r\n", "\r\n\t///"));
            }
            else
            {
                strclass.AppendSpaceLine(1, "/// " + _modelname + ":" + Languagelist["summary"].ToString());
            }
            strclass.AppendSpaceLine(1, "/// </summary>");
            strclass.AppendSpaceLine(1, "[Serializable]");
            strclass.AppendSpaceLine(1, "public partial class " + _modelname);
            strclass.AppendSpaceLine(1, "{");
            strclass.AppendSpaceLine(2, "public " + _modelname + "()");
            strclass.AppendSpaceLine(2, "{}");
            strclass.AppendLine(CreatModelMethod());
            strclass.AppendSpaceLine(1, "}");
            strclass.AppendLine("}");
            strclass.AppendLine("");

            return(strclass.ToString());
        }
        /// <summary>
        /// 生成完整Model类
        /// </summary>
        public string CreatModel()
        {
            StringPlus strclass = new StringPlus();

            strclass.AppendLine("using System;");
            strclass.AppendLine("using System.ComponentModel;");
            strclass.AppendLine("using System.ComponentModel.DataAnnotations;");
            strclass.AppendLine("using System.Data.Linq.Mapping;");
            strclass.AppendLine("using System.Collections;");
            strclass.AppendLine("using System.Collections.Generic;");
            strclass.AppendLine("namespace " + Modelpath);
            strclass.AppendLine("{");
            strclass.AppendSpaceLine(1, "/// <summary>");


            if (TableDescription.Length > 0)
            {
                strclass.AppendSpaceLine(1, "/// " + TableDescription.Replace("\r\n", "\r\n\t///"));
            }
            else
            {
                strclass.AppendSpaceLine(1, "/// " + _modelname + ":" + Languagelist["summary"].ToString());
            }
            strclass.AppendSpaceLine(1, "/// </summary>");
            strclass.AppendSpaceLine(1, "[Serializable]");
            strclass.AppendSpaceLine(1, "[global::System.Data.Linq.Mapping.TableAttribute(Name = \"dbo." + _modelname + "\")]");
            //strclass.AppendSpaceLine(1, "public partial class " + _modelname + "Model : INotifyPropertyChanging, INotifyPropertyChanged,IEnumerable");
            strclass.AppendSpaceLine(1, "public partial class " + _modelname + "Model : INotifyPropertyChanging, INotifyPropertyChanged");
            strclass.AppendSpaceLine(1, "{");
            strclass.AppendSpaceLine(2, "public " + _modelname + "Model()");
            strclass.AppendSpaceLine(2, "{}");
            strclass.AppendLine(CreatModelMethod());
            strclass.AppendSpaceLine(1, "}");
            strclass.AppendLine("}");
            strclass.AppendLine("");

            return(strclass.ToString());
        }
        /// <summary>
        /// 生成完整Model类
        /// </summary>
        public string CreatModel()
        {
            StringPlus strclass = new StringPlus();

            strclass.AppendLine("using System;");
            strclass.AppendLine("namespace " + Modelpath);
            strclass.AppendLine("{");
            strclass.AppendSpaceLine(1, "/// <summary>");
            if (TableDescription.Length > 0)
            {
                strclass.AppendSpaceLine(1, "/// 【Model】: " + TableDescription.Replace("\r\n", "\r\n\t///"));
            }
            else
            {
                strclass.AppendSpaceLine(1, "/// 【Model】: " + _modelname /*+ ":" + Languagelist["summary"].ToString()*/);
            }
            strclass.AppendSpaceLine(1, "/// </summary>");
            strclass.AppendSpaceLine(1, "[Serializable]");
            strclass.AppendSpaceLine(1, "public partial class " + _modelname);
            strclass.AppendSpaceLine(1, "{");
            strclass.AppendSpaceLine(2, "public " + _modelname + "()");
            strclass.AppendSpaceLine(2, "{}");
            strclass.AppendLine(CreatModelMethod());
            strclass.AppendSpaceLine(1, "}");
            strclass.AppendLine("}");
            strclass.AppendLine("");

            if (Modelpath.Contains("Maticsoft"))//如果为默认命名空间直接返回
            {
                return(strclass.ToString());
            }
            else//否则直接替换原始命名空间
            {
                return(strclass.ToString().Replace("Maticsoft", Modelpath.Split('.')[0]));
            }
        }
示例#4
0
        /// <summary>
        /// 得到整个类的代码
        /// </summary>
        public string GetBLLCode(bool Maxid, bool Exists, bool Add, bool Update, bool Delete, bool GetModel, bool GetModelByCache, bool List)
        {
            StringPlus strclass = new StringPlus();

            strclass.AppendLine("using System;");
            strclass.AppendLine("using System.Data;");
            strclass.AppendLine("using System.Collections.Generic;");
            if (GetModelByCache)
            {
                strclass.AppendLine("using Maticsoft.Common;");
            }
            strclass.AppendLine("using " + Modelpath + ";");
            if ((Factorypath != "") && (Factorypath != null))
            {
                strclass.AppendLine("using " + Factorypath + ";");
            }
            if ((IDALpath != "") && (IDALpath != null))
            {
                strclass.AppendLine("using " + IDALpath + ";");
            }
            strclass.AppendLine("namespace " + BLLpath);
            strclass.AppendLine("{");
            strclass.AppendSpaceLine(1, "/// <summary>");
            if (TableDescription.Length > 0)
            {
                strclass.AppendSpaceLine(1, "/// " + TableDescription.Replace("\r\n", "\r\n\t///"));
            }
            else
            {
                strclass.AppendSpaceLine(1, "/// " + BLLName + ":" + Languagelist["summary"].ToString());
            }
            strclass.AppendSpaceLine(1, "/// </summary>");
            strclass.AppendSpaceLine(1, "public partial class " + BLLName);
            strclass.AppendSpaceLine(1, "{");

            if ((IClass != "") && (IClass != null))
            {
                strclass.AppendSpaceLine(2, "private readonly " + IClass + " dal=" + "DataAccess.Create" + DALName + "();");
                //if (Folder != "")
                //{
                //    strclass.AppendSpaceLine(2, "private readonly " + IClass + " dal=" + "DataAccess<" + IClass + ">.Create(\"" + Folder + "." + DALName + "\");");
                //}
                //else
                //{
                //    strclass.AppendSpaceLine(2, "private readonly " + IClass + " dal=" + "DataAccess<" + IClass + ">.Create(\"" + DALName + "\");");
                //}
            }
            else
            {
                strclass.AppendSpaceLine(2, "private readonly " + DALSpace + " dal=" + "new " + DALSpace + "();");
            }
            strclass.AppendSpaceLine(2, "public " + BLLName + "()");
            strclass.AppendSpaceLine(2, "{}");
            strclass.AppendSpaceLine(2, "#region  BasicMethod");

            #region  方法代码
            if (Maxid)
            {
                if (Keys.Count > 0)
                {
                    foreach (ColumnInfo obj in Keys)
                    {
                        if (CodeCommon.DbTypeToCS(obj.TypeName) == "int")
                        {
                            if (obj.IsPrimaryKey)
                            {
                                strclass.AppendLine(CreatBLLGetMaxID());
                                break;
                            }
                        }
                    }
                }
            }
            if (Exists)
            {
                strclass.AppendLine(CreatBLLExists());
            }
            if (Add)
            {
                strclass.AppendLine(CreatBLLADD());
            }
            if (Update)
            {
                strclass.AppendLine(CreatBLLUpdate());
            }
            if (Delete)
            {
                strclass.AppendLine(CreatBLLDelete());
            }
            if (GetModel)
            {
                strclass.AppendLine(CreatBLLGetModel());
            }
            if (GetModelByCache)
            {
                strclass.AppendLine(CreatBLLGetModelByCache(ModelName));
            }
            if (List)
            {
                strclass.AppendLine(CreatBLLGetList());
                strclass.AppendLine(CreatBLLGetAllList());
                strclass.AppendLine(CreatBLLGetListByPage());
            }

            #endregion
            strclass.AppendSpaceLine(2, "#endregion  BasicMethod");

            strclass.AppendSpaceLine(2, "#region  ExtensionMethod");
            strclass.AppendLine("");
            strclass.AppendSpaceLine(2, "#endregion  ExtensionMethod");


            strclass.AppendSpaceLine(1, "}");
            strclass.AppendLine("}");
            strclass.AppendLine("");

            return(strclass.ToString());
        }
示例#5
0
        public string GetIDALCode(bool Maxid, bool Exists, bool Add, bool Update, bool Delete, bool GetModel, bool List)
        {
            StringPlus strclass = new StringPlus();

            strclass.AppendLine("using System;");
            strclass.AppendLine("using System.Data;");
            strclass.AppendLine("using System.Collections.Generic;");
            strclass.AppendLine("namespace " + IDALpath);
            strclass.AppendLine("{");
            strclass.AppendSpaceLine(1, "/// <summary>");
            //strclass.AppendSpaceLine(1, "/// 【IDAL】: 接口层" + TableDescription);
            if (TableDescription.Length > 0)
            {
                strclass.AppendSpaceLine(1, "/// 【IDAL】: " + TableDescription.Replace("\r\n", "\r\n\t///"));
            }
            else
            {
                strclass.AppendSpaceLine(1, "/// 【IDAL】: " + _modelname /*+ ":" + Languagelist["summary"].ToString()*/);
            }
            strclass.AppendSpaceLine(1, "/// </summary>");
            strclass.AppendSpaceLine(1, "public partial interface " + IClass);
            strclass.AppendSpaceLine(1, "{");
            strclass.AppendSpaceLine(2, "#region  成员方法");

            if (Maxid)
            {
                strclass.AppendLine();
                strclass.AppendSpaceLine(2, "#region Maxid");
                strclass.Append(CreatGetMaxID());
                strclass.Append(CreatGetMaxID2());//新增方法
                strclass.AppendSpaceLine(2, "#endregion");
            }
            if (Exists)
            {
                strclass.AppendLine();
                strclass.AppendSpaceLine(2, "#region Exists");
                strclass.Append(CreatExists());
                strclass.AppendLine(CreatExists2());//新增方法
                strclass.AppendSpaceLine(2, "#endregion");
            }
            if (Add)
            {
                strclass.AppendLine();
                strclass.AppendSpaceLine(2, "#region Add");
                strclass.Append(CreatAdd());
                strclass.AppendSpaceLine(2, "#endregion");
            }
            if (Update)
            {
                strclass.AppendLine();
                strclass.AppendSpaceLine(2, "#region Update");
                strclass.Append(CreatUpdate());
                strclass.AppendLine(CreatUpdate2());//新增方法
                //strclass.AppendLine(CreatAddOrUpdate());//新增方法
                strclass.AppendSpaceLine(2, "#endregion");
            }
            if (Delete)
            {
                strclass.AppendLine();
                strclass.AppendSpaceLine(2, "#region Delete");
                strclass.Append(CreatDelete());
                strclass.AppendLine(CreatDelete2());//新增方法
                strclass.AppendSpaceLine(2, "#endregion");
            }
            if (GetModel)
            {
                strclass.AppendLine();
                strclass.AppendSpaceLine(2, "#region GetModel");
                strclass.Append(CreatGetModel());
                strclass.Append(CreatGetModel2());//新增方法
                strclass.AppendSpaceLine(2, "#endregion");
            }
            if (List)
            {
                strclass.AppendLine();
                strclass.AppendSpaceLine(2, "#region List");
                strclass.Append(CreatGetList());
                //strclass.AppendLine(CreatGetList2());//新增方法,其实返回list是合理的,同样是数据,只是这个是强类型的数据,如同返回实体的信息一样
                strclass.AppendSpaceLine(2, "#endregion");
                strclass.AppendLine();
            }
            strclass.AppendSpaceLine(2, "#endregion  成员方法");


            strclass.AppendSpaceLine(2, "#region  MethodEx");
            strclass.AppendLine("");
            strclass.AppendSpaceLine(2, "#endregion  MethodEx");


            strclass.AppendLine("	} ");
            strclass.AppendLine("}");

            if (IDALpath.Contains("Maticsoft"))//如果为默认命名空间直接返回
            {
                return(strclass.ToString());
            }
            else//否则直接替换原始命名空间
            {
                return(strclass.ToString().Replace("Maticsoft", IDALpath.Split('.')[0]));
            }
        }