Skip to content

Fix FormatException in Update_Gui #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions WinNUT_V2/WinNUT-Client/Update_Gui.vb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Public Class Update_Gui
Return Resp.ContentLength
End Using
End Function

Public Sub VerifyUpdate()
LogFile.LogTracing("Verify Update", LogLvl.LOG_DEBUG, Me)
If WinNUT_Params.Arr_Reg_Key.Item("VerifyUpdate") Or Me.ManualUpdate Then
Expand All @@ -73,10 +74,16 @@ Public Class Update_Gui
End Select
Dim Today As Date = Now
Dim Diff As Integer = 1
If WinNUT_Params.Arr_Reg_Key.Item("LastDateVerification") <> "" Then
Dim LastVerif As Date = Convert.ToDateTime(WinNUT_Params.Arr_Reg_Key.Item("LastDateVerification"))
Diff = DateDiff(DelayVerif, LastVerif, Today, FirstDayOfWeek.Monday, FirstWeekOfYear.Jan1)
Dim lastCheckDate = WinNUT_Params.Arr_Reg_Key.Item("LastDateVerification")

If lastCheckDate <> "" Then
Try
Diff = DateDiff(DelayVerif, Convert.ToDateTime(lastCheckDate), Today)
Catch ex As FormatException
LogFile.LogTracing("Format exception when parsing last check date: " + lastCheckDate, LogLvl.LOG_ERROR, Me)
End Try
End If

If Diff >= 1 Or ManualUpdate Then
Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12
WebC.Headers.Add(Net.HttpRequestHeader.Accept, "application/json")
Expand Down Expand Up @@ -137,7 +144,9 @@ Public Class Update_Gui
Catch excep As Exception
LogFile.LogTracing(excep.Message, LogLvl.LOG_ERROR, Me)
End Try
WinNUT_Params.Arr_Reg_Key.Item("LastDateVerification") = Now.ToString

' Use the 's' format to get a standard datetime for error-free parsing in the future.
WinNUT_Params.Arr_Reg_Key.Item("LastDateVerification") = Date.Now.ToString("s")
WinNUT_Params.Save_Params()
Me.UpdateInfoRetrieved = True
Me.Show()
Expand Down