Commit 40745689 authored by 陈航's avatar 陈航

【编号:13356】模型生成工具

parent 4e8dcd77
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<appSettings> <startup>
<add key="UpdateTime" value="2021-12-30 10:52:06.703" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
<add key="ExceptFiles" value="" /> </startup>
<add key="ContainFiles" value="" />
<add key="PatchTimeFrame_Dll" value="48" />
<add key="PatchTimeFrame_Sql" value="720" />
<add key="PatchTimeFrame_Xml" value="720" />
<add key="Exclude_PDB" value="1" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
...@@ -19,11 +10,5 @@ ...@@ -19,11 +10,5 @@
<bindingRedirect oldVersion="0.0.0.0-1.3.2.10" newVersion="1.3.2.10" /> <bindingRedirect oldVersion="0.0.0.0-1.3.2.10" newVersion="1.3.2.10" />
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime> </runtime>
</configuration> </configuration>
\ No newline at end of file
...@@ -168,4 +168,10 @@ ...@@ -168,4 +168,10 @@
<UserId>sa</UserId> <UserId>sa</UserId>
<Pwd>a*1</Pwd> <Pwd>a*1</Pwd>
</links> </links>
<links>
<Link>192.168.1.204</Link>
<DbName>ln_pdm20230822</DbName>
<UserId>sa</UserId>
<Pwd>sa</Pwd>
</links>
</DocumentElement> </DocumentElement>
\ No newline at end of file
...@@ -33,10 +33,11 @@ ...@@ -33,10 +33,11 @@
// //
// wEditBasic // wEditBasic
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(384, 268); this.ClientSize = new System.Drawing.Size(448, 380);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.Name = "wEditBasic"; this.Name = "wEditBasic";
this.Text = "wEditBasic"; this.Text = "wEditBasic";
this.ResumeLayout(false); this.ResumeLayout(false);
......
...@@ -154,6 +154,12 @@ ...@@ -154,6 +154,12 @@
<Compile Include="UI\sys\wToolsPrief.Designer.cs"> <Compile Include="UI\sys\wToolsPrief.Designer.cs">
<DependentUpon>wToolsPrief.cs</DependentUpon> <DependentUpon>wToolsPrief.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="UI\wAutoModel.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\wAutoModel.Designer.cs">
<DependentUpon>wAutoModel.cs</DependentUpon>
</Compile>
<Compile Include="UI\wCefDemo.cs"> <Compile Include="UI\wCefDemo.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
...@@ -407,6 +413,9 @@ ...@@ -407,6 +413,9 @@
<EmbeddedResource Include="UI\sys\wToolsPrief.resx"> <EmbeddedResource Include="UI\sys\wToolsPrief.resx">
<DependentUpon>wToolsPrief.cs</DependentUpon> <DependentUpon>wToolsPrief.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="UI\wAutoModel.resx">
<DependentUpon>wAutoModel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\wCefDemo.resx"> <EmbeddedResource Include="UI\wCefDemo.resx">
<DependentUpon>wCefDemo.cs</DependentUpon> <DependentUpon>wCefDemo.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
...@@ -95,11 +95,14 @@ namespace Tools.UI ...@@ -95,11 +95,14 @@ namespace Tools.UI
string strTableName = lsbTableInfo.SelectedItem.ToString(); string strTableName = lsbTableInfo.SelectedItem.ToString();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.AppendLine($@" sb.AppendLine($@"SELECT b.name, b.user_type_id, c.name AS TypeName, ISNULL(d.value, b.name) AS Description
SELECT b.name,b.user_type_id,c.name as TypeName FROM sys.objects a FROM sys.objects a
INNER JOIN sys.columns b ON b.object_id = a.object_id INNER JOIN sys.columns b ON b.object_id = a.object_id
INNER JOIN sys.types c ON b.user_type_id=c.user_type_id INNER JOIN sys.types c ON b.user_type_id = c.user_type_id
WHERE a.name='{strTableName}' ORDER BY b.column_id LEFT JOIN sys.extended_properties d ON b.object_id = d.major_id
AND b.column_id = d.minor_id
WHERE a.name = '{strTableName}'
ORDER BY b.column_id;
"); ");
DataTable dataTable = this._db.GetDataTable(sb.ToString(), "结果列表"); DataTable dataTable = this._db.GetDataTable(sb.ToString(), "结果列表");
...@@ -115,7 +118,7 @@ WHERE a.name='{strTableName}' ORDER BY b.column_id ...@@ -115,7 +118,7 @@ WHERE a.name='{strTableName}' ORDER BY b.column_id
{ {
sb.Append($@" sb.Append($@"
/// <summary> /// <summary>
/// {row["name"]} /// {row["Description"]}
/// </summary> /// </summary>
public {GetCsharpTypeNameBySqlType(row["TypeName"].ToString())} {row["name"]} {{ get; set; }} public {GetCsharpTypeNameBySqlType(row["TypeName"].ToString())} {row["name"]} {{ get; set; }}
"); ");
......
namespace Tools.UI
{
partial class wAutoModel
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(wAutoModel));
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.panel4 = new System.Windows.Forms.Panel();
this.txtdate = new System.Windows.Forms.TextBox();
this.panel3 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.txtResult = new System.Windows.Forms.TextBox();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.tsbentity = new System.Windows.Forms.ToolStripButton();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.panel4.SuspendLayout();
this.panel3.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 25);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.panel4);
this.splitContainer1.Panel1.Controls.Add(this.panel3);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.txtResult);
this.splitContainer1.Size = new System.Drawing.Size(657, 545);
this.splitContainer1.SplitterDistance = 159;
this.splitContainer1.SplitterWidth = 10;
this.splitContainer1.TabIndex = 0;
//
// panel4
//
this.panel4.Controls.Add(this.txtdate);
this.panel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel4.Location = new System.Drawing.Point(0, 19);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(159, 526);
this.panel4.TabIndex = 4;
//
// txtdate
//
this.txtdate.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtdate.Location = new System.Drawing.Point(0, 0);
this.txtdate.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.txtdate.Multiline = true;
this.txtdate.Name = "txtdate";
this.txtdate.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtdate.Size = new System.Drawing.Size(159, 526);
this.txtdate.TabIndex = 2;
//
// panel3
//
this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel3.Controls.Add(this.label2);
this.panel3.Controls.Add(this.label1);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(159, 19);
this.panel3.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(90, 1);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(32, 17);
this.label2.TabIndex = 2;
this.label2.Text = "描述";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(17, 1);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(44, 17);
this.label1.TabIndex = 1;
this.label1.Text = "字段名";
//
// txtResult
//
this.txtResult.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtResult.Location = new System.Drawing.Point(0, 0);
this.txtResult.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.txtResult.Multiline = true;
this.txtResult.Name = "txtResult";
this.txtResult.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtResult.Size = new System.Drawing.Size(488, 545);
this.txtResult.TabIndex = 1;
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsbentity});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(657, 25);
this.toolStrip1.TabIndex = 1;
this.toolStrip1.Text = "toolStrip1";
//
// tsbentity
//
this.tsbentity.Image = global::Tools.Properties.Resources.实体类;
this.tsbentity.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbentity.Name = "tsbentity";
this.tsbentity.Size = new System.Drawing.Size(88, 22);
this.tsbentity.Text = "生成实体类";
this.tsbentity.Click += new System.EventHandler(this.tsbentity_Click);
//
// wAutoModel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(657, 570);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.toolStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "wAutoModel";
this.Text = "模型生成工具";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.panel4.ResumeLayout(false);
this.panel4.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.TextBox txtdate;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtResult;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton tsbentity;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tools.MyCommon;
namespace Tools.UI
{
public partial class wAutoModel : wEditBasic
{
public wAutoModel()
{
InitializeComponent();
}
/// <summary>
/// 生成实体类
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsbentity_Click(object sender, EventArgs e)
{
try
{
// 获取粘贴的字段名和描述内容
string clipboardText = txtdate.Text;
// 将字段名和描述按行分割
string[] lines = clipboardText.Split('\n');
// 创建实体类代码
StringBuilder sb = new StringBuilder();
sb.Append($@"
/// <summary>
/// XXXModel
/// </summary>
public class XXXModel
{{
");
// 遍历每一行
foreach (string line in lines)
{
if (!string.IsNullOrEmpty(line))
{
// 将行内容按制表符分割为字段名和描述
string[] parts = line.Split('\t');
if (parts.Length >= 2)
{
string fieldName = parts[0].Trim();
string fieldDescription = parts[1].Trim();
sb.Append($@"
/// <summary>
/// {fieldDescription}
/// </summary>
public string {fieldName} {{ get; set; }}
");
}
}
}
sb.Append($@"
}}
");
// 将实体类代码输出到右侧的 TextBox
txtResult.Text = sb.ToString();
sb.Clear();
}
catch (Exception ex)
{
// 处理异常
MessageBox.Show("发生错误:" + ex.Message);
}
}
}
}
This diff is collapsed.
...@@ -61,6 +61,7 @@ namespace Tools ...@@ -61,6 +61,7 @@ namespace Tools
this.CreateModule(Tools_dev, typeof(UI.wDbAnlysis), "SQL效率分析", "tr:用于分析SQL查询效率(执行计划和IO计数)"), this.CreateModule(Tools_dev, typeof(UI.wDbAnlysis), "SQL效率分析", "tr:用于分析SQL查询效率(执行计划和IO计数)"),
this.CreateModule(Tools_dev, typeof(UI.wSysChecker), "检查配置工具", "tr:系统通用检查配置服务(通过存储过程检查)"), this.CreateModule(Tools_dev, typeof(UI.wSysChecker), "检查配置工具", "tr:系统通用检查配置服务(通过存储过程检查)"),
this.CreateModule(Tools_dev, typeof(UI.wMuiltTaskSimulate), "批量并行任务模拟", "lxj:多线程并行运行指定测试项目,用来做压力性能测试等。。。"), this.CreateModule(Tools_dev, typeof(UI.wMuiltTaskSimulate), "批量并行任务模拟", "lxj:多线程并行运行指定测试项目,用来做压力性能测试等。。。"),
this.CreateModule(Tools_dev, typeof(UI.wAutoModel), "模型生成工具", "tb:将Excel字段名、描述复制到指定区域,生成为模型类"),
//------------------------------- //-------------------------------
this.CreateModule(Tools_human, typeof(UI.wUser), "员工管理", "tr:员工状态及头像管理"), this.CreateModule(Tools_human, typeof(UI.wUser), "员工管理", "tr:员工状态及头像管理"),
this.CreateModule(Tools_human, typeof(UI.wEvaluationOfEmployee), "员工考核", "tr:员工考核的记录工具"), this.CreateModule(Tools_human, typeof(UI.wEvaluationOfEmployee), "员工考核", "tr:员工考核的记录工具"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment