Browse Source

v6.5.2015.0701 升级自动更新机制,从网站自动更新

pull/2/head
nnhy 10 years ago
parent
commit
5f11f04011
  1. 37
      Program.cs
  2. 6
      Properties/AssemblyInfo.cs
  3. 4
      UpdateInfo.txt
  4. 18
      Windows/FrmMain.cs
  5. 2
      XCoder.csproj

37
Program.cs

@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using NewLife;
using NewLife.Log;
using NewLife.Net;
using NewLife.Threading;
using NewLife.Xml;
using XCode.DataAccessLayer;
@ -35,7 +37,7 @@ namespace XCoder
try
{
Update();
Update(true);
new TimerX(s => Runtime.ReleaseMemory(), null, 5000, 10000);
}
@ -47,6 +49,14 @@ namespace XCoder
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMDI());
// 此时执行自动更新
var up = _upgrade;
if (up != null)
{
_upgrade = null;
up.Update();
}
}
/// <summary>参数启动</summary>
@ -102,21 +112,30 @@ namespace XCoder
}
}
static void Update(Boolean isAsync = true)
static Upgrade _upgrade;
static void Update(Boolean isAsync)
{
if (!isAsync) XTrace.WriteLine("自动更新!");
if (XConfig.Current.LastUpdate.Date < DateTime.Now.Date)
{
XConfig.Current.LastUpdate = DateTime.Now;
var au = new AutoUpdate();
if (isAsync)
au.UpdateAsync();
else
au.Update();
var root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var up = new Upgrade();
if (XConfig.Current.Debug) up.Log = XTrace.Log;
up.Name = "XCoder";
up.Server = "http://www.newlifex.com/showtopic-260.aspx";
up.UpdatePath = root.CombinePath(up.UpdatePath);
if (up.Check())
{
up.Download();
if (!isAsync)
up.Update();
else
// 留到执行完成以后自动更新
_upgrade = up;
}
}
var ProcessHelper = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NewLife.ProcessHelper.exe");
if (File.Exists(ProcessHelper)) File.Delete(ProcessHelper);
if (isAsync)
{

6
Properties/AssemblyInfo.cs

@ -25,10 +25,12 @@ using System.Runtime.InteropServices;
// 内部版本号
// 修订号
//
[assembly: AssemblyVersion("6.4.*")]
[assembly: AssemblyFileVersion("6.4.2015.0519")]
[assembly: AssemblyVersion("6.5.*")]
[assembly: AssemblyFileVersion("6.5.2015.0701")]
/*
* v6.5.2015.0701
*
* v6.4.2015.0519
*
* v6.3.2015.0511

4
UpdateInfo.txt

@ -1,4 +1,6 @@
v6.4.2015.0519 改进串口调试工具,显示设备友好名
v6.5.2015.0701 升级自动更新机制,从网站自动更新
v6.4.2015.0519 改进串口调试工具,显示设备友好名
v6.3.2015.0511 改进网络调试工具,列出网络库的所有网络服务器

18
Windows/FrmMain.cs

@ -10,6 +10,7 @@ using System.Reflection;
using System.Text;
using System.Windows.Forms;
using NewLife.Log;
using NewLife.Net;
using NewLife.Reflection;
using NewLife.Threading;
using XCode.DataAccessLayer;
@ -615,10 +616,19 @@ namespace XCoder
try
{
var au = new AutoUpdate();
au.Update();
MessageBox.Show("没有可用更新!", "自动更新");
var root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var up = new Upgrade();
if (XConfig.Current.Debug) up.Log = XTrace.Log;
up.Name = "XCoder";
up.Server = "http://www.newlifex.com/showtopic-260.aspx";
up.UpdatePath = root.CombinePath(up.UpdatePath);
if (up.Check())
{
up.Download();
up.Update();
}
else
MessageBox.Show("没有可用更新!", "自动更新");
}
catch (Exception ex)
{

2
XCoder.csproj

@ -69,7 +69,6 @@
<Compile Include="NewModelForm\AddTable.Designer.cs">
<DependentUpon>AddTable.cs</DependentUpon>
</Compile>
<Compile Include="Network\AutoUpdate.cs" />
<Compile Include="Network\BingTranslate.cs" />
<Compile Include="Engine\FileSource.cs" />
<Compile Include="Engine\XConfig.cs" />
@ -247,7 +246,6 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="leaf.ico" />
<EmbeddedResource Include="NewLife.ProcessHelper.exe" />
<EmbeddedResource Include="Template\页面\类名.aspx" />
<EmbeddedResource Include="Template\页面\类名Form.aspx" />
<EmbeddedResource Include="UpdateInfo.txt" />

Loading…
Cancel
Save