public void CheckForUpdates() { var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); try { var updateData = GetUpdateData(); updateData.CurrentVersionMajorPart = assemblyVersion.FileMajorPart; updateData.CurrentVersionMinorPart = assemblyVersion.FileMinorPart; if (updateData.LatestVersionMajorPart >= updateData.CurrentVersionMajorPart && updateData.LatestVersionMinorPart > updateData.CurrentVersionMinorPart) { if (Settings.Default.SuppressUpdates == false || LatestVersionIsNewerThanSuppressedVersion(updateData)) { Settings.Default.SuppressUpdates = false; Settings.Default.Save(); updateData.UpdateAvailable = true; } } if (updateData.StaticDataUpdatedDate > Settings.Default.StaticDataLastUpdated) { var result = MessageBox.Show("New static data files are available (Item Base Types and Item Classes). Do you wish to download them?", "Static Data Update Available", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { try { UpdateStaticDataFiles(); Settings.Default.StaticDataLastUpdated = DateTime.Now; Settings.Default.Save(); MessageBox.Show("Static Data successfully updated!", "Update Success", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception e) { Logger.Error(e); MessageBox.Show($"An error occurred while updating the static data files {Environment.NewLine}{e.Message}", "Update Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } if (updateData.UpdateAvailable) { var updateAvailableView = new UpdateAvailableView { DataContext = _updateAvailableViewModel }; _updateAvailableViewModel.Initialise(updateData); _updateAvailableViewModel.OnRequestClose += (s, e) => updateAvailableView.Close(); updateAvailableView.ShowDialog(); } } catch (Exception e) { Logger.Debug(e); // We don't care if the update check fails, because it could fail for multiple reasons // including the user blocking Filtration in their firewall. } }
public async void CheckForUpdates() { var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); var result = await _updateCheckService.GetUpdateData(); try { if (result.LatestVersionMajorPart >= assemblyVersion.FileMajorPart && result.LatestVersionMinorPart > assemblyVersion.FileMinorPart) { if (Settings.Default.SuppressUpdates == false || LatestVersionIsNewerThanSuppressedVersion(result)) { Settings.Default.SuppressUpdates = false; Settings.Default.Save(); var updateAvailableView = new UpdateAvailableView {DataContext = _updateAvailableViewModel}; _updateAvailableViewModel.Initialise(result, assemblyVersion.FileMajorPart, assemblyVersion.FileMinorPart); _updateAvailableViewModel.OnRequestClose += (s, e) => updateAvailableView.Close(); updateAvailableView.ShowDialog(); } } } catch (Exception e) { if (_logger.IsDebugEnabled) { _logger.Debug(e); } // We don't care if the update check fails, because it could fail for multiple reasons // including the user blocking Filtration in their firewall. } }