diff --git a/source/CHANGELOG.md b/source/CHANGELOG.md index 9409c65d..0446ed6d 100644 --- a/source/CHANGELOG.md +++ b/source/CHANGELOG.md @@ -5,6 +5,7 @@ Version 2.3.2 ------------- CHANGED: * Analysis function GoodnessOfFit: more warnings in the log if not all data is usable +* Show version numbers in the update check messages Version 2.3.1 ------------- diff --git a/source/Controllers/WaveController.vb b/source/Controllers/WaveController.vb index 7d3a3791..b3c1c97c 100644 --- a/source/Controllers/WaveController.vb +++ b/source/Controllers/WaveController.vb @@ -35,6 +35,18 @@ Friend Class WaveController View.Show() End Sub + ''' + ''' Returns the current version of Wave + ''' + ''' only considers major, minor and build numbers, omitting the auto-generated revision number + ''' the current version number + Private ReadOnly Property CurrentVersion As Version + Get + Dim v As Version = Reflection.Assembly.GetExecutingAssembly.GetName().Version() + Return New Version($"{v.Major}.{v.Minor}.{v.Build}") + End Get + End Property + Private selectionMade As Boolean 'Flag zeigt an, ob bereits ein Auswahlbereich ausgewählt wurde ''' @@ -205,9 +217,9 @@ Friend Class WaveController Private Async Sub View_Load(sender As System.Object, e As System.EventArgs) 'Check for update Try - Dim updateAvailable As Boolean - updateAvailable = Await _model.CheckForUpdate() - If updateAvailable Then + Dim latestVersion As Version = Await GetLatestVersion() + If CurrentVersion < latestVersion Then + 'show update available notification View.ToolStripButton_UpdateNotification.Visible = True End If Catch ex As Exception @@ -1169,22 +1181,47 @@ Friend Class WaveController ''' Private Async Sub CheckForUpdate_Click(sender As Object, e As EventArgs) Try - Dim updateAvailable As Boolean = Await _model.CheckForUpdate() - If updateAvailable Then + 'get latest version from server + Dim latestVersion As Version = Await GetLatestVersion() + + 'compare versions + If CurrentVersion < latestVersion Then + 'Update is available View.ToolStripButton_UpdateNotification.Visible = True - Dim resp As MsgBoxResult = MsgBox($"A new version is available!{eol}Click OK to go to downloads.bluemodel.org to get it.", MsgBoxStyle.OkCancel) + Dim resp As MsgBoxResult = MsgBox($"A new version {latestVersion} is available!{eol}Click OK to go to downloads.bluemodel.org to download it.", MsgBoxStyle.OkCancel Or MsgBoxStyle.Exclamation) If resp = MsgBoxResult.Ok Then Process.Start(urlDownload) End If Else + 'No update available View.ToolStripButton_UpdateNotification.Visible = False - MsgBox("You are already up to date!", MsgBoxStyle.Information) + MsgBox($"Currently used version {CurrentVersion} is up to date!", MsgBoxStyle.Information) End If + Catch ex As Exception MsgBox("Error while checking for update:" & eol & ex.Message, MsgBoxStyle.Critical) End Try End Sub + ''' + ''' Checks for a newer version on the server + ''' + ''' True if a newer version is available + Private Async Function GetLatestVersion() As Threading.Tasks.Task(Of Version) + + 'retrieve latest version number from server + Dim client As New Net.Http.HttpClient() + Dim s As String = Await client.GetStringAsync(urlUpdateCheck) + Dim latestVersion As New Version(s) +#If Not DEBUG Then + 'TODO: Logging is not thread-safe and causes an exception in debug mode! + Log.AddLogEntry(Log.levels.debug, "CheckUpdate: Latest version on server: " & latestVersion.ToString()) +#End If + + Return latestVersion + + End Function + ''' ''' About Click ''' diff --git a/source/Wave.vb b/source/Wave.vb index 32491553..8dc869a8 100644 --- a/source/Wave.vb +++ b/source/Wave.vb @@ -765,35 +765,6 @@ Public Class Wave End Sub - ''' - ''' Checks for a newer version on the server - ''' - ''' True if a newer version is available - Friend Async Function CheckForUpdate() As Threading.Tasks.Task(Of Boolean) - - - 'get current version (only consider major, minor and build numbers, omitting the auto-generated revision number) - Dim v As Version = Reflection.Assembly.GetExecutingAssembly.GetName().Version() - Dim currentVersion As New Version($"{v.Major}.{v.Minor}.{v.Build}") - - 'retrieve latest version number from server - Dim client As New Net.Http.HttpClient() - Dim s As String = Await client.GetStringAsync(urlUpdateCheck) - Dim latestVersion As New Version(s) -#If Not DEBUG Then - 'TODO: Logging is not thread-safe and causes an exception in debug mode! - Log.AddLogEntry(Log.levels.debug, "CheckUpdate: Latest version on server: " & latestVersion.ToString()) -#End If - - 'compare versions - If currentVersion < latestVersion Then - Return True - Else - Return False - End If - - End Function - Friend Sub HighlightTimestampsHandler(timestamps As List(Of DateTime)) RaiseEvent HighlightTimestamps(timestamps) End Sub