Commit 65c60631 authored by tr's avatar tr

1、系统检查配置工具优化

parent ff988c8c
No preview for this file type
No preview for this file type
......@@ -24,4 +24,10 @@
<UserId>sa</UserId>
<Pwd>sa</Pwd>
</links>
<links>
<Link>192.168.1.204</Link>
<DbName>FTT_MES</DbName>
<UserId>sa</UserId>
<Pwd>sa</Pwd>
</links>
</DocumentElement>
\ No newline at end of file
使用说明:
2、操作说明:支持右键増行/删行
3、保存:保存配置信息主表和明细表
4、刷新:刷新配置信息和错误消息
5、服务测试:保存并执行配置信息。因配置信息保存在通用库,所以需重新选择一次目标库
6、数据库:选择系统检查配置的存储数据库,一般是通用库FTT
......@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -75,6 +76,21 @@ namespace Tools.MyUtils
new wMsgBox().Show(msg, width, height);
}
/// <summary>
/// 显示帮助信息
/// </summary>
/// <param name="txtFileName"></param>
public static void ShowHelp(string txtFileName)
{
var helpFileName = $@"{Utils.ConfigPath}\{txtFileName}.txt";
if (File.Exists(helpFileName))
{
using (var sr = new StreamReader(helpFileName))
{
Utils.Tip(sr.ReadToEnd(), 700, 400);
}
}
}
/// <summary>
/// 生成定长序号
/// </summary>
/// <param name="seed">序号</param>
......
......@@ -200,6 +200,16 @@ namespace Tools.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap 测试 {
get {
object obj = ResourceManager.GetObject("测试", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
......
......@@ -160,6 +160,9 @@
<data name="查询" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\查询.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="测试" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\测试.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="类" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\类.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
......
......@@ -226,5 +226,8 @@
<ItemGroup>
<None Include="Resources\保存.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\测试.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -337,15 +337,7 @@ namespace Tools.UI
private void TsbHelp_Click(object sender, EventArgs e)
{
var helpFileName = $@"{Utils.ConfigPath}\help.txt";
if (File.Exists(helpFileName))
{
using (var sr = new StreamReader(helpFileName))
{
Utils.Tip(sr.ReadToEnd(), 700, 300);
}
}
Utils.ShowHelp("dbtools_help");
}
#endregion
......
......@@ -49,6 +49,15 @@
this.panel2 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.dgvMessage = new System.Windows.Forms.DataGridView();
this.Column9 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column14 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column15 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column16 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column17 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.panel3 = new System.Windows.Forms.Panel();
this.label4 = new System.Windows.Forms.Label();
this.cmbFilter = new System.Windows.Forms.ComboBox();
......@@ -57,22 +66,15 @@
this.btnTodo = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.tsbSave = new System.Windows.Forms.ToolStripButton();
this.tsbRefresh = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.tsbDB = new System.Windows.Forms.ToolStripButton();
this.tstbLinkString = new System.Windows.Forms.ToolStripTextBox();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.tsbSave = new System.Windows.Forms.ToolStripButton();
this.tsbRefresh = new System.Windows.Forms.ToolStripButton();
this.tsbTestService = new System.Windows.Forms.ToolStripButton();
this.tsbDB = new System.Windows.Forms.ToolStripButton();
this.tsbHelp = new System.Windows.Forms.ToolStripButton();
this.Column9 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column12 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column13 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column14 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column15 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column16 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column17 = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
......@@ -307,6 +309,67 @@
this.dgvMessage.Size = new System.Drawing.Size(560, 516);
this.dgvMessage.TabIndex = 1;
//
// Column9
//
this.Column9.DataPropertyName = "IsSelect";
this.Column9.HeaderText = "选择";
this.Column9.Name = "Column9";
this.Column9.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.Column9.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.Column9.Width = 60;
//
// Column10
//
this.Column10.DataPropertyName = "ModelName";
this.Column10.HeaderText = "模块名称";
this.Column10.Name = "Column10";
//
// Column11
//
this.Column11.DataPropertyName = "TypeName";
this.Column11.HeaderText = "检查类型";
this.Column11.Name = "Column11";
//
// Column12
//
this.Column12.DataPropertyName = "TableName";
this.Column12.HeaderText = "表名";
this.Column12.Name = "Column12";
this.Column12.ToolTipText = "多个表名用逗号隔开";
//
// Column13
//
this.Column13.DataPropertyName = "KeyName";
this.Column13.HeaderText = "主键字段";
this.Column13.Name = "Column13";
this.Column13.ToolTipText = "多个字段用逗号隔开";
//
// Column14
//
this.Column14.DataPropertyName = "KeyValue";
this.Column14.HeaderText = "主键值";
this.Column14.Name = "Column14";
this.Column14.ToolTipText = "多个值用逗号隔开";
//
// Column15
//
this.Column15.DataPropertyName = "Describe";
this.Column15.HeaderText = "功能描述";
this.Column15.Name = "Column15";
//
// Column16
//
this.Column16.DataPropertyName = "Flag";
this.Column16.HeaderText = "处理标记";
this.Column16.Name = "Column16";
this.Column16.ToolTipText = "未处理/已处理/忽略:默认为\"未处理\"";
//
// Column17
//
this.Column17.DataPropertyName = "CreateDate";
this.Column17.HeaderText = "生成日期";
this.Column17.Name = "Column17";
//
// panel3
//
this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
......@@ -392,6 +455,8 @@
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsbSave,
this.tsbRefresh,
this.toolStripSeparator3,
this.tsbTestService,
this.toolStripSeparator2,
this.tsbDB,
this.tstbLinkString,
......@@ -403,6 +468,29 @@
this.toolStrip1.TabIndex = 1;
this.toolStrip1.Text = "toolStrip1";
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
//
// tstbLinkString
//
this.tstbLinkString.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
this.tstbLinkString.ForeColor = System.Drawing.Color.Green;
this.tstbLinkString.Name = "tstbLinkString";
this.tstbLinkString.ReadOnly = true;
this.tstbLinkString.Size = new System.Drawing.Size(150, 25);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25);
//
// tsbSave
//
this.tsbSave.Image = global::Tools.Properties.Resources.保存;
......@@ -419,10 +507,13 @@
this.tsbRefresh.Size = new System.Drawing.Size(52, 22);
this.tsbRefresh.Text = "刷新";
//
// toolStripSeparator2
// tsbTestService
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
this.tsbTestService.Image = global::Tools.Properties.Resources.测试;
this.tsbTestService.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsbTestService.Name = "tsbTestService";
this.tsbTestService.Size = new System.Drawing.Size(76, 22);
this.tsbTestService.Text = "服务测试";
//
// tsbDB
//
......@@ -432,19 +523,6 @@
this.tsbDB.Size = new System.Drawing.Size(64, 22);
this.tsbDB.Text = "数据库";
//
// tstbLinkString
//
this.tstbLinkString.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F);
this.tstbLinkString.ForeColor = System.Drawing.Color.Green;
this.tstbLinkString.Name = "tstbLinkString";
this.tstbLinkString.ReadOnly = true;
this.tstbLinkString.Size = new System.Drawing.Size(150, 25);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
//
// tsbHelp
//
this.tsbHelp.Image = global::Tools.Properties.Resources.使用说明;
......@@ -453,67 +531,6 @@
this.tsbHelp.Size = new System.Drawing.Size(76, 22);
this.tsbHelp.Text = "使用说明";
//
// Column9
//
this.Column9.DataPropertyName = "IsSelect";
this.Column9.HeaderText = "选择";
this.Column9.Name = "Column9";
this.Column9.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.Column9.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.Column9.Width = 60;
//
// Column10
//
this.Column10.DataPropertyName = "ModelName";
this.Column10.HeaderText = "模块名称";
this.Column10.Name = "Column10";
//
// Column11
//
this.Column11.DataPropertyName = "TypeName";
this.Column11.HeaderText = "检查类型";
this.Column11.Name = "Column11";
//
// Column12
//
this.Column12.DataPropertyName = "TableName";
this.Column12.HeaderText = "表名";
this.Column12.Name = "Column12";
this.Column12.ToolTipText = "多个表名用逗号隔开";
//
// Column13
//
this.Column13.DataPropertyName = "KeyName";
this.Column13.HeaderText = "主键字段";
this.Column13.Name = "Column13";
this.Column13.ToolTipText = "多个字段用逗号隔开";
//
// Column14
//
this.Column14.DataPropertyName = "KeyValue";
this.Column14.HeaderText = "主键值";
this.Column14.Name = "Column14";
this.Column14.ToolTipText = "多个值用逗号隔开";
//
// Column15
//
this.Column15.DataPropertyName = "Describe";
this.Column15.HeaderText = "功能描述";
this.Column15.Name = "Column15";
//
// Column16
//
this.Column16.DataPropertyName = "Flag";
this.Column16.HeaderText = "处理标记";
this.Column16.Name = "Column16";
this.Column16.ToolTipText = "未处理/已处理/忽略:默认为\"未处理\"";
//
// Column17
//
this.Column17.DataPropertyName = "CreateDate";
this.Column17.HeaderText = "生成日期";
this.Column17.Name = "Column17";
//
// wSysChecker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......@@ -593,5 +610,7 @@
private System.Windows.Forms.DataGridViewTextBoxColumn Column15;
private System.Windows.Forms.DataGridViewTextBoxColumn Column16;
private System.Windows.Forms.DataGridViewTextBoxColumn Column17;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripButton tsbTestService;
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
......@@ -96,6 +97,7 @@ namespace Tools.UI
//工具栏-事件
this.tsbSave.Click += TsbSave_Click;
this.tsbRefresh.Click += TsbRefresh_Click;
this.tsbTestService.Click += TsbTestService_Click;
this.tsbDB.Click += TsbDB_Click;
this.tsbHelp.Click += TsbHelp_Click;
//数据表格-事件
......@@ -116,21 +118,54 @@ namespace Tools.UI
{
if (!this.CheckDataSource())
return;
//结束编辑
this.dgvConfig.CommitEdit(DataGridViewDataErrorContexts.Display);
this.dgvConfigDetail.CommitEdit(DataGridViewDataErrorContexts.Display);
this.DataSetEndEdit(this._ds);
//保存配置信息
if (this._ds.HasChanges())
try
{
this.Save();
Utils.Tip($"保存成功!");
}
catch (Exception ex)
{
this._db.SaveData(this._link, this._ds, this.tableList);
Utils.Tip($"保存失败!\r\n{ex.Message}\r\n{ex.StackTrace}");
return;
}
Utils.Tip("保存成功!");
}
private void TsbRefresh_Click(object sender, EventArgs e)
{
this.InitData();
}
private void TsbTestService_Click(object sender, EventArgs e)
{
//先保存:存储过程内部检查是否启用,需要通过数据库判断
this.Save();
//选择执行库
var frm = new wDbSetting();
if (frm.ShowDialog() != DialogResult.OK)
return;
var localLink = frm.LinkModel.LinkString;
//生成语句
var sqlist = new List<string>();
foreach (DataRow r in this._ds.Tables[T_ConfigDetail].Rows)
{
if (r.RowState == DataRowState.Deleted)
continue;
sqlist.Add($"Exec {r["ProcName"]} @SerialNo={r["SerialNo"]};");
}
//计时器
Stopwatch sw = new Stopwatch();
sw.Start();
try
{
this._db.ExecNonSql(localLink, sqlist);
}
catch (Exception ex)
{
Utils.Tip($"测试执行出错!\r\n{ex.Message}\r\n{ex.StackTrace}");
return;
}
sw.Stop();
var second = sw.ElapsedMilliseconds / 1000.0;
Utils.Tip($"测试通过!总耗时{second.ToString("0.##")}秒");
}
private void TsbDB_Click(object sender, EventArgs e)
{
//数据库
......@@ -143,7 +178,7 @@ namespace Tools.UI
}
private void TsbHelp_Click(object sender, EventArgs e)
{
//帮助信息:最后处理
Utils.ShowHelp("syschecker_help");
}
#endregion
......@@ -314,26 +349,43 @@ namespace Tools.UI
return result;
}
/// <summary>
/// 结束数据集编辑
/// 结束编辑
/// </summary>
/// <param name="ds"></param>
private void DataSetEndEdit(DataSet ds)
private void EndEdit()
{
if (ds == null)
if (this._ds == null)
return;
foreach (DataTable dt in ds.Tables)
//数据表格界面提交
this.dgvConfig.CommitEdit(DataGridViewDataErrorContexts.Display);
this.dgvConfigDetail.CommitEdit(DataGridViewDataErrorContexts.Display);
//数据源结束编辑
foreach (DataTable dt in this._ds.Tables)
{
foreach (DataRow r in dt.Rows)
{
if (r.RowState != DataRowState.Deleted
&& r.RowState != DataRowState.Detached)
if (r.RowState != DataRowState.Deleted && r.RowState != DataRowState.Detached)
{
r.EndEdit();
}
}
}
}
/// <summary>
/// 保存配置信息
/// </summary>
private bool Save()
{
//结束编辑
this.EndEdit();
//保存配置信息
bool b = false;
if (this._ds.HasChanges())
{
b = this._db.SaveData(this._link, this._ds, this.tableList);
}
return b;
}
}
}
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