ab56a9bcf7
SVN-Revision: r240
133 lines
3.9 KiB
C#
133 lines
3.9 KiB
C#
/******************************
|
|
* 说明:自动升级中间程序
|
|
* 创建人:龚宇超
|
|
* 创建日期:2018-02-23
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Lskj.AutoUpdate;
|
|
using System.Net;
|
|
using System.IO;
|
|
|
|
namespace Lskj.Update
|
|
{
|
|
/// <summary>
|
|
/// 自动升级中间程序
|
|
/// </summary>
|
|
public partial class frmMain : Form
|
|
{
|
|
bool isMes = false;
|
|
string updateUrl = string.Empty;
|
|
|
|
public frmMain()
|
|
: this("", "", "")
|
|
{
|
|
|
|
}
|
|
|
|
public frmMain(string _isMes, string server, string database)
|
|
{
|
|
InitializeComponent();
|
|
|
|
if (!string.IsNullOrEmpty(server) && !string.IsNullOrEmpty(database))
|
|
{
|
|
SQLUtil.mConnStr = string.Format("Server={0};Database={1};Persist Security Info=True;User ID=lserpAdmin;Password=lserp110;Connection Timeout=5;pooling=false", server, database);
|
|
updateUrl = SQLUtil.ExecuteDataTable("select UpdateAddress from p_systemtab").Rows[0][0] + "";
|
|
}
|
|
isMes = (_isMes + "").Equals("1");
|
|
this.Hide();
|
|
this.StartBackGroundDownLoad();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:后台下载</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void StartBackGroundDownLoad()
|
|
{
|
|
if (string.IsNullOrEmpty(updateUrl))
|
|
{
|
|
bool isUpdateSucess = false;
|
|
ProcessManager pm = new ProcessManager();
|
|
pm.InitUpdateEnvironment();
|
|
IAutoUpdater updater = new AutoUpdater();
|
|
try
|
|
{
|
|
updater.Update();
|
|
isUpdateSucess = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("更新失败\r\n" + ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (!isUpdateSucess)
|
|
{
|
|
try
|
|
{
|
|
updater.RollBack();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
pm.StartProcess(isMes);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bool isUpdateSucess = false;
|
|
ProcessManager pm = new ProcessManager();
|
|
pm.InitUpdateEnvironment();
|
|
IAutoUpdater updater = new AutoUpdater(updateUrl, false);
|
|
try
|
|
{
|
|
updater.Update();
|
|
isUpdateSucess = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("更新失败\r\n" + ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (!isUpdateSucess)
|
|
{
|
|
try
|
|
{
|
|
updater.RollBack();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(updateUrl))
|
|
pm.StartProcess(isMes);
|
|
else
|
|
pm.CloseExe(ConstModel.LS_UPDATE_NAME);
|
|
}
|
|
}
|
|
}
|
|
private void frmMain_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|