LicenceManager 2.2a1:
- aggiunti i campi NestKey e NestDeadline in New/UpdateLicencePage - NestKey e NestDeadline vengono scritti nel DB, mentre il solo NestKey viene scritto nei file .Kge e .lic - Nel LicenceBox NestKey è nel contenuto del file mentre NestDeadline in un campo a sè - correzione refresh tabella DB Licenze dopo l'Update di una Licenza
This commit is contained in:
@@ -37,5 +37,7 @@
|
||||
Public Const DB_LICFILE As String = "LicFile"
|
||||
Public Const DB_NOTE As String = "Note"
|
||||
Public Const DB_SERIALE As String = "Seriale"
|
||||
Public Const DB_NESTKEY As String = "NestKey"
|
||||
Public Const DB_NESTDEADLINE As String = "NestDeadline"
|
||||
|
||||
End Module
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="0.2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="0.2*"/>
|
||||
@@ -136,6 +137,19 @@
|
||||
Grid.Row="1"
|
||||
IsReadOnly="True"
|
||||
HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
||||
|
||||
<TextBlock Text="{Binding NestDeadlineMsg}"
|
||||
Visibility="{Binding NestDlTxBl_Visibility}"
|
||||
Grid.Column="4"
|
||||
Grid.Row="1"
|
||||
Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
|
||||
<TextBox Text="{Binding NestDeadline}"
|
||||
Visibility="{Binding NestDlTxBx_Visibility}"
|
||||
Grid.Column="5"
|
||||
Grid.Row="1"
|
||||
IsReadOnly="True"
|
||||
HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
|
||||
@@ -50,6 +50,38 @@ Public Class LicenceBoxVM
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_NestDeadline As String
|
||||
Public Property NestDeadline As String
|
||||
Get
|
||||
Return m_NestDeadline
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_NestDeadline = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_NestDlTxBl_Visibility As Visibility
|
||||
Public Property NestDlTxBl_Visibility As Visibility
|
||||
Get
|
||||
Return m_NestDlTxBl_Visibility
|
||||
End Get
|
||||
Set(value As Visibility)
|
||||
m_NestDlTxBl_Visibility = value
|
||||
NotifyPropertyChanged("NestDlTxBl_Visibility")
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_NestDlTxBx_Visibility As Visibility
|
||||
Public Property NestDlTxBx_Visibility As Visibility
|
||||
Get
|
||||
Return m_NestDlTxBx_Visibility
|
||||
End Get
|
||||
Set(value As Visibility)
|
||||
m_NestDlTxBx_Visibility = value
|
||||
NotifyPropertyChanged("NestDlTxBx_Visibility")
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property Option1Msg As String
|
||||
Get
|
||||
Return "Option 1"
|
||||
@@ -74,6 +106,12 @@ Public Class LicenceBoxVM
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property NestDeadlineMsg As String
|
||||
Get
|
||||
Return "Nesting deadline"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property DownloadMsg As String
|
||||
Get
|
||||
Return "Download"
|
||||
@@ -107,6 +145,21 @@ Public Class LicenceBoxVM
|
||||
m_OptionDeadline = CType(Map.refSearchLicencePageVM.Row.Item, Licence).OptionDeadline.ToShortDateString()
|
||||
NotifyPropertyChanged("OptionDeadline")
|
||||
|
||||
m_NestDlTxBl_Visibility = Visibility.Hidden
|
||||
m_NestDlTxBx_Visibility = Visibility.Hidden
|
||||
|
||||
' Cerco NestDeadline associato alla Licenza, se presente lo visualizzo
|
||||
Dim licId As String = CType(Map.refSearchLicencePageVM.Row.Item, Licence).LicenceID
|
||||
Dim Query As String = "SELECT " & DB_NESTDEADLINE & " FROM " & DB_LICENCE & " WHERE " & DB_LICENCEID & " = " & licId
|
||||
Dim NestDl As String = ManageDb.ExecuteStringQuery(Query, DB_NESTDEADLINE)(0)
|
||||
If Not String.IsNullOrWhiteSpace(NestDl) Or Not String.IsNullOrEmpty(NestDl) Then
|
||||
m_NestDlTxBl_Visibility = Visibility.Visible
|
||||
m_NestDlTxBx_Visibility = Visibility.Visible
|
||||
m_NestDeadline = NestDl
|
||||
NotifyPropertyChanged("NestDeadline")
|
||||
End If
|
||||
|
||||
|
||||
' Inizializzo liste opzioni
|
||||
LoadOptions(1, m_Option1)
|
||||
LoadOptions(2, m_Option2)
|
||||
|
||||
@@ -59,5 +59,5 @@ Imports System.Windows
|
||||
' usando l'asterisco '*' come illustrato di seguito:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("2.1.12.1")>
|
||||
<Assembly: AssemblyFileVersion("2.1.12.1")>
|
||||
<Assembly: AssemblyVersion("2.2.1.1")>
|
||||
<Assembly: AssemblyFileVersion("2.2.1.1")>
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="2*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
@@ -164,8 +165,30 @@
|
||||
Grid.Row="4"
|
||||
Style="{StaticResource ParameterTextBox}" TextWrapping="Wrap" AcceptsReturn="True" HorizontalContentAlignment="Left" Width="Auto" />
|
||||
|
||||
<TextBlock Text="{Binding NestKeyMsg}"
|
||||
Grid.Column="0"
|
||||
Grid.Row="5"
|
||||
Style="{StaticResource ParametersTextBlock}"/>
|
||||
|
||||
<EgtWPFLib5:EgtTextBox Name="textBoxNestKey"
|
||||
Text="{Binding NestKey, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
|
||||
Grid.Column="1"
|
||||
Grid.Row="5"
|
||||
Style="{StaticResource ParameterTextBox}" TextWrapping="Wrap" AcceptsReturn="True" HorizontalContentAlignment="Left" Width="Auto" />
|
||||
|
||||
<TextBlock Text="{Binding NestDeadlineMsg}"
|
||||
Grid.Column="2"
|
||||
Grid.Row="5"
|
||||
Style="{StaticResource ParametersTextBlock}"/>
|
||||
|
||||
<DatePicker SelectedDate="{Binding NestDeadline}"
|
||||
Height="30"
|
||||
Width="170"
|
||||
Grid.Column="3"
|
||||
Grid.Row="5"/>
|
||||
|
||||
<GroupBox Header="{Binding Option1Msg}"
|
||||
Grid.Row="5" Grid.ColumnSpan="4">
|
||||
Grid.Row="6" Grid.ColumnSpan="4">
|
||||
|
||||
<ItemsControl ItemsSource="{Binding Option1}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
@@ -185,7 +208,7 @@
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="{Binding Option2Msg}"
|
||||
Grid.Row="6" Grid.ColumnSpan="4">
|
||||
Grid.Row="7" Grid.ColumnSpan="4">
|
||||
|
||||
<ItemsControl ItemsSource="{Binding Option2}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
@@ -208,14 +231,14 @@
|
||||
<Button Content="{Binding GenerateMsg}"
|
||||
Command="{Binding Generate_Command}"
|
||||
Grid.Column="0"
|
||||
Grid.Row="7"
|
||||
Grid.Row="8"
|
||||
Grid.ColumnSpan="2"
|
||||
Style="{StaticResource Page_Button}"/>
|
||||
|
||||
<Button Content="{Binding CancelMsg}"
|
||||
Command="{Binding Cancel_Command}"
|
||||
Grid.Column="2"
|
||||
Grid.Row="7"
|
||||
Grid.Row="8"
|
||||
Grid.ColumnSpan="2"
|
||||
Style="{StaticResource Page_Button}"/>
|
||||
|
||||
|
||||
@@ -206,6 +206,27 @@ Public Class NewLicencePageVM
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_NestKey As String
|
||||
Public Overloads Property NestKey As String
|
||||
Get
|
||||
Return m_NestKey
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_NestKey = value
|
||||
NotifyPropertyChanged("NestKey")
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_NestDeadline As Nullable(Of Date)
|
||||
Public Property NestDeadline As Nullable(Of Date)
|
||||
Get
|
||||
Return m_NestDeadline
|
||||
End Get
|
||||
Set(value As Nullable(Of Date))
|
||||
m_NestDeadline = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_Option1 As New ObservableCollection(Of KeyOption)
|
||||
Public ReadOnly Property Option1 As ObservableCollection(Of KeyOption)
|
||||
Get
|
||||
@@ -304,6 +325,18 @@ Public Class NewLicencePageVM
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property NestKeyMsg As String
|
||||
Get
|
||||
Return "Nesting encrypted string"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property NestDeadlineMsg As String
|
||||
Get
|
||||
Return "Nesting deadline"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property GenerateMsg As String
|
||||
Get
|
||||
Return "Generate"
|
||||
@@ -362,6 +395,11 @@ Public Class NewLicencePageVM
|
||||
|
||||
m_Note = String.Empty
|
||||
NotifyPropertyChanged("Note")
|
||||
|
||||
m_NestKey = String.Empty
|
||||
NotifyPropertyChanged("NestKey")
|
||||
m_NestDeadline = Date.Now
|
||||
NotifyPropertyChanged("NestDeadline")
|
||||
End Sub
|
||||
|
||||
Private Sub LoadOptions(nIndex As Integer, OptionList As ObservableCollection(Of KeyOption))
|
||||
@@ -483,6 +521,11 @@ Public Class NewLicencePageVM
|
||||
StringFile.Add("Opt1=" & nDecOption1)
|
||||
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
|
||||
StringFile.Add("NestKey=" & NestKey)
|
||||
End If
|
||||
|
||||
Try
|
||||
IO.File.WriteAllLines(fileName, StringFile, Text.Encoding.UTF8)
|
||||
Catch ex As Exception
|
||||
@@ -506,11 +549,25 @@ Public Class NewLicencePageVM
|
||||
MessageBox.Show(sOut, "KeyGenerator Error")
|
||||
Return
|
||||
Else
|
||||
' Se la licenza è stata generata correttamente: prima aggiungo la stringa NestKey (se prevista) poi, in ogni caso, aggiungo la licenza al DB.
|
||||
' 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)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Errore nell'aggiunta della stringa criptata per il Nesting al file .lic", "LicenceManager Error")
|
||||
Return
|
||||
End Try
|
||||
|
||||
' Ora aggiungo la licenza al DB
|
||||
Try
|
||||
Dim textLic As String = File.ReadAllText(Path.ChangeExtension(fileName.Replace("\", "\\"), ".lic"))
|
||||
|
||||
' Aggiungo una licenza al Db
|
||||
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
|
||||
If String.IsNullOrEmpty(NestKey) Or 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 & ", " &
|
||||
DB_DATE & ", " & DB_LICFILE & ", " & DB_NOTE & ")" &
|
||||
@@ -526,6 +583,27 @@ Public Class NewLicencePageVM
|
||||
"'" & Format(LicenseDate, "yyyy-MM-dd") & "', " &
|
||||
"'" & textLic & "', " &
|
||||
"'" & m_Note & "')"
|
||||
Else
|
||||
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
|
||||
DB_PRODUCTDEADLINE & ", " & DB_OPTION1 & ", " & DB_OPTION2 & ", " &
|
||||
DB_OPTIONDEADLINE & ", " & DB_LOCKID & ", " & DB_FILE & ", " &
|
||||
DB_DATE & ", " & DB_LICFILE & ", " & DB_NOTE & ", " &
|
||||
DB_NESTKEY & ", " & DB_NESTDEADLINE & ")" &
|
||||
" VALUES ('" & m_SelProduct.ProductID & "', " &
|
||||
"'" & m_SelVersion.VersionNumber & "', " &
|
||||
"'" & m_SelProductLevel & "', " &
|
||||
"Date('" & (String.Format("{0:yyyy-MM-dd}", ProductDeadline)) & "'), " &
|
||||
"'" & nDecOption1 & "', " &
|
||||
"'" & nDecOption2 & "', " &
|
||||
"Date('" & (String.Format("{0:yyyy-MM-dd}", OptionDeadline)) & "'), " &
|
||||
"'" & LockID & "', " &
|
||||
"'" & fileName.Replace("\", "\\") & "', " &
|
||||
"'" & Format(LicenseDate, "yyyy-MM-dd") & "', " &
|
||||
"'" & textLic & "', " &
|
||||
"'" & m_Note & "', " &
|
||||
"'" & m_NestKey & "', " &
|
||||
"Date('" & (String.Format("{0:yyyy-MM-dd}", NestDeadline)) & "')" & ")"
|
||||
End If
|
||||
ManageDb.ExecuteQuery(Query)
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
@@ -384,15 +384,17 @@ Public Class SearchLicencePageVM
|
||||
SelIsDongle = Nothing
|
||||
NotifyPropertyChanged("SelIsDongle")
|
||||
|
||||
' m_SearchResult = New ObservableCollection(Of SearchLicence)()
|
||||
Dim LicQuery As String = "SELECT * FROM " & DB_LICENCE & " INNER JOIN " & DB_PRODUCT &
|
||||
End If
|
||||
|
||||
' m_SearchResult = New ObservableCollection(Of SearchLicence)()
|
||||
Dim LicQuery As String = "SELECT * FROM " & DB_LICENCE & " INNER JOIN " & DB_PRODUCT &
|
||||
" ON " & DB_LICENCE & "." & DB_PRODUCTID & " = " & DB_PRODUCT & "." & DB_PRODUCTID &
|
||||
" INNER JOIN " & DB_VERSION &
|
||||
" ON " & DB_LICENCE & "." & DB_PRODUCTID & " = " & DB_VERSION & "." & DB_PRODUCTID &
|
||||
" AND " & DB_LICENCE & "." & DB_PRODUCTVERSION & " = " & DB_VERSION & "." & DB_VERSIONNUMBER
|
||||
m_SearchResult = New ObservableCollection(Of SearchLicence)(ManageDb.ExecuteSearchLicenceQuery(LicQuery))
|
||||
NotifyPropertyChanged("SearchResult")
|
||||
End If
|
||||
m_SearchResult = New ObservableCollection(Of SearchLicence)(ManageDb.ExecuteSearchLicenceQuery(LicQuery))
|
||||
NotifyPropertyChanged("SearchResult")
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Private Sub LoadOptions(nIndex As Integer, OptionList As ObservableCollection(Of KeyOption))
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
@@ -145,9 +146,31 @@
|
||||
Grid.Row="4"
|
||||
Visibility="{Binding KeyNumberCmBx_Visibility}"
|
||||
Style="{StaticResource ParametersComboBox}"/>
|
||||
|
||||
|
||||
<TextBlock Text="{Binding NestKeyMsg}"
|
||||
Grid.Column="0"
|
||||
Grid.Row="5"
|
||||
Style="{StaticResource ParametersTextBlock}"/>
|
||||
|
||||
<EgtWPFLib5:EgtTextBox Name="textBoxNestKey"
|
||||
Text="{Binding NestKey, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
|
||||
Grid.Column="1"
|
||||
Grid.Row="5"
|
||||
Style="{StaticResource ParameterTextBox}" TextWrapping="Wrap" AcceptsReturn="True" HorizontalContentAlignment="Left" Width="Auto" />
|
||||
|
||||
<TextBlock Text="{Binding NestDeadlineMsg}"
|
||||
Grid.Column="2"
|
||||
Grid.Row="5"
|
||||
Style="{StaticResource ParametersTextBlock}"/>
|
||||
|
||||
<DatePicker SelectedDate="{Binding NestDeadline}"
|
||||
Height="30"
|
||||
Width="170"
|
||||
Grid.Column="3"
|
||||
Grid.Row="5"/>
|
||||
|
||||
<GroupBox Header="{Binding Option1Msg}"
|
||||
Grid.Row="5" Grid.ColumnSpan="4">
|
||||
Grid.Row="6" Grid.ColumnSpan="4">
|
||||
|
||||
<ItemsControl ItemsSource="{Binding Option1}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
@@ -167,7 +190,7 @@
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="{Binding Option2Msg}"
|
||||
Grid.Row="6" Grid.ColumnSpan="4">
|
||||
Grid.Row="7" Grid.ColumnSpan="4">
|
||||
|
||||
<ItemsControl ItemsSource="{Binding Option2}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
@@ -189,14 +212,14 @@
|
||||
<Button Content="{Binding UpdateMsg}"
|
||||
Command="{Binding Update_Command}"
|
||||
Grid.Column="0"
|
||||
Grid.Row="7"
|
||||
Grid.Row="8"
|
||||
Grid.ColumnSpan="2"
|
||||
Style="{StaticResource Page_Button}"/>
|
||||
|
||||
<Button Content="{Binding CancelMsg}"
|
||||
Command="{Binding Cancel_Command}"
|
||||
Grid.Column="2"
|
||||
Grid.Row="7"
|
||||
Grid.Row="8"
|
||||
Grid.ColumnSpan="2"
|
||||
Style="{StaticResource Page_Button}"/>
|
||||
|
||||
|
||||
@@ -165,15 +165,17 @@ Public Class UpdateLicencePageVM
|
||||
Set(value As Key)
|
||||
m_SelNumber = value
|
||||
NotifyPropertyChanged("SelNumber")
|
||||
' Quando viene scelto un KeyNumber viene modificato automaticamente anche il FilePath sostituendo il KeyNumber e
|
||||
' calcolando il nome che il file dovrà avere senza o con '_' e con quale numero dopo)
|
||||
Dim LicQuery As String = "SELECT * FROM " & DB_LICENCE & " WHERE " & DB_LICENCEID & " = " & Licence.LicenceID
|
||||
Dim FilePath As String = ManageDb.ExecuteStringQuery(LicQuery, DB_FILE)(0)
|
||||
Dim KeyQuery As String = "SELECT * FROM " & DB_KEY & " WHERE " & DB_LOCKID & " = '" & Licence.Number & "' "
|
||||
FilePath = FilePath.Replace("-" & ManageDb.ExecuteKeyQuery(KeyQuery)(0).Number.ToString("D6") & "-",
|
||||
If Not IsNothing(value) Then
|
||||
' Quando viene scelto un KeyNumber viene modificato automaticamente anche il FilePath sostituendo il KeyNumber e
|
||||
' calcolando il nome che il file dovrà avere senza o con '_' e con quale numero dopo)
|
||||
Dim LicQuery As String = "SELECT * FROM " & DB_LICENCE & " WHERE " & DB_LICENCEID & " = " & Licence.LicenceID
|
||||
Dim FilePath As String = ManageDb.ExecuteStringQuery(LicQuery, DB_FILE)(0)
|
||||
Dim KeyQuery As String = "SELECT * FROM " & DB_KEY & " WHERE " & DB_LOCKID & " = '" & Licence.Number & "' "
|
||||
FilePath = FilePath.Replace("-" & ManageDb.ExecuteKeyQuery(KeyQuery)(0).Number.ToString("D6") & "-",
|
||||
"-" & SelNumber.Number.ToString("D6") & "-")
|
||||
m_FileName = ComputeFileNameForUpdateNew(FilePath, Path.GetFileNameWithoutExtension(FilePath))
|
||||
NotifyPropertyChanged("FileName")
|
||||
m_FileName = ComputeFileNameForUpdateNew(FilePath, Path.GetFileNameWithoutExtension(FilePath))
|
||||
NotifyPropertyChanged("FileName")
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
@@ -199,6 +201,27 @@ Public Class UpdateLicencePageVM
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_NestKey As String
|
||||
Public Overloads Property NestKey As String
|
||||
Get
|
||||
Return m_NestKey
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_NestKey = value
|
||||
NotifyPropertyChanged("NestKey")
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_NestDeadline As Nullable(Of Date)
|
||||
Public Property NestDeadline As Nullable(Of Date)
|
||||
Get
|
||||
Return m_NestDeadline
|
||||
End Get
|
||||
Set(value As Nullable(Of Date))
|
||||
m_NestDeadline = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
' Definizione comandi
|
||||
Private m_cmdUpdate As Command
|
||||
Private m_cmdCancel As Command
|
||||
@@ -273,6 +296,18 @@ Public Class UpdateLicencePageVM
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property NestKeyMsg As String
|
||||
Get
|
||||
Return "Nesting encrypted string"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property NestDeadlineMsg As String
|
||||
Get
|
||||
Return "Nesting deadline"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property UpdateMsg As String
|
||||
Get
|
||||
Return "Update"
|
||||
@@ -368,6 +403,18 @@ Public Class UpdateLicencePageVM
|
||||
m_LicenseDate = Licence.LicenseDate
|
||||
NotifyPropertyChanged("LicenseDate")
|
||||
|
||||
' Resetto i campi NestKey e NestDeadline e carico i valori grazie al LicenceID associato
|
||||
m_NestKey = String.Empty
|
||||
m_NestDeadline = Date.Now
|
||||
Dim NestQuery As String = "SELECT * FROM " & DB_LICENCE & " WHERE " & DB_LICENCEID & " = " & Licence.LicenceID
|
||||
m_NestKey = ManageDb.ExecuteStringQuery(NestQuery, DB_NESTKEY)(0)
|
||||
Dim sNestDl As String = ManageDb.ExecuteStringQuery(NestQuery, DB_NESTDEADLINE)(0)
|
||||
If Not String.IsNullOrEmpty(sNestDl) Then
|
||||
m_NestDeadline = Date.ParseExact(sNestDl, "dd/MM/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)
|
||||
End If
|
||||
NotifyPropertyChanged("NestKey")
|
||||
NotifyPropertyChanged("NestDeadline")
|
||||
|
||||
' Inizializzo liste opzioni
|
||||
LoadOptions(1, m_Option1)
|
||||
LoadOptions(2, m_Option2)
|
||||
@@ -468,7 +515,7 @@ Public Class UpdateLicencePageVM
|
||||
Dim sLicName As String = Path.GetFileNameWithoutExtension(FilePath)
|
||||
|
||||
' Nome file
|
||||
' Dim fileName As String = Map.refMainWindowVM.MainWindowM.sKeygenDataDir & "\" & sLicName & ".Kge"
|
||||
'Dim fileName As String = Map.refMainWindowVM.MainWindowM.sKeygenDataDir & "\" & sLicName & ".Kge"
|
||||
' Scrivo il file
|
||||
Dim StringFile As New List(Of String)
|
||||
StringFile.Add(";")
|
||||
@@ -486,6 +533,11 @@ Public Class UpdateLicencePageVM
|
||||
StringFile.Add("Opt1=" & nDecOption1)
|
||||
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
|
||||
StringFile.Add("NestKey=" & NestKey)
|
||||
End If
|
||||
|
||||
Try
|
||||
IO.File.WriteAllLines(FilePath, StringFile, Text.Encoding.UTF8)
|
||||
Catch ex As Exception
|
||||
@@ -508,6 +560,19 @@ Public Class UpdateLicencePageVM
|
||||
Dim sOut As String = "La Licenza non è stata generata correttamente (" & proc.ExitCode.ToString() & ")"
|
||||
MessageBox.Show(sOut, "KeyGenerator Error")
|
||||
Return
|
||||
Else
|
||||
' Se la licenza è stata generata correttamente aggiungo la stringa NestKey (se prevista).
|
||||
' 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)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Errore nell'aggiunta della stringa criptata per il Nesting al file .lic", "LicenceManager Error")
|
||||
Return
|
||||
End Try
|
||||
End If
|
||||
|
||||
Dim textLic As String = File.ReadAllText(Path.ChangeExtension(FilePath.Replace("\", "\\"), ".lic"))
|
||||
@@ -573,10 +638,20 @@ Public Class UpdateLicencePageVM
|
||||
Query &= DB_NOTE & " = '" & m_Note & "' "
|
||||
End If
|
||||
|
||||
' Alla fine in ogni caso aggiorniamo anche NestKey e NestDeadline
|
||||
EvalWhere(bFirstWhere, Query)
|
||||
If String.IsNullOrEmpty(NestKey) Or String.IsNullOrWhiteSpace(NestKey) Then
|
||||
Query &= DB_NESTKEY & " = NULL, " & DB_NESTDEADLINE & " = NULL "
|
||||
Else
|
||||
Query &= DB_NESTKEY & " = '" & m_NestKey & "', " & DB_NESTDEADLINE & " = '" & Format(NestDeadline, "yyyy-MM-dd") & "' "
|
||||
End If
|
||||
|
||||
Query &= "WHERE " & DB_LICENCEID & " = " & Licence.LicenceID
|
||||
Query = Query.TrimEnd(","c, " "c)
|
||||
End If
|
||||
Else
|
||||
' Altrimenti siamo nel caso Update (New)
|
||||
|
||||
' Verifico presenza di tutti i dati
|
||||
If IsNothing(m_Option1) OrElse
|
||||
IsNothing(m_Option2) OrElse
|
||||
@@ -654,6 +729,11 @@ Public Class UpdateLicencePageVM
|
||||
StringFile.Add("Opt1=" & nDecOption1)
|
||||
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
|
||||
StringFile.Add("NestKey=" & NestKey)
|
||||
End If
|
||||
|
||||
Try
|
||||
IO.File.WriteAllLines(FilePath, StringFile, Text.Encoding.UTF8)
|
||||
Catch ex As Exception
|
||||
@@ -677,11 +757,25 @@ Public Class UpdateLicencePageVM
|
||||
MessageBox.Show(sOut, "KeyGenerator Error")
|
||||
Return
|
||||
Else
|
||||
' Se la licenza è stata generata correttamente: prima aggiungo la stringa NestKey (se prevista) poi, in ogni caso, aggiungo la licenza al DB.
|
||||
' 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)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Errore nell'aggiunta della stringa criptata per il Nesting al file .lic", "LicenceManager Error")
|
||||
Return
|
||||
End Try
|
||||
|
||||
' Ora aggiungo la licenza al DB
|
||||
Try
|
||||
Dim textLic As String = File.ReadAllText(Path.ChangeExtension(FilePath.Replace("\", "\\"), ".lic"))
|
||||
|
||||
' Aggiungo una licenza al Db
|
||||
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
|
||||
If String.IsNullOrEmpty(NestKey) Or 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 & ", " &
|
||||
DB_DATE & ", " & DB_LICFILE & ", " & DB_NOTE & ")" &
|
||||
@@ -697,6 +791,27 @@ Public Class UpdateLicencePageVM
|
||||
"'" & Format(LicenseDate, "yyyy-MM-dd") & "', " &
|
||||
"'" & textLic & "', " &
|
||||
"'" & m_Note & "')"
|
||||
Else
|
||||
Query = "INSERT INTO " & DB_LICENCE & " (" & DB_PRODUCTID & ", " & DB_PRODUCTVERSION & ", " & DB_PRODUCTLEVEL & ", " &
|
||||
DB_PRODUCTDEADLINE & ", " & DB_OPTION1 & ", " & DB_OPTION2 & ", " &
|
||||
DB_OPTIONDEADLINE & ", " & DB_LOCKID & ", " & DB_FILE & ", " &
|
||||
DB_DATE & ", " & DB_LICFILE & ", " & DB_NOTE & ", " &
|
||||
DB_NESTKEY & ", " & DB_NESTDEADLINE & ")" &
|
||||
" VALUES ('" & ProductID & "', " &
|
||||
"'" & m_SelVersion.VersionNumber & "', " &
|
||||
"'" & m_SelProductLevel & "', " &
|
||||
"Date('" & (String.Format("{0:yyyy-MM-dd}", ProductDeadline)) & "'), " &
|
||||
"'" & nDecOption1 & "', " &
|
||||
"'" & nDecOption2 & "', " &
|
||||
"Date('" & (String.Format("{0:yyyy-MM-dd}", OptionDeadline)) & "'), " &
|
||||
"'" & LockID & "', " &
|
||||
"'" & FilePath.Replace("\", "\\") & "', " &
|
||||
"'" & Format(LicenseDate, "yyyy-MM-dd") & "', " &
|
||||
"'" & textLic & "', " &
|
||||
"'" & m_Note & "', " &
|
||||
"'" & m_NestKey & "', " &
|
||||
"Date('" & (String.Format("{0:yyyy-MM-dd}", NestDeadline)) & "')" & ")"
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Errore nella lettura dei dati per la scrittura su DB", "LicenceManager Error")
|
||||
@@ -706,7 +821,7 @@ Public Class UpdateLicencePageVM
|
||||
|
||||
End If
|
||||
|
||||
ManageDb.ExecuteQuery(Query)
|
||||
ManageDb.ExecuteQuery(Query)
|
||||
|
||||
m_ReturnFromUpdate = True
|
||||
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
||||
|
||||
Reference in New Issue
Block a user