diff --git a/WebAutoCodeOnline.v12.suo b/WebAutoCodeOnline.v12.suo index 14d8d1e..9e299b8 100644 Binary files a/WebAutoCodeOnline.v12.suo and b/WebAutoCodeOnline.v12.suo differ diff --git a/WinGenerateCodeDB/Cache/PageCache.cs b/WinGenerateCodeDB/Cache/PageCache.cs index 09ee2f1..7ada608 100644 --- a/WinGenerateCodeDB/Cache/PageCache.cs +++ b/WinGenerateCodeDB/Cache/PageCache.cs @@ -9,19 +9,6 @@ namespace WinGenerateCodeDB.Cache { public class PageCache { - private static List sqlColumnList = new List(); - - private static List ExtendList = new List(); - - private static List CmdList = new List(); - - /// - /// 0-asp.net - /// 1-asp.net mvc - /// 2-html - /// - public static int WebType { get; set; } - /// /// 0-mysql /// 1-mssql @@ -50,22 +37,6 @@ public class PageCache public static string TableName = string.Empty; - public static string TableName_Model - { - get - { - return TableName + ModelSuffix; - } - } - - public static string TableName_UI - { - get - { - return TableName + UISuffix; - } - } - public static string TableName_DAL { get @@ -74,12 +45,8 @@ public static string TableName_DAL } } - public static string KeyId { get; set; } - public static string KeyId_DbType { get; set; } - public static string TiTle { get; set; } - public static string NameSpaceStr { get; set; } public static string ModelSuffix { get; set; } @@ -88,8 +55,6 @@ public static string TableName_DAL public static string UISuffix { get; set; } - public static int FrameworkVersion { get; set; } - public static int ModelStyle { get; set; } public static string server = string.Empty; @@ -121,40 +86,6 @@ public static void SetTable(string tableName) TableName = tableName; } - public static void SetColumnList(List list, bool isImport) - { - sqlColumnList = list; - if (!isImport) - { - ExtendList = new List(); - var col = list.Find(p => p.IsMainKey); - if (col != null) - { - KeyId = col.Name; - KeyId_DbType = col.DbType; - } - } - } - - public static void AddAttribute(ExtendAttributeInfo extendInfo) - { - ExtendList.Add(extendInfo); - } - - public static void ChangeExtendInfo(string attrName, ExtendAttributeInfo extendInfo) - { - var item = ExtendList.Find(p => p.NewAttName == attrName); - if (item != null) - { - item = extendInfo; - } - } - - public static void RemoveAttribute(string attrName) - { - ExtendList.RemoveAll(p => p.NewAttName == attrName); - } - public static void SetDbTool(int dbTool) { DbTool = dbTool; @@ -170,11 +101,6 @@ public static void SetModelType(int model_type) ModelStyle = model_type; } - public static void SetWebType(int webType) - { - WebType = webType; - } - public static void SetParamValue(string namespaceStr, string modelSuffix, string dalSuffix, string uiSuffix) { NameSpaceStr = namespaceStr; @@ -183,305 +109,49 @@ public static void SetParamValue(string namespaceStr, string modelSuffix, string UISuffix = uiSuffix; } - public static void AddCmd(CmdInfo info) - { - CmdList.Add(info); - } - - public static void RemoveCmd(string guid) + private static void SaveConfig() { - CmdList.RemoveAll(p => p.Guid == guid); - } - - public static List GetCmdList() - { - return CmdList; + // 保存配置信息,下次打开还可以继续 } + } - public static CmdInfo GetCmd(string name) + public class config_info + { + public config_info() { - return CmdList.Find(p => p.CmdName == name); + asp_net_core_add_query_model = true; } - public static List GetColumnList() - { - return sqlColumnList; - } + public int db_type { get; set; } - public static List GetExtendList() - { - return ExtendList; - } + public string server { get; set; } - public static string ToXml() - { - StringBuilder content = new StringBuilder("\r\n"); - content.AppendLine(""); - - content.AppendLine(" "); - content.AppendLine(" " + PageCache.server + ""); - content.AppendLine(" " + PageCache.name + ""); - content.AppendLine(" " + PageCache.pwd + ""); - content.AppendLine(" " + PageCache.DatabaseName + ""); - content.AppendLine(" " + PageCache.port + ""); - content.AppendLine(" " + PageCache.TableName + "
"); - content.AppendLine("
"); - - content.AppendLine(" "); - foreach (var item in sqlColumnList) - { - content.AppendLine(" "); - content.AppendLine(" " + item.Name + ""); - content.AppendLine(" " + item.Name + ""); - content.AppendLine(" " + item.DbType + ""); - content.AppendLine(" " + item.DbType + ""); - content.AppendLine(" " + item.Comment + ""); - content.AppendLine(" "); - } - content.AppendLine(" "); + public string name { get; set; } - content.AppendLine(" "); - content.AppendLine(" " + KeyId + ""); - content.AppendLine(" " + KeyId_DbType + ""); - content.AppendLine(" "); + public string pwd { get; set; } - content.AppendLine(" "); - foreach (var item in ExtendList) - { - content.AppendLine(" "); - content.AppendLine(" " + item.NewAttName + ""); - content.AppendLine(" " + item.DependColumn + ""); - content.AppendLine(" " + item.DependColumnType + ""); - content.AppendLine(" varchar"); - content.AppendLine(" " + item.Comment + ""); - content.AppendLine(" " + item.FormatType + ""); - content.AppendLine(" "); - content.AppendLine(" "); - } - content.AppendLine(" "); + public string port { get; set; } - content.AppendLine(" "); - foreach (var item in CmdList) - { - content.AppendLine(" "); - content.AppendLine(" " + item.CmdName + ""); - content.AppendLine(" " + item.Guid + ""); - content.AppendLine(" "); - - foreach (var attr in item.AttrList) - { - content.AppendLine(" "); - content.AppendLine(" " + attr.AttrName + ""); - content.AppendLine(" " + attr.TitleName + ""); - content.AppendLine(" "); - content.AppendLine(" " + attr.Style.FieldName + ""); - content.AppendLine(" " + attr.Style.FormatType + ""); - content.AppendLine(" " + attr.Style.FormatStr + ""); - content.AppendLine(" "); - content.AppendLine(" "); - } - - content.AppendLine(" "); - content.AppendLine(" "); - } - content.AppendLine(" "); - - content.AppendLine(" "); - content.AppendLine(" " + DbType + ""); - content.AppendLine(" " + UIType + ""); - content.AppendLine(" " + WebType + ""); - content.AppendLine(" " + FrameworkVersion + ""); - content.AppendLine(" " + ModelStyle + ""); - content.AppendLine(" " + NameSpaceStr + ""); - content.AppendLine(" " + ModelSuffix + ""); - content.AppendLine(" " + DALSuffix + ""); - content.AppendLine(" " + UISuffix + ""); - content.AppendLine(" "); - - content.Append("
"); - return content.ToString(); - } + public string asp_net_ns { get; set; } - public static void ReadXml(string xml) - { - using (TextReader reader = new StringReader(xml)) - { - var doc = XDocument.Load(reader); - var dbinfo = doc.Element("root").Element("dbinfo"); - var server = dbinfo.Element("server").Value; - var uid = dbinfo.Element("uid").Value; - var pwd = dbinfo.Element("pwd").Value; - var database = dbinfo.Element("database").Value; - var port = dbinfo.Element("port").Value; - var table = dbinfo.Element("table").Value; - - PageCache.server = server; - PageCache.name = uid; - PageCache.pwd = pwd; - PageCache.DatabaseName = database; - int portNum = 0; - int.TryParse(port, out portNum); - PageCache.port = portNum; - PageCache.TableName = table; - - var keyinfo = doc.Element("root").Element("keyinfo"); - var keyid = keyinfo.Element("keyid").Value; - string keytype = keyinfo.Element("keytype").Value; - - PageCache.KeyId = keyid; - PageCache.KeyId_DbType = keytype; - - PageCache.sqlColumnList = new List(); - var cols = doc.Element("root").Element("cols"); - if (cols.HasElements) - { - var colList = cols.Elements("col"); - foreach (XElement colEle in colList) - { - var name = colEle.Element("name").Value; - var colname = colEle.Element("colname").Value; - var dbtype = colEle.Element("dbtype").Value; - var attrtype = colEle.Element("attrtype").Value; - var title = colEle.Element("title").Value; - - PageCache.sqlColumnList.Add(new SqlColumnInfo() - { - Name = colname, - DbType = dbtype, - Comment = title, - IsMainKey = colname == keyid, - }); - } - } - - PageCache.ExtendList = new List(); - var extends = doc.Element("root").Element("extends"); - var extendList = extends.Elements("extend"); - foreach (var extendEle in extendList) - { - var name = extendEle.Element("name").Value; - var colname = extendEle.Element("colname").Value; - var dbtype = extendEle.Element("dbtype").Value; - var attrtype = extendEle.Element("attrtype").Value; - var title = extendEle.Element("title").Value; - var formattype = extendEle.Element("formattype").Value; - int formatNum = 0; - var formatstr = extendEle.Element("formatstr").Value; - int.TryParse(formattype, out formatNum); - - PageCache.ExtendList.Add(new ExtendAttributeInfo() - { - NewAttName = name, - DependColumn = colname, - Comment = title, - DependColumnType = dbtype, - AttributeType = attrtype, - FormatStr = formatstr, - FormatType = formatNum - }); - } - - PageCache.CmdList = new List(); - var toolinfo = doc.Element("root").Element("toolinfo"); - var tools = toolinfo.Elements("tool"); - foreach (var toolEle in tools) - { - CmdInfo cmdInfo = new CmdInfo(); - var name = toolEle.Element("name").Value; - var guid = toolEle.Element("guid").Value; - cmdInfo.CmdName = name; - cmdInfo.Guid = guid; - cmdInfo.AttrList = new List(); - - var attrs = toolEle.Element("attrs"); - var attrList = attrs.Elements("attr"); - foreach (var attrEle in attrList) - { - var attrname = attrEle.Element("name").Value; - var title = attrEle.Element("title").Value; - var styleinfo = attrEle.Element("styleinfo"); - string style_name = styleinfo.Element("name").Value; - int style_type_Num = 0; - string style_type = styleinfo.Element("type").Value; - int.TryParse(style_type, out style_type_Num); - string style_str = styleinfo.Element("str").Value; - - var colInfo = PageCache.GetColumnList().Find(p => p.Name == attrname); - if (colInfo != null) - { - cmdInfo.AttrList.Add(new ClassAttributeInfo() - { - AttrName = attrname, - ColName = colInfo.Name, - DbType = colInfo.DbType, - AttrType = colInfo.DbType, - TitleName = colInfo.Comment, - Style = new FieldStyleInfo() - { - FieldName = style_name, - FormatType = style_type_Num, - FormatStr = style_str - } - }); - } - else - { - var extendInfo = PageCache.ExtendList.Find(p => p.NewAttName == attrname); - cmdInfo.AttrList.Add(new ClassAttributeInfo() - { - AttrName = attrname, - ColName = extendInfo.DependColumn, - DbType = extendInfo.DependColumnType, - AttrType = extendInfo.AttributeType, - TitleName = extendInfo.Comment, - Style = new FieldStyleInfo() - { - FieldName = style_name, - FormatType = style_type_Num, - FormatStr = style_str - } - }); - } - } - - PageCache.CmdList.Add(cmdInfo); - } - - var othersetting = doc.Element("root").Element("othersetting"); - PageCache.DbType = int.Parse(othersetting.Element("dbtype").Value); - PageCache.UIType = int.Parse(othersetting.Element("uitype").Value); - PageCache.WebType = int.Parse(othersetting.Element("webtype").Value); - PageCache.FrameworkVersion = int.Parse(othersetting.Element("version").Value); - PageCache.ModelStyle = int.Parse(othersetting.Element("modeltype").Value); - PageCache.NameSpaceStr = othersetting.Element("namespace").Value; - PageCache.ModelSuffix = othersetting.Element("modelsuffix").Value; - PageCache.DALSuffix = othersetting.Element("dalsuffix").Value; - PageCache.UISuffix = othersetting.Element("uisuffix").Value; - } - } - } + public string asp_net_ui_staff { get; set; } - public class CmdInfo - { - public string Guid { get; set; } + public string asp_net_model_staff { get; set; } - public string CmdName { get; set; } + public string asp_net_dal_staff { get; set; } - public List AttrList { get; set; } - } + public string asp_net_db_tool { get; set; } - public class ClassAttributeInfo - { - public string AttrName { get; set; } + public string asp_net_ui_type { get; set; } - public string ColName { get; set; } + public string asp_net_model_style { get; set; } - public string TitleName { get; set; } + public bool asp_net_core_add_query_model { get; set; } - public string AttrType { get; set; } + public string asp_net_core_ns { get; set; } - public string DbType { get; set; } + public string asp_net_core_model_staff { get; set; } - public FieldStyleInfo Style { get; set; } + public string asp_net_core_dal_staff { get; set; } } } \ No newline at end of file diff --git a/WinGenerateCodeDB/Code/AspNetCore/AspNetCoreApiController.cs b/WinGenerateCodeDB/Code/AspNetCore/AspNetCoreApiController.cs index 0432abe..cb17820 100644 --- a/WinGenerateCodeDB/Code/AspNetCore/AspNetCoreApiController.cs +++ b/WinGenerateCodeDB/Code/AspNetCore/AspNetCoreApiController.cs @@ -285,7 +285,7 @@ public string CreateQueryListMethod() display_{1} result = new display_{1}(); result.item_count = count; - result.page_count = (int)Math.Ceiling((double)count / model.pageSize); + result.page_count =if ((action & (int)Math.Ceiling((double)count / model.pageSize); result.list.AddRange(list); return result_info.Success(result); diff --git a/WinGenerateCodeDB/Code/AspNetCore/ModelHelper_DefaultCore.cs b/WinGenerateCodeDB/Code/AspNetCore/ModelHelper_DefaultCore.cs index 6b30d10..9eb3022 100644 --- a/WinGenerateCodeDB/Code/AspNetCore/ModelHelper_DefaultCore.cs +++ b/WinGenerateCodeDB/Code/AspNetCore/ModelHelper_DefaultCore.cs @@ -18,7 +18,7 @@ public ModelHelper_DefaultCore(string name_space, string model_suffix) this.model_suffix = model_suffix; } - public string CreateModel(string table_name, List colList, bool add_display_model = false, bool isCodeSplit = true) + public string CreateModel(string table_name, List colList, bool add_display_model = false) { this.model_name = table_name + model_suffix; @@ -37,11 +37,13 @@ public string CreateModel(string table_name, List colList, bool a content.AppendFormat("\tpublic class {0}\r\n", model_name); content.AppendLine("\t{"); + bool isCodeSplit = false; for (int i = 0; i < colList.Count; i++) { var item = colList[i]; if (!string.IsNullOrEmpty(item.Comment)) { + isCodeSplit = true; content.Append(CommentTool.CreateComment(item.Comment, 2)); } diff --git a/WinGenerateCodeDB/Code/Aspx/AspxHelper_Bootstrap.cs b/WinGenerateCodeDB/Code/Aspx/AspxHelper_Bootstrap.cs index d2b981b..53c35ee 100644 --- a/WinGenerateCodeDB/Code/Aspx/AspxHelper_Bootstrap.cs +++ b/WinGenerateCodeDB/Code/Aspx/AspxHelper_Bootstrap.cs @@ -70,7 +70,7 @@ private static string CreateSearchContent(int action, List colLis { StringBuilder searchContent = new StringBuilder(); int index = 0; - if ((action | (int)action_type.query_list) == (int)action_type.query_list) + if ((action & (int)action_type.query_list) == (int)action_type.query_list) { foreach (var item in colList.ToNotMainIdList()) { @@ -175,49 +175,49 @@ private static string CreateCmdToolBar(int action) { int itemCount = 0; StringBuilder toolBarContent = new StringBuilder(); - if ((action | (int)action_type.add) == (int)action_type.add) + if ((action & (int)action_type.add) == (int)action_type.add) { toolBarContent.Append(@" "); itemCount++; } - if ((action | (int)action_type.edit) == (int)action_type.edit) + if ((action & (int)action_type.edit) == (int)action_type.edit) { toolBarContent.Append(@" "); itemCount++; } - if ((action | (int)action_type.bat_edit) == (int)action_type.bat_edit) + if ((action & (int)action_type.bat_edit) == (int)action_type.bat_edit) { toolBarContent.Append(@" "); itemCount++; } - if ((action | (int)action_type.real_delete) == (int)action_type.real_delete) + if ((action & (int)action_type.real_delete) == (int)action_type.real_delete) { toolBarContent.Append(@" "); itemCount++; } - if ((action | (int)action_type.bat_real_delete) == (int)action_type.bat_real_delete) + if ((action & (int)action_type.bat_real_delete) == (int)action_type.bat_real_delete) { toolBarContent.Append(@" "); itemCount++; } - if ((action | (int)action_type.export_select) == (int)action_type.export_select) + if ((action & (int)action_type.export_select) == (int)action_type.export_select) { toolBarContent.Append(@" "); itemCount++; } - if ((action | (int)action_type.export_all) == (int)action_type.export_all) + if ((action & (int)action_type.export_all) == (int)action_type.export_all) { toolBarContent.Append(@" "); @@ -282,7 +282,7 @@ private static string CreateDialog(int action, List colList) StringBuilder dialogContent = new StringBuilder(); int addWidth = 400; #region 添加 - if ((action | (int)action_type.add) == (int)action_type.add) + if ((action & (int)action_type.add) == (int)action_type.add) { // 行数过多,分成两行 string template = @" @@ -442,7 +442,7 @@ private static string CreateDialog(int action, List colList) int editWidth = 400; #region 编辑 - if ((action | (int)action_type.edit) == (int)action_type.edit) + if ((action & (int)action_type.edit) == (int)action_type.edit) { // 行数过多,分成两行 string template = @" @@ -608,7 +608,7 @@ private static string CreateDialog(int action, List colList) int batEditWidth = 400; #region 批量编辑 - if ((action | (int)action_type.bat_edit) == (int)action_type.bat_edit) + if ((action & (int)action_type.bat_edit) == (int)action_type.bat_edit) { // 行数过多,分成两行 string template = @" @@ -802,7 +802,7 @@ private static string CreateJsOperation(int action, List colList, -", PageCache.TiTle); +", table_name); } - private static string CreateBodyHead() + private static string CreateBodyHead(string table_name) { return string.Format(@"

{0}

-", PageCache.TiTle); +", table_name); } - private static string CreateSearchContent() + private static string CreateSearchContent(int action, List colList) { StringBuilder searchContent = new StringBuilder(); int index = 0; - var showModel = PageCache.GetCmd("主显示"); - if (showModel != null) + if ((action & (int)action_type.query_list) == (int)action_type.query_list) { - foreach (var item in showModel.AttrList) + foreach (var item in colList.ToNotMainIdList()) { if (index % 3 == 0) { @@ -93,7 +92,6 @@ private static string CreateSearchContent() if (item.DbType.ToLower() == "datetime") { - string attribute = item.AttrName; searchContent.AppendFormat(@"
{1}: @@ -105,11 +103,10 @@ private static string CreateSearchContent() autoclose: true //选择日期后自动关闭 }}); -
", attribute, item.TitleName); +
", item.Name, item.Comment); } else if (item.DbType.ToLower() == "date") { - string attribute = item.AttrName; searchContent.AppendFormat(@"
{1}: @@ -123,15 +120,14 @@ private static string CreateSearchContent() loadMsg(1, pageSize); }}); -
", attribute, item.TitleName); + ", item.Name, item.Comment); } else { - string attribute = item.AttrName; searchContent.AppendFormat(@"
-
", attribute, item.TitleName); + ", item.Name, item.Comment); } index++; @@ -176,53 +172,53 @@ private static string CreateSearchContent() } } - private static string CreateCmdToolBar() + private static string CreateCmdToolBar(int action) { int itemCount = 0; StringBuilder toolBarContent = new StringBuilder(); - if (PageCache.GetCmd("添加") != null) + if ((action & (int)action_type.add) == (int)action_type.add) { toolBarContent.Append(@" "); itemCount++; } - if (PageCache.GetCmd("编辑") != null) + if ((action & (int)action_type.edit) == (int)action_type.edit) { toolBarContent.Append(@" "); itemCount++; } - if (PageCache.GetCmd("批量编辑") != null) + if ((action & (int)action_type.bat_edit) == (int)action_type.bat_edit) { toolBarContent.Append(@" "); itemCount++; } - if (PageCache.GetCmd("删除") != null) + if ((action & (int)action_type.real_delete) == (int)action_type.real_delete) { toolBarContent.Append(@" "); itemCount++; } - if (PageCache.GetCmd("删除选中") != null) + if ((action & (int)action_type.bat_real_delete) == (int)action_type.bat_real_delete) { toolBarContent.Append(@" "); itemCount++; } - if (PageCache.GetCmd("导出选中") != null) + if ((action & (int)action_type.export_select) == (int)action_type.export_select) { toolBarContent.Append(@" "); itemCount++; } - if (PageCache.GetCmd("导出全部") != null) + if ((action & (int)action_type.export_all) == (int)action_type.export_all) { toolBarContent.Append(@" "); @@ -250,7 +246,7 @@ private static string CreateCmdToolBar() } } - private static string CreateDataGrid() + private static string CreateDataGrid(int action, List colList) { // singleselect=""true"" string template = @" @@ -268,15 +264,12 @@ private static string CreateDataGrid() StringBuilder tbodyContent = new StringBuilder(); tbodyContent.Append(@" "); - var showModel = PageCache.GetCmd("主显示"); - if (showModel != null) + if ((action & (int)action_type.query_list) == (int)action_type.query_list) { - foreach (var item in showModel.AttrList) + foreach (var item in colList.ToNotMainIdList()) { - string attribute = item.AttrName; - tbodyContent.AppendFormat(@" - {0}", item.TitleName); + {0}", item.Comment); } return string.Format(template, tbodyContent.ToString()); @@ -292,13 +285,12 @@ private static string CreateDataGrid() ///
/// /// - private static string CreateDialog() + private static string CreateDialog(int action, List colList) { StringBuilder dialogContent = new StringBuilder(); int addWidth = 400; #region 添加 - var addModel = PageCache.GetCmd("添加"); - if (addModel != null) + if ((action & (int)action_type.add) == (int)action_type.add) { // 行数过多,分成两行 string template = @" @@ -336,14 +328,14 @@ private static string CreateDialog() // <=8 单列, <=18&&>8 双列,>18 三列 int index = 0; StringBuilder content = new StringBuilder(); - if (addModel.AttrList.Count > 18) + if (colList.ToNotMainIdList().Count > 18) { #region 三列 content.Append(@"
"); content.AppendFormat(@" - ", PageCache.KeyId); - foreach (var item in addModel.AttrList) + ", colList.ToKeyId()); + foreach (var item in colList.ToNotMainIdList()) { if (index % 3 == 0 && index != 0) { @@ -352,15 +344,13 @@ private static string CreateDialog()
"); } - string attribute = item.AttrName; - // 初始化form显示数据 //   占一个中文字符 content.AppendFormat(@"
-
", attribute, item.TitleName.PadLeftStr(4, " ")); +
", item.Name, item.Comment.PadLeftStr(4, " ")); index++; } @@ -386,14 +376,14 @@ private static string CreateDialog() addWidth *= 3; } - else if (addModel.AttrList.Count <= 18 & addModel.AttrList.Count > 8) + else if (colList.ToNotMainIdList().Count <= 18 & colList.ToNotMainIdList().Count > 8) { #region 二列 content.Append(@"
"); content.AppendFormat(@" - ", PageCache.KeyId); - foreach (var item in addModel.AttrList) + ", colList.ToKeyId()); + foreach (var item in colList.ToNotMainIdList()) { if (index % 2 == 0 && index != 0) { @@ -402,15 +392,13 @@ private static string CreateDialog()
"); } - string attribute = item.AttrName; - // 初始化form显示数据 //   占一个中文字符 content.AppendFormat(@"
-
", attribute, item.TitleName.PadLeftStr(4, " ")); +
", item.Name, item.Comment.PadLeftStr(4, " ")); index++; } @@ -434,12 +422,11 @@ private static string CreateDialog() { #region 一列 content.AppendFormat(@" - ", PageCache.KeyId); - foreach (var item in addModel.AttrList) + ", colList.ToKeyId()); + foreach (var item in colList.ToNotMainIdList()) { content.Append(@"
"); - string attribute = item.AttrName; // 初始化form显示数据 //   占一个中文字符 @@ -447,7 +434,7 @@ private static string CreateDialog()
-
", attribute, item.TitleName.PadLeftStr(4, " ")); +
", item.Name, item.Comment.PadLeftStr(4, " ")); content.Append(@"
"); @@ -463,8 +450,7 @@ private static string CreateDialog() int editWidth = 400; #region 编辑 - var editModel = PageCache.GetCmd("编辑"); - if (editModel != null) + if ((action & (int)action_type.edit) == (int)action_type.edit) { // 行数过多,分成两行 string template = @" @@ -501,15 +487,15 @@ private static string CreateDialog() int index = 0; StringBuilder content = new StringBuilder(); - if (editModel.AttrList.Count > 18) + if (colList.ToNotMainIdList().Count > 18) { #region 三列 content.Append(@"
"); content.AppendFormat(@" - ", PageCache.KeyId); - foreach (var item in editModel.AttrList) + ", colList.ToKeyId()); + foreach (var item in colList.ToNotMainIdList()) { if (index % 3 == 0 && index != 0) { @@ -518,15 +504,13 @@ private static string CreateDialog()
"); } - string attribute = item.AttrName; - // 初始化form显示数据 //   占一个中文字符 content.AppendFormat(@"
-
", attribute, item.TitleName.PadLeftStr(4, " ")); +
", item.Name, item.Comment.PadLeftStr(4, " ")); index++; } @@ -552,15 +536,15 @@ private static string CreateDialog() editWidth *= 3; } - else if (editModel.AttrList.Count <= 18 & editModel.AttrList.Count > 8) + else if (colList.ToNotMainIdList().Count <= 18 & colList.ToNotMainIdList().Count > 8) { #region 二列 content.Append(@"
"); content.AppendFormat(@" - ", PageCache.KeyId); - foreach (var item in editModel.AttrList) + ", colList.ToKeyId()); + foreach (var item in colList.ToNotMainIdList()) { if (index % 2 == 0 && index != 0) { @@ -569,15 +553,13 @@ private static string CreateDialog()
"); } - string attribute = item.AttrName; - // 初始化form显示数据 //   占一个中文字符 content.AppendFormat(@"
-
", attribute, item.TitleName.PadLeftStr(4, " ")); +
", item.Name, item.Comment.PadLeftStr(4, " ")); index++; } @@ -605,21 +587,19 @@ private static string CreateDialog() content.AppendFormat(@" -
", PageCache.KeyId); - foreach (var item in editModel.AttrList) +
", colList.ToKeyId()); + foreach (var item in colList.ToNotMainIdList()) { content.Append(@"
"); - string attribute = item.AttrName; - // 初始化form显示数据 //   占一个中文字符 content.AppendFormat(@"
-
", attribute, item.TitleName.PadLeftStr(4, " ")); +
", item.Name, item.Comment.PadLeftStr(4, " ")); index++; content.Append(@" @@ -636,8 +616,7 @@ private static string CreateDialog() int batEditWidth = 400; #region 批量编辑 - var batEditModel = PageCache.GetCmd("批量编辑"); - if (batEditModel != null) + if ((action & (int)action_type.bat_edit) == (int)action_type.bat_edit) { // 行数过多,分成两行 string template = @" @@ -673,14 +652,14 @@ private static string CreateDialog()
"; int index = 1; StringBuilder content = new StringBuilder(); - if (batEditModel.AttrList.Count > 18) + if (colList.ToNotMainIdList().Count > 18) { #region 三列 content.Append(@"
"); content.AppendFormat(@" - ", PageCache.KeyId); - foreach (var item in batEditModel.AttrList) + ", colList.ToKeyId()); + foreach (var item in colList.ToNotMainIdList()) { if (index % 3 == 0 && index != 0) { @@ -689,14 +668,12 @@ private static string CreateDialog()
"); } - string attribute = item.AttrName; - //   占一个中文字符 content.AppendFormat(@"
-
", attribute, item.TitleName.PadLeftStr(4, " ")); +
", item.Name, item.Comment.PadLeftStr(4, " ")); index++; } @@ -722,14 +699,14 @@ private static string CreateDialog() batEditWidth *= 3; } - else if (batEditModel.AttrList.Count <= 18 & batEditModel.AttrList.Count > 8) + else if (colList.ToNotMainIdList().Count <= 18 & colList.ToNotMainIdList().Count > 8) { #region 二列 content.Append(@"
"); content.AppendFormat(@" - ", PageCache.KeyId); - foreach (var item in batEditModel.AttrList) + ", colList.ToKeyId()); + foreach (var item in colList.ToNotMainIdList()) { if (index % 2 == 0 && index != 0) { @@ -738,14 +715,12 @@ private static string CreateDialog()
"); } - string attribute = item.AttrName; - //   占一个中文字符 content.AppendFormat(@"
-
", attribute, item.TitleName.PadLeftStr(4, " ")); +
", item.Name, item.Comment.PadLeftStr(4, " ")); index++; } @@ -771,20 +746,18 @@ private static string CreateDialog() content.Append(@"
"); content.AppendFormat(@" -
", PageCache.KeyId); - foreach (var item in batEditModel.AttrList) +
", colList.ToKeyId()); + foreach (var item in colList.ToNotMainIdList()) { content.Append(@"
"); - string attribute = item.AttrName; - //   占一个中文字符 content.AppendFormat(@"
-
", attribute, item.TitleName.PadLeftStr(4, " ")); //       +
", item.Name, item.Comment.PadLeftStr(4, " ")); //       content.Append(@"
"); @@ -799,7 +772,6 @@ private static string CreateDialog() #endregion return dialogContent.ToString(); - //} } private static string CreateNotifyMsg() @@ -830,53 +802,51 @@ function checkAll() {{ "; } - private static string CreateJsOperation() + private static string CreateJsOperation(int action, List colList, string table_name) { StringBuilder content = new StringBuilder(@" -", PageCache.TableName, - PageCache.KeyId); +", table_name, + colList.ToKeyId()); content.Append(template); diff --git a/WinGenerateCodeDB/DAL/SqlHelper.cs b/WinGenerateCodeDB/DAL/SqlHelper.cs index 16d9706..b58a7e1 100644 --- a/WinGenerateCodeDB/DAL/SqlHelper.cs +++ b/WinGenerateCodeDB/DAL/SqlHelper.cs @@ -965,7 +965,7 @@ public static SqlDataReader ExecuteReader(SqlTransaction transaction, string spN /// /// /// 示例: - /// int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount"); + /// int orderCount =if ((action & (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount"); /// /// 一个有效的数据库连接字符串 /// 命令类型 (存储过程,命令文本或其它) @@ -982,7 +982,7 @@ public static object ExecuteScalar(string connectionString, CommandType commandT /// /// /// 示例: - /// int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24)); + /// int orderCount =if ((action & (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24)); /// /// 一个有效的数据库连接字符串 /// 命令类型 (存储过程,命令文本或其它) @@ -1009,7 +1009,7 @@ public static object ExecuteScalar(string connectionString, CommandType commandT /// 此方法不提供访问存储过程输出参数和返回值参数. /// /// 示例: - /// int orderCount = (int)ExecuteScalar(connString, "GetOrderCount", 24, 36); + /// int orderCount =if ((action & (int)ExecuteScalar(connString, "GetOrderCount", 24, 36); /// /// 一个有效的数据库连接字符串 /// 存储过程名称 @@ -1044,7 +1044,7 @@ public static object ExecuteScalar(string connectionString, string spName, param /// /// /// 示例: - /// int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount"); + /// int orderCount =if ((action & (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount"); /// /// 一个有效的数据库连接对象 /// 命令类型 (存储过程,命令文本或其它) @@ -1061,7 +1061,7 @@ public static object ExecuteScalar(SqlConnection connection, CommandType command /// /// /// 示例: - /// int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24)); + /// int orderCount =if ((action & (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24)); /// /// 一个有效的数据库连接对象 /// 命令类型 (存储过程,命令文本或其它) @@ -1097,7 +1097,7 @@ public static object ExecuteScalar(SqlConnection connection, CommandType command /// 此方法不提供访问存储过程输出参数和返回值参数. /// /// 示例: - /// int orderCount = (int)ExecuteScalar(conn, "GetOrderCount", 24, 36); + /// int orderCount =if ((action & (int)ExecuteScalar(conn, "GetOrderCount", 24, 36); /// /// 一个有效的数据库连接对象 /// 存储过程名称 @@ -1132,7 +1132,7 @@ public static object ExecuteScalar(SqlConnection connection, string spName, para /// /// /// 示例: - /// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount"); + /// int orderCount =if ((action & (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount"); /// /// 一个有效的连接事务 /// 命令类型 (存储过程,命令文本或其它) @@ -1149,7 +1149,7 @@ public static object ExecuteScalar(SqlTransaction transaction, CommandType comma /// /// /// 示例: - /// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24)); + /// int orderCount =if ((action & (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24)); /// /// 一个有效的连接事务 /// 命令类型 (存储过程,命令文本或其它) @@ -1181,7 +1181,7 @@ public static object ExecuteScalar(SqlTransaction transaction, CommandType comma /// 此方法不提供访问存储过程输出参数和返回值参数. /// /// 示例: - /// int orderCount = (int)ExecuteScalar(trans, "GetOrderCount", 24, 36); + /// int orderCount =if ((action & (int)ExecuteScalar(trans, "GetOrderCount", 24, 36); /// /// 一个有效的连接事务 /// 存储过程名称 diff --git a/WinGenerateCodeDB/Helper/AspNetCoreHelper.cs b/WinGenerateCodeDB/Helper/AspNetCoreHelper.cs index e8797b8..e642de2 100644 --- a/WinGenerateCodeDB/Helper/AspNetCoreHelper.cs +++ b/WinGenerateCodeDB/Helper/AspNetCoreHelper.cs @@ -31,13 +31,13 @@ public static void AddColumnList(string tbName, List list) } } - public static Dictionary CreateModel(string name_space, string model_suffix, bool isAddQueryModel, bool isCodeSplit) + public static Dictionary CreateModel(string name_space, string model_suffix, bool isAddQueryModel) { Dictionary result = new Dictionary(); ModelHelper_DefaultCore helper = new ModelHelper_DefaultCore(name_space, model_suffix); foreach (var item in tbDic) { - string text = helper.CreateModel(item.Key, item.Value, isAddQueryModel, isCodeSplit); + string text = helper.CreateModel(item.Key, item.Value, isAddQueryModel); result.Add(item.Key + model_suffix, text); } diff --git a/WinGenerateCodeDB/Helper/AspNetHelper.cs b/WinGenerateCodeDB/Helper/AspNetHelper.cs index a356a9a..4912640 100644 --- a/WinGenerateCodeDB/Helper/AspNetHelper.cs +++ b/WinGenerateCodeDB/Helper/AspNetHelper.cs @@ -32,7 +32,7 @@ public static void AddColumnList(string tbName, List list) } } - public static Dictionary CreateModel(string name_space, string model_suffix, bool isAddQueryModel, bool isCodeSplit) + public static Dictionary CreateModel(string name_space, string model_suffix) { Dictionary result = new Dictionary(); foreach (var item in tbDic) @@ -57,45 +57,121 @@ public static Dictionary CreateModel(string name_space, string m return result; } - public static Dictionary CreateDAL(string name_space, string dal_suffix, string model_suffix) + public static Dictionary CreateAspx(string name_space, string model_staff, int action) { Dictionary result = new Dictionary(); - DALHelper_DapperCore helper = new DALHelper_DapperCore(db_name, name_space, dal_suffix, model_suffix); foreach (var item in tbDic) { - string text = helper.CreateDAL(item.Key, item.Value); + string text = string.Empty; + if (PageCache.UIType == 0) + { + text = AspxHelper_EasyUI.CreateASPX(name_space, item.Key, action, item.Value); + } + else if (PageCache.UIType == 1) + { + text = AspxHelper_Bootstrap.CreateASPX(name_space, item.Key, action, item.Value); + } - result.Add(item.Key + dal_suffix, text); + result.Add(item.Key + ".aspx", text); } return result; } - public static Dictionary CreateApiController(string name_space, string dal_suffix, string model_suffix) + public static Dictionary CreateAspxcs(string name_space, string model_staff, string dal_staff, int action) { Dictionary result = new Dictionary(); - AspNetCoreApiController helper = new AspNetCoreApiController(name_space, dal_suffix, model_suffix); foreach (var item in tbDic) { - string text = helper.CreateApiController(item.Key, item.Value); + string text = string.Empty; + if (PageCache.UIType == 0) + { + text = AspxCsHelper_EasyUI.CreateASPXCS(name_space, item.Key, action, item.Value, item.Key + model_staff, item.Key + dal_staff); + } + else if (PageCache.UIType == 1) + { + text = AspxCsHelper_Bootstrap.CreateASPXCS(name_space, item.Key, action, item.Value, item.Key + model_staff, item.Key + dal_staff); + } - result.Add(item.Key.ToFirstUpper() + "Controller", text); + result.Add(item.Key + ".aspx.cs", text); } return result; } - public static Dictionary CreateOther(string name_space) + public static Dictionary CreateDAL(string name_space, string model_staff, string dal_staff, int action) { Dictionary result = new Dictionary(); - AspNetCoreOther helper = new AspNetCoreOther(name_space); - result.Add("ConnectionFactory", helper.CreateFactory(db_name)); - result.Add("result_info", helper.CreateResultInfo()); + foreach (var item in tbDic) + { + string text = string.Empty; + if (PageCache.DbTool == 0 && PageCache.UIType == 0 && PageCache.DbType == 0) + { + // easyui mysql + text = DALHelper_EasyUI_MySql.CreateDAL(name_space, item.Key, item.Value, action, item.Key + dal_staff, item.Key + model_staff, db_name); + } + else if (PageCache.DbTool == 0 && PageCache.UIType == 0 && PageCache.DbType == 1) + { + // easyui mssql + text = DALHelper_EasyUI_MsSql.CreateDAL(name_space, item.Key, item.Value, action, item.Key + dal_staff, item.Key + model_staff, db_name); + } + else if (PageCache.DbTool == 0 && PageCache.UIType == 1 && PageCache.DbType == 0) + { + // bootstarp mysql + text = DALHelper_Bootstrap_MySql.CreateDAL(name_space, item.Key, item.Value, action, item.Key + dal_staff, item.Key + model_staff, db_name); + } + else if (PageCache.DbTool == 0 && PageCache.UIType == 1 && PageCache.DbType == 1) + { + // bootstarp mssql + text = DALHelper_Bootstrap_MsSql.CreateDAL(name_space, item.Key, item.Value, action, item.Key + dal_staff, item.Key + model_staff, db_name); + } + else if (PageCache.DbTool == 1) + { + text = DALHelper_Dapper.CreateDAL(name_space, item.Key, item.Value, action, item.Key + dal_staff, item.Key + model_staff, db_name); + } + + result.Add(item.Key + dal_staff + ".cs", text); + } return result; } - public static Dictionary CreateAspx(string name_space, string model_staff, int action) + public static Dictionary CreateFactory(string name_space) + { + string text = string.Empty; + if (PageCache.DbTool == 0 && PageCache.DbType == 0) + { + text = FactoryHelper_MySql.CreateFactory(name_space, db_name); + } + else if (PageCache.DbTool == 0 && PageCache.DbType == 1) + { + text = FactoryHelper_MsSql.CreateFactory(name_space, db_name); + } + else if (PageCache.DbTool == 1 && PageCache.DbType == 0) + { + text = FactoryHelper_Dapper_MySql.CreateFactory(name_space, db_name); + } + else if (PageCache.DbTool == 1 && PageCache.DbType == 1) + { + text = FactoryHelper_Dapper_MsSql.CreateFactory(name_space, db_name); + } + + Dictionary result = new Dictionary(); + result.Add("ConnectionFactory.cs", text); + + return result; + } + + public static Dictionary CreateConfig() + { + string text = ConfigHelper.GetConnectStringConfig(db_name, PageCache.ConnectionString); + Dictionary result = new Dictionary(); + result.Add("Web.config", text); + + return result; + } + + public static Dictionary CreateView(string name_space, string model_staff, string dal_staff, string ui_staff, int action) { Dictionary result = new Dictionary(); foreach (var item in tbDic) @@ -103,35 +179,27 @@ public static Dictionary CreateAspx(string name_space, string mo string text = string.Empty; if (PageCache.UIType == 0) { - text = AspxHelper_EasyUI.CreateASPX(name_space, item.Key, action, item.Value); + text = MvcViewHelper_EasyUI.CreateView(name_space, item.Key, action, item.Value, item.Key + model_staff, item.Key + dal_staff); } else if (PageCache.UIType == 1) { - text = AspxHelper_Bootstrap.CreateASPX(name_space, item.Key, action, item.Value); + text = MvcViewHelper_Bootstrap.CreateView(name_space, item.Key, action, item.Value, item.Key + model_staff, item.Key + dal_staff); } - result.Add(item.Key + ".aspx", text); + result.Add(item.Key + ui_staff + ".shtml", text); } return result; } - public static Dictionary CreateAspxcs(string name_space, string model_staff, string dal_staff, int action) + public static Dictionary CreateController(string name_space, string model_staff, string dal_staff, int action) { Dictionary result = new Dictionary(); foreach (var item in tbDic) { - string text = string.Empty; - if (PageCache.UIType == 0) - { - text = AspxCsHelper_EasyUI.CreateASPXCS(name_space, item.Key, action, item.Value, item.Key + model_staff, item.Key + dal_staff); - } - else if (PageCache.UIType == 1) - { - text = AspxCsHelper_Bootstrap.CreateASPXCS(name_space, item.Key, action, item.Value, item.Key + model_staff, item.Key + dal_staff); - } + string text = MvcControllerHelper.CreateController(name_space, item.Key, action, item.Value, item.Key + model_staff, item.Key + dal_staff); - result.Add(item.Key + ".aspx.cs", text); + result.Add(item.Key + dal_staff + ".cs", text); } return result; diff --git a/WinGenerateCodeDB/MainFrm_New.Designer.cs b/WinGenerateCodeDB/MainFrm_New.Designer.cs index 8a68084..46c10cc 100644 --- a/WinGenerateCodeDB/MainFrm_New.Designer.cs +++ b/WinGenerateCodeDB/MainFrm_New.Designer.cs @@ -66,21 +66,14 @@ private void InitializeComponent() this.label8 = new System.Windows.Forms.Label(); this.txtNameSpace = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); - this.groupBox12 = new System.Windows.Forms.GroupBox(); - this.rbtn_web_html = new System.Windows.Forms.RadioButton(); - this.rbtn_web_mvc = new System.Windows.Forms.RadioButton(); - this.rbtn_web_asp_net = new System.Windows.Forms.RadioButton(); this.groupBox11 = new System.Windows.Forms.GroupBox(); this.rbtn_attr_lowStart = new System.Windows.Forms.RadioButton(); this.rbtn_attr_attr = new System.Windows.Forms.RadioButton(); - this.rbtn_field = new System.Windows.Forms.RadioButton(); + this.rbtn_attr_field = new System.Windows.Forms.RadioButton(); this.groupBox9 = new System.Windows.Forms.GroupBox(); - this.rbtn_Layui = new System.Windows.Forms.RadioButton(); this.rbtnBootstrap = new System.Windows.Forms.RadioButton(); this.rbtnEasyUI = new System.Windows.Forms.RadioButton(); this.groupBox6 = new System.Windows.Forms.GroupBox(); - this.rbtn_EF = new System.Windows.Forms.RadioButton(); - this.rbtn_NHibernate = new System.Windows.Forms.RadioButton(); this.rbtn_ORM_Dapper = new System.Windows.Forms.RadioButton(); this.rbtn_Sql = new System.Windows.Forms.RadioButton(); this.btmExport = new System.Windows.Forms.Button(); @@ -93,7 +86,6 @@ private void InitializeComponent() this.btnTest = new System.Windows.Forms.Button(); this.btnGenerate = new System.Windows.Forms.Button(); this.tabPage6 = new System.Windows.Forms.TabPage(); - this.chkIsSplit = new System.Windows.Forms.CheckBox(); this.chkQueryModel = new System.Windows.Forms.CheckBox(); this.txtCoreDalSuffix = new System.Windows.Forms.TextBox(); this.label16 = new System.Windows.Forms.Label(); @@ -118,6 +110,7 @@ private void InitializeComponent() this.btnNextMulTable = new System.Windows.Forms.Button(); this.printDialog1 = new System.Windows.Forms.PrintDialog(); this.btnReturn = new System.Windows.Forms.Button(); + this.chkActionList = new System.Windows.Forms.CheckedListBox(); this.groupBox1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); @@ -129,7 +122,6 @@ private void InitializeComponent() this.tbAspNet.SuspendLayout(); this.tabPage7.SuspendLayout(); this.groupBox7.SuspendLayout(); - this.groupBox12.SuspendLayout(); this.groupBox11.SuspendLayout(); this.groupBox9.SuspendLayout(); this.groupBox6.SuspendLayout(); @@ -237,7 +229,7 @@ private void InitializeComponent() this.groupBox4.Size = new System.Drawing.Size(366, 266); this.groupBox4.TabIndex = 4; this.groupBox4.TabStop = false; - this.groupBox4.Text = "表"; + this.groupBox4.Text = "表 - 支持多选"; // // lstTables // @@ -385,11 +377,11 @@ private void InitializeComponent() // // tabPage4 // + this.tabPage4.Controls.Add(this.chkActionList); this.tabPage4.Controls.Add(this.btnCopyFullClass_aspnet); this.tabPage4.Controls.Add(this.btnCopyClass_aspnet); this.tabPage4.Controls.Add(this.tbAspNet); this.tabPage4.Controls.Add(this.groupBox7); - this.tabPage4.Controls.Add(this.groupBox12); this.tabPage4.Controls.Add(this.groupBox11); this.tabPage4.Controls.Add(this.groupBox9); this.tabPage4.Controls.Add(this.groupBox6); @@ -417,6 +409,7 @@ private void InitializeComponent() this.btnCopyFullClass_aspnet.TabIndex = 11; this.btnCopyFullClass_aspnet.Text = "CopyFullClass"; this.btnCopyFullClass_aspnet.UseVisualStyleBackColor = true; + this.btnCopyFullClass_aspnet.Click += new System.EventHandler(this.btnGenerate_Click); // // btnCopyClass_aspnet // @@ -426,6 +419,7 @@ private void InitializeComponent() this.btnCopyClass_aspnet.TabIndex = 12; this.btnCopyClass_aspnet.Text = "CopyClass"; this.btnCopyClass_aspnet.UseVisualStyleBackColor = true; + this.btnCopyClass_aspnet.Click += new System.EventHandler(this.btnGenerate_Click); // // tbAspNet // @@ -452,7 +446,7 @@ private void InitializeComponent() this.txtTemp.Location = new System.Drawing.Point(6, 6); this.txtTemp.Multiline = true; this.txtTemp.Name = "txtTemp"; - this.txtTemp.Size = new System.Drawing.Size(663, 493); + this.txtTemp.Size = new System.Drawing.Size(663, 479); this.txtTemp.TabIndex = 0; // // groupBox7 @@ -465,7 +459,7 @@ private void InitializeComponent() this.groupBox7.Controls.Add(this.label8); this.groupBox7.Controls.Add(this.txtNameSpace); this.groupBox7.Controls.Add(this.label7); - this.groupBox7.Location = new System.Drawing.Point(699, 182); + this.groupBox7.Location = new System.Drawing.Point(699, 234); this.groupBox7.Name = "groupBox7"; this.groupBox7.Size = new System.Drawing.Size(340, 105); this.groupBox7.TabIndex = 8; @@ -536,58 +530,11 @@ private void InitializeComponent() this.label7.TabIndex = 0; this.label7.Text = "命名空间:"; // - // groupBox12 - // - this.groupBox12.Controls.Add(this.rbtn_web_html); - this.groupBox12.Controls.Add(this.rbtn_web_mvc); - this.groupBox12.Controls.Add(this.rbtn_web_asp_net); - this.groupBox12.Location = new System.Drawing.Point(898, 464); - this.groupBox12.Name = "groupBox12"; - this.groupBox12.Size = new System.Drawing.Size(141, 129); - this.groupBox12.TabIndex = 6; - this.groupBox12.TabStop = false; - this.groupBox12.Text = "Web窗体选择"; - // - // rbtn_web_html - // - this.rbtn_web_html.AutoSize = true; - this.rbtn_web_html.Enabled = false; - this.rbtn_web_html.Location = new System.Drawing.Point(24, 94); - this.rbtn_web_html.Name = "rbtn_web_html"; - this.rbtn_web_html.Size = new System.Drawing.Size(47, 16); - this.rbtn_web_html.TabIndex = 0; - this.rbtn_web_html.TabStop = true; - this.rbtn_web_html.Text = "html"; - this.rbtn_web_html.UseVisualStyleBackColor = true; - // - // rbtn_web_mvc - // - this.rbtn_web_mvc.AutoSize = true; - this.rbtn_web_mvc.Location = new System.Drawing.Point(24, 62); - this.rbtn_web_mvc.Name = "rbtn_web_mvc"; - this.rbtn_web_mvc.Size = new System.Drawing.Size(89, 16); - this.rbtn_web_mvc.TabIndex = 0; - this.rbtn_web_mvc.TabStop = true; - this.rbtn_web_mvc.Text = "asp.net mvc"; - this.rbtn_web_mvc.UseVisualStyleBackColor = true; - // - // rbtn_web_asp_net - // - this.rbtn_web_asp_net.AutoSize = true; - this.rbtn_web_asp_net.Checked = true; - this.rbtn_web_asp_net.Location = new System.Drawing.Point(24, 31); - this.rbtn_web_asp_net.Name = "rbtn_web_asp_net"; - this.rbtn_web_asp_net.Size = new System.Drawing.Size(65, 16); - this.rbtn_web_asp_net.TabIndex = 0; - this.rbtn_web_asp_net.TabStop = true; - this.rbtn_web_asp_net.Text = "asp.net"; - this.rbtn_web_asp_net.UseVisualStyleBackColor = true; - // // groupBox11 // this.groupBox11.Controls.Add(this.rbtn_attr_lowStart); this.groupBox11.Controls.Add(this.rbtn_attr_attr); - this.groupBox11.Controls.Add(this.rbtn_field); + this.groupBox11.Controls.Add(this.rbtn_attr_field); this.groupBox11.Location = new System.Drawing.Point(699, 464); this.groupBox11.Name = "groupBox11"; this.groupBox11.Size = new System.Drawing.Size(183, 129); @@ -600,10 +547,10 @@ private void InitializeComponent() this.rbtn_attr_lowStart.AutoSize = true; this.rbtn_attr_lowStart.Location = new System.Drawing.Point(24, 66); this.rbtn_attr_lowStart.Name = "rbtn_attr_lowStart"; - this.rbtn_attr_lowStart.Size = new System.Drawing.Size(95, 16); + this.rbtn_attr_lowStart.Size = new System.Drawing.Size(119, 16); this.rbtn_attr_lowStart.TabIndex = 0; this.rbtn_attr_lowStart.TabStop = true; - this.rbtn_attr_lowStart.Text = "字段小写开头"; + this.rbtn_attr_lowStart.Text = "使用字段小写开头"; this.rbtn_attr_lowStart.UseVisualStyleBackColor = true; // // rbtn_attr_attr @@ -611,123 +558,86 @@ private void InitializeComponent() this.rbtn_attr_attr.AutoSize = true; this.rbtn_attr_attr.Location = new System.Drawing.Point(24, 97); this.rbtn_attr_attr.Name = "rbtn_attr_attr"; - this.rbtn_attr_attr.Size = new System.Drawing.Size(107, 16); + this.rbtn_attr_attr.Size = new System.Drawing.Size(119, 16); this.rbtn_attr_attr.TabIndex = 0; - this.rbtn_attr_attr.TabStop = true; - this.rbtn_attr_attr.Text = "使用属性初始化"; + this.rbtn_attr_attr.Text = "使用属性初始化值"; this.rbtn_attr_attr.UseVisualStyleBackColor = true; // - // rbtn_field + // rbtn_attr_field // - this.rbtn_field.AutoSize = true; - this.rbtn_field.Checked = true; - this.rbtn_field.Location = new System.Drawing.Point(24, 31); - this.rbtn_field.Name = "rbtn_field"; - this.rbtn_field.Size = new System.Drawing.Size(107, 16); - this.rbtn_field.TabIndex = 0; - this.rbtn_field.TabStop = true; - this.rbtn_field.Text = "使用字段默认值"; - this.rbtn_field.UseVisualStyleBackColor = true; + this.rbtn_attr_field.AutoSize = true; + this.rbtn_attr_field.Checked = true; + this.rbtn_attr_field.Location = new System.Drawing.Point(24, 31); + this.rbtn_attr_field.Name = "rbtn_attr_field"; + this.rbtn_attr_field.Size = new System.Drawing.Size(107, 16); + this.rbtn_attr_field.TabIndex = 0; + this.rbtn_attr_field.TabStop = true; + this.rbtn_attr_field.Text = "使用字段下划线"; + this.rbtn_attr_field.UseVisualStyleBackColor = true; // // groupBox9 // - this.groupBox9.Controls.Add(this.rbtn_Layui); this.groupBox9.Controls.Add(this.rbtnBootstrap); this.groupBox9.Controls.Add(this.rbtnEasyUI); - this.groupBox9.Location = new System.Drawing.Point(892, 302); + this.groupBox9.Location = new System.Drawing.Point(892, 354); this.groupBox9.Name = "groupBox9"; - this.groupBox9.Size = new System.Drawing.Size(154, 156); + this.groupBox9.Size = new System.Drawing.Size(154, 93); this.groupBox9.TabIndex = 4; this.groupBox9.TabStop = false; this.groupBox9.Text = "前端样式选择"; // - // rbtn_Layui - // - this.rbtn_Layui.AutoSize = true; - this.rbtn_Layui.Enabled = false; - this.rbtn_Layui.Location = new System.Drawing.Point(20, 118); - this.rbtn_Layui.Name = "rbtn_Layui"; - this.rbtn_Layui.Size = new System.Drawing.Size(53, 16); - this.rbtn_Layui.TabIndex = 1; - this.rbtn_Layui.Text = "Layui"; - this.rbtn_Layui.UseVisualStyleBackColor = true; - // // rbtnBootstrap // this.rbtnBootstrap.AutoSize = true; - this.rbtnBootstrap.Location = new System.Drawing.Point(20, 77); + this.rbtnBootstrap.Checked = true; + this.rbtnBootstrap.Location = new System.Drawing.Point(20, 65); this.rbtnBootstrap.Name = "rbtnBootstrap"; this.rbtnBootstrap.Size = new System.Drawing.Size(77, 16); this.rbtnBootstrap.TabIndex = 0; + this.rbtnBootstrap.TabStop = true; this.rbtnBootstrap.Text = "Bootstrap"; this.rbtnBootstrap.UseVisualStyleBackColor = true; // // rbtnEasyUI // this.rbtnEasyUI.AutoSize = true; - this.rbtnEasyUI.Checked = true; this.rbtnEasyUI.Location = new System.Drawing.Point(20, 34); this.rbtnEasyUI.Name = "rbtnEasyUI"; this.rbtnEasyUI.Size = new System.Drawing.Size(59, 16); this.rbtnEasyUI.TabIndex = 0; - this.rbtnEasyUI.TabStop = true; this.rbtnEasyUI.Text = "EasyUI"; this.rbtnEasyUI.UseVisualStyleBackColor = true; // // groupBox6 // - this.groupBox6.Controls.Add(this.rbtn_EF); - this.groupBox6.Controls.Add(this.rbtn_NHibernate); this.groupBox6.Controls.Add(this.rbtn_ORM_Dapper); this.groupBox6.Controls.Add(this.rbtn_Sql); - this.groupBox6.Location = new System.Drawing.Point(699, 302); + this.groupBox6.Location = new System.Drawing.Point(699, 354); this.groupBox6.Name = "groupBox6"; - this.groupBox6.Size = new System.Drawing.Size(155, 156); + this.groupBox6.Size = new System.Drawing.Size(155, 93); this.groupBox6.TabIndex = 5; this.groupBox6.TabStop = false; this.groupBox6.Text = "数据处理选择"; // - // rbtn_EF - // - this.rbtn_EF.AutoSize = true; - this.rbtn_EF.Enabled = false; - this.rbtn_EF.Location = new System.Drawing.Point(20, 131); - this.rbtn_EF.Name = "rbtn_EF"; - this.rbtn_EF.Size = new System.Drawing.Size(35, 16); - this.rbtn_EF.TabIndex = 0; - this.rbtn_EF.Text = "EF"; - this.rbtn_EF.UseVisualStyleBackColor = true; - // - // rbtn_NHibernate - // - this.rbtn_NHibernate.AutoSize = true; - this.rbtn_NHibernate.Enabled = false; - this.rbtn_NHibernate.Location = new System.Drawing.Point(20, 97); - this.rbtn_NHibernate.Name = "rbtn_NHibernate"; - this.rbtn_NHibernate.Size = new System.Drawing.Size(83, 16); - this.rbtn_NHibernate.TabIndex = 0; - this.rbtn_NHibernate.Text = "NHibernate"; - this.rbtn_NHibernate.UseVisualStyleBackColor = true; - // // rbtn_ORM_Dapper // this.rbtn_ORM_Dapper.AutoSize = true; + this.rbtn_ORM_Dapper.Checked = true; this.rbtn_ORM_Dapper.Location = new System.Drawing.Point(20, 65); this.rbtn_ORM_Dapper.Name = "rbtn_ORM_Dapper"; this.rbtn_ORM_Dapper.Size = new System.Drawing.Size(89, 16); this.rbtn_ORM_Dapper.TabIndex = 0; + this.rbtn_ORM_Dapper.TabStop = true; this.rbtn_ORM_Dapper.Text = "ORM(Dapper)"; this.rbtn_ORM_Dapper.UseVisualStyleBackColor = true; // // rbtn_Sql // this.rbtn_Sql.AutoSize = true; - this.rbtn_Sql.Checked = true; this.rbtn_Sql.Location = new System.Drawing.Point(20, 34); this.rbtn_Sql.Name = "rbtn_Sql"; this.rbtn_Sql.Size = new System.Drawing.Size(65, 16); this.rbtn_Sql.TabIndex = 0; - this.rbtn_Sql.TabStop = true; this.rbtn_Sql.Text = "Sql语句"; this.rbtn_Sql.UseVisualStyleBackColor = true; // @@ -737,9 +647,9 @@ private void InitializeComponent() this.btmExport.Name = "btmExport"; this.btmExport.Size = new System.Drawing.Size(62, 23); this.btmExport.TabIndex = 0; - this.btmExport.Text = "导出"; + this.btmExport.Text = "SaveFile"; this.btmExport.UseVisualStyleBackColor = true; - this.btmExport.Click += new System.EventHandler(this.btmExport_Click); + this.btmExport.Click += new System.EventHandler(this.btnGenerate_Click); // // btnTest5 // @@ -823,7 +733,6 @@ private void InitializeComponent() // // tabPage6 // - this.tabPage6.Controls.Add(this.chkIsSplit); this.tabPage6.Controls.Add(this.chkQueryModel); this.tabPage6.Controls.Add(this.txtCoreDalSuffix); this.tabPage6.Controls.Add(this.label16); @@ -847,24 +756,12 @@ private void InitializeComponent() this.tabPage6.Text = " asp.net core "; this.tabPage6.UseVisualStyleBackColor = true; // - // chkIsSplit - // - this.chkIsSplit.AutoSize = true; - this.chkIsSplit.Checked = true; - this.chkIsSplit.CheckState = System.Windows.Forms.CheckState.Checked; - this.chkIsSplit.Location = new System.Drawing.Point(16, 28); - this.chkIsSplit.Name = "chkIsSplit"; - this.chkIsSplit.Size = new System.Drawing.Size(72, 16); - this.chkIsSplit.TabIndex = 15; - this.chkIsSplit.Text = "代码间距"; - this.chkIsSplit.UseVisualStyleBackColor = true; - // // chkQueryModel // this.chkQueryModel.AutoSize = true; this.chkQueryModel.Checked = true; this.chkQueryModel.CheckState = System.Windows.Forms.CheckState.Checked; - this.chkQueryModel.Location = new System.Drawing.Point(16, 6); + this.chkQueryModel.Location = new System.Drawing.Point(16, 17); this.chkQueryModel.Name = "chkQueryModel"; this.chkQueryModel.Size = new System.Drawing.Size(102, 16); this.chkQueryModel.TabIndex = 15; @@ -980,7 +877,7 @@ private void InitializeComponent() // // btnOther // - this.btnOther.Location = new System.Drawing.Point(339, 50); + this.btnOther.Location = new System.Drawing.Point(378, 50); this.btnOther.Name = "btnOther"; this.btnOther.Size = new System.Drawing.Size(62, 23); this.btnOther.TabIndex = 1; @@ -1000,7 +897,7 @@ private void InitializeComponent() // // btnApiController // - this.btnApiController.Location = new System.Drawing.Point(216, 50); + this.btnApiController.Location = new System.Drawing.Point(239, 50); this.btnApiController.Name = "btnApiController"; this.btnApiController.Size = new System.Drawing.Size(94, 23); this.btnApiController.TabIndex = 2; @@ -1060,9 +957,9 @@ private void InitializeComponent() // this.btnNextMulTable.Location = new System.Drawing.Point(150, 651); this.btnNextMulTable.Name = "btnNextMulTable"; - this.btnNextMulTable.Size = new System.Drawing.Size(120, 23); + this.btnNextMulTable.Size = new System.Drawing.Size(146, 23); this.btnNextMulTable.TabIndex = 4; - this.btnNextMulTable.Text = "下一步(多表core)"; + this.btnNextMulTable.Text = "下一步(asp.net core)"; this.btnNextMulTable.UseVisualStyleBackColor = true; this.btnNextMulTable.Click += new System.EventHandler(this.btnNextMulTable_Click); // @@ -1072,7 +969,7 @@ private void InitializeComponent() // // btnReturn // - this.btnReturn.Location = new System.Drawing.Point(303, 651); + this.btnReturn.Location = new System.Drawing.Point(326, 651); this.btnReturn.Name = "btnReturn"; this.btnReturn.Size = new System.Drawing.Size(63, 23); this.btnReturn.TabIndex = 4; @@ -1080,6 +977,16 @@ private void InitializeComponent() this.btnReturn.UseVisualStyleBackColor = true; this.btnReturn.Click += new System.EventHandler(this.btnReturn_Click); // + // chkActionList + // + this.chkActionList.ColumnWidth = 150; + this.chkActionList.FormattingEnabled = true; + this.chkActionList.Location = new System.Drawing.Point(692, 16); + this.chkActionList.MultiColumn = true; + this.chkActionList.Name = "chkActionList"; + this.chkActionList.Size = new System.Drawing.Size(347, 212); + this.chkActionList.TabIndex = 13; + // // MainFrm_New // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -1108,8 +1015,6 @@ private void InitializeComponent() this.tabPage7.PerformLayout(); this.groupBox7.ResumeLayout(false); this.groupBox7.PerformLayout(); - this.groupBox12.ResumeLayout(false); - this.groupBox12.PerformLayout(); this.groupBox11.ResumeLayout(false); this.groupBox11.PerformLayout(); this.groupBox9.ResumeLayout(false); @@ -1183,24 +1088,16 @@ private void InitializeComponent() private System.Windows.Forms.Button btnSaveFile; private System.Windows.Forms.Button btnReturn; private System.Windows.Forms.CheckBox chkQueryModel; - private System.Windows.Forms.CheckBox chkIsSplit; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TabPage tabPage3; - private System.Windows.Forms.GroupBox groupBox12; - private System.Windows.Forms.RadioButton rbtn_web_html; - private System.Windows.Forms.RadioButton rbtn_web_mvc; - private System.Windows.Forms.RadioButton rbtn_web_asp_net; private System.Windows.Forms.GroupBox groupBox11; private System.Windows.Forms.RadioButton rbtn_attr_lowStart; private System.Windows.Forms.RadioButton rbtn_attr_attr; - private System.Windows.Forms.RadioButton rbtn_field; + private System.Windows.Forms.RadioButton rbtn_attr_field; private System.Windows.Forms.GroupBox groupBox9; - private System.Windows.Forms.RadioButton rbtn_Layui; private System.Windows.Forms.RadioButton rbtnBootstrap; private System.Windows.Forms.RadioButton rbtnEasyUI; private System.Windows.Forms.GroupBox groupBox6; - private System.Windows.Forms.RadioButton rbtn_EF; - private System.Windows.Forms.RadioButton rbtn_NHibernate; private System.Windows.Forms.RadioButton rbtn_ORM_Dapper; private System.Windows.Forms.RadioButton rbtn_Sql; private System.Windows.Forms.GroupBox groupBox7; @@ -1217,6 +1114,7 @@ private void InitializeComponent() private System.Windows.Forms.TextBox txtTemp; private System.Windows.Forms.Button btnCopyFullClass_aspnet; private System.Windows.Forms.Button btnCopyClass_aspnet; + private System.Windows.Forms.CheckedListBox chkActionList; } } diff --git a/WinGenerateCodeDB/MainFrm_New.cs b/WinGenerateCodeDB/MainFrm_New.cs index 73edd57..82a1f18 100644 --- a/WinGenerateCodeDB/MainFrm_New.cs +++ b/WinGenerateCodeDB/MainFrm_New.cs @@ -54,6 +54,27 @@ private void MainFrm_Load(object sender, EventArgs e) { this.tabControl1.TabPages.RemoveAt(1); } while (this.tabControl1.TabPages.Count > 1); + + // 初始化 chkActionList + var values = Enum.GetValues(typeof(action_type)); + foreach (var item in values) + { + if ((int)(action_type)item == 0) + { + continue; + } + + if ((action_type)item == action_type.add || + (action_type)item == action_type.edit || + (action_type)item == action_type.query_list) + { + chkActionList.Items.Add(item, true); + } + else + { + chkActionList.Items.Add(item, false); + } + } } private void InitListViewColumns() @@ -188,7 +209,6 @@ private void lstTables_SelectedIndexChanged(object sender, EventArgs e) SetColumnsList(list); PageCache.SetTable(this.tablename); - PageCache.SetColumnList(list, isImport); } } @@ -292,163 +312,155 @@ private void btnNoSave_Click(object sender, EventArgs e) private void btnGenerate_Click(object sender, EventArgs e) { PageCache.SetUIType(this.rbtnEasyUI.Checked ? 0 : 1); - PageCache.SetDbTool(this.rbtn_Sql.Checked ? 0 : this.rbtn_ORM_Dapper.Checked ? 1 : this.rbtn_NHibernate.Checked ? 2 : 3); - PageCache.SetWebType(this.rbtn_web_asp_net.Checked ? 0 : this.rbtn_web_mvc.Checked ? 1 : 2); - PageCache.SetModelType(this.rbtn_attr_attr.Checked ? 0 : this.rbtn_attr_lowStart.Checked ? 1 : 2); + PageCache.SetDbTool(this.rbtn_Sql.Checked ? 0 : 1); + PageCache.SetModelType(this.rbtn_attr_field.Checked ? 0 : this.rbtn_attr_lowStart.Checked ? 1 : 2); PageCache.SetParamValue(this.txtNameSpace.Text, this.txtModelSuffix.Text, this.txtDalSuffix.Text, this.txtUISuffix.Text); + int action = 0; + foreach (object ci in this.chkActionList.CheckedItems) + { + action = (action | (int)(action_type)ci); + } + Button btn = sender as Button; - string action = btn.Text; - switch (action) + string name = btn.Text; + switch (name) { case "Model": AspNet_CreateModel(); break; case "Aspx": - AspNet_CreateAspx(); + AspNet_CreateAspx(action); break; case "Aspx.cs": - AspNet_CreateAspxcs(); + AspNet_CreateAspxcs(action); + break; + case "DAL": + AspNet_CreateDAL(action); + break; + case "Factory": + AspNet_CreateFactory(); + break; + case "Config": + AspNet_CreateConfig(); + break; + case "View": + AspNet_CreateView(action); + break; + case "Controller": + AspNet_CreateController(action); + break; + case "CopyClass": + AspNet_CopyClass(); + break; + case "CopyFullClass": + AspNet_CopyFullClass(); + break; + case "SaveFile": + AspNet_SaveFile(); break; } + } - if (btn.Text == "Model") - { - } - else if (btn.Text == "Aspx") - { - } - else if (btn.Text == "Aspx.cs") - { - } - else if (btn.Text == "DAL") - { - #region DAL - int uitype = PageCache.UIType; - int dbtype = PageCache.DbType; - int dbtool = PageCache.DbTool; - if (dbtool == 0) - { - if (uitype == 0) - { - // easyui - if (dbtype == 0) - { - // mysql - string modelStr = DALHelper_EasyUI_MySql.CreateDAL(); - } - else if (dbtype == 1) - { - // mssql - string modelStr = DALHelper_EasyUI_MsSql.CreateDAL(); - } - } - else if (uitype == 1) - { - // bootstarp - if (dbtype == 0) - { - // mysql - string modelStr = DALHelper_Bootstrap_MySql.CreateDAL(); - } - else if (dbtype == 1) - { - // mssql - string modelStr = DALHelper_Bootstrap_MsSql.CreateDAL(); - } - } - } - else if (dbtool == 1) - { - string modelStr = DALHelper_Dapper.CreateDAL(); - } - #endregion - } - else if (btn.Text == "Factory") - { - #region Factory - int dbtype = PageCache.DbType; - int dbtool = PageCache.DbTool; - if (dbtool == 0) - { - if (dbtype == 0) - { - // mysql - string modelStr = FactoryHelper_MySql.CreateFactory(); - } - else if (dbtype == 1) - { - // mysql - string modelStr = FactoryHelper_MsSql.CreateFactory(); - } - } - else if (dbtool == 1) - { - if (dbtype == 0) - { - // mysql - string modelStr = FactoryHelper_Dapper_MySql.CreateFactory(); - } - else if (dbtype == 1) - { - // mysql - string modelStr = FactoryHelper_Dapper_MsSql.CreateFactory(); - } - } - #endregion - } - else if (btn.Text == "Config") + private void AspNet_SaveFile() + { + // 打包当前数据到zip并保存 + if (tbAspNet.TabPages.Count > 0) { - #region Config - int uitype = PageCache.UIType; - int dbtype = PageCache.DbType; - if (uitype == 0) + Dictionary fileDic = new Dictionary(); + foreach (TabPage item in tbAspNet.TabPages) { - // easyui - if (dbtype == 0) + string key = item.Text; + string text = (item.Controls[0] as TextBox).Text; + + if (!fileDic.ContainsKey(key + ".cs")) { - // mysql - string modelStr = ConfigHelper.GetConnectStringConfig(); + fileDic.Add(key + ".cs", text); } } - else if (uitype == 1) + + if (fileDic.Count > 0) { - // bootstarp - if (dbtype == 0) + var data = ZipHelper.Zip(fileDic); + + SaveFileDialog dialog = new SaveFileDialog(); + dialog.Filter = "压缩文件|*.zip"; + if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - // mysql - string modelStr = ConfigHelper.GetConnectStringConfig(); + string fileName = dialog.FileName; + if (!fileName.EndsWith(".zip")) + { + fileName += ".zip"; + } + + File.WriteAllBytes(fileName, data); } } - #endregion } - else if (btn.Text == "View") + } + + private void AspNet_CopyFullClass() + { + if (this.tbAspNet.TabPages.Count > 0) { - #region View - int webType = PageCache.WebType; - int uiType = PageCache.UIType; - if (webType == 1) - { - if (uiType == 0) - { - string viewStr = MvcViewHelper_EasyUI.CreateView(); - } - else if (uiType == 1) - { - string viewStr = MvcViewHelper_Bootstrap.CreateView(); - } + string text = (this.tbAspNet.TabPages[this.tbAspNet.SelectedIndex].Controls[0] as TextBox).Text; - } - #endregion + // 处理 text + Clipboard.SetText(text); } - else if (btn.Text == "Controller") + } + + private void AspNet_CopyClass() + { + if (this.tbAspNet.TabPages.Count > 0) { - #region Controller - string controllerStr = MvcControllerHelper.CreateController(); - #endregion + string text = (this.tbAspNet.TabPages[this.tbAspNet.SelectedIndex].Controls[0] as TextBox).Text; + + // 只拷贝类代码 + Regex regex = new Regex(@"\{\s+(?[\s\S]+)\s+\}\s{0,}$"); + string data = regex.Match(text).Groups["text"].Value; + + // 处理 text + Clipboard.SetText(data); } } + private void AspNet_CreateView(int action) + { + Dictionary result = AspNetHelper.CreateView(this.txtNameSpace.Text, this.txtModelSuffix.Text, this.txtDalSuffix.Text, this.txtUISuffix.Text, action); + + FillInTab_AspNet(result, tbAspNet); + } + + private void AspNet_CreateController(int action) + { + Dictionary result = AspNetHelper.CreateController(this.txtNameSpace.Text, this.txtModelSuffix.Text, this.txtDalSuffix.Text, action); + + FillInTab_AspNet(result, tbAspNet); + } + + private void AspNet_CreateConfig() + { + Dictionary result = AspNetHelper.CreateConfig(); + + FillInTab_AspNet(result, tbAspNet); + } + + private void AspNet_CreateFactory() + { + Dictionary result = AspNetHelper.CreateFactory(this.txtNameSpace.Text); + + FillInTab_AspNet(result, tbAspNet); + } + + private void AspNet_CreateDAL(int action) + { + Dictionary result = AspNetHelper.CreateDAL(this.txtNameSpace.Text, this.txtModelSuffix.Text, this.txtDalSuffix.Text, action); + + FillInTab_AspNet(result, tbAspNet); + + } + private void btmExport_Click(object sender, EventArgs e) { // 打包当前数据到zip并保存 @@ -488,25 +500,23 @@ private void btmExport_Click(object sender, EventArgs e) private void AspNet_CreateModel() { - Dictionary result = AspNetHelper.CreateModel(this.txtNameSpace.Text, this.txtModelSuffix.Text, this.chkQueryModel.Checked, this.chkIsSplit.Checked); + Dictionary result = AspNetHelper.CreateModel(this.txtNameSpace.Text, this.txtModelSuffix.Text); - FillInTab(result, tbAspNet); + FillInTab_AspNet(result, tbAspNet); } - private void AspNet_CreateAspx() + private void AspNet_CreateAspx(int action) { - int action = (int)(action_type.add | action_type.edit | action_type.query_all); Dictionary result = AspNetHelper.CreateAspx(this.txtNameSpace.Text, this.txtModelSuffix.Text, action); - FillInTab(result, tbAspNet); + FillInTab_AspNet(result, tbAspNet); } - private void AspNet_CreateAspxcs() + private void AspNet_CreateAspxcs(int action) { - int action = (int)(action_type.add | action_type.edit | action_type.query_all); Dictionary result = AspNetHelper.CreateAspxcs(this.txtNameSpace.Text, this.txtModelSuffix.Text, this.txtDalSuffix.Text, action); - FillInTab(result, tbAspNet); + FillInTab_AspNet(result, tbAspNet); } #endregion @@ -544,7 +554,7 @@ private void btnCore_Click(object sender, EventArgs e) private void Core_CreateModel() { - Dictionary result = AspNetCoreHelper.CreateModel(this.txtCoreNameSpace.Text, this.txtCoreModelSuffix.Text, this.chkQueryModel.Checked, this.chkIsSplit.Checked); + Dictionary result = AspNetCoreHelper.CreateModel(this.txtCoreNameSpace.Text, this.txtCoreModelSuffix.Text, this.chkQueryModel.Checked); FillInTab(result, tbAspNetCore); } @@ -652,6 +662,27 @@ private void FillInTab(Dictionary result, TabControl tabControl) } } + private void FillInTab_AspNet(Dictionary result, TabControl tabControl) + { + tabControl.TabPages.Clear(); + foreach (var item in result) + { + TextBox textBox = new TextBox(); + textBox.Location = new System.Drawing.Point(6, 6); + textBox.Multiline = true; + textBox.Size = new System.Drawing.Size(660, 479); + textBox.TabIndex = 0; + textBox.ScrollBars = ScrollBars.Vertical; + textBox.Text = item.Value; + + TabPage tb = new TabPage(); + tb.Text = item.Key; + tb.Controls.Add(textBox); + + tabControl.TabPages.Add(tb); + } + } + private void txtResult_KeyPress(object sender, KeyPressEventArgs e) { TextBox textBox = sender as TextBox;