From f4f19bb8f016c758ff0fd8e9270560b7f6acb43d Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 9 Oct 2023 13:11:06 +0200 Subject: [PATCH] LicenceManager 2.5j1 : - aggiornamenti vari. --- LicenceBox/LicenceBoxVM.vb | 2 +- My Project/AssemblyInfo.vb | 8 ++--- NewLicencePage/NewLicencePageVM.vb | 8 ++--- SearchKeyPage/SearchKeyPageVM.vb | 4 +-- SearchResellerPage/SearchResellerPageVM.vb | 2 +- UpdateLicencePage/UpdateLicencePageVM.vb | 38 +++++++++++----------- Utility/ManageFile.vb | 8 ++--- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/LicenceBox/LicenceBoxVM.vb b/LicenceBox/LicenceBoxVM.vb index 31b775d..77d0c5f 100644 --- a/LicenceBox/LicenceBoxVM.vb +++ b/LicenceBox/LicenceBoxVM.vb @@ -164,7 +164,7 @@ Public Class LicenceBoxVM Dim Query As String = "SELECT " & DB_NESTDEADLINE & " FROM " & DB_LICENCE & " WHERE " & DB_LICENCEID & " = " & licId Dim m_NestKeyDict As Dictionary(Of String, String) = ManageDb.ExecuteStringDictionaryQuery(Query) Dim NestDl As String = m_NestKeyDict(DB_NESTDEADLINE) - If Not String.IsNullOrWhiteSpace(NestDl) Or Not String.IsNullOrEmpty(NestDl) Then + If Not String.IsNullOrWhiteSpace(NestDl) Then m_NestDlTxBl_Visibility = Visibility.Visible m_NestDlTxBx_Visibility = Visibility.Visible m_NestDeadline = NestDl diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 4464d4b..ca4ea32 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -17,9 +17,9 @@ Imports System.Windows #End If - + - + @@ -59,5 +59,5 @@ Imports System.Windows ' usando l'asterisco '*' come illustrato di seguito: ' - - + + diff --git a/NewLicencePage/NewLicencePageVM.vb b/NewLicencePage/NewLicencePageVM.vb index db22d0f..5988273 100644 --- a/NewLicencePage/NewLicencePageVM.vb +++ b/NewLicencePage/NewLicencePageVM.vb @@ -573,7 +573,7 @@ Public Class NewLicencePageVM StringFile.Add("Opt2=" & nDecOption2) StringFile.Add("OptExpDays=" & DayOptionDeadline) ' Se il campo NestKey non è vuoto aggiungo anche quello al file - If Not String.IsNullOrEmpty(NestKey) Or Not String.IsNullOrWhiteSpace(NestKey) Then + If Not String.IsNullOrWhiteSpace(NestKey) Then StringFile.Add("NestKey=" & NestKey) End If @@ -614,8 +614,8 @@ Public Class NewLicencePageVM ' L'aggiunta della string NestKey al file .lic è necessaria perchè viene sì scritta nel .Kge ma viene ignorata dal KeyGenerator Try Dim sLicFile As String = Path.ChangeExtension(fileName.Replace("\", "\\"), ".lic") - If (File.Exists(sLicFile)) And (Not String.IsNullOrEmpty(NestKey) Or Not String.IsNullOrWhiteSpace(NestKey)) Then - My.Computer.FileSystem.WriteAllText(sLicFile, "NestKey=" & NestKey, True, Text.Encoding.UTF8) + If (File.Exists(sLicFile)) And Not String.IsNullOrWhiteSpace(NestKey) Then + My.Computer.FileSystem.WriteAllText(sLicFile, "NestKey=" & NestKey & vbNewLine, True, Text.Encoding.UTF8) End If Catch ex As Exception @@ -634,7 +634,7 @@ Public Class NewLicencePageVM Try - If String.IsNullOrEmpty(NestKey) Or String.IsNullOrWhiteSpace(NestKey) Then + If String.IsNullOrWhiteSpace(NestKey) Then Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " & DB_PRODUCTDEADLINE & ", " & DB_OPTION1 & ", " & DB_OPTION2 & ", " & DB_OPTIONDEADLINE & ", " & DB_LOCKID & ", " & DB_FILE & ", " & diff --git a/SearchKeyPage/SearchKeyPageVM.vb b/SearchKeyPage/SearchKeyPageVM.vb index d2b1be6..c2722d1 100644 --- a/SearchKeyPage/SearchKeyPageVM.vb +++ b/SearchKeyPage/SearchKeyPageVM.vb @@ -81,7 +81,7 @@ Public Class SearchKeyPageVM End Property Private m_Note As String - Public Property Note As String + Public Overloads Property Note As String Get Return m_Note End Get @@ -92,7 +92,7 @@ Public Class SearchKeyPageVM End Property Private m_Seriale As String - Public Property Seriale As String + Public Overloads Property Seriale As String Get Return m_Seriale End Get diff --git a/SearchResellerPage/SearchResellerPageVM.vb b/SearchResellerPage/SearchResellerPageVM.vb index 8de6e0e..6f5e1a9 100644 --- a/SearchResellerPage/SearchResellerPageVM.vb +++ b/SearchResellerPage/SearchResellerPageVM.vb @@ -276,7 +276,7 @@ Public Class SearchReseller End Property Private m_Note As String - Public ReadOnly Property Note As String + Public Overloads ReadOnly Property Note As String Get Return m_Note End Get diff --git a/UpdateLicencePage/UpdateLicencePageVM.vb b/UpdateLicencePage/UpdateLicencePageVM.vb index 3400bd6..db2122c 100644 --- a/UpdateLicencePage/UpdateLicencePageVM.vb +++ b/UpdateLicencePage/UpdateLicencePageVM.vb @@ -524,7 +524,7 @@ Public Class UpdateLicencePageVM m_NestKey = m_NestKeyDict(DB_NESTKEY) Dim sNestDl As String = m_NestKeyDict(DB_NESTDEADLINE) Dim splittedNestDl() As String = Split(sNestDl) - If Not String.IsNullOrEmpty(splittedNestDl(0)) Then + If Not String.IsNullOrWhiteSpace(splittedNestDl(0)) Then m_NestDeadline = Date.ParseExact(splittedNestDl(0), "dd/MM/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo) End If NotifyPropertyChanged("NestKey") @@ -660,7 +660,7 @@ Public Class UpdateLicencePageVM StringFile.Add("Opt2=" & nDecOption2) StringFile.Add("OptExpDays=" & DayOptionDeadline) ' Se il campo NestKey non è vuoto aggiungo anche quello al file - If Not String.IsNullOrEmpty(NestKey) Or Not String.IsNullOrWhiteSpace(NestKey) Then + If Not String.IsNullOrWhiteSpace(NestKey) Then StringFile.Add("NestKey=" & NestKey) End If @@ -701,8 +701,8 @@ Public Class UpdateLicencePageVM ' L'aggiunta della string NestKey al file .lic è necessaria perchè viene sì scritta nel .Kge ma viene ignorata dal KeyGenerator Try Dim sLicFile As String = Path.ChangeExtension(FilePath.Replace("\", "\\"), ".lic") - If (File.Exists(sLicFile)) And (Not String.IsNullOrEmpty(NestKey) Or Not String.IsNullOrWhiteSpace(NestKey)) Then - My.Computer.FileSystem.WriteAllText(sLicFile, "NestKey=" & NestKey, True, Text.Encoding.UTF8) + If (File.Exists(sLicFile)) And Not String.IsNullOrWhiteSpace(NestKey) Then + My.Computer.FileSystem.WriteAllText(sLicFile, "NestKey=" & NestKey & vbNewLine, True, Text.Encoding.UTF8) End If Catch ex As Exception @@ -719,15 +719,15 @@ Public Class UpdateLicencePageVM ' Cerco nella tabella Licence Query = "UPDATE " & DB_LICENCE Dim bFirstWhere As Boolean = True - If Not IsNothing(m_SelVersion) OrElse - Not String.IsNullOrWhiteSpace(m_SelProductLevel) OrElse - Not IsNothing(ProductDeadline) OrElse - Not nDecOption1 = 0 OrElse - Not nDecOption2 = 0 OrElse - Not IsNothing(OptionDeadline) OrElse - Not IsNothing(LicenseDate) OrElse - Not String.IsNullOrWhiteSpace(FileName) OrElse - Not String.IsNullOrWhiteSpace(LockID) Then + If (Not IsNothing(m_SelVersion) OrElse + Not String.IsNullOrWhiteSpace(m_SelProductLevel.ToString()) OrElse + Not IsNothing(ProductDeadline) OrElse + Not nDecOption1 = 0 OrElse + Not nDecOption2 = 0 OrElse + Not IsNothing(OptionDeadline) OrElse + Not IsNothing(LicenseDate) OrElse + Not String.IsNullOrWhiteSpace(FileName) OrElse + Not String.IsNullOrWhiteSpace(LockID)) Then Query &= " SET " If Not IsNothing(m_SelVersion) Then EvalWhere(bFirstWhere, Query) @@ -735,7 +735,7 @@ Public Class UpdateLicencePageVM End If If Not IsNothing(m_SelProductLevel) Then EvalWhere(bFirstWhere, Query) - Query &= DB_PRODUCTLEVEL & " = '" & m_SelProductLevel & "' " + Query &= DB_PRODUCTLEVEL & " = '" & m_SelProductLevel.ToString() & "' " End If If Not IsNothing(ProductDeadline) Then EvalWhere(bFirstWhere, Query) @@ -776,7 +776,7 @@ Public Class UpdateLicencePageVM ' Alla fine in ogni caso aggiorniamo anche NestKey e NestDeadline EvalWhere(bFirstWhere, Query) - If String.IsNullOrEmpty(NestKey) Or String.IsNullOrWhiteSpace(NestKey) Then + If String.IsNullOrWhiteSpace(NestKey) Then Query &= DB_NESTKEY & " = NULL, " & DB_NESTDEADLINE & " = NULL " Else Query &= DB_NESTKEY & " = '" & m_NestKey & "', " & DB_NESTDEADLINE & " = '" & Format(NestDeadline, "yyyy-MM-dd") & "' " @@ -848,7 +848,7 @@ Public Class UpdateLicencePageVM StringFile.Add("Opt2=" & nDecOption2) StringFile.Add("OptExpDays=" & DayOptionDeadline) ' Se il campo NestKey non è vuoto aggiungo anche quello al file - If Not String.IsNullOrEmpty(NestKey) Or Not String.IsNullOrWhiteSpace(NestKey) Then + If Not String.IsNullOrWhiteSpace(NestKey) Then StringFile.Add("NestKey=" & NestKey) End If @@ -889,8 +889,8 @@ Public Class UpdateLicencePageVM ' L'aggiunta della string NestKey al file .lic è necessaria perchè viene sì scritta nel .Kge ma viene ignorata dal KeyGenerator Try Dim sLicFile As String = Path.ChangeExtension(FilePath.Replace("\", "\\"), ".lic") - If (File.Exists(sLicFile)) And (Not String.IsNullOrEmpty(NestKey) Or Not String.IsNullOrWhiteSpace(NestKey)) Then - My.Computer.FileSystem.WriteAllText(sLicFile, "NestKey=" & NestKey, True, Text.Encoding.UTF8) + If (File.Exists(sLicFile)) And Not String.IsNullOrWhiteSpace(NestKey) Then + My.Computer.FileSystem.WriteAllText(sLicFile, "NestKey=" & NestKey & vbNewLine, True, Text.Encoding.UTF8) End If Catch ex As Exception @@ -902,7 +902,7 @@ Public Class UpdateLicencePageVM Try Dim textLic As String = File.ReadAllText(Path.ChangeExtension(FilePath.Replace("\", "\\"), ".lic")) - If String.IsNullOrEmpty(NestKey) Or String.IsNullOrWhiteSpace(NestKey) Then + If String.IsNullOrWhiteSpace(NestKey) Then Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " & DB_PRODUCTDEADLINE & ", " & DB_OPTION1 & ", " & DB_OPTION2 & ", " & DB_OPTIONDEADLINE & ", " & DB_LOCKID & ", " & DB_FILE & ", " & diff --git a/Utility/ManageFile.vb b/Utility/ManageFile.vb index 75e7e11..7a9dde4 100644 --- a/Utility/ManageFile.vb +++ b/Utility/ManageFile.vb @@ -4,11 +4,11 @@ Module ManageFile Public Function ComputeFileName(FilePath As String, FileNameOnly As String) As String ' Resetto il nome del file (in modo che sia senza '_' e numero) e cerco nel DB se è già presente un file con lo stesso nome - FilePath = Path.GetDirectoryName(FilePath) & "\" & FileNameOnly.Split("_")(0) & ".Kge" + FilePath = Path.GetDirectoryName(FilePath) & "\" & FileNameOnly.Split("_"c)(0) & ".Kge" FilePath = FilePath.Replace("\", "\\") Dim sFileNameQuery = "SELECT * FROM " & DB_LICENCE & " WHERE " & DB_FILE & " = '" & FilePath & "' " Dim m_UpdateLicDict As Dictionary(Of String, String) = ManageDb.ExecuteStringDictionaryQuery(sFileNameQuery) - If m_UpdateLicDict.ContainsKey(DB_FILE) AndAlso Not String.IsNullOrEmpty(m_UpdateLicDict(DB_FILE)) Then + If m_UpdateLicDict.ContainsKey(DB_FILE) AndAlso Not String.IsNullOrWhiteSpace(m_UpdateLicDict(DB_FILE)) Then ' Se il nome del file già esiste procedo col loop per il calcolo del numero dopo '_' FilePath = FilePath.Replace("\\", "\") Dim fileNumber As Integer = 0 @@ -16,7 +16,7 @@ Module ManageFile FilePath = FilePath.Replace("\", "\\") sFileNameQuery = "SELECT * FROM " & DB_LICENCE & " WHERE " & DB_FILE & " = '" & FilePath & "' " m_UpdateLicDict = ManageDb.ExecuteStringDictionaryQuery(sFileNameQuery) - If m_UpdateLicDict.ContainsKey(DB_FILE) AndAlso Not String.IsNullOrEmpty(m_UpdateLicDict(DB_FILE)) Then + If m_UpdateLicDict.ContainsKey(DB_FILE) AndAlso Not String.IsNullOrWhiteSpace(m_UpdateLicDict(DB_FILE)) Then 'The file does exist, so increment and try the next one fileNumber = fileNumber + 1 FilePath = FilePath.Replace("\\", "\") @@ -28,7 +28,7 @@ Module ManageFile Else 'The file does not exist, do something.. If fileNumber = 1 Then - FilePath = FilePath.Split("_")(0) & "_1.Kge" + FilePath = FilePath.Split("_"c)(0) & "_1.Kge" End If Exit Do End If