1038 lines
37 KiB
VB.net
1038 lines
37 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports System.IO.Compression
|
|
Imports System.Reflection
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class ConfigurationPageVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Public Enum ConfigSubPages As Integer
|
|
GENERAL = 0
|
|
MACHINE = 1
|
|
PDFEDITOR = 2
|
|
End Enum
|
|
|
|
Private m_SelConfigSubPage As ConfigSubPages = ConfigSubPages.GENERAL
|
|
Public Property SelConfigSubPage As Integer
|
|
Get
|
|
Return m_SelConfigSubPage
|
|
End Get
|
|
Set(value As Integer)
|
|
m_SelConfigSubPage = value
|
|
If m_SelConfigSubPage = ConfigSubPages.GENERAL Then
|
|
' Controllo se il file CustomConfig Json è stato modificato
|
|
If Map.refStrategyManagerVM.bIsModifyStrategy Then Map.refStrategyManagerVM.SaveCustomConfigJson()
|
|
SetGeneral_Visibility(True)
|
|
SetStrategyManager_Visibility(False)
|
|
SetPDFEditor_Visibility(False)
|
|
ElseIf m_SelConfigSubPage = ConfigSubPages.MACHINE Then
|
|
' Controllo se il file CustomConfig Json è stato modificato
|
|
If Map.refStrategyManagerVM.bIsModifyStrategy Then Map.refStrategyManagerVM.SaveCustomConfigJson()
|
|
SetGeneral_Visibility(False)
|
|
SetStrategyManager_Visibility(False)
|
|
SetPDFEditor_Visibility(False)
|
|
ElseIf m_SelConfigSubPage = ConfigSubPages.PDFEDITOR Then
|
|
' Controllo se il file CustomConfig Json è stato modificato
|
|
If Map.refStrategyManagerVM.bIsModifyStrategy Then Map.refStrategyManagerVM.SaveCustomConfigJson()
|
|
SetPDFEditor_Visibility(True)
|
|
SetGeneral_Visibility(False)
|
|
SetStrategyManager_Visibility(False)
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' flag modifica parametri Macchina
|
|
Friend bModifyMachParam As Boolean
|
|
|
|
Public ReadOnly Property MachinePanelVM As MachinePanelVM
|
|
Get
|
|
Return Map.refMachinePanelVM
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Custom_Visibility As Visibility
|
|
Get
|
|
Return Visibility.Visible
|
|
End Get
|
|
End Property
|
|
|
|
Private m_PRCList As New ObservableCollection(Of PRC)
|
|
Public ReadOnly Property PRCList As ObservableCollection(Of PRC)
|
|
Get
|
|
Return m_PRCList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_LanguageList As New ObservableCollection(Of Language)
|
|
Public ReadOnly Property LanguageList As ObservableCollection(Of Language)
|
|
Get
|
|
Return m_LanguageList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_UnitMeasureList As List(Of String) = New List(Of String)({"inch", "mm"})
|
|
Public ReadOnly Property UnitMeasureList As List(Of String)
|
|
Get
|
|
Return m_UnitMeasureList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelectedLanguage As Language
|
|
Public Property SelectedLanguage As Language
|
|
Get
|
|
Return m_SelectedLanguage
|
|
End Get
|
|
Set(value As Language)
|
|
If value IsNot m_SelectedLanguage Then
|
|
m_SelectedLanguage = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public Property SelMeasureUnit As Integer
|
|
Get
|
|
Return If(EgtUiUnitsAreMM(), MeasureUnitOpt.MM, MeasureUnitOpt.INCH)
|
|
End Get
|
|
Set(value As Integer)
|
|
' salvo unità di misura precedente
|
|
Dim PrevMeasureUnit As MeasureUnitOpt = If(EgtUiUnitsAreMM(), MeasureUnitOpt.MM, MeasureUnitOpt.INCH)
|
|
If value <> PrevMeasureUnit Then
|
|
' cambio unità di misura
|
|
EgtSetUiUnits(DirectCast(value, MeasureUnitOpt) = MeasureUnitOpt.MM)
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SectionTime As Double
|
|
Public Property SectionTime As String
|
|
Get
|
|
Return DoubleToString(m_SectionTime, 5)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dVal As Double = 0
|
|
If StringToDoubleAdv(value, dVal, True) AndAlso dVal > 0 Then
|
|
m_SectionTime = dVal
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_PartTime As Double
|
|
Public Property PartTime As String
|
|
Get
|
|
Return DoubleToString(m_PartTime, 5)
|
|
End Get
|
|
Set(value As String)
|
|
Dim dVal As Double = 0
|
|
If StringToDoubleAdv(value, dVal, True) AndAlso dVal > 0 Then
|
|
m_PartTime = dVal
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bPrintLabel_IsChecked As Boolean
|
|
Public Property bPrintLabel_IsChecked As String
|
|
Get
|
|
Return m_bPrintLabel_IsChecked
|
|
End Get
|
|
Set(value As String)
|
|
m_bPrintLabel_IsChecked = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bBackupRunning As Boolean = False
|
|
Public ReadOnly Property bBackupRunning As Boolean
|
|
Get
|
|
Return m_bBackupRunning
|
|
End Get
|
|
End Property
|
|
|
|
Private m_bRestoreRunning As Boolean = False
|
|
Public ReadOnly Property bRestoreRunning As Boolean
|
|
Get
|
|
Return m_bRestoreRunning
|
|
End Get
|
|
End Property
|
|
|
|
Private m_bExternalBackupActive As Boolean
|
|
Public Property bExternalBackupActive As Boolean
|
|
Get
|
|
Return m_bExternalBackupActive
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bExternalBackupActive = value
|
|
WriteMainPrivateProfileString(S_BACKUPANDRESTORE, K_EXTERNALBACKUPACTIVE, If(m_bExternalBackupActive, 1, 0))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ExternalBackupFolderPath As String
|
|
Public Property ExternalBackupFolderPath As String
|
|
Get
|
|
Return m_ExternalBackupFolderPath
|
|
End Get
|
|
Set(value As String)
|
|
m_ExternalBackupFolderPath = value
|
|
WriteMainPrivateProfileString(S_BACKUPANDRESTORE, K_EXTERNALFILEPATH, m_ExternalBackupFolderPath)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ReminderList As New List(Of IdNameStruct)({New IdNameStruct(0, EgtMsg(61988)), New IdNameStruct(1, EgtMsg(61989)), New IdNameStruct(2, EgtMsg(61990)), New IdNameStruct(7, EgtMsg(61991)), New IdNameStruct(14, EgtMsg(61992)), New IdNameStruct(30, EgtMsg(61993))})
|
|
Public ReadOnly Property ReminderList As List(Of IdNameStruct)
|
|
Get
|
|
Return m_ReminderList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelReminder As IdNameStruct
|
|
Public Property SelReminder As IdNameStruct
|
|
Get
|
|
Return m_SelReminder
|
|
End Get
|
|
Set(value As IdNameStruct)
|
|
m_SelReminder = value
|
|
WriteMainPrivateProfileString(S_BACKUPANDRESTORE, K_REMINDERFREQUENCY, m_SelReminder.Id)
|
|
End Set
|
|
End Property
|
|
|
|
Private m_bGeneral_Visibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property General_Visibility As Visibility
|
|
Get
|
|
Return m_bGeneral_Visibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetGeneral_Visibility(value As Boolean)
|
|
m_bGeneral_Visibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(General_Visibility))
|
|
End Sub
|
|
|
|
Private m_bStrategyManager_Visibility As Visibility = Visibility.Visible
|
|
Public ReadOnly Property StrategyManager_Visibility As Visibility
|
|
Get
|
|
Return m_bStrategyManager_Visibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetStrategyManager_Visibility(value As Boolean)
|
|
m_bStrategyManager_Visibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(StrategyManager_Visibility))
|
|
End Sub
|
|
|
|
Private m_bMachine_Visibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property Machine_Visibility As Visibility
|
|
Get
|
|
Return m_bMachine_Visibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetMachine_Visibility(value As Boolean)
|
|
m_bMachine_Visibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(Machine_Visibility))
|
|
End Sub
|
|
|
|
Private m_bPDFEditor_Visibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property PDFEditor_Visibility As Visibility
|
|
Get
|
|
Return m_bPDFEditor_Visibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetPDFEditor_Visibility(value As Boolean)
|
|
m_bPDFEditor_Visibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(PDFEditor_Visibility))
|
|
End Sub
|
|
|
|
Friend m_MachineParameter_Visibility As Visibility = Visibility.Collapsed
|
|
Public ReadOnly Property MachineParameter_Visibility As Visibility
|
|
Get
|
|
Return m_MachineParameter_Visibility
|
|
End Get
|
|
End Property
|
|
Friend Sub SetMachineParameter_Visibility(value As Boolean)
|
|
m_MachineParameter_Visibility = If(value, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(MachineParameter_Visibility))
|
|
End Sub
|
|
|
|
Private m_bVerifyImportBTL_IsChecked As Boolean = False
|
|
Public Property bVerifyImportBTL_IsChecked As String
|
|
Get
|
|
Return m_bVerifyImportBTL_IsChecked
|
|
End Get
|
|
Set(value As String)
|
|
m_bVerifyImportBTL_IsChecked = value
|
|
WriteMainPrivateProfileString(S_GENERAL, K_VERIFYIMPORTBTL, If(m_bVerifyImportBTL_IsChecked, 1, 0))
|
|
End Set
|
|
End Property
|
|
|
|
'Private ReadOnly m_ThemesDataService As New ThemesDataServiceVM()
|
|
|
|
'Private m_Themes As New ObservableCollection(Of ThemesDataServiceM)
|
|
'Public Property Themes As ObservableCollection(Of ThemesDataServiceM)
|
|
' Get
|
|
' Return m_Themes
|
|
' End Get
|
|
' Set(value As ObservableCollection(Of ThemesDataServiceM))
|
|
' If Not m_Themes.Equals(value) Then
|
|
' m_Themes = value
|
|
' End If
|
|
' End Set
|
|
'End Property
|
|
|
|
'Private m_SelectedThema As Integer = 0
|
|
'Private m_SelectedTheme As ThemesDataServiceM
|
|
'Public Property SelectedTheme As ThemesDataServiceM
|
|
' Get
|
|
' Return m_SelectedTheme
|
|
' End Get
|
|
' Set(value As ThemesDataServiceM)
|
|
' m_ThemesDataService.SetTheme(value)
|
|
' m_SelectedTheme = value
|
|
' ' salvo in file ini la scelta del tema corrente
|
|
' Dim IndexThema As Integer = Themes.IndexOf(m_SelectedTheme)
|
|
' If IndexThema < 0 Then
|
|
' IndexThema = 0
|
|
' End If
|
|
' WriteMainPrivateProfileString(S_GENERAL, K_THEMA, IndexThema.ToString())
|
|
' m_SelectedThema = IndexThema
|
|
' End Set
|
|
'End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdSave As ICommand
|
|
Private m_cmdChooseExternalBackupFolderPath As ICommand
|
|
Private m_cmdBackup As ICommand
|
|
Private m_cmdRestore As ICommand
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property L_Msg As String
|
|
Get
|
|
Return EgtMsg(61803)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property T_Msg As String
|
|
Get
|
|
Return EgtMsg(61804)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PRC_Msg As String
|
|
Get
|
|
Return EgtMsg(61805)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PND_Msg As String
|
|
Get
|
|
Return EgtMsg(61809)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Type_Msg As String
|
|
Get
|
|
Return EgtMsg(61850)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NAM_Msg As String
|
|
Get
|
|
Return EgtMsg(61608)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Description_Msg As String
|
|
Get
|
|
Return EgtMsg(61603)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Default_Msg As String
|
|
Get
|
|
Return EgtMsg(61802)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Min_Msg As String
|
|
Get
|
|
Return EgtMsg(61616)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Max_Msg As String
|
|
Get
|
|
Return EgtMsg(61617)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CurrentLanguage_Msg As String
|
|
Get
|
|
Return EgtMsg(6501)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property LanguageAdvert_Msg As String
|
|
Get
|
|
Return EgtMsg(6502)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property MMUnits_Msg As String
|
|
Get
|
|
Return EgtMsg(6540)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Nesting_Msg As String
|
|
Get
|
|
Return EgtMsg(61829)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SectionTime_Msg As String
|
|
Get
|
|
Return EgtMsg(61806)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PartTime_Msg As String
|
|
Get
|
|
Return EgtMsg(61807)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DisplayIndex_Msg As String
|
|
Get
|
|
Return EgtMsg(61842)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ColumnName_Msg As String
|
|
Get
|
|
Return EgtMsg(61843)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CanUserReorder_Msg As String
|
|
Get
|
|
Return EgtMsg(61844)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CanUserResize_Msg As String
|
|
Get
|
|
Return EgtMsg(61845)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CanUserSort_Msg As String
|
|
Get
|
|
Return EgtMsg(61846)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property IsReadOnly_Msg As String
|
|
Get
|
|
Return EgtMsg(61847)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Visible_Msg As String
|
|
Get
|
|
Return EgtMsg(61848)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PrintLabel_Msg As String
|
|
Get
|
|
Return EgtMsg(61894)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property General_Msg As String
|
|
Get
|
|
Return EgtMsg(62535).ToUpper()
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Strategy_Msg As String
|
|
Get
|
|
Return EgtMsg(62569).ToUpper()
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Machine_Msg As String
|
|
Get
|
|
Return EgtMsg(62537).ToUpper()
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PDFEditor_Msg As String
|
|
Get
|
|
Return EgtMsg(62538).ToUpper()
|
|
End Get
|
|
End Property
|
|
|
|
' Messaggi Versione
|
|
|
|
Public ReadOnly Property CtrlVersion_Msg As String
|
|
Get
|
|
Return EgtMsg(61739).ToUpper()
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ActVersion_Msg As String
|
|
Get
|
|
Return EgtMsg(61740)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property AllVersion_Msg As String
|
|
Get
|
|
Return EgtMsg(61741)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property VersionFrom_Msg As String
|
|
Get
|
|
Return EgtMsg(61742)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property NumVersion_Msg As String
|
|
Get
|
|
Return EgtMsg(61743)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Version_Msg As String
|
|
Get
|
|
Return EgtMsg(61744)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DateVersion_Msg As String
|
|
Get
|
|
Return EgtMsg(61745)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property StateVersion_Msg As String
|
|
Get
|
|
Return EgtMsg(61746)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property TemaAdvert_Msg As String
|
|
Get
|
|
Return EgtMsg(110008) ' Il nuovo tema diventerà corrente quando verrà selezionato.
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Tema_Msg As String
|
|
Get
|
|
Return EgtMsg(110009) ' Tema
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Import_Msg As String
|
|
Get
|
|
Return EgtMsg(63042)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Backup_Msg As String
|
|
Get
|
|
Return EgtMsg(63022)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Restore_Msg As String
|
|
Get
|
|
Return EgtMsg(63025)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Remainder_Msg As String
|
|
Get
|
|
Return EgtMsg(63043)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property External_Msg As String
|
|
Get
|
|
Return EgtMsg(63044)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property BackupRestore_Msg As String
|
|
Get
|
|
Return EgtMsg(63045)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' imposto riferimento in Map
|
|
Map.SetRefConfigurationPageVM(Me)
|
|
' Leggo nome lingua corrente
|
|
Dim sLanguage As String = String.Empty
|
|
GetMainPrivateProfileString(S_GENERAL, K_MESSAGES, "", sLanguage)
|
|
' Leggo elenco lingue disponibili da file ini e imposto lingua corrente
|
|
Dim nIndex As Integer = 1
|
|
While True
|
|
Dim ReadLanguage As Language = GetMainPrivateProfileLanguage(S_LANGUAGES, K_LANGUAGE & nIndex)
|
|
If IsNothing(ReadLanguage) Then Exit While
|
|
m_LanguageList.Add(ReadLanguage)
|
|
If String.Compare(ReadLanguage.Name, sLanguage, True) = 0 Then
|
|
m_SelectedLanguage = ReadLanguage
|
|
End If
|
|
nIndex += 1
|
|
End While
|
|
' Inizializzo la lingua corrente
|
|
m_SelectedLanguage = m_LanguageList(0)
|
|
Dim sMsgName As String = String.Empty
|
|
IniFile.GetMainPrivateProfileString(S_GENERAL, K_MESSAGES, "", sMsgName)
|
|
For Each Language In m_LanguageList
|
|
If Language.Name = sMsgName Then
|
|
m_SelectedLanguage = Language
|
|
Exit For
|
|
End If
|
|
Next
|
|
' 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)
|
|
' leggo dati per backup
|
|
GetMainPrivateProfileString(S_BACKUPANDRESTORE, K_EXTERNALFILEPATH, "", m_ExternalBackupFolderPath)
|
|
Dim nDefaultReminderFrequency As Integer = GetMainPrivateProfileInt(S_BACKUPANDRESTORE, K_REMINDERFREQUENCY, 1)
|
|
SelReminder = m_ReminderList.FirstOrDefault(Function(x) x.Id = nDefaultReminderFrequency)
|
|
Dim nExternalBackupActive As Integer = GetMainPrivateProfileInt(S_BACKUPANDRESTORE, K_EXTERNALBACKUPACTIVE, 0)
|
|
m_bExternalBackupActive = nExternalBackupActive > 0
|
|
SetMachineParameter_Visibility(False)
|
|
SetMachine_Visibility(False)
|
|
' Recupero flag per verificare se fare solo l'importazione del btl o anche la verifica
|
|
m_bVerifyImportBTL_IsChecked = GetMainPrivateProfileInt(S_GENERAL, K_VERIFYIMPORTBTL, 0) <> 0
|
|
'' imposto il tema
|
|
'm_SelectedThema = GetMainPrivateProfileInt(S_GENERAL, K_THEMA, 0)
|
|
'LoadThemes()
|
|
NotifyPropertyChanged(NameOf(bExternalBackupActive))
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "METHODS"
|
|
|
|
' funzione che verifica la modifica dei valori in Configurazione e ne chiede il salvataggio
|
|
Friend Sub VerifyConfigPageModification()
|
|
' aggiorno tutti i valori senza verificare modifiche
|
|
WriteMainPrivateProfileString(S_GENERAL, K_MESSAGES, m_SelectedLanguage.Name)
|
|
WriteMainPrivateProfileString(S_SCENE, K_MMUNITS, SelMeasureUnit.ToString())
|
|
WriteMainPrivateProfileString(S_NEST, K_SECTIONTIME, DoubleToString(m_SectionTime, 5))
|
|
WriteMainPrivateProfileString(S_NEST, K_PARTTIME, DoubleToString(m_PartTime, 5))
|
|
WriteMainPrivateProfileString(S_PRINTER, K_ENABLE, If(m_bPrintLabel_IsChecked, 1, 0))
|
|
Map.refMyMachine.VerifyConfigPageModification()
|
|
End Sub
|
|
|
|
' funzione che verifica l'inserimento della password quando si edita un parametro Macchina
|
|
Friend Function VerifyConfigPagePassword() As Boolean
|
|
' Display message, title, and default value.
|
|
Dim InputPwdWndVM As New InputPwdWndVM()
|
|
Dim InputPwdWnd As New InputPwdWndV(Application.Current.MainWindow, InputPwdWndVM)
|
|
If InputPwdWnd.ShowDialog() Then
|
|
' Lettura PWD dall'INI e confronto
|
|
Dim sPwdIni As String = String.Empty
|
|
If GetMainPrivateProfileString(S_MACH, K_PASSWORD, "", sPwdIni) <> 0 Then
|
|
If sPwdIni = InputPwdWndVM.sPassword Then Return True
|
|
End If
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
'''' <summary>
|
|
'''' Seleziona il tema se presente
|
|
'''' </summary>
|
|
'''' <param name="IndexThema"></param>
|
|
'Public Sub SetThema(IndexThema As Integer)
|
|
' If m_Themes.Count > 0 Then
|
|
' m_ThemesDataService.SetTheme(m_Themes(IndexThema))
|
|
' End If
|
|
'End Sub
|
|
|
|
'''' <summary>
|
|
'''' Fuzione che carica i temi del dizionario
|
|
'''' </summary>
|
|
'Private Sub LoadThemes()
|
|
' ' Popolo la lista temi
|
|
' m_Themes.Add(New ThemesDataServiceM() With {
|
|
' .Name = "Default",
|
|
' .Path = "Themes/DefaultDictionary.xaml",
|
|
' .AssemblyName = "EgtBEAMWALL.Core"
|
|
' })
|
|
' m_Themes.Add(New ThemesDataServiceM() With {
|
|
' .Name = "Dark",
|
|
' .Path = "Themes/DarkDictionary.xaml",
|
|
' .AssemblyName = "EgtBEAMWALL.Core"
|
|
' })
|
|
' ' Seleziono elemento in ComboBox
|
|
' m_SelectedTheme = m_Themes(m_SelectedThema)
|
|
' ' Attivo il tema letto sopra
|
|
' SetThema(m_SelectedThema)
|
|
'End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "SaveCommand"
|
|
|
|
Public ReadOnly Property SaveCommand As ICommand
|
|
Get
|
|
If m_cmdSave Is Nothing Then
|
|
m_cmdSave = New Command(AddressOf Save)
|
|
End If
|
|
Return m_cmdSave
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Save()
|
|
VerifyConfigPageModification()
|
|
End Sub
|
|
|
|
#End Region ' SaveCommand
|
|
|
|
#Region "ChooseExternalBackupFolderPath"
|
|
|
|
Public ReadOnly Property ChooseExternalBackupFolderPath_Command As ICommand
|
|
Get
|
|
If m_cmdChooseExternalBackupFolderPath Is Nothing Then
|
|
m_cmdChooseExternalBackupFolderPath = New Command(AddressOf ChooseExternalBackupFolderPath)
|
|
End If
|
|
Return m_cmdChooseExternalBackupFolderPath
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ChooseExternalBackupFolderPath()
|
|
Dim FileDialog As New Microsoft.Win32.SaveFileDialog() With {.InitialDirectory = m_ExternalBackupFolderPath,
|
|
.CheckFileExists = False,
|
|
.CheckPathExists = False,
|
|
.DefaultExt = ".folder",
|
|
.OverwritePrompt = False,
|
|
.FileName = "Select this ",
|
|
.Title = EgtMsg(63039)}
|
|
If FileDialog.ShowDialog() Then
|
|
m_ExternalBackupFolderPath = Path.GetDirectoryName(FileDialog.FileName)
|
|
WriteMainPrivateProfileString(S_BACKUPANDRESTORE, K_EXTERNALFILEPATH, m_ExternalBackupFolderPath)
|
|
NotifyPropertyChanged(NameOf(ExternalBackupFolderPath))
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' ChooseExternalBackupFolderPath
|
|
|
|
#Region "Backup"
|
|
|
|
Public ReadOnly Property Backup_Command As ICommand
|
|
Get
|
|
If m_cmdBackup Is Nothing Then
|
|
m_cmdBackup = New Command(AddressOf BackupCmd)
|
|
End If
|
|
Return m_cmdBackup
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub BackupCmd()
|
|
Backup(True)
|
|
End Sub
|
|
|
|
Public Sub Backup(bLoadingWindow As Boolean)
|
|
m_bBackupRunning = True
|
|
' verifico se esiste cartella backup, altrimenti la creo
|
|
Dim sBackupFolder As String = Map.refMainWindowVM.MainWindowM.sDataDir & "\Backup"
|
|
If Directory.Exists(sBackupFolder) Then
|
|
' verifico se devo cancellare backup vecchi
|
|
Dim nBackupCount As Integer = 0
|
|
Dim YearDirList() As String = Directory.GetDirectories(sBackupFolder)
|
|
For YearIndex = YearDirList.Length - 1 To 0 Step -1
|
|
Dim nYear As Integer = 0
|
|
Integer.TryParse(Path.GetFileName(YearDirList(YearIndex)), nYear)
|
|
Dim sYearDir As String = sBackupFolder & "\" & nYear
|
|
Dim MonthDirList() As String = Directory.GetDirectories(sYearDir)
|
|
For MonthIndex = MonthDirList.Length - 1 To 0 Step -1
|
|
Dim nMonth As Integer = 0
|
|
Integer.TryParse(Path.GetFileName(MonthDirList(MonthIndex)), nMonth)
|
|
Dim sMonthDir As String = sYearDir & "\" & nMonth
|
|
Dim DayDirList() As String = Directory.GetDirectories(sMonthDir)
|
|
For DayIndex = DayDirList.Length - 1 To 0 Step -1
|
|
Dim nDay As Integer = 0
|
|
Integer.TryParse(Path.GetFileName(DayDirList(DayIndex)), nDay)
|
|
If nBackupCount > 3 Then
|
|
Directory.Delete(sBackupFolder & "\" & nYear & "\" & nMonth & "\" & nDay, True)
|
|
End If
|
|
Next
|
|
DayDirList = Directory.GetDirectories(sMonthDir)
|
|
If IsNothing(DayDirList) OrElse DayDirList.Length = 0 Then
|
|
Directory.Delete(sMonthDir)
|
|
End If
|
|
Next
|
|
MonthDirList = Directory.GetDirectories(sYearDir)
|
|
If IsNothing(MonthDirList) OrElse MonthDirList.Length = 0 Then
|
|
Directory.Delete(sYearDir)
|
|
End If
|
|
Next
|
|
Else
|
|
Directory.CreateDirectory(sBackupFolder)
|
|
End If
|
|
sBackupFolder &= "\" & DateTime.Now().Year
|
|
If Not Directory.Exists(sBackupFolder) Then
|
|
Directory.CreateDirectory(sBackupFolder)
|
|
End If
|
|
sBackupFolder &= "\" & DateTime.Now().Month
|
|
If Not Directory.Exists(sBackupFolder) Then
|
|
Directory.CreateDirectory(sBackupFolder)
|
|
End If
|
|
sBackupFolder &= "\" & DateTime.Now().Day
|
|
If Not Directory.Exists(sBackupFolder) Then
|
|
Directory.CreateDirectory(sBackupFolder)
|
|
End If
|
|
sBackupFolder &= "\" & DateTime.Now().ToString("yyyyMMddHHmmss") & ".bwbck"
|
|
Dim sBackupZipPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\DbBackup.zip"
|
|
' apro finestra di caricamento
|
|
If bLoadingWindow Then LoadingWndHelper.OpenLoadingWnd(ActiveIds.BACKUP, 2, EgtMsg(63022), EgtMsg(63023), 15) ' Backup ' Database backup
|
|
Dim bOk As Boolean = True
|
|
' backup del Db corrente
|
|
Try
|
|
DataLayer.DbConfig.DataBaseDumpToFile(sBackupZipPath)
|
|
Catch ex As Exception
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(62103), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
bOk = False
|
|
End Try
|
|
If bOk AndAlso File.Exists(sBackupZipPath) Then
|
|
If bLoadingWindow Then LoadingWndHelper.UpdateLoadingWnd(ActiveIds.BACKUP, 2, EgtMsg(63024), 15, 100) ' Projects backup
|
|
' backup dei progetti correnti
|
|
Try
|
|
Using zipStream As FileStream = New FileStream(sBackupFolder, FileMode.Create)
|
|
Using archive As ZipArchive = New ZipArchive(zipStream, ZipArchiveMode.Create)
|
|
Dim dbEntry As ZipArchiveEntry = archive.CreateEntry(Path.GetFileName(sBackupZipPath), CompressionLevel.NoCompression)
|
|
Using entryStream = dbEntry.Open()
|
|
Using fileStream = File.OpenRead(sBackupZipPath)
|
|
fileStream.CopyTo(entryStream)
|
|
End Using
|
|
End Using
|
|
|
|
Dim sProjectFolder As String = Map.refMainWindowVM.MainWindowM.sDataDir & "\"
|
|
Dim sKey As String = ""
|
|
EgtGetKeyInfo(sKey)
|
|
sKey = sKey.Replace(" ", "")
|
|
|
|
Dim sUserFolder As String = ""
|
|
If Not IsNothing(sKey) AndAlso sKey.Length > 11 Then
|
|
sUserFolder = sKey.Substring(3, 6)
|
|
sProjectFolder &= sUserFolder
|
|
End If
|
|
|
|
If Directory.Exists(sProjectFolder) Then
|
|
AddDirectoryToZip(archive, sProjectFolder, sUserFolder)
|
|
End If
|
|
End Using
|
|
End Using
|
|
Catch ex As Exception
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(62103), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
bOk = False
|
|
End Try
|
|
End If
|
|
' se esiste zip del Db, lo elimino
|
|
If File.Exists(sBackupZipPath) Then
|
|
File.Delete(sBackupZipPath)
|
|
End If
|
|
' se richiesto faccio copia su external source
|
|
If m_bExternalBackupActive Then
|
|
If Directory.Exists(m_ExternalBackupFolderPath) Then
|
|
CopyForExternalBackup(sBackupFolder, m_ExternalBackupFolderPath)
|
|
Else
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(62104), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) ' External folder does not exist or is not reachable! Copy to external folder impossible!
|
|
End If
|
|
End If
|
|
'chiudo finestra di caricamento
|
|
If bLoadingWindow Then LoadingWndHelper.CloseLoadingWnd(ActiveIds.BACKUP)
|
|
m_bBackupRunning = False
|
|
End Sub
|
|
|
|
Private Async Sub CopyForExternalBackup(sBackupFile As String, sExternalBackupFolder As String)
|
|
Using SourceStream As FileStream = File.Open(sBackupFile, FileMode.Open)
|
|
Dim sExternalBackupFile As String = sExternalBackupFolder & "\" & Path.GetFileName(sBackupFile)
|
|
Using DestinationStream As FileStream = File.Create(sExternalBackupFile)
|
|
Await SourceStream.CopyToAsync(DestinationStream)
|
|
End Using
|
|
End Using
|
|
End Sub
|
|
|
|
Private Sub AddDirectoryToZip(archive As ZipArchive, folderPath As String, entryRoot As String)
|
|
Dim files As String() = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories)
|
|
|
|
For Each file As String In files
|
|
Dim relativePath As String = entryRoot & "\" & file.Substring(folderPath.Length).TrimStart("\"c)
|
|
Dim entry As ZipArchiveEntry = archive.CreateEntry(relativePath, CompressionLevel.NoCompression)
|
|
|
|
Using entryStream = entry.Open()
|
|
Using fileStream = System.IO.File.OpenRead(file)
|
|
fileStream.CopyTo(entryStream)
|
|
End Using
|
|
End Using
|
|
Next
|
|
End Sub
|
|
|
|
#End Region ' Backup
|
|
|
|
#Region "Restore"
|
|
|
|
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
|
|
|
|
Public Sub Restore()
|
|
' recupero processo del supervisore
|
|
Dim sSupervisorName As String = "Aedifica.SupervisorR32"
|
|
Dim localProc As Process() = Process.GetProcessesByName(sSupervisorName)
|
|
' verifico che sia chiuso
|
|
If localProc.Length > 0 Then
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(62105), EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) ' Please verify the machine is stoped and close the supervisor before proceding with the restore operation!
|
|
Return
|
|
End If
|
|
m_bRestoreRunning = True
|
|
' verifico se esiste backup
|
|
Dim sBackupFolder As String = Map.refMainWindowVM.MainWindowM.sDataDir & "\Backup"
|
|
Dim nYear As Integer = 0
|
|
Dim nMonth As Integer = 0
|
|
Dim nDay As Integer = 0
|
|
Dim sRestorePath As String = ""
|
|
If Directory.Exists(sBackupFolder) Then
|
|
Dim YearDirList() As String = Directory.GetDirectories(sBackupFolder)
|
|
For YearIndex = YearDirList.Length - 1 To 0 Step -1
|
|
nYear = 0
|
|
Integer.TryParse(Path.GetFileName(YearDirList(YearIndex)), nYear)
|
|
Dim sYearDir As String = sBackupFolder & "\" & nYear
|
|
Dim MonthDirList() As String = Directory.GetDirectories(sYearDir)
|
|
For MonthIndex = MonthDirList.Length - 1 To 0 Step -1
|
|
nMonth = 0
|
|
Integer.TryParse(Path.GetFileName(MonthDirList(MonthIndex)), nMonth)
|
|
Dim sMonthDir As String = sYearDir & "\" & nMonth
|
|
Dim DayDirList() As String = Directory.GetDirectories(sMonthDir)
|
|
For DayIndex = DayDirList.Length - 1 To 0 Step -1
|
|
nDay = 0
|
|
Integer.TryParse(Path.GetFileName(DayDirList(DayIndex)), nDay)
|
|
Dim sDayDir As String = sMonthDir & "\" & nDay
|
|
Dim VersionList() As String = Directory.GetFiles(sDayDir)
|
|
If VersionList.Length > 0 Then
|
|
Dim nMaxVersion As Int64 = 0
|
|
For Each item As String In VersionList
|
|
Dim nTmp As Int64 = 0
|
|
Int64.TryParse(Path.GetFileNameWithoutExtension(item), nTmp)
|
|
nMaxVersion = Math.Max(nMaxVersion, nTmp)
|
|
Next
|
|
If nMaxVersion > 0 Then
|
|
sRestorePath = sDayDir & "\" & nMaxVersion & ".bwbck"
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
If Not String.IsNullOrEmpty(sRestorePath) Then Exit For
|
|
Next
|
|
If Not String.IsNullOrEmpty(sRestorePath) Then Exit For
|
|
Next
|
|
End If
|
|
If String.IsNullOrEmpty(sRestorePath) Then
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(62106), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) ' Restore impossible! Last backup not found!
|
|
m_bRestoreRunning = False
|
|
Return
|
|
End If
|
|
If EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, String.Format(EgtMsg(62107), nYear, nMonth, nDay), EgtMsg(15002), MessageBoxButton.OKCancel, MessageBoxImage.Warning) <> MessageBoxResult.OK Then 'Are you sure you want to restore the last backup from {0}\{1}\{2}? If you proceed you will lose actual data!
|
|
m_bRestoreRunning = False
|
|
Return
|
|
End If
|
|
Dim bDoBackup = False
|
|
Select Case EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(62108), EgtMsg(15003), MessageBoxButton.YesNoCancel, MessageBoxImage.Information) ' Do you want to do a backup of the current project before proceding with the restore?
|
|
Case MessageBoxResult.Yes
|
|
bDoBackup = True
|
|
Case MessageBoxResult.No
|
|
bDoBackup = False
|
|
Case MessageBoxResult.Cancel
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(62109), EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
m_bRestoreRunning = False
|
|
Return
|
|
End Select
|
|
' apro finestra di caricamento
|
|
LoadingWndHelper.OpenLoadingWnd(ActiveIds.RESTORE, 3, EgtMsg(63025), EgtMsg(63026), If(bDoBackup, 40, 10)) ' Restore ' Database Restore
|
|
If bDoBackup Then
|
|
Backup(False)
|
|
End If
|
|
' recupero cartella corrente dei progetti
|
|
Dim sProjectFolder As String = Map.refMainWindowVM.MainWindowM.sDataDir
|
|
Dim sKey As String = ""
|
|
EgtGetKeyInfo(sKey)
|
|
sKey = sKey.Replace(" ", "")
|
|
Dim sUserFolder As String = ""
|
|
If Not IsNothing(sKey) AndAlso sKey.Length > 11 Then
|
|
sUserFolder = sKey.Substring(3, 6)
|
|
End If
|
|
If Directory.Exists(sProjectFolder & "\" & sUserFolder) Then
|
|
' elimino cartella dei progetti
|
|
Directory.Delete(sProjectFolder & "\" & sUserFolder, True)
|
|
End If
|
|
LoadingWndHelper.UpdateLoadingWnd(ActiveIds.RESTORE, 2, EgtMsg(63027), If(bDoBackup, 40, 10), 80) ' Restore data extraction
|
|
' estraggo lo zip nella cartella Temp
|
|
Dim sRestoreDir As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\Restore"
|
|
If Directory.Exists(sRestoreDir) Then
|
|
Directory.Delete(sRestoreDir, True)
|
|
End If
|
|
Directory.CreateDirectory(sRestoreDir)
|
|
Dim bOk As Boolean = True
|
|
' apro file zip
|
|
Try
|
|
If Directory.Exists(sRestoreDir) Then Directory.Delete(sRestoreDir, True)
|
|
ZipFile.ExtractToDirectory(sRestorePath, sRestoreDir)
|
|
Catch ex1 As Exception
|
|
EgtOutLog("Error! Impossible importing Recovery file " & sRestorePath & "!")
|
|
EgtOutLog("Exception in zip: " & ex1.ToString())
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(62110), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) ' Impossible importing Recovery file!
|
|
bOk = False
|
|
End Try
|
|
Dim sBackupTempPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\DbRestore"
|
|
LoadingWndHelper.UpdateLoadingWnd(ActiveIds.RESTORE, 3, EgtMsg(63028), 80, 100) ' Database restore
|
|
If bOk Then
|
|
' restore del Db
|
|
Try
|
|
DataLayer.DbConfig.DataBaseRestoreFromFile(sRestoreDir & "\DbBackup.zip", "", sBackupTempPath)
|
|
Catch ex As Exception
|
|
EgtBEAMWALL.Core.EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(62111), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) ' Restore failed! Impossible to restore the backup Database
|
|
bOk = False
|
|
End Try
|
|
End If
|
|
If File.Exists(sRestoreDir & "\DbBackup.zip") Then
|
|
File.Delete(sRestoreDir & "\DbBackup.zip")
|
|
End If
|
|
If bOk Then
|
|
' sposto il backup al posto giusto
|
|
Directory.Move(sRestoreDir & "\" & sUserFolder, sProjectFolder & "\" & sUserFolder)
|
|
End If
|
|
If Directory.Exists(sRestoreDir) Then
|
|
Directory.Delete(sRestoreDir)
|
|
End If
|
|
LoadingWndHelper.CloseLoadingWnd(ActiveIds.RESTORE)
|
|
m_bRestoreRunning = False
|
|
End Sub
|
|
|
|
#End Region ' Restore
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class |