public static string CreateFactory(BootstrapModel model)
        {
            string template = @"using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace {0}
{{
    public class ConnectionFactory
    {{
        public static MySqlConnection {1}
        {{
            get
            {{
                return new MySqlConnection(ConfigurationManager.ConnectionStrings[""{1}""].ConnectionString);
            }}
        }}
    }}
}}";

            return(string.Format(template, model.NameSpace, model.DbName.ToFirstUpper()));
        }
Ejemplo n.º 2
0
        public string CreateFactory(BootstrapModel model)
        {
            StringBuilder facContent = new StringBuilder();

            facContent.Append(BootstrapMySqlFactoryHelper.CreateFactory(model));

            return(facContent.ToString());
        }
Ejemplo n.º 3
0
            public BootstrapState(BootstrapMediator mediator)
            {
                this.Mediator       = mediator;
                this.BootstrapModel = mediator._bootstrapModel;
                this.View           = mediator._view;
                this.SignalBus      = mediator.SignalBus;

                this.GameSettings = mediator._gameSettings;
            }
Ejemplo n.º 4
0
        public static string CreateEditData(BootstrapModel model)
        {
            StringBuilder editContent = new StringBuilder();
            StringBuilder createModel = new StringBuilder();

            editContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtEdit{1}\"]);\r\n", model.MainKeyIdStr.ToFirstLower(), model.MainKeyIdStr.ToFirstUpper());
            createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", model.MainKeyIdStr.ToFirstUpper(), ExtendMethod.ToStringToType(model.MainKeyIdStr.ToFirstLower(), model.MainKeyIdDBType));
            foreach (var item in model.EditColumns)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();
                if (item.DBType.ToLower() == "datetime" ||
                    item.DBType.ToLower() == "date" ||
                    item.DBType.ToLower() == "int" ||
                    item.DBType.ToLower() == "tinyint")
                {
                    createModel.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(Request[\"txtEdit{1}\"]);\r\n", field, attribute);
                    if (item.DBType.ToLower() == "datetime" || item.DBType.ToLower() == "date")
                    {
                        editContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", field);
                        editContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", field);
                    }
                    else
                    {
                        editContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", field);
                        editContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", field);
                    }

                    createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", attribute, ExtendMethod.ToStringToType(field, item.DBType));
                }
                else
                {
                    editContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtEdit{1}\"]);\r\n", field, attribute);
                    createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", attribute, ExtendMethod.ToStringToType(field, item.DBType));
                }
            }

            string template = @"
        private void EditData()
        {{
{0}
            {1} model = new {1}();
{2}
            {1}DAL dal = new {1}DAL();
            dal.Update{1}(model);

            Response.Write(""0"");
        }}
";

            return(string.Format(template, editContent.ToString(), model.TableName.ToFirstUpper(), createModel.ToString()));
        }
Ejemplo n.º 5
0
        public static string CreateBatEditData(BootstrapModel model)
        {
            StringBuilder batEditContent = new StringBuilder();
            StringBuilder createModel    = new StringBuilder();

            batEditContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtBatEdit{1}\"]);\r\n", model.MainKeyIdStr.ToFirstLower(), model.MainKeyIdStr.ToFirstUpper());
            batEditContent.AppendFormat(@"           List<string> idList = {0}.Split(new char[]{{','}}, StringSplitOptions.RemoveEmptyEntries).ToList();{1}", model.MainKeyIdStr.ToFirstLower(), Environment.NewLine);
            foreach (var item in model.BatEditColumns)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();
                if (item.DBType.ToLower() == "datetime" ||
                    item.DBType.ToLower() == "date" ||
                    item.DBType.ToLower() == "int" ||
                    item.DBType.ToLower() == "tinyint")
                {
                    batEditContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(Request[\"txtBatEdit{1}\"]);\r\n", field, attribute);
                    if (item.DBType.ToLower() == "datetime" || item.DBType.ToLower() == "date")
                    {
                        batEditContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", field);
                        batEditContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", field);
                    }
                    else
                    {
                        batEditContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", field);
                        batEditContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", field);
                    }

                    createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", attribute, ExtendMethod.ToStringToType(field, item.DBType));
                }
                else
                {
                    batEditContent.AppendFormat("\t\t\tstring {0} = HttpUtility.UrlDecode(Request[\"txtBatEdit{1}\"]);\r\n", field, attribute);
                    createModel.AppendFormat("\t\t\tmodel.{0} = {1};\r\n", attribute, ExtendMethod.ToStringToType(field, item.DBType));
                }
            }

            string template = @"
        private void BatEditData()
        {{
{0}
            {1} model = new {1}();
{2}
            {1}DAL dal = new {1}DAL();
            dal.BatUpdate{1}(idList, model);

            Response.Write(""0"");
        }}
";

            return(string.Format(template, batEditContent.ToString(), model.TableName.ToFirstUpper(), createModel.ToString()));
        }
Ejemplo n.º 6
0
        public static string CreateBatEditMethod(BootstrapModel model)
        {
            StringBuilder updateContent = new StringBuilder(@"string updateSql = string.Format(""update ");

            updateContent.AppendFormat(" {0} set ", model.TableName);
            StringBuilder updateParamsContent = new StringBuilder("List<MySqlParameter> listParams = new List<MySqlParameter>();\r\n");

            int index = 0;

            foreach (var item in model.BatEditColumns)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();

                if (index == 0)
                {
                    updateContent.AppendFormat("{0}=@{0}", item.ColumnName);
                }
                else
                {
                    updateContent.AppendFormat(",{0}=@{0}", item.ColumnName);
                }

                updateParamsContent.AppendFormat("\t\t\tlistParams.Add(new MySqlParameter(\"@{0}\", {1}) {{ Value = model.{2} }});\r\n", item.ColumnName, item.DBType.ToMySqlDbType(), attribute);
                index++;
            }

            updateContent.Append(" where ");
            updateContent.AppendFormat(" {0} in ({{0}})\", idStr);", model.MainKeyIdStr);
            updateParamsContent.AppendFormat("\t\t\tlistParams.Add(new MySqlParameter(\"@{0}\", {1}) {{ Value = model.{2} }});\r\n", model.MainKeyIdStr.ToFirstUpper(), model.MainKeyIdDBType.ToMySqlDbType(), model.MainKeyIdStr.ToFirstUpper());

            string template = @"
        public bool BatUpdate{0}(List<string> list, {0} model)
        {{
            var array = (from f in list
                        select ""'"" + f + ""'"").ToArray();
            string idStr = string.Join("","", array);
			{1}
            {2}
            using (MySqlConnection sqlcn = ConnectionFactory.{3})
            {{
                return MySqlHelper2.ExecuteNonQuery(sqlcn, CommandType.Text, updateSql, listParams.ToArray()) > 0;
            }}
        }}
";

            return(string.Format(template, model.TableName.ToFirstUpper(), updateContent.ToString(), updateParamsContent.ToString(), model.DbName.ToFirstUpper()));
        }
Ejemplo n.º 7
0
        public string CreateASPXCS(BootstrapModel model)
        {
            StringBuilder aspxcsContent = new StringBuilder();

            aspxcsContent.Append(BootstrapAspxCsHelper.CreateCSHead(model.NameSpace, model.TableName.ToFirstUpper()));
            aspxcsContent.Append(BootstrapAspxCsHelper.CreatePageLoad(model));
            aspxcsContent.Append(BootstrapAspxCsHelper.CreateLoadData(model));
            aspxcsContent.Append(BootstrapAspxCsHelper.CreateAddData(model));
            aspxcsContent.Append(BootstrapAspxCsHelper.CreateEditData(model));
            aspxcsContent.Append(BootstrapAspxCsHelper.CreateBatEditData(model));
            aspxcsContent.Append(BootstrapAspxCsHelper.CreateDeleteData(model));
            aspxcsContent.Append(BootstrapAspxCsHelper.CreateDownAndDownAll(model));
            aspxcsContent.Append(BootstrapAspxCsHelper.CreateBottom());

            return(aspxcsContent.ToString());
        }
Ejemplo n.º 8
0
        public string CreateDAL(BootstrapModel model)
        {
            StringBuilder dalContent = new StringBuilder();

            dalContent.Append(BootstrapMySqlDALHelper.CreateDALHeader(model.NameSpace, model.TableName.ToFirstUpper()));
            dalContent.Append(BootstrapMySqlDALHelper.CreateAddMethod(model));
            dalContent.Append(BootstrapMySqlDALHelper.CreateEditMethod(model));
            dalContent.Append(BootstrapMySqlDALHelper.CreateBatEditMethod(model));
            dalContent.Append(BootstrapMySqlDALHelper.CreateDeleteMethod(model));
            dalContent.Append(BootstrapMySqlDALHelper.CreateQueryListMethod(model));
            dalContent.Append(BootstrapMySqlDALHelper.CreateGetAllAndPart(model));

            dalContent.Append(BootstrapMySqlDALHelper.CreateBottom());

            return(dalContent.ToString());
        }
Ejemplo n.º 9
0
        public static string CreateEditMethod(BootstrapModel model)
        {
            StringBuilder updateContent = new StringBuilder("string updateSql = \"update top(1)");

            updateContent.AppendFormat(" {0} set ", model.TableName);
            StringBuilder updateParamsContent = new StringBuilder("List<SqlParameter> listParams = new List<SqlParameter>();\r\n");

            int index = 0;

            foreach (var item in model.EditColumns)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();

                if (index == 0)
                {
                    updateContent.AppendFormat("{0}=@{0}", item.ColumnName);
                }
                else
                {
                    updateContent.AppendFormat(",{0}=@{0}", item.ColumnName);
                }

                updateParamsContent.AppendFormat("\t\t\tlistParams.Add(new SqlParameter(\"@{0}\", {1}) {{ Value = model.{2} }});\r\n", item.ColumnName, item.DBType.ToMsSqlDbType(), attribute);

                index++;
            }

            updateContent.Append(" where ");
            updateContent.AppendFormat(" {0}=@{1} \";", model.MainKeyIdStr, model.MainKeyIdStr.ToFirstUpper());
            updateParamsContent.AppendFormat("\t\t\tlistParams.Add(new SqlParameter(\"@{0}\", {1}) {{ Value = model.{2} }});\r\n", model.MainKeyIdStr.ToFirstUpper(), model.MainKeyIdDBType.ToMsSqlDbType(), model.MainKeyIdStr.ToFirstUpper());

            string template = @"
        public bool Update{0}({0} model)
        {{
			{1}
            {2}
            using (SqlConnection sqlcn = ConnectionFactory.{3})
            {{
                return SqlHelper.ExecuteNonQuery(sqlcn, CommandType.Text, updateSql, listParams.ToArray()) > 0;
            }}
        }}
";

            return(string.Format(template, model.TableName.ToFirstUpper(), updateContent.ToString(), updateParamsContent.ToString(), model.DbName.ToFirstUpper()));
        }
Ejemplo n.º 10
0
        public static string CreateAddMethod(BootstrapModel model)
        {
            StringBuilder addContent       = new StringBuilder();
            StringBuilder valueContent     = new StringBuilder(") values (");
            StringBuilder addparamsContent = new StringBuilder("List<MySqlParameter> listParams = new List<MySqlParameter>();\r\n");

            addContent.AppendFormat("string insertSql = \"insert {0}(", model.TableName);
            var addlist = (from f in model.ColumnList where !f.IsMainKey select f).ToList();
            int index   = 0;

            foreach (var item in addlist)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();

                if (index == 0)
                {
                    addContent.Append(item.ColumnName);
                    valueContent.Append("@" + item.ColumnName);
                }
                else
                {
                    addContent.Append(" ," + item.ColumnName);
                    valueContent.Append(" ,@" + item.ColumnName);
                }

                addparamsContent.AppendFormat("\t\t\tlistParams.Add(new MySqlParameter(\"@{0}\", {1}) {{ Value = model.{2} }});\r\n", item.ColumnName, item.DBType.ToMySqlDbType(), attribute);

                index++;
            }

            addContent.Append(valueContent.ToString() + ")\";");
            string template = @"
        public bool Add{0}({0} model)
        {{
			{1}
            {2}
            using (MySqlConnection sqlcn = ConnectionFactory.{3})
            {{
                return MySqlHelper2.ExecuteNonQuery(sqlcn, CommandType.Text, insertSql, listParams.ToArray()) > 0;
            }}
        }}
";

            return(string.Format(template, model.TableName.ToFirstUpper(), addContent.ToString(), addparamsContent.ToString(), model.DbName.ToFirstUpper()));
        }
Ejemplo n.º 11
0
        private void btnCreateBootStrap_Click(object sender, EventArgs e)
        {
            BootstrapModel model = new BootstrapModel();

            model.DbName            = this.txtDBName.Text.Trim();
            model.AddColumnsStr     = this.txtAddColumnName.Text.Trim();
            model.SearchColumnsStr  = this.txtSearchColumnName.Text.Trim();
            model.EditColumnsStr    = this.txtEditColumnName.Text.Trim();
            model.BatEditColumnsStr = this.txtBatEdit.Text.Trim();
            model.TableStr          = this.txtName.Text.Trim();
            model.NameSpace         = this.txtNameSpace.Text.Trim();
            model.DbType            = rbtnMSSQL.Checked ? 0 : 1;
            model.IsDel             = this.chkDel.Checked;
            model.IsBatDel          = this.chkBatDel.Checked;
            model.IsBatEdit         = this.chkBatEdit.Checked;
            model.IsAdd             = this.chkAdd.Checked;
            model.IsEdit            = this.chkEdit.Checked;
            model.IsExport          = this.chkExport.Checked;

            // 初始化model对象的属性
            UIHelper.InitBootstrap(model);
            if (model.DbType == 0)
            {
                BootstrapHelper bootStrapHelper = new BootstrapHelper();
                this.txtClassCode.Text = bootStrapHelper.CreateModel(model);
                string aspxStr = bootStrapHelper.CreateASPX(model);
                this.txtAspxCode.Text    = aspxStr;
                this.txtAspxCsCode.Text  = bootStrapHelper.CreateASPXCS(model);
                this.txtDALCode.Text     = bootStrapHelper.CreateDAL(model);
                this.txtFactoryCode.Text = bootStrapHelper.CreateFactory(model);
                this.txtSqlHelper.Text   = SourceHelper.GetResource("sqlhelper.txt").Replace("命名空间", model.NameSpace);
            }
            else if (model.DbType == 1)
            {
                BootstrapHelper bootStrapHelper = new BootstrapHelper();
                this.txtClassCode.Text = bootStrapHelper.CreateModel(model);
                string aspxStr = bootStrapHelper.CreateASPX(model);
                this.txtAspxCode.Text   = aspxStr;
                this.txtAspxCsCode.Text = bootStrapHelper.CreateASPXCS(model);
                MySqlBootstrapHelper mysqlHelper = new MySqlBootstrapHelper();
                this.txtDALCode.Text     = mysqlHelper.CreateDAL(model);
                this.txtFactoryCode.Text = mysqlHelper.CreateFactory(model);
                this.txtSqlHelper.Text   = SourceHelper.GetResource("sqlhelper.txt").Replace("命名空间", model.NameSpace);
            }
        }
Ejemplo n.º 12
0
        public string CreateASPX(BootstrapModel model)
        {
            StringBuilder aspxContent = new StringBuilder();

            aspxContent.Append(BootstrapAspxHelper.CreatePageHead(model.NameSpace, model.TableName.ToFirstUpper() + "Manager"));
            aspxContent.Append(BootstrapAspxHelper.CreateHeader(model.Title));
            aspxContent.Append(BootstrapAspxHelper.CreateBodyHead(model.Title));
            aspxContent.Append(BootstrapAspxHelper.CreateSearchContent(model));
            aspxContent.Append(BootstrapAspxHelper.CreateCmdToolBar(model));
            aspxContent.Append(BootstrapAspxHelper.CreateDataGrid(model));
            aspxContent.Append(BootstrapAspxHelper.CreateDialog(model));
            aspxContent.Append(BootstrapAspxHelper.CreateNotifyMsg());
            aspxContent.Append(BootstrapAspxHelper.CreateJsDateFormat());
            aspxContent.Append(BootstrapAspxHelper.CreateJsOperation(model));
            aspxContent.Append(BootstrapAspxHelper.CreateJsLoad(model));
            aspxContent.Append(BootstrapAspxHelper.CreateBottomContent());

            return(aspxContent.ToString());
        }
Ejemplo n.º 13
0
        public static string CreateDeleteData(BootstrapModel model)
        {
            StringBuilder batContent = new StringBuilder();

            batContent.AppendFormat("            string ids = HttpUtility.UrlDecode(Request[\"ids\"]);\r\n", model.MainKeyIdStr.ToFirstLower(), model.MainKeyIdStr.ToFirstUpper());
            batContent.Append("            List<string> idList = ids.Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries).ToList();\r\n");

            string template = @"
        private void DeleteData()
        {{
{0}
            {1}DAL dal = new {1}DAL();
            dal.Delete{1}(idList);

            Response.Write(""0"");
        }}
";

            return(string.Format(template, batContent.ToString(), model.TableName.ToFirstUpper()));
        }
Ejemplo n.º 14
0
        public static string CreateDeleteMethod(BootstrapModel model)
        {
            StringBuilder deleteContent = new StringBuilder();

            deleteContent.AppendFormat(@"string deleteSql = string.Format(""delete from {0} ", model.TableName);
            deleteContent.AppendFormat(" where {0} in ({{0}})\", idStr);", model.MainKeyIdStr);

            string template = @"
        public bool Delete{0}(List<string> list)
        {{
            var array = (from f in list
                        select ""'"" + f + ""'"").ToArray();
            string idStr = string.Join("","", array);
			{1}
            using (MySqlConnection sqlcn = ConnectionFactory.{2})
            {{
                return MySqlHelper2.ExecuteNonQuery(sqlcn, CommandType.Text, deleteSql, null) > 0;
            }}
        }}
";

            return(string.Format(template, model.TableName.ToFirstUpper(), deleteContent.ToString(), model.DbName.ToFirstUpper()));
        }
Ejemplo n.º 15
0
        public static void InitBootstrap(BootstrapModel model)
        {
            if (model.DbType == 0)
            {
                // MS SQL
                Regex tableComRegex = new Regex(@"--\s{0,}(?<tablecom>[^\s]+)\s{0,}create\s+table\s+");
                Regex tableRegex    = new Regex(@"create\s+table\s+(?<tableName>\w+)");
                Regex columnRegex   = new Regex(@"\s{0,}(?<key>\w+)\s+(?<type>\w+)");
                Regex mainKeyRegex  = new Regex(@"primary\s+key", RegexOptions.IgnoreCase);
                Regex commentRegex  = new Regex(@"-{2,}\s{0,}(?<comment>[^\s]+)");
                model.TableName = tableRegex.Match(model.TableStr).Groups["tableName"].Value;
                model.Title     = tableComRegex.Match(model.TableStr).Groups["tablecom"].Value;

                #region 加载列集合
                var      columnList = new List <ColumnInfo>();
                string[] lines      = model.TableStr.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < lines.Length; i++)
                {
                    var    line  = lines[i];
                    Match  m     = columnRegex.Match(line);
                    string key   = m.Groups["key"].Value;
                    string value = m.Groups["type"].Value;
                    if (key == "" || value == "" || key.ToLower() == "create" || value.ToLower() == "table")
                    {
                        continue;
                    }

                    string comment = commentRegex.Match(line).Groups["comment"].Value;
                    if (string.IsNullOrEmpty(comment))
                    {
                        comment = key;
                    }

                    columnList.Add(new ColumnInfo()
                    {
                        ColumnName      = key,
                        DBType          = value,
                        IsAutoIncrement = line.ToLower().Contains("identity"),
                        IsMainKey       = mainKeyRegex.IsMatch(line),
                        Comment         = comment
                    });
                }

                model.ColumnList.AddRange(columnList.ToArray());
                string[] array = model.SearchColumnsStr.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in array)
                {
                    var m = model.ColumnList.Find(p => p.ColumnName == item);
                    if (m != null)
                    {
                        model.SearchColumns.Add(m);
                    }
                }
                #endregion

                #region 添加,编辑,批量编辑
                if (model.IsAdd)
                {
                    array = model.AddColumnsStr.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in array)
                    {
                        var m = model.ColumnList.Find(p => p.ColumnName == item);
                        if (m != null)
                        {
                            model.AddColumns.Add(m);
                        }
                    }
                }

                if (model.IsEdit)
                {
                    array = model.EditColumnsStr.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in array)
                    {
                        var m = model.ColumnList.Find(p => p.ColumnName == item);
                        if (m != null)
                        {
                            model.EditColumns.Add(m);
                        }
                    }
                }

                if (model.IsBatEdit)
                {
                    array = model.BatEditColumnsStr.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in array)
                    {
                        var m = model.ColumnList.Find(p => p.ColumnName == item);
                        if (m != null)
                        {
                            model.BatEditColumns.Add(m);
                        }
                    }
                }
                #endregion
            }
            else if (model.DbType == 1)
            {
                // MySQL
                Regex tableComRegex = new Regex(@"--\s{0,}(?<tablecom>[^\s]+)\s{0,}create\s+table\s+");
                Regex tableRegex    = new Regex(@"create\s+table\s+(?<tableName>\w+)");
                Regex columnRegex   = new Regex(@"\s{0,}(?<key>\w+)\s+(?<type>\w+)");
                Regex mainKeyRegex  = new Regex(@"primary\s+key", RegexOptions.IgnoreCase);
                Regex commentRegex  = new Regex(@"-{2,}\s{0,}(?<comment>[^\s]+)");
                model.TableName = tableRegex.Match(model.TableStr).Groups["tableName"].Value;
                model.Title     = tableComRegex.Match(model.TableStr).Groups["tablecom"].Value;

                #region 加载列集合
                var      columnList = new List <ColumnInfo>();
                string[] lines      = model.TableStr.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < lines.Length; i++)
                {
                    var    line  = lines[i];
                    Match  m     = columnRegex.Match(line);
                    string key   = m.Groups["key"].Value;
                    string value = m.Groups["type"].Value;
                    if (key == "" || value == "" || key.ToLower() == "create" || value.ToLower() == "table")
                    {
                        continue;
                    }

                    string comment = commentRegex.Match(line).Groups["comment"].Value;
                    if (string.IsNullOrEmpty(comment))
                    {
                        comment = key;
                    }

                    columnList.Add(new ColumnInfo()
                    {
                        ColumnName      = key,
                        DBType          = value,
                        IsAutoIncrement = line.ToLower().Contains("auto_increment"),
                        IsMainKey       = mainKeyRegex.IsMatch(line),
                        Comment         = comment
                    });
                }

                model.ColumnList.AddRange(columnList.ToArray());
                string[] array = model.SearchColumnsStr.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in array)
                {
                    var m = model.ColumnList.Find(p => p.ColumnName == item);
                    if (m != null)
                    {
                        model.SearchColumns.Add(m);
                    }
                }
                #endregion

                #region 添加,编辑,批量编辑
                if (model.IsAdd)
                {
                    array = model.AddColumnsStr.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in array)
                    {
                        var m = model.ColumnList.Find(p => p.ColumnName == item);
                        if (m != null)
                        {
                            model.AddColumns.Add(m);
                        }
                    }
                }

                if (model.IsEdit)
                {
                    array = model.EditColumnsStr.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in array)
                    {
                        var m = model.ColumnList.Find(p => p.ColumnName == item);
                        if (m != null)
                        {
                            model.EditColumns.Add(m);
                        }
                    }
                }

                if (model.IsBatEdit)
                {
                    array = model.BatEditColumnsStr.Split(new char[] { ',', ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in array)
                    {
                        var m = model.ColumnList.Find(p => p.ColumnName == item);
                        if (m != null)
                        {
                            model.BatEditColumns.Add(m);
                        }
                    }
                }
                #endregion
            }

            var col = model.ColumnList.Find(p => p.IsMainKey);
            if (col != null)
            {
                model.MainKeyIdStr    = col.ColumnName;
                model.MainKeyIdDBType = col.DBType;
            }
        }
Ejemplo n.º 16
0
        public static string GetClassString(BootstrapModel model)
        {
            StringBuilder content = new StringBuilder();

            content.AppendLine("using System;");
            content.AppendLine("using System.Collections.Generic;");
            content.AppendLine("using System.Text;");
            content.AppendLine("namespace " + (string.IsNullOrEmpty(model.NameSpace) ? "命名空间" : model.NameSpace));
            content.AppendLine("{");
            if (!string.IsNullOrEmpty(model.Title))
            {
                content.Append(CreateComment(model.Title, 1));
            }

            content.AppendFormat("\tpublic class {0}\r\n", model.TableName.ToFirstUpper());
            content.AppendLine("\t{");
            for (int i = 0; i < model.ColumnList.Count; i++)
            {
                var item = model.ColumnList.Skip(i).Take(1).First();
                if (!string.IsNullOrEmpty(item.Comment))
                {
                    content.Append(CreateComment(item.Comment, 2));
                }

                content.AppendFormat("\t\tprivate {0} {1} = {2};\r\n", GetFormatString(item.DBType), item.ColumnName.ToFirstLower(), GetDefaultValueStr(item.DBType));

                content.AppendLine();
                if (!string.IsNullOrEmpty(item.Comment))
                {
                    content.Append(CreateComment(item.Comment, 2));
                }

                content.AppendFormat("\t\tpublic {0} {1}\r\n", GetFormatString(item.DBType), item.ColumnName.ToFirstUpper());
                content.AppendLine("\t\t{");
                content.AppendLine("\t\t\tget { return this." + item.ColumnName.ToFirstLower() + "; }");
                content.AppendLine("\t\t\tset { this." + item.ColumnName.ToFirstLower() + " = value; }");
                content.AppendLine("\t\t}");

                if (item.DBType.ToLower().Contains("date") && !model.ColumnList.Exists(p => p.ColumnName.ToLower().Contains(item.ColumnName.ToLower() + "str")))
                {
                    content.AppendLine();
                    // 增加字符串属性
                    if (!string.IsNullOrEmpty(item.Comment))
                    {
                        content.Append(CreateComment(item.Comment, 2));
                    }

                    content.AppendFormat("\t\tpublic string {0}Str\r\n", item.ColumnName.ToFirstUpper());
                    content.AppendLine("\t\t{");
                    if (item.DBType.ToLower() == "date")
                    {
                        content.AppendLine("\t\t\tget { return this." + item.ColumnName.ToFirstLower() + ".ToString(\"yyyy-MM-dd\"); }");
                    }
                    else
                    {
                        content.AppendLine("\t\t\tget { return this." + item.ColumnName.ToFirstLower() + ".ToString(\"yyyy-MM-dd HH:mm\"); }");
                    }

                    content.AppendLine("\t\t}");
                }

                if ((i + 1) < model.ColumnList.Count)
                {
                    content.AppendLine();
                }
            }

            content.AppendLine("\t}");
            content.AppendLine("}");

            return(content.ToString());
        }
Ejemplo n.º 17
0
 public async Task <IViewComponentResult> InvokeAsync(BootstrapModel m)
 {
     //Modal m = new GSOptima.ViewModels.Modal() { Body = body, Header = header };
     return(View(m));
 }
Ejemplo n.º 18
0
        public static string CreateDownAndDownAll(BootstrapModel model)
        {
            StringBuilder searchContent    = new StringBuilder();
            StringBuilder searchStrContent = new StringBuilder();

            foreach (var item in model.SearchColumns)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();
                if (item.DBType.ToLower() == "datetime" ||
                    item.DBType.ToLower() == "date" ||
                    item.DBType.ToLower() == "int" ||
                    item.DBType.ToLower() == "tinyint")
                {
                    searchContent.AppendFormat("\t\t\tstring {0}Str = HttpUtility.UrlDecode(Request[\"txtSearch{1}\"]);\r\n", field, attribute);
                    if (item.DBType.ToLower() == "datetime" || item.DBType.ToLower() == "date")
                    {
                        searchContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", field);
                        searchContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", field);
                    }
                    else
                    {
                        searchContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", field);
                        searchContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", field);
                    }
                }
                else
                {
                    searchContent.AppendFormat("            string {0} = HttpUtility.UrlDecode(Request[\"txtSearch{1}\"]);\r\n", field, attribute);
                }

                searchStrContent.AppendFormat(" {0},", field);
            }

            // 移除最后的逗号
            string searchStrCount = searchStrContent.Length > 0 ? searchStrContent.ToString().Substring(0, searchStrContent.Length - 1) : searchStrContent.ToString();

            StringBuilder batContent = new StringBuilder();

            batContent.AppendFormat("            string ids = HttpUtility.UrlDecode(Request[\"ids\"]);\r\n", model.MainKeyIdStr.ToFirstLower(), model.MainKeyIdStr.ToFirstUpper());
            batContent.Append("            List<string> idList = ids.Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries).ToList();\r\n");
            batContent.Append(searchContent.ToString());

            StringBuilder content = new StringBuilder();

            content.Append("<table border='1'><thead><tr>");
            foreach (var item in model.ColumnList)
            {
                content.AppendFormat("<th>{0}</th>", item.Comment);
            }

            content.Append("</tr></thead>");

            StringBuilder appendFormat = new StringBuilder();

            foreach (var item in model.ColumnList)
            {
                appendFormat.AppendFormat(@"                content.AppendFormat(""<td>{{0}}</td>"", list[i].{0});{1}", item.ColumnName.ToFirstUpper(), Environment.NewLine);
            }

            string template = @"
        private void Down()
        {{
{0}
            {1}DAL dal = new {1}DAL();
            List<{1}> data = dal.GetPartAll({4}idList);
            string content = CreateTable(data);
            Response.Clear(); 
            Response.Buffer = true; 
            Response.Charset = ""UTF-8""; 
            Response.AddHeader(""Content-Disposition"", ""attachment; filename={1}.xls""); 
            Response.ContentEncoding = System.Text.Encoding.GetEncoding(""UTF-8""); 
            Response.ContentType = ""application/ms-excel;charset=UTF-8""; 
            Response.Write(content); 
            Response.Flush(); 
            Response.End(); 
        }}

        private void DownAll()
        {{
{0}
            {1}DAL dal = new {1}DAL();
            List<{1}> data = dal.GetAll({5});
            string content = CreateTable(data);
            Response.Clear(); 
            Response.Buffer = true; 
            Response.Charset = ""UTF-8""; 
            Response.AddHeader(""Content-Disposition"", ""attachment; filename={1}.xls""); 
            Response.ContentEncoding = System.Text.Encoding.GetEncoding(""UTF-8""); 
            Response.ContentType = ""application/ms-excel;charset=UTF-8""; 
            Response.Write(content); 
            Response.Flush(); 
            Response.End(); 
        }}

        private string CreateTable(List<{1}> list)
        {{
            StringBuilder content = new StringBuilder();
            
            // create columns header
            content.Append(""{2}"");
            for (int i = 0, len = list.Count; i < len; i++)
            {{
                content.Append(""<tr>"");
{3}
                content.Append(""</tr>"");
            }}
            content.Append(""</tbody></table>"");

            return content.ToString();            
        }}";

            // TODO
            return(string.Format(template, batContent.ToString(), model.TableName.ToFirstUpper(), content.ToString(), appendFormat.ToString(), searchStrContent.ToString(), searchStrCount));
        }
Ejemplo n.º 19
0
 /// <summary>
 /// 创建Model类
 /// </summary>
 /// <param name="model">模板对象</param>
 public string CreateModel(BootstrapModel model)
 {
     return(BootstrapModelHelper.GetClassString(model));
 }
Ejemplo n.º 20
0
        public static string CreatePageLoad(BootstrapModel model)
        {
            string        template = @"
        protected void Page_Load(object sender, EventArgs e)
        {{
            if (Request.HttpMethod.ToUpper() == ""POST"")
            {{
                string type = Request.QueryString[""type""];
                switch (type)
                {{
{0}    
                }}

                Response.Flush();
                Response.End();
            }}{1}
        }}
";
            StringBuilder content  = new StringBuilder();

            content.Append(@"
                    case ""loaddata"":
                        LoadData();
                        break;
");
            if (model.IsAdd)
            {
                content.Append(@"
                    case ""add"":
                        AddData();
                        break;
");
            }

            if (model.IsEdit)
            {
                content.Append(@"
                    case ""edit"":
                        EditData();
                        break;
");
            }

            if (model.IsBatEdit)
            {
                content.Append(@"
                    case ""batedit"":
                        BatEditData();
                        break;
");
            }

            if (model.IsDel)
            {
                content.Append(@"
                    case ""delete"":
                        DeleteData();
                        break;
");
            }

            StringBuilder elseContent = new StringBuilder();

            if (model.IsExport)
            {
                elseContent.AppendFormat(@"
            else{{
                string type = Request.QueryString[""type""];
                switch (type)
                {{
                    case ""down"":
                        Down();
                        break;
                    case ""downall"":
                        DownAll();
                        break;
                }}
            }}");
            }

            return(string.Format(template, content.ToString(), elseContent.ToString()));
        }
Ejemplo n.º 21
0
        public static string CreateLoadData(BootstrapModel model)
        {
            string        template         = @"
        private void LoadData()
        {{
            int page = Convert.ToInt32(Request.Form[""page""]);
            int pageSize = Convert.ToInt32(Request.Form[""pageSize""]);
{0}
            {1}DAL dal = new {1}DAL();
            var list = dal.QueryList({2}page, pageSize);
{4}
            int itemCount = dal.QueryListCount({3});
            int pageCount = (int)Math.Ceiling((double)itemCount / (double)pageSize);
			JavaScriptSerializer js = new JavaScriptSerializer();
            var str = js.Serialize(new {{ PageCount = pageCount, ItemCount = itemCount, Data = list }});
            Response.Write(str);
        }}
";
            StringBuilder searchContent    = new StringBuilder();
            StringBuilder searchStrContent = new StringBuilder();

            foreach (var item in model.SearchColumns)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();
                if (item.DBType.ToLower() == "datetime" ||
                    item.DBType.ToLower() == "date" ||
                    item.DBType.ToLower() == "int" ||
                    item.DBType.ToLower() == "tinyint")
                {
                    searchContent.AppendFormat("\t\t\tstring {1}Str = HttpUtility.UrlDecode(Request[\"txtSearch{2}\"]);\r\n", item.DBType.ToMsSqlClassType(), field, attribute);
                    if (item.DBType.ToLower() == "datetime" || item.DBType.ToLower() == "date")
                    {
                        searchContent.AppendFormat("\t\t\tDateTime {0} = DateTime.MinValue;\r\n", field);
                        searchContent.AppendFormat("\t\t\tDateTime.TryParse({0}Str, out {0});\r\n", field);
                    }
                    else
                    {
                        searchContent.AppendFormat("\t\t\tint {0} = 0;;\r\n", field);
                        searchContent.AppendFormat("\t\t\tint.TryParse({0}Str, out {0});\r\n", field);
                    }
                }
                else
                {
                    searchContent.AppendFormat("\t\t\tstring {1} = HttpUtility.UrlDecode(Request[\"txtSearch{2}\"]);\r\n", item.DBType.ToMsSqlClassType(), field, attribute);
                }

                searchStrContent.AppendFormat(" {0},", field);
            }

            StringBuilder encodeContent = new StringBuilder();

            foreach (var item in model.ColumnList)
            {
                if (item.DBType == "varchar")
                {
                    string attribute = item.ColumnName.ToFirstUpper();

                    encodeContent.AppendLine(string.Format("\t\t\tlist.ForEach(p => p.{0} = HttpUtility.HtmlEncode(p.{0}));", attribute));
                }
            }

            // 移除最后的逗号
            string searchStrCount = searchStrContent.Length > 0 ? searchStrContent.ToString().Substring(0, searchStrContent.Length - 1) : searchStrContent.ToString();

            return(string.Format(template, searchContent.ToString(), model.TableName.ToFirstUpper(), searchStrContent.ToString(), searchStrCount, encodeContent.ToString()));
        }
Ejemplo n.º 22
0
        public static string CreateGetAllAndPart(BootstrapModel model)
        {
            StringBuilder queryWhereContent = new StringBuilder();
            StringBuilder queryListParams   = new StringBuilder();
            int           index             = 0;

            foreach (var item in model.SearchColumns)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();
                queryListParams.AppendFormat("{0} {1},", item.DBType.ToMsSqlClassType(), field);

                if (index == 0)
                {
                    if (item.DBType.ToLower() == "int")
                    {
                        queryWhereContent.AppendFormat("            if ({0} > 0)\r\n", field);
                    }
                    else if (item.DBType.ToLower() == "tinyint")
                    {
                        queryWhereContent.AppendFormat("            if ({0} >= 0)\r\n", field);
                    }
                    else if (item.DBType.ToLower() == "datetime" || item.DBType.ToLower() == "datetime")
                    {
                        queryWhereContent.AppendFormat("            if ({0} != DateTime.MinValue)\r\n", field);
                    }
                    else
                    {
                        queryWhereContent.AppendFormat("            if (!string.IsNullOrEmpty({0}))\r\n", field);
                    }
                }
                else
                {
                    if (item.DBType.ToLower() == "int")
                    {
                        queryWhereContent.AppendFormat("            if ({0} > 0)\r\n", field);
                    }
                    else if (item.DBType.ToLower() == "tinyint")
                    {
                        queryWhereContent.AppendFormat("            if ({0} >= 0)\r\n", field);
                    }
                    else if (item.DBType.ToLower() == "datetime" || item.DBType.ToLower() == "datetime")
                    {
                        queryWhereContent.AppendFormat("            if ({0} != DateTime.MinValue)\r\n", field);
                    }
                    else
                    {
                        queryWhereContent.AppendFormat("            if (!string.IsNullOrEmpty({0}))\r\n", field);
                    }
                }

                queryWhereContent.Append("            {\r\n");
                queryWhereContent.AppendFormat("                listParams.Add(new MySqlParameter(\"@{0}\", {1}) {{ Value = {2} }});\r\n", item.ColumnName, item.DBType.ToMySqlDbType(), field);

                queryWhereContent.AppendFormat("                whereStr += \" and {0}=@{0} \";\r\n", item.ColumnName.ToFirstUpper());
                queryWhereContent.Append("            }\r\n");
                queryWhereContent.AppendLine();

                index++;
            }

            StringBuilder selectSqlContent = new StringBuilder();

            selectSqlContent.Append("            string selectSql = string.Format(@\"select * from\r\n");
            selectSqlContent.Append("            " + model.TableName + " where " + model.MainKeyIdStr + " in ({1})\r\n");
            selectSqlContent.Append("            {0};\", whereStr, idArrayStr);\r\n");

            var assignContent = new StringBuilder();

            foreach (var item in model.ColumnList)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();
                assignContent.AppendFormat("                        model.{0} = sqldr[\"{1}\"] == DBNull.Value ? {2} : {3};\r\n", attribute, item.ColumnName, ExtendMethod.ToDefaultValue(item.DBType), ExtendMethod.ToDefaultDBValue(item.DBType, item.ColumnName));
            }

            string template = @"
        public List<{0}> GetPartAll({1}List<string> idList)
        {{
            var idArrayStr = string.Join("","", (from f in idList
                                select ""'""+ f + ""'"").ToArray());
            string whereStr = string.Empty;
            List<MySqlParameter> listParams = new List<MySqlParameter>();
{2}
{7}
            List<{0}> result = new List<{0}>();
            using (MySqlConnection sqlcn = ConnectionFactory.{3})
            {{
                using(MySqlDataReader sqldr = MySqlHelper2.ExecuteDataReader(sqlcn, CommandType.Text, selectSql, listParams.ToArray()))
                {{
                    while(sqldr.Read())
                    {{
                        {0} model = new {0}();
{5}
                        result.Add(model);
                    }}
                }}
            }}

            return result;
        }}

        public List<{0}> GetAll({4})
        {{
            string whereStr = string.Empty;
            List<MySqlParameter> listParams = new List<MySqlParameter>();
{2}
            string selectAllSql = string.Format(""select * from {6} where 1=1 {{0}}"", whereStr);
            List<{0}> result = new List<{0}>();
            using (MySqlConnection sqlcn = ConnectionFactory.{3})
            {{
                using(MySqlDataReader sqldr = MySqlHelper2.ExecuteDataReader(sqlcn, CommandType.Text, selectAllSql, listParams.ToArray()))
                {{
                    while(sqldr.Read())
                    {{
                        {0} model = new {0}();
{5}
                        result.Add(model);
                    }}
                }}
            }}

            return result;
        }}
";

            string queryCountParams = queryListParams.Length > 0 ? queryListParams.ToString().Substring(0, queryListParams.Length - 1) : queryListParams.ToString();

            return(string.Format(template, model.TableName.ToFirstUpper(), queryListParams.ToString(), queryWhereContent.ToString(), model.DbName.ToFirstUpper(), queryCountParams, assignContent.ToString(), model.TableName, selectSqlContent.ToString()));
        }
Ejemplo n.º 23
0
        public static string CreateQueryListMethod(BootstrapModel model)
        {
            StringBuilder queryWhereContent = new StringBuilder();
            StringBuilder queryListParams   = new StringBuilder();
            int           index             = 0;

            foreach (var item in model.SearchColumns)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();
                queryListParams.AppendFormat("{0} {1},", item.DBType.ToMsSqlClassType(), field);

                if (index == 0)
                {
                    if (item.DBType.ToLower() == "int")
                    {
                        queryWhereContent.AppendFormat("if ({0} > 0)\r\n", field);
                    }
                    else if (item.DBType.ToLower() == "tinyint")
                    {
                        queryWhereContent.AppendFormat("if ({0} >= 0)\r\n", field);
                    }
                    else if (item.DBType.ToLower() == "datetime" || item.DBType.ToLower() == "date")
                    {
                        queryWhereContent.AppendFormat("if ({0} != DateTime.MinValue)\r\n", field);
                    }
                    else
                    {
                        queryWhereContent.AppendFormat("if (!string.IsNullOrEmpty({0}))\r\n", field);
                    }
                }
                else
                {
                    if (item.DBType.ToLower() == "int")
                    {
                        queryWhereContent.AppendFormat("\t\t\tif ({0} > 0)\r\n", field);
                    }
                    else if (item.DBType.ToLower() == "tinyint")
                    {
                        queryWhereContent.AppendFormat("\t\t\tif ({0} >= 0)\r\n", field);
                    }
                    else if (item.DBType.ToLower() == "datetime" || item.DBType.ToLower() == "date")
                    {
                        queryWhereContent.AppendFormat("\t\t\tif ({0} != DateTime.MinValue)\r\n", field);
                    }
                    else
                    {
                        queryWhereContent.AppendFormat("\t\t\tif (!string.IsNullOrEmpty({0}))\r\n", field);
                    }
                }

                queryWhereContent.Append("\t\t\t{\r\n");
                queryWhereContent.AppendFormat("\t\t\t\tlistParams.Add(new SqlParameter(\"@{0}\", {1}) {{ Value = {2} }});\r\n", item.ColumnName, item.DBType.ToMsSqlDbType(), field);

                queryWhereContent.AppendFormat("\t\t\t\twhereStr += \" and {0}=@{0} \";\r\n", item.ColumnName.ToFirstUpper());
                queryWhereContent.Append("\t\t\t}\r\n");
                queryWhereContent.AppendLine();

                index++;
            }

            StringBuilder selectSqlContent = new StringBuilder();

            selectSqlContent.Append("\tstring selectSql = string.Format(@\"select * from\r\n");
            selectSqlContent.AppendFormat("\t        (select top 100 percent *,ROW_NUMBER() over(order by {0}) as rownumber from\r\n", model.MainKeyIdStr);
            selectSqlContent.Append("\t        " + model.TableName + " where 1=1 {0}) as T\r\n");
            selectSqlContent.Append("\t        where rownumber between {1} and {2};\", whereStr, ((page - 1) * pageSize + 1), page * pageSize);\r\n");

            var assignContent = new StringBuilder();

            foreach (var item in model.ColumnList)
            {
                string field     = item.ColumnName.ToFirstLower();
                string attribute = item.ColumnName.ToFirstUpper();
                assignContent.AppendFormat("                        model.{0} = sqldr[\"{1}\"] == DBNull.Value ? {2} : {3};\r\n", attribute, item.ColumnName, ExtendMethod.ToDefaultValue(item.DBType), ExtendMethod.ToDefaultDBValue(item.DBType, item.ColumnName));
            }

            string template = @"
        public List<{0}> QueryList({1}int page, int pageSize)
        {{
            string whereStr = string.Empty;
            List<SqlParameter> listParams = new List<SqlParameter>();
            {2}
            {7}
            List<{0}> result = new List<{0}>();
            using (SqlConnection sqlcn = ConnectionFactory.{3})
            {{
                using(SqlDataReader sqldr = SqlHelper.ExecuteReader(sqlcn, CommandType.Text, selectSql, listParams.ToArray()))
                {{
                    while(sqldr.Read())
                    {{
                        {0} model = new {0}();
{5}
                        result.Add(model);
                    }}
                }}
            }}

            return result;
        }}

        public int QueryListCount({4})
        {{
            string whereStr = string.Empty;
            List<SqlParameter> listParams = new List<SqlParameter>();
            {2}
            string selectCountSql = string.Format(""select count(0) from {6} where 1=1 {{0}}"", whereStr);
            using (SqlConnection sqlcn = ConnectionFactory.{3})
            {{
                return Convert.ToInt32(SqlHelper.ExecuteScalar(sqlcn, CommandType.Text, selectCountSql, listParams.ToArray()));
            }}
        }}
";

            string queryCountParams = queryListParams.Length > 0 ? queryListParams.ToString().Substring(0, queryListParams.Length - 1) : queryListParams.ToString();

            return(string.Format(template, model.TableName.ToFirstUpper(), queryListParams.ToString(), queryWhereContent.ToString(), model.DbName.ToFirstUpper(), queryCountParams, assignContent.ToString(), model.TableName, selectSqlContent.ToString()));
        }