Esempio n. 1
0
        /// <summary>
        /// After the background worker is done, prompt to update if there is one
        /// </summary>
        private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // If there is a file on the server
            if (!e.Cancelled)
            {
                AutoUpdateXml update = (AutoUpdateXml)e.Result;

                // Check if the update is not null and is a newer version than the current application
                if (update != null && update.IsNewerThan(this.applicationInfo.ApplicationAssembly.GetName().Version))
                {
                    // Ask to accept the update
                    if (new AutoUpdateAcceptForm(this.applicationInfo, update).ShowDialog(this.applicationInfo.Context) == DialogResult.Yes)
                    {
                        this.DownloadUpdate(update);                         // Do the update
                    }
                }
                else
                {
                    if (!autoCheck)
                    {
                        MessageBoxEx.Show(this.applicationInfo.Context, tools.GetString("autoUpdater_result_latest"));
                    }
                }
            }
            else
            {
                MessageBoxEx.Show(this.applicationInfo.Context, tools.GetString("autoUpdater_result_none"));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Downloads update and installs the update
        /// </summary>
        /// <param name="update">The update xml info</param>
        private void DownloadUpdate(AutoUpdateXml update)
        {
            AutoUpdateDownloadForm form   = new AutoUpdateDownloadForm(this.applicationInfo, update.Uri, update.MD5, this.applicationInfo.ApplicationIcon);
            DialogResult           result = form.ShowDialog(this.applicationInfo.Context);

            // Download update
            if (result == DialogResult.OK)
            {
                string currentPath = this.applicationInfo.ApplicationAssembly.Location;
                string newPath     = Path.GetDirectoryName(currentPath) + "\\" + update.FileName;

                // "Install" it
                AutoClosingMessageBox.Show(this.applicationInfo.Context,
                                           tools.GetString("autoUpdater_msg_success"),
                                           tools.GetString("autoUpdater_msg_success_title"),
                                           5000);
                UpdateApplication(form.TempFilePath, currentPath, newPath, update.LaunchArgs);

                Application.Exit();
            }
            else if (result == DialogResult.Abort)
            {
                MessageBoxEx.Show(this.applicationInfo.Context,
                                  tools.GetString("autoUpdater_msg_terminated"),
                                  tools.GetString("autoUpdater_msg_terminated_title"),
                                  MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBoxEx.Show(this.applicationInfo.Context,
                                  tools.GetString("autoUpdater_msg_failed"),
                                  tools.GetString("autoUpdater_msg_failed_title"),
                                  MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Checks for/parses update.xml on server
        /// </summary>
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            AutoUpdatable application = (AutoUpdatable)e.Argument;

            // Check for update on server
            if (!AutoUpdateXml.ExistsOnServer(application.UpdateXmlLocation))
            {
                e.Cancel = true;
            }
            else             // Parse update xml
            {
                e.Result = AutoUpdateXml.Parse(application.UpdateXmlLocation, application.ApplicationID);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Checks for/parses update.xml on server
        /// </summary>
        private void BgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // Check for update on server
            e.Cancel = (!AutoUpdateXml.IsExistServer(UpdateXmlServer) ||
                        !AutoUpdateXml.IsExistLocation(UpdateXmlLocation));

            if (e.Cancel)
            {
                return;
            }

            Server = AutoUpdateXml.XmlParse(UpdateXmlServer);
            Local  = AutoUpdateXml.XmlParse(UpdateXmlLocation);
        }
Esempio n. 5
0
        /// <summary>
        /// After the background worker is done, prompt to update if there is one
        /// </summary>
        private void BgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            bool IsUpdate = false;

            // If there is a file on the server
            if (e.Cancelled)
            {
                return;
            }


            if (AutoUpdateXml.IsNeedUpdate(Server, Local))
            {
                AcceptForm acceptform = new AcceptForm(Server);
                acceptform.ShowDialog();
                IsUpdate = (acceptform.DialogResult == DialogResult.Yes);
            }
            if (UpdateComplete != null)
            {
                UpdateComplete(IsUpdate);
            }
        }
        /// <summary>
        /// Creates a new AutoUpdateAcceptForm
        /// </summary>
        /// <param name="applicationInfo"></param>
        /// <param name="updateInfo"></param>
        internal AutoUpdateAcceptForm(AutoUpdatable applicationInfo, AutoUpdateXml updateInfo)
        {
            InitializeComponent();

            this.applicationInfo = applicationInfo;
            this.updateInfo      = updateInfo;
            this.tools           = applicationInfo.Tools;

            pictureBox.Image = tools.Img;

            this.Text = tools.GetString("update_found_title");

            this.lblAppName.Text          = this.applicationInfo.ApplicationName;
            this.lblUpdateAvail.Text      = tools.GetString("update_found");
            this.lblNewVersion_label.Text = tools.GetString("update_new");
            this.lblCurVersion_label.Text = tools.GetString("update_cur");
            this.lblDescription.Text      = tools.GetString("update_description");

            this.btnYes.Text = tools.GetString("button_ok");
            this.btnNo.Text  = tools.GetString("button_cancel");

            // Assigns the icon if it isn't null
            if (this.applicationInfo.ApplicationIcon != null)
            {
                this.Icon = this.applicationInfo.ApplicationIcon;
            }

            // Adds the current version # to the form
            this.lblCurVersion.Text = applicationInfo.ApplicationAssembly.GetName().Version.ToString();

            // Adds the update version # to the form
            this.lblNewVersion.Text = this.updateInfo.Version.ToString();

            // Fill in update info
            this.txtDescription.Text = updateInfo.Description;
        }