Commit 19864606 authored by 罗显健's avatar 罗显健

【编号:11907】增加打包日志显示

parent ed0c148d
...@@ -128,6 +128,9 @@ namespace Ftt.PatchPack ...@@ -128,6 +128,9 @@ namespace Ftt.PatchPack
string destFileName = Path.Combine(path, file.Name); string destFileName = Path.Combine(path, file.Name);
File.Copy(file.FullName, destFileName, true); File.Copy(file.FullName, destFileName, true);
//源文件有可能是只读的,这里设置属性,后续需要删除文件。2023-03-27 17:53:40 lxj
File.SetAttributes(destFileName, FileAttributes.Normal);
} }
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -34,11 +34,17 @@ ...@@ -34,11 +34,17 @@
this.btnEdit = new System.Windows.Forms.Button(); this.btnEdit = new System.Windows.Forms.Button();
this.lstProject = new System.Windows.Forms.ListView(); this.lstProject = new System.Windows.Forms.ListView();
this.lblNotes = new System.Windows.Forms.Label(); this.lblNotes = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel(); this.pnlTop = new System.Windows.Forms.Panel();
this.ckbShowLog = new System.Windows.Forms.CheckBox();
this.ckbDelHisPack = new System.Windows.Forms.CheckBox(); this.ckbDelHisPack = new System.Windows.Forms.CheckBox();
this.btnOpenDirectory = new System.Windows.Forms.Button(); this.btnOpenDirectory = new System.Windows.Forms.Button();
this.btnDel = new System.Windows.Forms.Button(); this.btnDel = new System.Windows.Forms.Button();
this.panel1.SuspendLayout(); this.pnlLeft = new System.Windows.Forms.Panel();
this.gpbLog = new System.Windows.Forms.GroupBox();
this.txtLog = new System.Windows.Forms.TextBox();
this.pnlTop.SuspendLayout();
this.pnlLeft.SuspendLayout();
this.gpbLog.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnAdd // btnAdd
...@@ -93,7 +99,7 @@ ...@@ -93,7 +99,7 @@
this.lstProject.RightToLeft = System.Windows.Forms.RightToLeft.No; this.lstProject.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.lstProject.RightToLeftLayout = true; this.lstProject.RightToLeftLayout = true;
this.lstProject.ShowGroups = false; this.lstProject.ShowGroups = false;
this.lstProject.Size = new System.Drawing.Size(599, 231); this.lstProject.Size = new System.Drawing.Size(573, 231);
this.lstProject.TabIndex = 10; this.lstProject.TabIndex = 10;
this.lstProject.UseCompatibleStateImageBehavior = false; this.lstProject.UseCompatibleStateImageBehavior = false;
this.lstProject.View = System.Windows.Forms.View.List; this.lstProject.View = System.Windows.Forms.View.List;
...@@ -105,24 +111,38 @@ ...@@ -105,24 +111,38 @@
this.lblNotes.Location = new System.Drawing.Point(0, 289); this.lblNotes.Location = new System.Drawing.Point(0, 289);
this.lblNotes.Name = "lblNotes"; this.lblNotes.Name = "lblNotes";
this.lblNotes.Padding = new System.Windows.Forms.Padding(12, 8, 0, 0); this.lblNotes.Padding = new System.Windows.Forms.Padding(12, 8, 0, 0);
this.lblNotes.Size = new System.Drawing.Size(599, 52); this.lblNotes.Size = new System.Drawing.Size(573, 52);
this.lblNotes.TabIndex = 11; this.lblNotes.TabIndex = 11;
this.lblNotes.Text = "注意:本工具只打包项目设定文件夹内通用文件。。。。。详细内容见源代码"; this.lblNotes.Text = "注意:本工具只打包项目设定文件夹内通用文件。。。。。详细内容见源代码";
// //
// panel1 // pnlTop
// //
this.panel1.Controls.Add(this.ckbDelHisPack); this.pnlTop.Controls.Add(this.ckbShowLog);
this.panel1.Controls.Add(this.btnOpenDirectory); this.pnlTop.Controls.Add(this.ckbDelHisPack);
this.panel1.Controls.Add(this.btnDel); this.pnlTop.Controls.Add(this.btnOpenDirectory);
this.panel1.Controls.Add(this.btnEdit); this.pnlTop.Controls.Add(this.btnDel);
this.panel1.Controls.Add(this.btnPatch); this.pnlTop.Controls.Add(this.btnEdit);
this.panel1.Controls.Add(this.btnAdd); this.pnlTop.Controls.Add(this.btnPatch);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.pnlTop.Controls.Add(this.btnAdd);
this.panel1.Location = new System.Drawing.Point(0, 0); this.pnlTop.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.pnlTop.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1"; this.pnlTop.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.panel1.Size = new System.Drawing.Size(599, 58); this.pnlTop.Name = "pnlTop";
this.panel1.TabIndex = 12; this.pnlTop.Size = new System.Drawing.Size(573, 58);
this.pnlTop.TabIndex = 12;
//
// ckbShowLog
//
this.ckbShowLog.AutoSize = true;
this.ckbShowLog.BackColor = System.Drawing.SystemColors.Control;
this.ckbShowLog.ForeColor = System.Drawing.Color.Blue;
this.ckbShowLog.Location = new System.Drawing.Point(488, 34);
this.ckbShowLog.Name = "ckbShowLog";
this.ckbShowLog.Size = new System.Drawing.Size(75, 21);
this.ckbShowLog.TabIndex = 13;
this.ckbShowLog.Text = "显示日志";
this.ckbShowLog.UseVisualStyleBackColor = false;
this.ckbShowLog.CheckedChanged += new System.EventHandler(this.ckbShowLog_CheckedChanged);
// //
// ckbDelHisPack // ckbDelHisPack
// //
...@@ -142,7 +162,7 @@ ...@@ -142,7 +162,7 @@
// //
this.btnOpenDirectory.BackColor = System.Drawing.SystemColors.Control; this.btnOpenDirectory.BackColor = System.Drawing.SystemColors.Control;
this.btnOpenDirectory.ForeColor = System.Drawing.SystemColors.WindowText; this.btnOpenDirectory.ForeColor = System.Drawing.SystemColors.WindowText;
this.btnOpenDirectory.Location = new System.Drawing.Point(486, 15); this.btnOpenDirectory.Location = new System.Drawing.Point(486, 3);
this.btnOpenDirectory.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.btnOpenDirectory.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.btnOpenDirectory.Name = "btnOpenDirectory"; this.btnOpenDirectory.Name = "btnOpenDirectory";
this.btnOpenDirectory.Size = new System.Drawing.Size(81, 27); this.btnOpenDirectory.Size = new System.Drawing.Size(81, 27);
...@@ -164,14 +184,44 @@ ...@@ -164,14 +184,44 @@
this.btnDel.UseVisualStyleBackColor = false; this.btnDel.UseVisualStyleBackColor = false;
this.btnDel.Click += new System.EventHandler(this.btnDel_Click); this.btnDel.Click += new System.EventHandler(this.btnDel_Click);
// //
// pnlLeft
//
this.pnlLeft.Controls.Add(this.lstProject);
this.pnlLeft.Controls.Add(this.lblNotes);
this.pnlLeft.Controls.Add(this.pnlTop);
this.pnlLeft.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlLeft.Location = new System.Drawing.Point(0, 0);
this.pnlLeft.Name = "pnlLeft";
this.pnlLeft.Size = new System.Drawing.Size(573, 341);
this.pnlLeft.TabIndex = 13;
//
// gpbLog
//
this.gpbLog.Controls.Add(this.txtLog);
this.gpbLog.Dock = System.Windows.Forms.DockStyle.Right;
this.gpbLog.Location = new System.Drawing.Point(573, 0);
this.gpbLog.Name = "gpbLog";
this.gpbLog.Size = new System.Drawing.Size(360, 341);
this.gpbLog.TabIndex = 0;
this.gpbLog.TabStop = false;
this.gpbLog.Text = "************** 操作日志 **************";
//
// txtLog
//
this.txtLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtLog.Location = new System.Drawing.Point(3, 19);
this.txtLog.Multiline = true;
this.txtLog.Name = "txtLog";
this.txtLog.Size = new System.Drawing.Size(354, 319);
this.txtLog.TabIndex = 0;
//
// FrmMain // FrmMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); 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(599, 341); this.ClientSize = new System.Drawing.Size(933, 341);
this.Controls.Add(this.lstProject); this.Controls.Add(this.pnlLeft);
this.Controls.Add(this.panel1); this.Controls.Add(this.gpbLog);
this.Controls.Add(this.lblNotes);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
...@@ -182,8 +232,11 @@ ...@@ -182,8 +232,11 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Feteto更新包辅助工具"; this.Text = "Feteto更新包辅助工具";
this.Load += new System.EventHandler(this.FrmMain_Load); this.Load += new System.EventHandler(this.FrmMain_Load);
this.panel1.ResumeLayout(false); this.pnlTop.ResumeLayout(false);
this.panel1.PerformLayout(); this.pnlTop.PerformLayout();
this.pnlLeft.ResumeLayout(false);
this.gpbLog.ResumeLayout(false);
this.gpbLog.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
...@@ -194,10 +247,14 @@ ...@@ -194,10 +247,14 @@
private System.Windows.Forms.Button btnEdit; private System.Windows.Forms.Button btnEdit;
private System.Windows.Forms.ListView lstProject; private System.Windows.Forms.ListView lstProject;
private System.Windows.Forms.Label lblNotes; private System.Windows.Forms.Label lblNotes;
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel pnlTop;
private System.Windows.Forms.Button btnDel; private System.Windows.Forms.Button btnDel;
private System.Windows.Forms.Button btnOpenDirectory; private System.Windows.Forms.Button btnOpenDirectory;
private System.Windows.Forms.CheckBox ckbDelHisPack; private System.Windows.Forms.CheckBox ckbDelHisPack;
private System.Windows.Forms.Panel pnlLeft;
private System.Windows.Forms.CheckBox ckbShowLog;
private System.Windows.Forms.GroupBox gpbLog;
private System.Windows.Forms.TextBox txtLog;
} }
} }
...@@ -8,6 +8,7 @@ namespace Ftt.PatchPack ...@@ -8,6 +8,7 @@ namespace Ftt.PatchPack
{ {
public partial class FrmMain : Form public partial class FrmMain : Form
{ {
private const int WIDTH_LOG_AREA = 360;
Dictionary<string, Project> projects = new Dictionary<string, Project>(); Dictionary<string, Project> projects = new Dictionary<string, Project>();
...@@ -33,6 +34,9 @@ namespace Ftt.PatchPack ...@@ -33,6 +34,9 @@ namespace Ftt.PatchPack
private void InitForm() private void InitForm()
{ {
gpbLog.Width = WIDTH_LOG_AREA;
LogVisible(false);
projects = ProjectHelp.Read(); projects = ProjectHelp.Read();
if (projects == null) projects = new Dictionary<string, Project>(); if (projects == null) projects = new Dictionary<string, Project>();
foreach (var cli in projects) foreach (var cli in projects)
...@@ -127,10 +131,14 @@ namespace Ftt.PatchPack ...@@ -127,10 +131,14 @@ namespace Ftt.PatchPack
item.Checked = false; item.Checked = false;
item.BackColor = Color.Green; item.BackColor = Color.Green;
success++; success++;
WriteLog($"打包【{item.Text}】成功.");
} }
catch (Exception) catch (Exception ex)
{ {
item.BackColor = Color.Yellow; item.BackColor = Color.Yellow;
WriteLog($"打包【{item.Text}】失败:");
WriteLog(ex.Message);
} }
finally finally
{ {
...@@ -141,10 +149,10 @@ namespace Ftt.PatchPack ...@@ -141,10 +149,10 @@ namespace Ftt.PatchPack
Cursor.Current = Cursors.Default; Cursor.Current = Cursors.Default;
int fail = totalCount - success; int fail = totalCount - success;
if (fail > 0) ckbShowLog.Checked = true;
string strFail = fail == 0 ? "" : $",失败{fail}个"; string strFail = fail == 0 ? "" : $",失败{fail}个";
MessageBox.Show($"打包项目{totalCount}个,成功{success}个 { strFail }。"); MessageBox.Show($"打包项目{totalCount}个,成功{success}个 {strFail}。");
} }
...@@ -157,7 +165,53 @@ namespace Ftt.PatchPack ...@@ -157,7 +165,53 @@ namespace Ftt.PatchPack
{ {
System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory); System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory);
} }
/// <summary>
/// 显示日志
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ckbShowLog_CheckedChanged(object sender, EventArgs e)
{
LogVisible(ckbShowLog.Checked);
}
#endregion #endregion
#region 内部方法
private void LogVisible(bool visible)
{
if (this.InvokeRequired)
{
this.BeginInvoke(new Action<bool>(LogVisible), visible);
}
else
{
if (visible)
this.Width += gpbLog.Width;
else
this.Width -= gpbLog.Width;
gpbLog.Visible = visible;
}
}
/// <summary>
/// 写日志
/// </summary>
/// <param name="content"></param>
private void WriteLog(string content)
{
if (this.InvokeRequired)
{
this.BeginInvoke(new Action<string>(WriteLog), content);
}
else
{
txtLog.AppendText(content + "\r\n");
}
}
#endregion
} }
} }
...@@ -117,36 +117,6 @@ ...@@ -117,36 +117,6 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="btnAdd.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="btnPatch.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="btnEdit.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lstProject.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblNotes.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="panel1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ckbDelHisPack.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="btnOpenDirectory.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="btnDel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
......
...@@ -193,12 +193,14 @@ namespace Ftt.PatchPack ...@@ -193,12 +193,14 @@ namespace Ftt.PatchPack
List<PatchFileInfo> valid = new List<PatchFileInfo>(); List<PatchFileInfo> valid = new List<PatchFileInfo>();
var dires = this.GetDbPatchDirectory(PatchTimeFrame_Sql); // 取有效期内的文件夹,文件夹内的文件不用判断时间 var dires = this.GetDbPatchDirectory(PatchTimeFrame_Sql); // 取有效期内的文件夹,文件夹内的文件不用判断时间
if (dires != null)// 有返回null的情况。
string path = Path.Combine(AbsoluteRootDirectory, RelativeDbFilePath);
foreach (var dire in dires)
{ {
valid.AddRange(GetValidPatchFile(dire.FullName, "*.sql", SearchOption.AllDirectories, path, "DB", -1)); // 脚本文件夹里的文件永久有效。 string path = Path.Combine(AbsoluteRootDirectory, RelativeDbFilePath);
foreach (var dire in dires)
{
valid.AddRange(GetValidPatchFile(dire.FullName, "*.sql", SearchOption.AllDirectories, path, "DB", -1)); // 脚本文件夹里的文件永久有效。
}
} }
return valid; return valid;
......
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