diff --git a/EgtBEAMWALL.Core/Constants/ConstIni.vb b/EgtBEAMWALL.Core/Constants/ConstIni.vb
index 192e08cf..b9cddde1 100644
--- a/EgtBEAMWALL.Core/Constants/ConstIni.vb
+++ b/EgtBEAMWALL.Core/Constants/ConstIni.vb
@@ -161,4 +161,7 @@ Public Module ConstIni
Public Const K_TYPE As String = "Type"
Public Const K_DEFAULTQUANTITY As String = "DefaultQuantity"
+ Public Const S_BACKUPANDRESTORE As String = "Backup&Restore"
+ Public Const K_FILEPATH As String = "FilePath"
+
End Module
diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml
index cdc3bc49..ed45da28 100644
--- a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml
+++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageV.xaml
@@ -71,6 +71,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb
index 7cd1983b..bad8875e 100644
--- a/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb
+++ b/EgtBEAMWALL.ViewerOptimizer/ConfigurationPage/ConfigurationPageVM.vb
@@ -3,6 +3,8 @@ Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Imports EgtBEAMWALL.Core
+Imports MS.Internal
+Imports Org.BouncyCastle.X509
Public Class ConfigurationPageVM
Inherits VMBase
@@ -36,8 +38,6 @@ Public Class ConfigurationPageVM
' flag modifica parametri Macchina
Friend bModifyMachParam As Boolean
- ' Definizione comandi
- Private m_cmdSave As ICommand
Public ReadOnly Property MachinePanelVM As MachinePanelVM
Get
@@ -160,6 +160,23 @@ Public Class ConfigurationPageVM
End Set
End Property
+ Private m_BackupFilePath As String
+ Public Property BackupFilePath As String
+ Get
+ Return m_BackupFilePath
+ End Get
+ Set(value As String)
+ m_BackupFilePath = value
+ WriteMainPrivateProfileString(S_BACKUPANDRESTORE, K_FILEPATH, m_BackupFilePath)
+ End Set
+ End Property
+
+ ' Definizione comandi
+ Private m_cmdSave As ICommand
+ Private m_cmdChooseBackupFilePath As ICommand
+ Private m_cmdBackup As ICommand
+ Private m_cmdRestore As ICommand
+
#Region "Messages"
Public ReadOnly Property L_Msg As String
@@ -327,7 +344,7 @@ Public Class ConfigurationPageVM
' leggo SectionTime e PartTime
GetMainPrivateProfileString(S_NEST, K_SECTIONTIME, "", SectionTime)
GetMainPrivateProfileString(S_NEST, K_PARTTIME, "", PartTime)
- m_bPrintLabel_IsChecked = ( GetMainPrivateProfileInt(S_PRINTER, K_ENABLE, 0) <> 0)
+ m_bPrintLabel_IsChecked = (GetMainPrivateProfileInt(S_PRINTER, K_ENABLE, 0) <> 0)
' assegno le liste dei parametri della macchina corrente alla ConfigMachTableList alla pagina di Configurazione
ConfigMachTableList = CurrentMachine.MachTableList
' carico i parametri Q dei Process letti dall'ini
@@ -346,10 +363,14 @@ Public Class ConfigurationPageVM
m_QBTLParamVMList_View = CollectionViewSource.GetDefaultView(m_QBTLParamVMList)
m_QBTLParamVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(QBTLParamVM.GroupType)))
m_QBTLParamVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(QBTLParamVM.ghDesc)))
+ ' leggo path per backup
+ GetMainPrivateProfileString(S_BACKUPANDRESTORE, K_FILEPATH, "", m_BackupFilePath)
End Sub
#End Region ' Constructor
+#Region "COMMANDS"
+
#Region "SaveCommand"
'''
@@ -373,6 +394,123 @@ Public Class ConfigurationPageVM
#End Region ' SaveCommand
+#Region "ChooseBackupFilePath"
+
+ '''
+ ''' Returns a command that do Save.
+ '''
+ Public ReadOnly Property ChooseBackupFilePath_Command As ICommand
+ Get
+ If m_cmdChooseBackupFilePath Is Nothing Then
+ m_cmdChooseBackupFilePath = New Command(AddressOf ChooseBackupFilePath)
+ End If
+ Return m_cmdChooseBackupFilePath
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Save. This method is invoked by the SaveCommand.
+ '''
+ Public Sub ChooseBackupFilePath()
+ Dim FileDialog As New Microsoft.Win32.SaveFileDialog() With {.FileName = m_BackupFilePath,
+ .CheckFileExists = False,
+ .CheckPathExists = False,
+ .OverwritePrompt = False,
+ .Title = "Backup & Restore File Path"}
+ If FileDialog.ShowDialog() Then
+ m_BackupFilePath = FileDialog.FileName
+ NotifyPropertyChanged(NameOf(BackupFilePath))
+ End If
+ End Sub
+
+#End Region ' ChooseBackupFilePath
+
+#Region "Backup"
+
+ '''
+ ''' Returns a command that do Save.
+ '''
+ Public ReadOnly Property Backup_Command As ICommand
+ Get
+ If m_cmdBackup Is Nothing Then
+ m_cmdBackup = New Command(AddressOf Backup)
+ End If
+ Return m_cmdBackup
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Save. This method is invoked by the SaveCommand.
+ '''
+ Public Sub Backup()
+ If Not String.IsNullOrWhiteSpace(m_BackupFilePath) AndAlso Directory.Exists(Path.GetDirectoryName(m_BackupFilePath)) Then
+ If File.Exists(m_BackupFilePath) Then
+ If MessageBox.Show("Are you sure you want to overwrite the file?", "Info", MessageBoxButton.OKCancel, MessageBoxImage.Warning) = MessageBoxResult.OK Then
+ ' rinomino ed elimino file gia' esistente
+ Try
+ File.Move(m_BackupFilePath, m_BackupFilePath & ".old")
+ File.Delete(m_BackupFilePath)
+ Catch ex As Exception
+ MessageBox.Show("Backup failed! Impossible to move or delete previous file!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
+ End Try
+ ' backup del corrente
+ Try
+
+ Catch ex As Exception
+ MessageBox.Show("Backup failed! Impossible to create the backup package!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
+ End Try
+ Else Return
+ End If
+ End If
+ End If
+ End Sub
+
+#End Region ' Backup
+
+#Region "Restore"
+
+ '''
+ ''' Returns a command that do Save.
+ '''
+ Public ReadOnly Property Restore_Command As ICommand
+ Get
+ If m_cmdRestore Is Nothing Then
+ m_cmdRestore = New Command(AddressOf Restore)
+ End If
+ Return m_cmdRestore
+ End Get
+ End Property
+
+ '''
+ ''' Execute the Save. This method is invoked by the SaveCommand.
+ '''
+ Public Sub Restore()
+ If Not String.IsNullOrWhiteSpace(m_BackupFilePath) AndAlso Directory.Exists(Path.GetDirectoryName(m_BackupFilePath)) Then
+ If File.Exists(m_BackupFilePath) Then
+ If MessageBox.Show("Are you sure you want to restore this file?", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning) = MessageBoxResult.OK Then
+ ' backup del corrente
+ Try
+ File.Move(m_BackupFilePath, m_BackupFilePath & ".old")
+ File.Delete(m_BackupFilePath)
+ Catch ex As Exception
+ MessageBox.Show("Backup failed! Impossible to move or delete previous file!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
+ End Try
+ ' restore di quello indicato
+ Try
+
+ Catch ex As Exception
+ MessageBox.Show("Backup failed! Impossible to create the backup package!", "Error", MessageBoxButton.OK, MessageBoxImage.Error)
+ End Try
+ Else Return
+ End If
+ End If
+ End If
+ End Sub
+
+#End Region ' Restore
+
+#End Region ' COMMANDS
+
#Region "Methods"
' funzione che scrive i parametri modificati sul file INI