|
|
@@ -40,38 +40,47 @@ namespace UAS_AutoUpdate
|
|
|
doc.AppendChild(xeRoot);
|
|
|
doc.Save(ConfigFile);
|
|
|
}
|
|
|
- WebClient wc = new WebClient();
|
|
|
- wc.DownloadFile(new Uri(GetCacheData(ConfigFile, "ServerConfigPath").ToString()), ServerConfigFile);
|
|
|
- //服务器获取的配置文件
|
|
|
- Version ver1 = new Version(GetCacheData(ServerConfigFile, "Version").ToString());
|
|
|
- //本地的配置文件
|
|
|
- Version ver2 = new Version(GetCacheData(ConfigFile, "Version").ToString());
|
|
|
- //进行版本的比较
|
|
|
- if (ver1 > ver2)
|
|
|
+ try
|
|
|
{
|
|
|
- Process[] pro = Process.GetProcessesByName("UAS_MES_NEW");
|
|
|
- if (pro.Length > 0)
|
|
|
+ WebClient wc = new WebClient();
|
|
|
+ wc.DownloadFile(new Uri(GetCacheData(ConfigFile, "ServerConfigPath").ToString()), ServerConfigFile);
|
|
|
+ //服务器获取的配置文件
|
|
|
+ Version ver1 = new Version(GetCacheData(ServerConfigFile, "Version").ToString());
|
|
|
+ //本地的配置文件
|
|
|
+ Version ver2 = new Version(GetCacheData(ConfigFile, "Version").ToString());
|
|
|
+ //进行版本的比较
|
|
|
+ if (ver1 > ver2)
|
|
|
{
|
|
|
- string CloseProcess = MessageBox.Show(this.ParentForm, "检测到程序仍在运行,是否关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
|
|
|
- if (CloseProcess == "Yes")
|
|
|
+ Process[] pro = Process.GetProcessesByName("UAS_MES_NEW");
|
|
|
+ if (pro.Length > 0)
|
|
|
{
|
|
|
- for (int i = 0; i < pro.Length; i++)
|
|
|
+ string CloseProcess = MessageBox.Show(this.ParentForm, "检测到程序仍在运行,是否关闭", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
|
|
|
+ if (CloseProcess == "Yes")
|
|
|
{
|
|
|
- Process.GetProcessById(pro[i].Id).Kill();
|
|
|
+ for (int i = 0; i < pro.Length; i++)
|
|
|
+ {
|
|
|
+ Process.GetProcessById(pro[i].Id).Kill();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CloseWhenFinished = true;
|
|
|
+ Close();
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- CloseWhenFinished = true;
|
|
|
- Close();
|
|
|
- return;
|
|
|
- }
|
|
|
+ wc.DownloadProgressChanged += Wc_DownloadProgressChanged;
|
|
|
+ wc.DownloadFileAsync(new Uri(GetCacheData(ConfigFile, "UpdatePath").ToString()), "UAS_MES.zip");
|
|
|
+ SetCacheData(ConfigFile, "Version", ver1.ToString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Process p = Process.Start("UAS_MES_NEW.exe");
|
|
|
+ CloseWhenFinished = true;
|
|
|
+ Close();
|
|
|
}
|
|
|
- wc.DownloadProgressChanged += Wc_DownloadProgressChanged;
|
|
|
- wc.DownloadFileAsync(new Uri(GetCacheData(ConfigFile, "UpdatePath").ToString()), "UAS_MES.zip");
|
|
|
- SetCacheData(ConfigFile, "Version", ver1.ToString());
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception)
|
|
|
{
|
|
|
Process p = Process.Start("UAS_MES_NEW.exe");
|
|
|
CloseWhenFinished = true;
|