Пример #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            AutoUpdater.AutoUpdater au = new AutoUpdater.AutoUpdater();
            try
            {
                au.Update();
            }
            catch (WebException exp)
            {
                MessageBox.Show(String.Format("无法找到指定资源/n/n{0}", exp.Message), "自动升级", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (XmlException exp)
            {
                MessageBox.Show(String.Format("下载的升级文件有错误/n/n{0}", exp.Message), "自动升级", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (NotSupportedException exp)
            {
                MessageBox.Show(String.Format("升级地址配置错误/n/n{0}", exp.Message), "自动升级", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (ArgumentException exp)
            {
                MessageBox.Show(String.Format("下载的升级文件有错误/n/n{0}", exp.Message), "自动升级", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception exp)
            {
                MessageBox.Show(String.Format("升级过程中发生错误/n/n{0}", exp.Message), "自动升级", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Application.Run(new Form1());
        }
Пример #2
0
        static void Main()
        {
            Application.ThreadException += Application_ThreadException;

            var t = new Thread(()=>{
                while (true) {
                    bool bHasError = false;
                    IAutoUpdater autoUpdater = new AutoUpdater();
                    try {
                        autoUpdater.CheckUpdate();
                    } catch (Exception e) {
                        var errmsg = string.Format("{0}{1}{2}", DateTime.Now + Environment.NewLine, e.Message + Environment.NewLine, e.StackTrace + Environment.NewLine);
                        File.AppendAllText(apppath, errmsg);
                        bHasError = true;
                    } finally {
                        if (bHasError == true) {
                            try {
                                autoUpdater.RollBack();
                            } catch (Exception) {
                                //Log the message to your file or database
                            }
                        }
                    }

                    Thread.Sleep(10 * 1000);
                }
            });
            t.Start();
            t.Join();
        }
Пример #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();
            }
        }
Пример #4
0
        public MainForm()
        {
            mainDriver             = new Driver();
            updater                = new AutoUpdater.AutoUpdater();
            updater.currentVersion = version;
            InitializeComponent();
            Driver.Log             += Driver_Log;
            JoystickHelper.Log     += Driver_Log;
            SystemHelper.Log       += Driver_Log;
            Configuration.Log      += Driver_Log;
            Configuration.StopProc += btnStop_Click;
            this.FormClosing       += MainForm_FormClosing;
            this.FormClosed        += MainForm_FormClosed;

            Configuration.PropogateSettings();
            bool updating = false;

            if (autoUpdate && MainForm.updater.updateAvailable)
            {
                Update u = new Update();
                if (u.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
                {
                    updating = true;
                }
            }
            //quietly finish the constructor if we're updating.
            if (!updating)
            {
                SystemHelper.checkForMissingDrivers();
                if (disablePortsOnExit)
                {
                    SystemHelper.EnablevJoyDLL();
                }
                if (startInTray)
                {
                    this.Hide();
                }
                else
                {
                    this.Show();
                }
                if (autoStart)
                {
                    btnStart_Click(null, EventArgs.Empty);
                }
            }
        }
Пример #5
0
 private void TimerElapsed(object sender, ElapsedEventArgs e)
 {
     _timer.Stop();
     AutoUpdater.Start();
 }