From c2fa981fb19aa0fee113dd684f5f14956d58bd93 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周三, 07 5月 2025 18:41:05 +0800 Subject: [PATCH] 优化 --- Weben_CMS专用代码生成器/Code/MainForm.cs | 124 ++++++++++++++++++++++++ Weben_CMS专用代码生成器/Code/File/GenerateCodeConfigParamFiles/物料信息表配置文本.txt | 12 ++ Weben_CMS专用代码生成器/Code/Model/GenerateCodeConfigParam.cs | 25 +++++ Weben_CMS专用代码生成器/Code/MainForm.Designer.cs | 80 +++++++++++---- Weben_CMS专用代码生成器/Code/GenerateCode_WeiBen_CMS.csproj | 4 5 files changed, 224 insertions(+), 21 deletions(-) diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/File/GenerateCodeConfigParamFiles/\347\211\251\346\226\231\344\277\241\346\201\257\350\241\250\351\205\215\347\275\256\346\226\207\346\234\254.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/File/GenerateCodeConfigParamFiles/\347\211\251\346\226\231\344\277\241\346\201\257\350\241\250\351\205\215\347\275\256\346\226\207\346\234\254.txt" new file mode 100644 index 0000000..329cf9e --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/File/GenerateCodeConfigParamFiles/\347\211\251\346\226\231\344\277\241\346\201\257\350\241\250\351\205\215\347\275\256\346\226\207\346\234\254.txt" @@ -0,0 +1,12 @@ +锘縖琛ㄥ悕]:scms_wmsmaterials +[瀹炰綋绫诲悕]:WmsMaterial +[瀹炰綋绫诲璞″悕]:wmsMaterial +[椤甸潰鑿滃崟鍚峕:鐗╂枡淇℃伅 +[椤甸潰鑿滃崟瀵硅薄缂╁啓]:wmsMaterial +[琛ㄧ殑涓枃娉ㄨВ]:鐗╂枡鍩虹淇℃伅琛� +[閲嶅鎬ф牎楠屽瓧娈礭:MaterialCode +[鍒犻櫎鎻愮ず瀛楁]:MaterialCode +[妯$硦鏌ヨ瀛楁]:'MaterialCode', 'MaterialName', 'Remark' +[妯$硦鏌ヨ瀛楁鍚峕:璇疯緭鍏ョ墿鏂欑紪鐮�/鐗╂枡鍚嶇О/澶囨敞 +[椤圭洰鍛藉悕绌洪棿]:HIAWms +[鏋氫妇绫诲瀷瀛楁闆嗗悎]:PurchaseType|PurchaseTypeEnum|PurchaseTypeDesc,MaterialType|MaterialTypeEnum|MaterialTypeDesc,IsMainBranch|YesNoEnum|IsMainBranchDesc \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" index 1a67be7..78d2604 100644 --- "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" @@ -249,6 +249,7 @@ <Compile Include="Generate\Web\Views\Pages\EntityNameClass\EntityNameClass_Config_Generate.cs" /> <Compile Include="Generate\Web\Views\Pages\EntityNameClass\EntityNameClass_Generate.cs" /> <Compile Include="Generate\Web\Views\Pages\EntityNameClass\EntityNameClass_module_Generate.cs" /> + <Compile Include="Model\GenerateCodeConfigParam.cs" /> <Compile Include="Model\GenerateCodeParam.cs" /> <Compile Include="Model\Enum\DataBaseEnum.cs" /> <Compile Include="Model\Enum\DataTypeEnum.cs" /> @@ -475,6 +476,9 @@ <Content Include="Templete\Web\Views\Pages\EntityNameClass\EntityNameClass妯℃澘.txt"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> + <Content Include="File\GenerateCodeConfigParamFiles\鐗╂枡淇℃伅閰嶇疆鏂囨湰.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> <Content Include="甯哥敤.txt" /> </ItemGroup> <ItemGroup /> diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" index 7337df2..94dc57c 100644 --- "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" @@ -64,6 +64,8 @@ this.lbl_DataSource = new System.Windows.Forms.Label(); this.cmb_DataSource = new System.Windows.Forms.ComboBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.tb_DeleteAlertAttr = new System.Windows.Forms.TextBox(); + this.label25 = new System.Windows.Forms.Label(); this.tb_ValidateRepeatName = new System.Windows.Forms.TextBox(); this.label24 = new System.Windows.Forms.Label(); this.tb_LikeQueryAttrsName = new System.Windows.Forms.TextBox(); @@ -87,8 +89,9 @@ this.label12 = new System.Windows.Forms.Label(); this.tb_templeteFileDownName = new System.Windows.Forms.TextBox(); this.label14 = new System.Windows.Forms.Label(); - this.label25 = new System.Windows.Forms.Label(); - this.tb_DeleteAlertAttr = new System.Windows.Forms.TextBox(); + this.tb_FilePath = new System.Windows.Forms.TextBox(); + this.btn_SelectFile = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -96,7 +99,7 @@ // // btnPath // - this.btnPath.Location = new System.Drawing.Point(425, 570); + this.btnPath.Location = new System.Drawing.Point(453, 723); this.btnPath.Name = "btnPath"; this.btnPath.Size = new System.Drawing.Size(97, 23); this.btnPath.TabIndex = 1; @@ -115,7 +118,7 @@ // // tbPath // - this.tbPath.Location = new System.Drawing.Point(106, 566); + this.tbPath.Location = new System.Drawing.Point(134, 719); this.tbPath.Name = "tbPath"; this.tbPath.ReadOnly = true; this.tbPath.Size = new System.Drawing.Size(253, 21); @@ -123,7 +126,7 @@ // // btnExit // - this.btnExit.Location = new System.Drawing.Point(649, 600); + this.btnExit.Location = new System.Drawing.Point(677, 753); this.btnExit.Name = "btnExit"; this.btnExit.Size = new System.Drawing.Size(171, 67); this.btnExit.TabIndex = 8; @@ -133,7 +136,7 @@ // // btn_CreateFile // - this.btn_CreateFile.Location = new System.Drawing.Point(106, 600); + this.btn_CreateFile.Location = new System.Drawing.Point(134, 753); this.btn_CreateFile.Name = "btn_CreateFile"; this.btn_CreateFile.Size = new System.Drawing.Size(157, 67); this.btn_CreateFile.TabIndex = 14; @@ -324,7 +327,7 @@ // // btn_InsertSql // - this.btn_InsertSql.Location = new System.Drawing.Point(385, 600); + this.btn_InsertSql.Location = new System.Drawing.Point(413, 753); this.btn_InsertSql.Name = "btn_InsertSql"; this.btn_InsertSql.Size = new System.Drawing.Size(157, 67); this.btn_InsertSql.TabIndex = 42; @@ -454,6 +457,22 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "鑷畾涔夐厤缃�"; // + // tb_DeleteAlertAttr + // + this.tb_DeleteAlertAttr.Location = new System.Drawing.Point(552, 246); + this.tb_DeleteAlertAttr.Name = "tb_DeleteAlertAttr"; + this.tb_DeleteAlertAttr.Size = new System.Drawing.Size(145, 21); + this.tb_DeleteAlertAttr.TabIndex = 65; + // + // label25 + // + this.label25.AutoSize = true; + this.label25.Location = new System.Drawing.Point(452, 255); + this.label25.Name = "label25"; + this.label25.Size = new System.Drawing.Size(83, 12); + this.label25.TabIndex = 64; + this.label25.Text = "鍒犻櫎鎻愮ず瀛楁:"; + // // tb_ValidateRepeatName // this.tb_ValidateRepeatName.Location = new System.Drawing.Point(402, 108); @@ -555,7 +574,7 @@ // // tb_EnumList // - this.tb_EnumList.Location = new System.Drawing.Point(418, 361); + this.tb_EnumList.Location = new System.Drawing.Point(431, 361); this.tb_EnumList.Multiline = true; this.tb_EnumList.Name = "tb_EnumList"; this.tb_EnumList.Size = new System.Drawing.Size(369, 104); @@ -654,27 +673,43 @@ this.label14.TabIndex = 47; this.label14.Text = "鏂囦欢涓嬭浇鍚嶅瓧:"; // - // label25 + // tb_FilePath // - this.label25.AutoSize = true; - this.label25.Location = new System.Drawing.Point(452, 255); - this.label25.Name = "label25"; - this.label25.Size = new System.Drawing.Size(83, 12); - this.label25.TabIndex = 64; - this.label25.Text = "鍒犻櫎鎻愮ず瀛楁:"; + this.tb_FilePath.Enabled = false; + this.tb_FilePath.Location = new System.Drawing.Point(51, 579); + this.tb_FilePath.Name = "tb_FilePath"; + this.tb_FilePath.Size = new System.Drawing.Size(568, 21); + this.tb_FilePath.TabIndex = 47; + this.tb_FilePath.TextChanged += new System.EventHandler(this.tb_FilePath_TextChanged); // - // tb_DeleteAlertAttr + // btn_SelectFile // - this.tb_DeleteAlertAttr.Location = new System.Drawing.Point(552, 246); - this.tb_DeleteAlertAttr.Name = "tb_DeleteAlertAttr"; - this.tb_DeleteAlertAttr.Size = new System.Drawing.Size(145, 21); - this.tb_DeleteAlertAttr.TabIndex = 65; + this.btn_SelectFile.Location = new System.Drawing.Point(632, 571); + this.btn_SelectFile.Name = "btn_SelectFile"; + this.btn_SelectFile.Size = new System.Drawing.Size(252, 34); + this.btn_SelectFile.TabIndex = 48; + this.btn_SelectFile.Text = "璇峰湪姝ゅ鍏ョ敓鎴愪唬鐮侀渶瑕佺殑閰嶇疆鏂囨湰锛侊紒"; + this.btn_SelectFile.UseVisualStyleBackColor = true; + this.btn_SelectFile.Click += new System.EventHandler(this.btn_SelectFile_Click); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(890, 571); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(108, 34); + this.button1.TabIndex = 49; + this.button1.Text = "娓呯┖瀵煎叆璺緞锛侊紒"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click_1); // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1250, 672); + this.ClientSize = new System.Drawing.Size(1250, 831); + this.Controls.Add(this.button1); + this.Controls.Add(this.btn_SelectFile); + this.Controls.Add(this.tb_FilePath); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Controls.Add(this.btn_InsertSql); @@ -760,6 +795,9 @@ private System.Windows.Forms.Label label24; private System.Windows.Forms.TextBox tb_DeleteAlertAttr; private System.Windows.Forms.Label label25; + private System.Windows.Forms.TextBox tb_FilePath; + private System.Windows.Forms.Button btn_SelectFile; + private System.Windows.Forms.Button button1; } } diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" index aa960f0..8f187c0 100644 --- "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" @@ -9,6 +9,7 @@ using GenerateCode_WeiBen_WMS.Const; using GenerateCode_WeiBen_WMS.Model; using GenerateCode_WeiBen_WMS.Utility; +using System.Xml; namespace GenerateCode_GEBrilliantFactory { @@ -685,5 +686,128 @@ dataBaseEnum = (DataBaseEnum)Enum.Parse(typeof(DataBaseEnum), name); } + + private void btn_SelectFile_Click(object sender, EventArgs e) + { + OpenFileDialog fileDialog = new OpenFileDialog(); + fileDialog.Multiselect = true; + fileDialog.Title = "璇烽�夋嫨鏂囦欢"; + fileDialog.Filter = "鎵�鏈夋枃浠�(*txt*)|*.txt*"; //璁剧疆瑕侀�夋嫨鐨勬枃浠剁殑绫诲瀷 + if (fileDialog.ShowDialog() == DialogResult.OK) + { + string file = fileDialog.FileName;//杩斿洖鏂囦欢鐨勫畬鏁磋矾寰� + this.tb_FilePath.Text = file; + } + } + + private void tb_FilePath_TextChanged(object sender, EventArgs e) + { + try + { + string filePath = this.tb_FilePath.Text; + + string[] lines = File.ReadAllLines(filePath); + + // 鍒涘缓瀹炰綋绫诲璞� + GenerateCodeConfigParam entity = new GenerateCodeConfigParam(); + + // 瑙f瀽姣忎竴琛屽唴瀹瑰苟璧嬪�肩粰瀹炰綋绫诲睘鎬� + foreach (string line in lines) + { + if (line.Contains(":")) + { + string[] parts = line.Split(':'); + string propertyName = parts[0].Trim('[', ']'); + string propertyValue = parts[1].Trim(); + + // 鏍规嵁灞炴�у悕璧嬪�� + switch (propertyName) + { + case "琛ㄥ悕": + entity.琛ㄥ悕 = propertyValue; + break; + case "瀹炰綋绫诲悕": + entity.瀹炰綋绫诲悕 = propertyValue; + break; + case "瀹炰綋绫诲璞″悕": + entity.瀹炰綋绫诲璞″悕 = propertyValue; + break; + case "椤甸潰鑿滃崟鍚�": + entity.椤甸潰鑿滃崟鍚� = propertyValue; + break; + case "椤甸潰鑿滃崟瀵硅薄缂╁啓": + entity.椤甸潰鑿滃崟瀵硅薄缂╁啓 = propertyValue; + break; + case "琛ㄧ殑涓枃娉ㄨВ": + entity.琛ㄧ殑涓枃娉ㄨВ = propertyValue; + break; + case "閲嶅鎬ф牎楠屽瓧娈�": + entity.閲嶅鎬ф牎楠屽瓧娈� = propertyValue; + break; + case "鍒犻櫎鎻愮ず瀛楁": + entity.鍒犻櫎鎻愮ず瀛楁 = propertyValue; + break; + case "妯$硦鏌ヨ瀛楁": + entity.妯$硦鏌ヨ瀛楁 = propertyValue; + break; + case "妯$硦鏌ヨ瀛楁鍚�": + entity.妯$硦鏌ヨ瀛楁鍚� = propertyValue; + break; + case "椤圭洰鍛藉悕绌洪棿": + entity.椤圭洰鍛藉悕绌洪棿 = propertyValue; + break; + case "鏋氫妇绫诲瀷瀛楁闆嗗悎": + entity.鏋氫妇绫诲瀷瀛楁闆嗗悎 = propertyValue; + break; + } + } + } + + //缁欑晫闈㈣祴鍊� + this.tb_TableName.Text = "";//琛ㄥ悕 + this.tb_WCF_NameSpacePath.Text = "";//琛ㄥ悕 + this.tb_ChinaComment.Text = "";//琛ㄥ悕 + this.tb_MenuName.Text = "";//琛ㄥ悕 + this.tb_PageMenuInstanceName.Text = "";//琛ㄥ悕 + this.tb_EntityName.Text = "";//琛ㄥ悕 + + this.tb_LikeQueryAttrs.Text = "";//琛ㄥ悕 + this.tb_LikeQueryAttrsName.Text = "";//琛ㄥ悕 + + this.tb_EntityProName.Text = "";//琛ㄥ悕 + this.tb_EnumList.Text = "";//琛ㄥ悕 + this.tb_ValidateRepeatName.Text = "";//琛ㄥ悕 + this.tb_DeleteAlertAttr.Text = "";//琛ㄥ悕 + + this.tb_TableName.Text = entity.琛ㄥ悕;//琛ㄥ悕 + this.tb_WCF_NameSpacePath.Text = entity.椤圭洰鍛藉悕绌洪棿;//WCF椤圭洰鍛藉悕绌洪棿 + this.tb_ChinaComment.Text = entity.琛ㄧ殑涓枃娉ㄨВ;//涓枃娉ㄩ噴 + this.tb_MenuName.Text = entity.椤甸潰鑿滃崟鍚�; + this.tb_PageMenuInstanceName.Text = entity.椤甸潰鑿滃崟瀵硅薄缂╁啓; + this.tb_EntityName.Text = entity.瀹炰綋绫诲悕;//瀹炰綋绫诲悕 + + this.tb_LikeQueryAttrs.Text = entity.妯$硦鏌ヨ瀛楁; + this.tb_LikeQueryAttrsName.Text = entity.妯$硦鏌ヨ瀛楁鍚�; + + this.tb_EntityProName.Text = entity.瀹炰綋绫诲璞″悕;//瀹炰綋绫诲璞″悕 + this.tb_EnumList.Text = entity.鏋氫妇绫诲瀷瀛楁闆嗗悎; + this.tb_ValidateRepeatName.Text = entity.閲嶅鎬ф牎楠屽瓧娈�; + this.tb_DeleteAlertAttr.Text = entity.鍒犻櫎鎻愮ず瀛楁; + + } + catch (FileNotFoundException) + { + Console.WriteLine("閿欒: 鏂囦欢鏈壘鍒�!"); + } + catch (Exception ex) + { + Console.WriteLine($"閿欒: 鍙戠敓浜嗕竴涓湭鐭ラ敊璇�: {ex.Message}"); + } + } + + private void button1_Click_1(object sender, EventArgs e) + { + this.tb_FilePath.Text = ""; + } } } diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/GenerateCodeConfigParam.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/GenerateCodeConfigParam.cs" new file mode 100644 index 0000000..572a0b7 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/GenerateCodeConfigParam.cs" @@ -0,0 +1,25 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_WeiBen_WMS.Model +{ + internal class GenerateCodeConfigParam + { + public string 琛ㄥ悕 { get; set; } + public string 瀹炰綋绫诲悕 { get; set; } + public string 瀹炰綋绫诲璞″悕 { get; set; } + public string 椤甸潰鑿滃崟鍚� { get; set; } + public string 椤甸潰鑿滃崟瀵硅薄缂╁啓 { get; set; } + public string 琛ㄧ殑涓枃娉ㄨВ { get; set; } + public string 閲嶅鎬ф牎楠屽瓧娈� { get; set; } + public string 鍒犻櫎鎻愮ず瀛楁 { get; set; } + public string 妯$硦鏌ヨ瀛楁 { get; set; } + public string 妯$硦鏌ヨ瀛楁鍚� { get; set; } + public string 椤圭洰鍛藉悕绌洪棿 { get; set; } + + public string 鏋氫妇绫诲瀷瀛楁闆嗗悎 { get; set; } + } +} -- Gitblit v1.9.3