Exemple #1
0
        /// <summary>
        /// 点击稍后更新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClose_Click(object sender, EventArgs e)
        {
            //关掉主程序,还是先杀掉以前的进程,避免出现死进程
            OperProcess oper = new OperProcess();

            oper.InitUpdateEnvironment();
        }
Exemple #2
0
        /// <summary>
        /// 判断用户是否做过点击更新操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("更新将强制关闭已经打开的程序,是否继续!", "警告提醒", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) == DialogResult.OK)
            {
                //关掉主程序
                OperProcess oper = new OperProcess();
                oper.InitUpdateEnvironment();


                Config config = Config.LoadConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FILENAME));
                config.IsUpdate = true;
                config.SaveConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FILENAME));
            }
        }
Exemple #3
0
        /// <summary>
        /// 检测更新
        /// </summary>
        static void InitCheckUpdate()
        {
            bool         bHasError   = false;
            IAutoUpdater autoUpdater = new AutoUpdater.AutoUpdater();

            try
            {
                autoUpdater.Update();
            }
            catch (WebException exp)
            {
                MessageBox.Show("服务器连接失败");
                bHasError = true;
            }
            catch (XmlException exp)
            {
                bHasError = true;
                MessageBox.Show("下载更新文件错误");
            }
            catch (NotSupportedException exp)
            {
                bHasError = true;
                MessageBox.Show("升级文件配置错误");
            }
            catch (ArgumentException exp)
            {
                bHasError = true;
                MessageBox.Show("下载升级文件错误");
            }
            catch (Exception exp)
            {
                bHasError = true;
                MessageBox.Show("更新过程中出现错误");
            }
            finally
            {
                if (bHasError == true)
                {
                    try
                    {
                        autoUpdater.RollBack();
                    }
                    catch { }
                }
                OperProcess op = new OperProcess();
                //启动进程
                op.StartProcess();
            }
        }