示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public bool CheckForUpdate()
 {
     if (AutoUpdateXml.ExistsOnServer(applicationInfo.UpdateXmlLocation))
     {
         return(AutoUpdateXml.Parse(applicationInfo.UpdateXmlLocation, applicationInfo.ApplicationId)
                .IsNewerThan(applicationInfo.ApplicationAssembly.GetName().Version));
     }
     return(false);
 }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="applicationInfo"></param>
        /// <param name="update"></param>
        internal AutoUpdateAcceptForm(IAutoUpdatable applicationInfo, AutoUpdateXml update)
        {
            InitializeComponent();
            this.applicationInfo = applicationInfo;
            this.update          = update;

            Text = applicationInfo.ApplicationName + " Update Available";
            if (applicationInfo.ApplicationIcon != null)
            {
                Icon = applicationInfo.ApplicationIcon;
            }
            lblNewVersion.Text = String.Format("New Version: {0}", update.Version.ToString());
        }
示例#3
0
        /// <summary>
        /// Checks for/parses update.xml on the server.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            IAutoUpdatable appInfo = (IAutoUpdatable)e.Argument;

            if (!AutoUpdateXml.ExistsOnServer(appInfo.UpdateXmlLocation))
            {
                e.Cancel = true;
            }
            else
            {
                e.Result = AutoUpdateXml.Parse(appInfo.UpdateXmlLocation, appInfo.ApplicationId);
            }
        }
示例#4
0
        /// <summary>
        /// Creates a new InfoForm.
        /// </summary>
        /// <param name="applicationInfo"></param>
        /// <param name="updateInfo"></param>
        internal InfoForm(IAutoUpdatable applicationInfo, AutoUpdateXml updateInfo)
        {
            InitializeComponent();
            //Sets the icon if it's not null
            if (applicationInfo.ApplicationIcon != null)
            {
                Icon = applicationInfo.ApplicationIcon;
            }

            //Fill the UI
            Text             = applicationInfo.ApplicationName + " Update Info";
            lblVersions.Text = String.Format("Current Version: {0}\nUpdate Version: {1}",
                                             applicationInfo.ApplicationAssembly.GetName().Version.ToString(), updateInfo.Version.ToString());
            txtDescription.Text = updateInfo.Description;
        }
示例#5
0
        /// <summary>
        /// Initiates download after update.xml is downloaded and parsed if it is needed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                return;
            }

            AutoUpdateXml update = (AutoUpdateXml)e.Result;

            if (update == null || !update.IsNewerThan(applicationInfo.ApplicationAssembly.GetName().Version))
            {
                return;
            }

            if (new AutoUpdateAcceptForm(applicationInfo, update).ShowDialog() == DialogResult.Yes)
            {
                DownloadUpdate(update);
            }
        }
示例#6
0
        /// <summary>
        /// Creates download update form and updates application.
        /// </summary>
        /// <param name="update"></param>
        private void DownloadUpdate(AutoUpdateXml update)
        {
            lblDownloading form   = new lblDownloading(update.Uri.ToString(), update.Directory, applicationInfo.ApplicationIcon);
            DialogResult   result = form.ShowDialog();

            if (result == DialogResult.OK)
            {
                string currentPath = applicationInfo.ApplicationAssembly.Location;
                //path of the root folder of installation
                string rootPath = Path.GetDirectoryName(currentPath);
                //path of the root folder of updates
                string rootTempPath = $"{Path.GetTempPath()}AutoUpdate\\updates";

                string argv = PrepareArgs(update.LaunchArgs);
                string args =
                    $"\"{rootPath}\" \"{rootTempPath}\" \"{Process.GetCurrentProcess().MainModule.FileName}\" \"{update.Exe}\" {argv}";
                ProcessStartInfo info = new ProcessStartInfo("Update progress.exe");
                info.Arguments = args;
                info.Verb      = "runas";

                //ProcessStartInfo info = UpdateApplication(rootTempPath, rootPath, update.Directory, update.LaunchArgs, update.Exe);

                //info.UseShellExecute = false;

                Process.Start(info);
                Process.GetCurrentProcess().Kill();
            }
            else if (result == DialogResult.Abort)
            {
                MessageBox.Show("The update download was canceled.\nThis program has not been modified.",
                                "Update Download Canceled", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("There was a problem downloading update.\nPlease try again later.",
                                "Update Download Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }