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

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

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