示例#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)
            {
                SharpUpdateXML update = (SharpUpdateXML)e.Result;

                // Check if the update is not null and is a newer version than the current application
                if (update != null)
                {
                    //Check for missing files
                    if (!update.HasAllFiles(AssemblyDirectory()))
                    {
                        this.DownloadUpdate(update);
                    }
                    else if (update.IsNewerThan(this.applicationInfo.ApplicationAssembly.GetName().Version))
                    {
                        // Ask to accept the update
                        if (new SharpUpdateAcceptDialog(this.applicationInfo, update).ShowDialog(this.applicationInfo.Context) == DialogResult.Yes)
                        {
                            if (doUpdate)
                            {
                                this.DownloadUpdate(update); // Do the update
                            }
                            else
                            {//This is not the only instance
                                KryptonMessageBox.Show(Language.LanguageEN.SharpUpdater_DoubleInstanceWarning,
                                                       Language.LanguageEN.SharpUpdater_DoubleInstanceWarningTitle,
                                                       MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary>Initializes a new instance of the <see cref="SharpUpdateAcceptDialog" /> class.</summary>
        /// <param name="applicationInfo">The application information.</param>
        /// <param name="updateInfo">The update information.</param>
        internal SharpUpdateAcceptDialog(ISharpUpdatable applicationInfo, SharpUpdateXML updateInfo)
        {
            InitializeComponent();

            try
            {
                _applicationInfo = applicationInfo;

                _updateInfo = updateInfo;

                Text = LanguageEN.SharpUpdateAcceptForm_Title;

                klblpdateAvail.Text = LanguageEN.SharpUpdateAcceptForm_lblUpdateAvail;

                klblNewVersion.Text = string.Format(LanguageEN.SharpUpdateAcceptForm_lblNewVersion, _updateInfo.Version.ToString());

                //kbtnYes.Text = LanguageEN.SharpUpdateAcceptForm_btnYes;

                //kbtnNo.Text = LanguageEN.SharpUpdateAcceptForm_btnNo;

                kbtnDetails.Text = LanguageEN.SharpUpdateAcceptForm_btnDetails;
            }
            catch (Exception e)
            {
                ExceptionHandler.CaptureException(e);
            }

            if (applicationInfo.ApplicationIcon != null)
            {
                Icon = applicationInfo.ApplicationIcon;
            }
        }
示例#3
0
        internal SharpUpdateInfoDialog(ISharpUpdatable applicationInfo, SharpUpdateXML updateInfo)
        {
            InitializeComponent();

            try
            {
                if (applicationInfo.ApplicationIcon != null)
                {
                    Icon = applicationInfo.ApplicationIcon;
                }

                Text = LanguageEN.SharpUpdateInfoForm_Title;

                klblVersions.Text = string.Format(LanguageEN.SharpUpdateInfoForm_Version, applicationInfo.ApplicationAssembly.GetName().Version.ToString(), updateInfo.Version.ToString());

                klblDescription.Text = LanguageEN.SharpUpdateInfoForm_lblDescription;

                ktxtDescription.Text = updateInfo.Description;

                kbtnBack.Text = LanguageEN.SharpUpdateInfoForm_btnBack;
            }
            catch (Exception e)
            {
                throw;
            }
        }
示例#4
0
        /// <summary>
        /// Checks for/parses update.xml on server
        /// </summary>
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            ISharpUpdatable application = (ISharpUpdatable)e.Argument;

            // Check for update on server
            if (!SharpUpdateXML.ExistsOnServer(application.UpdateXmlLocation))
            {
                e.Cancel = true;
            }
            else // Parse update xml
            {
                e.Result = SharpUpdateXML.Parse(application.UpdateXmlLocation, application.ApplicationID);
            }
        }
示例#5
0
        /// <summary>
        /// Downloads update and installs the update
        /// </summary>
        /// <param name="update">The update xml info</param>
        private void DownloadUpdate(SharpUpdateXML update)
        {
            SharpUpdateDownloadDialog form = new SharpUpdateDownloadDialog(update.UpdateFiles, this.applicationInfo.ApplicationIcon);
            DialogResult result            = form.ShowDialog(this.applicationInfo.Context);

            // Download update
            if (result == DialogResult.OK)
            {
                string currentPath = this.applicationInfo.ApplicationAssembly.Location;
                // "Install" it
                UpdateApplication(form.TempFilesPath, currentPath, update.LaunchArgs);

                Application.Exit();
            }
            else if (result == DialogResult.Abort)
            {
                KryptonMessageBox.Show(Language.LanguageEN.SharpUpdater_DownloadCancelled, Language.LanguageEN.SharpUpdater_DownloadCancelledTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                KryptonMessageBox.Show(Language.LanguageEN.SharpUpdater_DownloadProblem, Language.LanguageEN.SharpUpdater_DownloadProblemTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }