Commit 988d4a63 authored by 罗显健's avatar 罗显健

1.更新器用系统默认应用打开sql文件。2.工具升级程序更新进度信息调整

parent 29829eb5
using ICSharpCode.SharpZipLib.Zip;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
......@@ -72,8 +67,8 @@ namespace AutoUpdate
private void AppUpdate()
{
string link = this.GetDbLinkString204("FTT_Work");
DataTable dt = this.GetDataTable(link, "SELECT TOP 1 * FROM dbo.FTT_AutoUpdate ORDER BY UDate DESC", "FTT_AutoUpdate");
var dt = GetPackageData();
this.AddProcessText(80);
if (dt.DefaultView.Count > 0)
{
//结束原进程
......@@ -85,30 +80,68 @@ namespace AutoUpdate
p.Kill();
}
}
this.AddProcessText(10);
this.AddProcessText(80);
//获取更新数据
var drv = dt.DefaultView[0];
var fileName = drv["UName"].ToString();
var bytes = drv["UData"] as byte[];
//默认解压覆盖指定目录
var fileFullName = $@"{this._path}\{fileName}";
this.AddProcessText(30);
this.AddProcessText(85);
//创建本地更新包
File.WriteAllBytes(fileFullName, bytes);
this.AddProcessText(60);
this.AddProcessText(90);
//解压更新包到指定目录
this.ZipDecompress(fileFullName, this._path);
this.AddProcessText(90);
this.AddProcessText(95);
//删除更新包
File.Delete(fileFullName);
this.AddProcessText(100);
}
}
private DataTable GetPackageData()
{
string link = this.GetDbLinkString204("FTT_Work");
var task = Task.Run(() =>
{
return this.GetDataTable(link, "SELECT TOP 1 * FROM dbo.FTT_AutoUpdate ORDER BY UDate DESC", "FTT_AutoUpdate");
});
var progress = 0;
while (!task.IsCompleted)
{
Thread.Sleep(100);
Application.DoEvents();
AddProcessText("正在下载更新包", progress++ / 10, true, 79);
}
return task.Result;
}
private void AddProcessText(int value)
{
this.textBox1.Text += $"进度完成{value}%\r\n";
textBox1.Invoke(new MethodInvoker(() =>
{
textBox1.Text += $"进度完成{value}%\r\n";
}));
}
private void AddProcessText(string processText, int value, bool isClearn = false, int maxValue = 100)
{
if (value >= maxValue) value = maxValue;
if (processText == null) processText = "进度完成";
textBox1.Invoke(new MethodInvoker(() =>
{
if (isClearn) textBox1.Text = "";
textBox1.Text += $"{processText}{value}%\r\n";
}));
}
#region 工具方法
/// <summary>
......
......@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FTT-Tools")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.*")]
......@@ -11,7 +11,7 @@
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<Deterministic>false</Deterministic>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
......
......@@ -219,7 +219,8 @@ namespace UpdateExecuter
var fileFullName = (listViewMsg.SelectedItems[0] as ListViewItem).SubItems[2].Text;
if (!string.IsNullOrEmpty(fileFullName)) Process.Start("notepad.exe", fileFullName);
//以操作系统默认应用打开文件。
if (!string.IsNullOrEmpty(fileFullName)) Process.Start(fileFullName);
}
/// <summary>
......
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