/// <summary> /// <para>Launch the update process and wait for answer.</para> /// <para>Better wrap this function in a Try-Catch block or it may fail the calling application (e.g. internet connection problems).</para> /// <para>Returns True if updated successfully, False if no updates are available; throws Exception if error (e.g. no internet connection).<br/> /// If user already have last version installed, returns false because no updates were made. Use CheckedAlreadyUpToDate property.</para> /// </summary> /// <param name="notificateNoUpdates">If false, do not show message box saying 'You already have the latest version'.</param> /// <returns>True if updated successfully, False if not updated, Exception if error (e.g. no internet connection)</returns> public bool DoUpdateSync(bool notificateNoUpdates = true) { if (!Tools.CheckForInternetConnection()) { throw new WebException(lang.noInternetConnectionError, WebExceptionStatus.ConnectFailure); } if (MUpdateXml.ExistsOnServer(applicationInfo.UpdateXmlLocation)) // Si le fichier de mise à jour existe { return(CompareVersions(MUpdateXml.Parse(applicationInfo.UpdateXmlLocation, applicationInfo.ApplicationID), notificateNoUpdates)); // Retourne si une nouvelle mise à jour est disponible et demande à l'utilisateur ce qu'il souhaite faire. } return(false); }
/// <summary> /// Parses data from update.xml located on the specified Uri /// </summary> private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { if (!Tools.CheckForInternetConnection()) { throw new WebException(lang.noInternetConnectionError, WebExceptionStatus.ConnectFailure); } IMUpdatable application = (IMUpdatable)e.Argument; if (!MUpdateXml.ExistsOnServer(application.UpdateXmlLocation)) { e.Cancel = true; } else { e.Result = MUpdateXml.Parse(application.UpdateXmlLocation, application.ApplicationID); } }