public void CheckForUpdates() { using (var service = new UpdateInformationService.UpdateInformationService()) { service.Url = Settings.Default.UpdateInformationServiceUrl; var installedProduct = new Product { Name = ProductInformation.Component, Version = ProductInformation.Version.ToString(), VersionSuffix = ProductInformation.VersionSuffix, Edition = ProductInformation.Edition, Release = ProductInformation.Release }; try { var request = new UpdateInformationRequest { InstalledProduct = installedProduct }; UpdateInformationResult result = service.GetUpdateInformation(request); if (result == null) { throw new Exception("Bad data received from service."); } if (!IsValidComponent(result.InstalledProduct) || IsSameComponent(result.InstalledProduct, installedProduct)) { base.Context.DesktopWindow.ShowMessageBox(SR.MessageNoUpdate, MessageBoxActions.Ok); } else { var upgrade = result.InstalledProduct; string message = String.Format(SR.MessageUpdateAvailable, ToString(upgrade)); UpdateAvailableForm.Show(message, result.DownloadUrl); } } catch (Exception e) { Platform.Log(LogLevel.Warn, e, "The request for update information failed."); Context.DesktopWindow.ShowMessageBox(SR.MessageUpdateRequestFailed, MessageBoxActions.Ok); } } }
public override void DoWork(WorkerThread workerThread) { string[] remotePaths = { "http://waddu.flauschig.ch/download/latest.txt", "http://www.red-demon.com/waddu/download/latest.txt" }; workerThread.InfoText = "Version Check for Waddu"; Logger.Instance.AddLog(LogType.Information, "Thread #{0}: Version Check for Waddu", workerThread.ThreadId); var success = false; var version = string.Empty; foreach (var path in remotePaths) { success = WebHelper.GetString(path, out version); if (success) { break; } } if (success) { if (version == GetType().Assembly.GetName().Version.ToString()) { Logger.Instance.AddLog(LogType.Information, "Thread #{0}: No Update for Waddu available: {1}", workerThread.ThreadId, version); } else { MainForm.Instance.Invoke((MethodInvoker)(() => { using (var dlg = new UpdateAvailableForm(version)) { dlg.StartPosition = FormStartPosition.CenterParent; dlg.ShowDialog(); } })); } } else { Logger.Instance.AddLog(LogType.Warning, "Thread #{0}: Could not check the Version", workerThread.ThreadId); } }