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 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 124 insertions(+), 0 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/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 = "";
+        }
     }
 }

--
Gitblit v1.9.3