From fd2c73c63bfeec8cc4f9ebc78b1ce2f5475f76a0 Mon Sep 17 00:00:00 2001 From: gbakeman Date: Sat, 9 Mar 2024 14:51:22 -0500 Subject: [PATCH 1/3] Upgrade Settings at start if necessary Application Settings upgrade routine is only run automatically when using the ClickOnce installer. Since it's not run with our current MSI build, this code will then run when the program is started for the first time (nothing happens) or if it's an upgraded MSI installation with a fresh copy of settings. In that case, the Upgrade function will find the older copy and import/apply them. This operation won't be attempted until the next upgrade. Need to remove once using pure ClickOnce. --- WinNUT_V2/WinNUT-Client/App.config | 3 +++ WinNUT_V2/WinNUT-Client/ApplicationEvents.vb | 17 +++++++++++++++++ .../My Project/Settings.Designer.vb | 14 +++++++++++++- .../WinNUT-Client/My Project/Settings.settings | 3 +++ WinNUT_V2/WinNUT-Client/WinNUT-client.vbproj | 1 + 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/WinNUT_V2/WinNUT-Client/App.config b/WinNUT_V2/WinNUT-Client/App.config index 2afa4ac..ae1c5c8 100644 --- a/WinNUT_V2/WinNUT-Client/App.config +++ b/WinNUT_V2/WinNUT-Client/App.config @@ -157,6 +157,9 @@ 18 + + True + diff --git a/WinNUT_V2/WinNUT-Client/ApplicationEvents.vb b/WinNUT_V2/WinNUT-Client/ApplicationEvents.vb index ffc730d..3bfea89 100644 --- a/WinNUT_V2/WinNUT-Client/ApplicationEvents.vb +++ b/WinNUT_V2/WinNUT-Client/ApplicationEvents.vb @@ -40,7 +40,24 @@ Namespace My Private Sub MyApplication_Startup(sender As Object, e As StartupEventArgs) Handles Me.Startup ' Uncomment below and comment out Handles line for _UnhandledException sub when debugging unhandled exceptions. ' AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf AppDomainUnhandledException + Init_Globals() + + ' If first run indicated by Settings, attempt upgrade in case older version is present. + ' Only necessary when deploying MSI. Remove once using pure ClickOnce. + If Settings.IsFirstRun Then + Try + Settings.Upgrade() + LogFile.LogTracing("Settings upgrade completed without exception.", LogLvl.LOG_NOTICE, Me) + Catch ex As ConfigurationErrorsException + LogFile.LogTracing("Error encountered while trying to upgrade Settings:", LogLvl.LOG_ERROR, Me) + LogFile.LogException(ex, Me) + End Try + + Settings.IsFirstRun = False + Settings.Save() + End If + LogFile.LogTracing("MyApplication_Startup complete.", LogLvl.LOG_DEBUG, Me) End Sub diff --git a/WinNUT_V2/WinNUT-Client/My Project/Settings.Designer.vb b/WinNUT_V2/WinNUT-Client/My Project/Settings.Designer.vb index 571af38..1933ec7 100644 --- a/WinNUT_V2/WinNUT-Client/My Project/Settings.Designer.vb +++ b/WinNUT_V2/WinNUT-Client/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase @@ -506,6 +506,18 @@ Namespace My Me("CAL_BattVMax") = value End Set End Property + + _ + Public Property IsFirstRun() As Boolean + Get + Return CType(Me("IsFirstRun"),Boolean) + End Get + Set + Me("IsFirstRun") = value + End Set + End Property End Class End Namespace diff --git a/WinNUT_V2/WinNUT-Client/My Project/Settings.settings b/WinNUT_V2/WinNUT-Client/My Project/Settings.settings index 47d8895..6496226 100644 --- a/WinNUT_V2/WinNUT-Client/My Project/Settings.settings +++ b/WinNUT_V2/WinNUT-Client/My Project/Settings.settings @@ -116,5 +116,8 @@ 18 + + True + \ No newline at end of file diff --git a/WinNUT_V2/WinNUT-Client/WinNUT-client.vbproj b/WinNUT_V2/WinNUT-Client/WinNUT-client.vbproj index 06629a9..ac2ed99 100644 --- a/WinNUT_V2/WinNUT-Client/WinNUT-client.vbproj +++ b/WinNUT_V2/WinNUT-Client/WinNUT-client.vbproj @@ -112,6 +112,7 @@ + From 1bfcfef512d40d4819fc6f46c478531dc40c89af Mon Sep 17 00:00:00 2001 From: gbakeman Date: Sat, 9 Mar 2024 15:03:05 -0500 Subject: [PATCH 2/3] Removing header text Top LICENSE file still applies. Will clean up files as needed. Started by cleaning up assemblyinfo files. Adding some additional information. --- WinNUT_V2/.editorconfig | 15 +++++++--- WinNUT_V2/SharedAssemblyInfo.vb | 28 +------------------ .../WinNUT-Client/My Project/AssemblyInfo.vb | 23 ++------------- 3 files changed, 14 insertions(+), 52 deletions(-) diff --git a/WinNUT_V2/.editorconfig b/WinNUT_V2/.editorconfig index 43518d1..2c5d42d 100644 --- a/WinNUT_V2/.editorconfig +++ b/WinNUT_V2/.editorconfig @@ -6,7 +6,6 @@ root = true # All files [*] indent_style = space -file_header_template = WinNUT-Client is a NUT windows client for monitoring your ups hooked up to your favorite linux server.\nCopyright (C) 2019-2021 Gawindx (Decaux Nicolas)\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the\nGNU General Public License as published by the Free Software Foundation, either version 3 of the\nLicense, or any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\neven the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nGeneral Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program.\nIf not, see https://www.gnu.org/licenses/.\n # Code files [*.{cs,csx,vb,vbx}] indent_size = 4 @@ -67,14 +66,16 @@ tab_width = 4 end_of_line = crlf dotnet_style_allow_multiple_blank_lines_experimental = true:silent dotnet_style_allow_statement_immediately_after_block_experimental = true:silent +dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion +dotnet_code_quality_unused_parameters = all:suggestion ############################### # C# Coding Conventions # ############################### [*.cs] # var preferences -csharp_style_var_for_built_in_types = true:silent -csharp_style_var_when_type_is_apparent = true:silent -csharp_style_var_elsewhere = true:silent +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = false:silent +csharp_style_var_elsewhere = false:silent # Expression-bodied members csharp_style_expression_bodied_methods = false:silent csharp_style_expression_bodied_constructors = false:silent @@ -149,6 +150,12 @@ csharp_style_prefer_readonly_struct_member = true:suggestion csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent +csharp_style_prefer_switch_expression = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_extended_property_pattern = true:suggestion ############################### # VB Coding Conventions # ############################### diff --git a/WinNUT_V2/SharedAssemblyInfo.vb b/WinNUT_V2/SharedAssemblyInfo.vb index f5f33f4..6dc41cc 100644 --- a/WinNUT_V2/SharedAssemblyInfo.vb +++ b/WinNUT_V2/SharedAssemblyInfo.vb @@ -1,36 +1,10 @@ -' WinNUT-Client is a NUT windows client for monitoring your ups hooked up to your favorite linux server. -' Copyright (C) 2019-2021 Gawindx (Decaux Nicolas) -' -' This program is free software: you can redistribute it and/or modify it under the terms of the -' GNU General Public License as published by the Free Software Foundation, either version 3 of the -' License, or any later version. -' -' This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY - +Imports System.Reflection Imports System.Resources -Imports System.Reflection - -' Les informations générales relatives à un assembly dépendent de -' l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations -' associées à un assembly. - -' Vérifiez les valeurs des attributs de l'assembly -' Les informations de version pour un assembly se composent des quatre valeurs suivantes : -' -' Version principale -' Version secondaire -' Numéro de build -' Révision -' -' Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut -' en utilisant '*', comme indiqué ci-dessous : -' - diff --git a/WinNUT_V2/WinNUT-Client/My Project/AssemblyInfo.vb b/WinNUT_V2/WinNUT-Client/My Project/AssemblyInfo.vb index 2e0d603..d8b9b06 100644 --- a/WinNUT_V2/WinNUT-Client/My Project/AssemblyInfo.vb +++ b/WinNUT_V2/WinNUT-Client/My Project/AssemblyInfo.vb @@ -1,26 +1,7 @@ -Imports System.Resources -' WinNUT-Client is a NUT windows client for monitoring your ups hooked up to your favorite linux server. -' Copyright (C) 2019-2021 Gawindx (Decaux Nicolas) -' -' This program is free software: you can redistribute it and/or modify it under the terms of the -' GNU General Public License as published by the Free Software Foundation, either version 3 of the -' License, or any later version. -' -' This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY - -Imports System.Reflection +Imports System.Reflection Imports System.Runtime.InteropServices -' Les informations générales relatives à un assembly dépendent de -' l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations -' associées à un assembly. - -' Vérifiez les valeurs des attributs de l'assembly - - - + - -'Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM From da9b79b0eb5797d2c888d313126e946ce44006f3 Mon Sep 17 00:00:00 2001 From: gbakeman Date: Sat, 9 Mar 2024 15:06:36 -0500 Subject: [PATCH 3/3] Bump v.2.3.8834 --- WinNUT_V2/Setup/Setup.vdproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/WinNUT_V2/Setup/Setup.vdproj b/WinNUT_V2/Setup/Setup.vdproj index 625120e..1c9bd50 100644 --- a/WinNUT_V2/Setup/Setup.vdproj +++ b/WinNUT_V2/Setup/Setup.vdproj @@ -9379,7 +9379,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:AGauge, Version=2.1.8824.26289, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:AGauge, Version=2.1.8834.24289, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_7643B2E01E55816C8BA2265FF9E9B786" @@ -11434,7 +11434,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:WinNUT-Client_Common, Version=2.3.8824.26289, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:WinNUT-Client_Common, Version=2.3.8834.24289, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_CB7240238DDFA669FCF3046E48D0A447" @@ -12788,15 +12788,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:WinNUT Client" - "ProductCode" = "8:{ED2181E2-D5FB-43AE-B50E-A0D019730CEB}" - "PackageCode" = "8:{5AAB5E2D-D11E-46D6-906F-F0F7385AFB42}" + "ProductCode" = "8:{AAAE0531-0B77-4CE7-A034-1583EA07BD87}" + "PackageCode" = "8:{8DFC349A-62F6-4FF2-BB1F-7C42432D8772}" "UpgradeCode" = "8:{7EA17151-76E7-4E29-8F6A-621C1B4144C2}" "AspNetVersion" = "8:2.0.50727.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:2.3.8824" + "ProductVersion" = "8:2.3.8834" "Manufacturer" = "8:NUTDotNet" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:https://github.com/nutdotnet/WinNUT-Client/issues"