From 1089579f8e6ccbb839324333b7ab69891037b568 Mon Sep 17 00:00:00 2001
From: zs <zhousong@weben-smart.com>
Date: 周四, 08 5月 2025 14:20:19 +0800
Subject: [PATCH] 任务更新校验
---
Weben_CMS专用代码生成器/Code/MainForm.cs | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 157 insertions(+), 9 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 8fab23e..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"
@@ -8,6 +8,8 @@
using GenerateCode_WeiBen_WMS.DataBaseFactory;
using GenerateCode_WeiBen_WMS.Const;
using GenerateCode_WeiBen_WMS.Model;
+using GenerateCode_WeiBen_WMS.Utility;
+using System.Xml;
namespace GenerateCode_GEBrilliantFactory
{
@@ -81,6 +83,7 @@
//涓�閿敓鎴愭墍鏈夋枃浠�
private void btn_CreateFile_Click(object sender, EventArgs e)
{
+ var genCodeRootPath = "";
try
{
projectNamePrefix = this.tb_ProjectNamePrefix.Text;
@@ -104,6 +107,14 @@
string filePrefixName = this.tb_FileName.Text.Trim();//鏂囦欢鍓嶇紑鍚�
string modulelogo = this.tb_Modulelogo.Text.Trim();//妯″潡绠�鍐�
+
+ string _tb_DeleteAlertAttr = this.tb_DeleteAlertAttr.Text.Trim();//涓枃娉ㄩ噴
+ if (_tb_DeleteAlertAttr == "")
+ {
+ MessageBox.Show("璇疯緭鍏� 鍒犻櫎鎻愮ず瀛楁锛�");
+ this.tb_DeleteAlertAttr.Focus();
+ return;
+ }
string _tb_ValidateRepeatName = this.tb_ValidateRepeatName.Text.Trim();//涓枃娉ㄩ噴
if (_tb_ValidateRepeatName == "")
@@ -210,6 +221,7 @@
GenerateCodeParam param = new GenerateCodeParam()
{
+ DeleteAlertAttr = CommonHelper.FirstLowercase(_tb_DeleteAlertAttr),
Modulelogo = modulelogo,
ChinaComment = chinaComment,
PageMenuName = menuName,
@@ -227,6 +239,9 @@
var str_enumList = this.tb_EnumList.Text.Trim();
if (str_enumList.IndexOf(',') > -1)
{
+ str_enumList = str_enumList.Replace("\n", "");
+ str_enumList = str_enumList.Replace("\t", "");
+ str_enumList = str_enumList.Replace("\r", "");
var arr_enumList = str_enumList.Split(',');
foreach (var item in arr_enumList)
{
@@ -257,9 +272,10 @@
//鐢熸垚Model
//CreateModelFile(columnList, tableName, filePrefixName, wcf_NameSpacePath, createPerson, chinaComment, entityName, modulelogo);
//CreateModelParamFile(columnList, tableName, filePrefixName, wcf_NameSpacePath, createPerson, chinaComment, entityName, modulelogo);
-
+ genCodeRootPath = tbPath.Text + @"\" + tb_WCF_NameSpacePath.Text.Trim();
+ var webFolerPath = (tb_WCF_NameSpacePath.Text.Trim() + "_Web").ToLower();
#region 瀹炰綋绫�
- var entityFilePath = tbPath.Text + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".Application.Contracts\Dtos\" + tb_EntityName.Text.Trim();
+ var entityFilePath = genCodeRootPath + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".Application.Contracts\Dtos\" + tb_EntityName.Text.Trim();
//1銆佺敓鎴� 鍒嗛〉鏌ヨ瀹炰綋 鏂囦欢
str_generate = InputQueryModel_Generate.CreateQueryModelLText(param);
tf = TextHelper.Export2File_V2(entityFilePath, $"Get{param.EntityName}Input.cs", tableName, str_generate, FileType.InputModel, filePrefixName, entityName, modulelogo);
@@ -293,12 +309,12 @@
#region AppSerivice
//8銆佺敓鎴� IAppService 鏂囦欢
- var appServiceFilePath = tbPath.Text + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".Application.Contracts\Services";
+ var appServiceFilePath = genCodeRootPath + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".Application.Contracts\Services";
str_generate = IAppService_Generate.CreateText(param);
tf = TextHelper.Export2File_V2(appServiceFilePath, $"I{param.EntityName}AppService.cs", tableName, str_generate, FileType.InputModel, filePrefixName, entityName, modulelogo);
//9銆佺敓鎴� AppService 鏂囦欢
- appServiceFilePath = tbPath.Text + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".Application\Implements";
+ appServiceFilePath = genCodeRootPath + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".Application\Implements";
str_generate = AppService_Generate.CreateText(param);
tf = TextHelper.Export2File_V2(appServiceFilePath, $"{param.EntityName}AppService.cs", tableName, str_generate, FileType.InputModel, filePrefixName, entityName, modulelogo);
@@ -308,7 +324,7 @@
#region Contorller
//10銆佺敓鎴� Contorller 鏂囦欢
- var continerlllePath = tbPath.Text + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @"\Controller";
+ var continerlllePath = genCodeRootPath + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @"\Controller";
str_generate = Controller_Generate.CreateText(param);
tf = TextHelper.Export2File_V2(continerlllePath, $"{param.EntityName}Controller.cs", tableName, str_generate, FileType.InputModel, filePrefixName, entityName, modulelogo);
@@ -318,7 +334,7 @@
#region Domain
//11銆佺敓鎴� IRepository 鏂囦欢
- var iRepositoryPath = tbPath.Text + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".Domain\" + tb_EntityName.Text.Trim(); ;
+ var iRepositoryPath = genCodeRootPath + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".Domain\" + tb_EntityName.Text.Trim(); ;
str_generate = IRepository_Generate.CreateText(param);
tf = TextHelper.Export2File_V2(iRepositoryPath, $"I{param.EntityName}Repository.cs", tableName, str_generate, FileType.InputModel, filePrefixName, entityName, modulelogo);
@@ -328,7 +344,7 @@
#region EntityFrameworkCore
//12銆佺敓鎴� EfCoreRepository 鏂囦欢
- var efCoreRepositoryPath = tbPath.Text + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".EntityFrameworkCore\Repositories";
+ var efCoreRepositoryPath = genCodeRootPath + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".EntityFrameworkCore\Repositories";
str_generate = EfCoreRepository_Generate.CreateText(param);
tf = TextHelper.Export2File_V2(efCoreRepositoryPath, $"EfCore{param.EntityName}Repository.cs", tableName, str_generate, FileType.InputModel, filePrefixName, entityName, modulelogo);
@@ -336,7 +352,7 @@
#endregion
#region Web
- var webRootPath = tbPath.Text + @"\web\src\widgets\" + tb_EntityName.Text.Trim();
+ var webRootPath = genCodeRootPath + @"\" + webFolerPath + @"\src\widgets\" + tb_EntityName.Text.Trim();
//13銆佺敓鎴� Index 鏂囦欢
str_generate = Index_Generate.CreateText(param);
@@ -442,6 +458,15 @@
#endregion
+ //36銆佺敓鎴� AutoMapperProfile 鏂囦欢
+ var autoMapFilePath = genCodeRootPath + @"\server\src\CMS.Plugin." + tb_WCF_NameSpacePath.Text.Trim() + @".Application\MapperProfiles";
+ str_generate = AutoMapperProfile_Generate.CreateText(param);
+ tf = TextHelper.Export2File_V2(autoMapFilePath, param.EntityName + $"AutoMapperProfile.cs", tableName, str_generate, FileType.InputModel, filePrefixName, entityName, modulelogo);
+
+ //37銆佺敓鎴� 瀵煎嚭妯℃澘Excel鏂囦欢
+ List<ColumnModel> newColumnNameList = ListHelper.RemoveForPageTableListQueryAttributes(param.ColumnNameList);
+ ImportTemplteHelper.CreateImportTemplte(param, newColumnNameList, genCodeRootPath);
+
////鐢熸垚 OutputModel 鏂囦欢
//str_generate = OutputModel_Generate.CreateQueryModelLText(modulelogo, chinaComment, columnList, entityName);
@@ -506,7 +531,7 @@
}
//MessageBox.Show("鐢熸垚鏂囦欢鎴愬姛锛�");
//鎴愬姛涔嬪悗鎵撳紑鏂囦欢澶�
- using (System.Diagnostics.Process.Start(this.tbPath.Text))
+ using (System.Diagnostics.Process.Start(genCodeRootPath))
{
}
@@ -661,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