Commit 93d4ea90 authored by 罗显健's avatar 罗显健

1.优化打包工具、脚本执行工具: 配置文件迁移到Config目录中

2.自动更新程序优化
parent dda11c52
......@@ -8,9 +8,6 @@
<add key="PatchTimeFrame_Dll" value="48"/>
<add key="PatchTimeFrame_Sql" value="720"/>
<add key="PatchTimeFrame_Xml" value="720"/>
<add key="PatchTimeFrame_Xml" value="720"/>
<!--是否排除.pdb文件。1:排除,其他包含。-->
<add key="Exclude_PDB" value="1"/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
......
......@@ -23,6 +23,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......
......@@ -16,6 +16,11 @@ namespace AutoUpdate
string _exeName = ""; //程序名称(即进程名称)
string _exportName = "AppHome"; //程序导出路径,此默认为AppHome
/// <summary>
/// 更新结果,反馈给调用程序
/// </summary>
private bool updateSuccess = false;
public Form1(string[] args)
{
InitializeComponent();
......@@ -57,7 +62,7 @@ namespace AutoUpdate
ProcessStartInfo info = new ProcessStartInfo()
{
FileName = startup,
Arguments = "1",
Arguments = updateSuccess ? "1" : "0", // 更新成功携带参数1,反之0.
UseShellExecute = false,
RedirectStandardError = true,
};
......@@ -68,7 +73,7 @@ namespace AutoUpdate
private void AppUpdate()
{
var dt = GetPackageData();
this.AddProcessText(80);
this.AddProcessText(75);
if (dt.DefaultView.Count > 0)
{
//结束原进程
......@@ -97,6 +102,12 @@ namespace AutoUpdate
//删除更新包
File.Delete(fileFullName);
this.AddProcessText(100);
updateSuccess = true;
}
else
{
MessageBox.Show("更新失败,继续使用当前版本!");
}
}
......@@ -112,10 +123,12 @@ namespace AutoUpdate
while (!task.IsCompleted)
{
Thread.Sleep(100);
Application.DoEvents();
AddProcessText("正在下载更新包", progress++ / 10, true, 79);
AddProcessText("正在下载更新包", progress++ / 10, true, 100);
Application.DoEvents();
}
AddProcessText("更新包下载完成", 100, true);
return task.Result;
}
......@@ -161,8 +174,8 @@ namespace AutoUpdate
{
conn = new SqlConnection(strLink);
conn.Open();
var ada = new SqlDataAdapter(strSql, conn);
SetCommandTimeout(ada, 600); // 默认30秒,与服务器网络不畅的情况下会下载失败,设置10分钟
if (Schema) ada.FillSchema(dt, SchemaType.Mapped);//取出数据结构
ada.Fill(dt);//填充数据
}
......@@ -223,6 +236,31 @@ namespace AutoUpdate
}
}
#region 设置Command超时时间
/// <summary>
/// 设置Command超时时间
/// </summary>
/// <param name="sqlDataAdapter"></param>
/// <param name="seconds"></param>
private void SetCommandTimeout(SqlDataAdapter sqlDataAdapter, int seconds)
{
SetCommandTimeout(sqlDataAdapter.SelectCommand, seconds);
SetCommandTimeout(sqlDataAdapter.InsertCommand, seconds);
SetCommandTimeout(sqlDataAdapter.UpdateCommand, seconds);
SetCommandTimeout(sqlDataAdapter.DeleteCommand, seconds);
}
/// <summary>
/// 设置Command超时时间
/// </summary>
/// <param name="sqlCommand"></param>
/// <param name="seconds"></param>
private void SetCommandTimeout(SqlCommand sqlCommand, int seconds)
{
if (sqlCommand != null) sqlCommand.CommandTimeout = seconds;
}
#endregion
#endregion
}
}
......@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AutoUpdate")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[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.8.17.24")]
......@@ -8,9 +8,6 @@
<add key="PatchTimeFrame_Dll" value="48"/>
<add key="PatchTimeFrame_Sql" value="720"/>
<add key="PatchTimeFrame_Xml" value="720"/>
<add key="PatchTimeFrame_Xml" value="720"/>
<!--是否排除.pdb文件。1:排除,其他包含。-->
<add key="Exclude_PDB" value="1"/>
<add key="ClientSettingsProvider.ServiceUri" value=""/>
......
......@@ -37,6 +37,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......
......@@ -399,10 +399,23 @@ namespace Ftt.PatchPack
/// </summary>
public class ProjectHelp
{
static private string fileName = "project.json";
static private string fileName = @"project.json";
static private Encoding encoding = Encoding.Default;
static string FilePath { get { return Path.Combine(Application.StartupPath, fileName); } }
static ProjectHelp()
{
#region 统一调整配置文件的位置,并把已存在文件迁移过去。下个版本可以删除,并修改 fileName = @"config\project.json";
var oldPath = FilePath;
fileName = @"config\project.json";
if (File.Exists(oldPath))
{
File.Copy(oldPath, FilePath, true);
File.Delete(oldPath);
}
#endregion
}
public static Dictionary<string, Project> Read()
{
Dictionary<string, Project> keyValues = new Dictionary<string, Project>();
......
......@@ -9,7 +9,7 @@ namespace UpdateExecuter.Helper
public static class ClientHelp
{
static private string fileName = "db.json";
static private string fileName = @"db.json";
static string FilePath { get { return Path.Combine(Application.StartupPath, fileName); } }
......@@ -17,11 +17,19 @@ namespace UpdateExecuter.Helper
static ClientHelp()
{
#region 统一调整配置文件的位置,并把已存在文件迁移过去。下个版本可以删除,并修改 fileName = @"config\db.json";
var oldPath = FilePath;
fileName = @"config\db.json";
if (File.Exists(oldPath))
{
File.Copy(oldPath, FilePath, true);
File.Delete(oldPath);
}
#endregion
Init();
}
#region 私有操作
private static Dictionary<string, Client> Init()
......@@ -43,8 +51,6 @@ namespace UpdateExecuter.Helper
#endregion
/// <summary>
/// 返回用户信息
/// </summary>
......@@ -69,8 +75,6 @@ namespace UpdateExecuter.Helper
return true;
}
/// <summary>
/// 序列化保存
/// </summary>
......@@ -88,8 +92,5 @@ namespace UpdateExecuter.Helper
}
return true;
}
}
}
\ No newline at end of file
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