系统自动更新AutoUpdate

上传人:博****1 文档编号:493570122 上传时间:2023-02-20 格式:DOCX 页数:12 大小:58.46KB
返回 下载 相关 举报
系统自动更新AutoUpdate_第1页
第1页 / 共12页
系统自动更新AutoUpdate_第2页
第2页 / 共12页
系统自动更新AutoUpdate_第3页
第3页 / 共12页
系统自动更新AutoUpdate_第4页
第4页 / 共12页
系统自动更新AutoUpdate_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《系统自动更新AutoUpdate》由会员分享,可在线阅读,更多相关《系统自动更新AutoUpdate(12页珍藏版)》请在金锄头文库上搜索。

1、系统自动更新分为插件更新和系统主程序更新,其中插件更新需要用户手动检查,系统主程序更新在程序启动时检查一般情况下不更新主程序配置文件,因为主程序配置文件里包含了用户个性化配置 如果更新主程序配置文件就会清空用户配置。2. 更新的前提条件如下:(1) 需要配置IIS服务器提供Web服务,供AutoUpdate.exe从服务器上下载更 新文件。(2) 在程序中设置配置文件的路径:http:/192.168.1.100/UFVideo/CSFiles/UpdateXMLFile.xml配置文件的内容如下:13http:/192.168.1.100/UFVideo/CSFiles/UpdateMain

2、Files.zip 配置文件提供了两个值一是最新的版本号13v/Ver,二是更新文件的下载路 径 http:/192.168.1.100/UFVideo/CSFiles/UpdateMainFiles.zipv/Path3. AutoUpdate.exe 的工作流程(1)系统登录时主程序检查版本,主程序根据设置配置文件的服务器 XML 路径 检查比较自身版本和服务器提供版本是否一致,如果低于服务器版本就提示用户更 新。 用户根据提示同意更新后由主程序启动AutoUpdate.exe,并且在启动时提供 三个参数:最新的版本号、主程序名称、下载文件路径。(3)AutoUpdate.exe 启动后就

3、开始根据提供的下载路径参数下载更新文件。(4)更新文件下载完成后解压到自身的启动目录中,完成文件更新。(5)更新主程序配置文件中的版本号。(6)重新启动主程序,完成更新任务。using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.IO;using DevExpress.XtraEditors;using Syst

4、em.Threading;using Shell32;using System.Configuration;namespace AutoUpdatepublic partial class XtraFormUpdate : DevExpress.XtraEditors.XtraFormpublic XtraFormUpdate(string agr)InitializeComponent(); this.ShowInTaskbar = false;this.MaximizeBox = false;this.MinimizeBox = false;this.StartPosition = Sys

5、tem.Windows.Forms.FormStartPosition.CenterScreen; public XtraFormUpdate()InitializeComponent(); this.ShowInTaskbar = false;this.MaximizeBox = false;this.MinimizeBox = false;this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; static string HttpPath = ;static string Ver = ;static

6、 string strProcName = ;static class ProgramSTAThreadstatic void Main(string agr)if (agr.Length = 1)string a = agr0.ToString().Split(|);HttpPath = a0.ToString();Ver = a1.ToString();strProcName = a2.ToString();XtraFormUpdate form = new XtraFormUpdate(agr); Application.Run(form);elseApplication.Run(new

7、 XtraFormUpdate();/ / 关闭主进程/ /param name=ProcessName主进程名称/parampublic void KillProcess(string ProcessName)System.Diagnostics.Process ps = System.Diagnostics.Process.GetProcesses(); foreach (System.Diagnostics.Process p in ps)/MessageBox.Show(p.ProcessName);if (p.ProcessName.ToString() = ProcessName)

8、p.Kill();break;public void DownFile(string UpdateHttpPath)trystring TempPath = System.IO.Path.GetTempPath() + GFK;if (System.IO.Directory.Exists(TempPath) = true)System.IO.Directory.Delete(TempPath, true);if (System.IO.Directory.Exists(TempPath) = false) System.IO.Directory.CreateDirectory(TempPath)

9、; if (UpdateHttpPath != null & UpdateHttpPath != )string FilePath = TempPath + + HttpPath.Substring(HttpPath.LastIndexOf(/) + 1);NewHttpDown nhd =new NewHttpDown(); nhd.Dock = DockStyle.Top;/ SystemNewVer = int.Parse(NewVer);for (int i = 0; i panelControl1.Controls.Count; i+) nhd.Top = 150 + i * 30;

10、 / 新增控件布局nhd.RemoveControls += new NewHttpDown.RemoveControlsdelegate(下载完 执行);nhd.scFileName = FilePath; nhd.scUrl = HttpPath; panelControl1.Controls.Add(nhd);elseDevExpress.XtraEditors. XtraMessageBox.Show(更新地址不正确,请咨询 IT 部获取 正确的更新地址。, 操作提示);catch public delegate void 下载 delegate(DevExpress.XtraEdit

11、ors.XtraUserControl b); 下载 delegate 下载 OK;public void 下载完执行(DevExpress.XtraEditors. XtraUserControl b)tryif (InvokeRequired)Invoke(new 下载 delegate(下载完执行),b);elsetry/ simpleButton3.Enabled = true;string Text = b.Tag.ToString();if (Text != labelControl2)string PPath = Text.Replace(文件保存路径:,);string Fil

12、eName = PPath.Substring(PPath.LastIndexOf() + 1);UpdateSys(PPath);string Path = PPath.Replace(FileName, );DevExpress.XtraEditors.SimpleButton bt = new DevExpress.XtraEditors.SimpleButton();bt.Text = PPath;bt.Tag = Path;bt.ToolTip = Text + rn + 本次升级任务下载的文件;bt.Dock = DockStyle.Top;bt.Appearance.ForeCo

13、lor = System.Drawing.Color.Blue; bt.Appearance.Options.UseFont = true; bt.Appearance.Options.UseForeColor = true; bt.Appearance.TextOptions.HAlignment =DevExpress.Utils.HorzAlignment.Near;bt.Click += new System.EventHandler(link);for (int i = 0; i panelControl1.Controls.Count; i+) bt.Top = i * 30; /

14、生成一个类似超链接的按钮,打开文件下载的位置panelControl1.Controls.Add(bt);panelControl1.Controls.Remove(b);/ DevExpress.XtraEditors.XtraMessageBox.Show(本次升级任务完成,自动重启 主程序。, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information);WriteConfig(Application.StartupPath + + strProcName + .exe, Version, Ver);System.Diagnostics.Process.Start(Application.StartupPath + + strProcName + .exe);KillProcess(AutoUpdate);catch catchDevExpress.XtraEditors. XtraMessageBox.Show(尚有未完成的下载任务,下次可继续下载。, 提示, MessageBoxButtons.OK, Me

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号