Imports System.Collections.ObjectModel
Imports EgtWPFLib5
Imports Newtonsoft.Json
Imports System.IO
Imports EgtBEAMWALL.Core
Imports EgtUILib
Public Class StrategyManagerVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
#Region "bMatchingJson"
' Controllo se le due liste sono uguali
Private m_bMatchingJson As Boolean = True
Friend ReadOnly Property bMatchingJson As Boolean
Get
Return m_bMatchingJson
End Get
End Property
Friend Sub SetbMatchingJson(value As Boolean)
m_bMatchingJson = value
NotifyPropertyChanged(NameOf(bMatchingJson))
End Sub
#End Region ' bMatchingJson
#Region "AvailableStrategy"
' Lista che contiene il file json AvailableStrategyList
Private m_JsonStrategyFeatureList As New ObservableCollection(Of JsonStrategyFeature)
Public Property JsonStrategyFeatureList As ObservableCollection(Of JsonStrategyFeature)
Get
Return m_JsonStrategyFeatureList
End Get
Set(value As ObservableCollection(Of JsonStrategyFeature))
m_JsonStrategyFeatureList = value
NotifyPropertyChanged(NameOf(JsonStrategyFeatureList))
End Set
End Property
' Lista che contiene il file json AvailableStrategyList
Private m_AvailableStrategyList As New ObservableCollection(Of StrategyFeature)
Public Property AvailableStrategyList As ObservableCollection(Of StrategyFeature)
Get
Return m_AvailableStrategyList
End Get
Set(value As ObservableCollection(Of StrategyFeature))
m_AvailableStrategyList = value
NotifyPropertyChanged(NameOf(AvailableStrategyList))
End Set
End Property
#End Region ' AvailableStrategy
#Region "DeactivateStrategy"
' Lista che contiene le strategie che vengono rese non attive
Private m_DeactivateStrategyList As New ObservableCollection(Of Strategy)
Public Property DeactivateStrategyList As ObservableCollection(Of Strategy)
Get
Return m_DeactivateStrategyList
End Get
Set(value As ObservableCollection(Of Strategy))
m_DeactivateStrategyList = value
NotifyPropertyChanged(NameOf(DeactivateStrategyList))
End Set
End Property
' Seleziona l'elemento della lista StrategyList
Public m_SelectDeactivateStrategy As Strategy
Public Property SelectDeactivateStrategy As Strategy
Get
Return m_SelectDeactivateStrategy
End Get
Set(value As Strategy)
m_SelectDeactivateStrategy = value
m_SelectedStrategyParamList = m_SelectDeactivateStrategy
If Not IsNothing(m_SelectDeactivateStrategy) Then
GetTypeMode(m_SelectDeactivateStrategy)
End If
NotifyPropertyChanged(NameOf(SelectDeactivateStrategy))
NotifyPropertyChanged(NameOf(SelectedStrategyParamList))
End Set
End Property
Friend Sub SetSelectedStrategy(value As Strategy)
m_SelectDeactivateStrategy = value
m_SelectedStrategyParamList = value
NotifyPropertyChanged(NameOf(SelectDeactivateStrategy))
NotifyPropertyChanged(NameOf(SelectedStrategyParamList))
End Sub
' Seleziona l'elemento della lista StrategyList
Public m_SelectedStrategyParamList As Strategy
Public Property SelectedStrategyParamList As Strategy
Get
Return m_SelectedStrategyParamList
End Get
Set(value As Strategy)
m_SelectedStrategyParamList = value
If Not IsNothing(m_SelectedStrategyParamList) Then
GetTypeMode(m_SelectedStrategyParamList)
SetStrategyProductionPath(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM.sName & "\" & m_SelectedStrategyParamList.sStrategyID)
End If
NotifyPropertyChanged(NameOf(SelectedStrategyParamList))
End Set
End Property
#End Region ' DeactivateStrategy
#Region "CustomerConfiguration"
' Lista che contiene il file json AvailableStrategyList
Private m_CustomerConfigurationList As New ObservableCollection(Of StrategyFeature)
Public Property CustomerConfigurationList As ObservableCollection(Of StrategyFeature)
Get
Return m_CustomerConfigurationList
End Get
Set(value As ObservableCollection(Of StrategyFeature))
m_CustomerConfigurationList = value
NotifyPropertyChanged(NameOf(CustomerConfigurationList))
End Set
End Property
#End Region ' CustomerConfiguration
#Region "SelTreeItem"
' Permette di selezionare l'elemento dell'albero
Public m_SelTreeItem As Topology
Public Property SelTreeItem As Topology
Get
Return m_SelTreeItem
End Get
Set(value As Topology)
m_SelTreeItem = value
NotifyPropertyChanged(NameOf(SelTreeItem))
End Set
End Property
'''
''' Funzione che aggiorna la selezione dell'elemento dell'albero
'''
''' Elemento dell'albero
Friend Sub UpdateSelTreeItem(Item As Topology)
m_SelTreeItem = Item
' Riattivo pulsanti moveup e movedown
If m_ActiveStrategyList.Count > 0 Then
If Not m_MoveUpSelectedStrategyEnable Then
SetMoveUpSelectedStrategyVisibility(True)
End If
If Not m_MoveDownSelectedStrategyEnable Then
SetMoveDownSelectedStrategyVisibility(True)
End If
End If
NotifyPropertyChanged(NameOf(SelTreeItem))
End Sub
#End Region ' SelTreeItem
#Region "ActiveStrategy"
' Lista che contiene le strategie che vengono rese attive
Private m_ActiveStrategyList As New ObservableCollection(Of Strategy)
Public Property ActiveStrategyList As ObservableCollection(Of Strategy)
Get
Return m_ActiveStrategyList
End Get
Set(value As ObservableCollection(Of Strategy))
m_ActiveStrategyList = value
NotifyPropertyChanged(NameOf(ActiveStrategyList))
End Set
End Property
' Seleziona l'elemento della lista ActiveStrategyList
Public m_SelectedActiveStrategy As Strategy
Public Property SelectedActiveStrategy As Strategy
Get
Return m_SelectedActiveStrategy
End Get
Set(value As Strategy)
m_SelectedActiveStrategy = value
m_SelectedStrategyParamList = m_SelectedActiveStrategy
' Controllo se selezionato non è nullo
If Not IsNothing(m_SelectedActiveStrategy) Then
GetTypeMode(m_SelectedActiveStrategy)
End If
NotifyPropertyChanged(NameOf(SelectedActiveStrategy))
NotifyPropertyChanged(NameOf(SelectedStrategyParamList))
End Set
End Property
Friend Sub SetSelectedActiveStrategy(value As Strategy)
m_SelectedActiveStrategy = value
m_SelectedStrategyParamList = value
NotifyPropertyChanged(NameOf(SelectedActiveStrategy))
NotifyPropertyChanged(NameOf(SelectedStrategyParamList))
End Sub
#End Region ' ActiveStrategy
#Region "AISetup"
' Utilizzata per salvare ultimo file json utilizzato
Public m_sLastCustomConfigJson As String = String.Empty
' Lista dei file json presenti nella cartella AISetUp
Private m_sAISetUpList As New ObservableCollection(Of String)
Public Property sAISetUpList As ObservableCollection(Of String)
Get
Return m_sAISetUpList
End Get
Set(value As ObservableCollection(Of String))
m_sAISetUpList = value
NotifyPropertyChanged(NameOf(sAISetUpList))
End Set
End Property
' File selezionato dalla lista AISetUpList
Private m_sSelectedAISetUp As String
Public Property sSelectedAISetUp As String
Get
Return m_sSelectedAISetUp
End Get
Set(value As String)
m_sSelectedAISetUp = value
If Not IsNothing(m_sSelectedAISetUp) Then
m_ActiveStrategyList.Clear()
m_DeactivateStrategyList.Clear()
ReadAvailableStrategyJson(m_sSelectedAISetUp)
End If
NotifyPropertyChanged(NameOf(sSelectedAISetUp))
End Set
End Property
#End Region ' AISetup
#Region "MoveCommad"
' Rende attivo o disattivo il pulsante moveup
Private m_MoveUpSelectedStrategyEnable As Boolean = True
Public ReadOnly Property MoveUpSelectedStrategyEnable As Boolean
Get
Return m_MoveUpSelectedStrategyEnable
End Get
End Property
Friend Sub SetMoveUpSelectedStrategyVisibility(value As Boolean)
m_MoveUpSelectedStrategyEnable = value
NotifyPropertyChanged(NameOf(MoveUpSelectedStrategyEnable))
End Sub
' Rende attivo o disattivo il pulsante movedown
Private m_MoveDownSelectedStrategyEnable As Boolean = True
Public ReadOnly Property MoveDownSelectedStrategyEnable As Boolean
Get
Return m_MoveDownSelectedStrategyEnable
End Get
End Property
Friend Sub SetMoveDownSelectedStrategyVisibility(value As Boolean)
m_MoveDownSelectedStrategyEnable = value
NotifyPropertyChanged(NameOf(MoveDownSelectedStrategyEnable))
End Sub
#End Region ' MoveCommand
#Region "ModifyStrategy"
' Utilizzato per indicare che viene effettuata una modifica
Private m_bIsModifyStrategy As Boolean = False
Public ReadOnly Property bIsModifyStrategy As Boolean
Get
Return m_bIsModifyStrategy
End Get
End Property
Friend Sub SetbIsModifyStrategy(value As Boolean)
m_bIsModifyStrategy = value
If m_bIsModifyStrategy Then
SetSaveImage("pack://application:,,,/Resources/NewPage/SaveModify.png")
Else
SetSaveImage("pack://application:,,,/Resources/ProjectManager/Save.png")
End If
NotifyPropertyChanged(NameOf(bIsModifyStrategy))
End Sub
' Immagine SaveCommand
Private m_SaveImage As String = "pack://application:,,,/Resources/ProjectManager/Save.png"
Public ReadOnly Property SaveImage As String
Get
Return m_SaveImage
End Get
End Property
Friend Sub SetSaveImage(value As String)
m_SaveImage = value
NotifyPropertyChanged(NameOf(SaveImage))
End Sub
#End Region ' ModifyStrategy
#Region "StrategyProduction"
' Lista che contiene le strategie filtrate
Private m_StrategyProductionList As New ObservableCollection(Of Strategy)
Public Property StrategyProductionList As ObservableCollection(Of Strategy)
Get
Return m_StrategyProductionList
End Get
Set(value As ObservableCollection(Of Strategy))
m_StrategyProductionList = value
NotifyPropertyChanged(NameOf(StrategyProductionList))
End Set
End Property
Private m_StrategyProductionPath As String = String.Empty
Public ReadOnly Property StrategyProductionPath As String
Get
Return m_StrategyProductionPath
End Get
End Property
Friend Sub SetStrategyProductionPath(value As String)
m_StrategyProductionPath = value
NotifyPropertyChanged(NameOf(StrategyProductionPath))
End Sub
#End Region ' StrategyProduction
#Region "Messages"
Public ReadOnly Property SaveToolTip As String
Get
Return EgtMsg(62571)
End Get
End Property
Public ReadOnly Property SaveAsToolTip As String
Get
Return EgtMsg(62572)
End Get
End Property
#End Region ' Messages
' Definizione Comandi
Private m_AddSelectedStrategyCommand As ICommand
Private m_RemoveSelectedStrategyCommand As ICommand
Private m_OpenCommand As ICommand
Private m_SaveCommand As ICommand
Private m_OpenFileNameCustomConfigCommand As ICommand
Private m_MoveUpSelectedStrategyCommand As ICommand
Private m_MoveDownSelectedStrategyCommand As ICommand
Private m_cmdOk As ICommand
Private m_cmdCancel As ICommand
#End Region ' Field & Properties
#Region "CONSTRUCTOR"
Sub New()
' Setto riferimento
Map.SetRefStrategyManagerVM(Me)
' Recupero i file contenti nella Cartella AISetup
m_sAISetUpList = GetFileNamesAISetup(Map.refMainWindowVM.MainWindowM.GetAISetupDirPath())
' Controllo se la lista sAISetUpList non è vuota
If m_sAISetUpList.Count > 0 Then
' Controllo se l'ultimo file json utilizzato è presente
If Not String.IsNullOrEmpty(m_sLastCustomConfigJson) Then
' Se si lo apro
m_sSelectedAISetUp = m_sLastCustomConfigJson
Else
' Se no apro il primo
m_sSelectedAISetUp = m_sAISetUpList(0)
End If
End If
' Leggo file json strategie
If Not IsNothing(m_sSelectedAISetUp) Then
ReadAvailableStrategyJson(m_sSelectedAISetUp)
Else
ReadAvailableStrategyJson(CUSTOMERCONFIG_FILE)
End If
' Aggiorno elemento selezionato dall'albero
Topology.refUpdateSelTreeItem = AddressOf UpdateSelTreeItem
End Sub
#End Region ' Constructor
#Region "METHODS"
'''
''' Funzione che legge il file json AVAILABLESTRATEGYLIST
'''
Friend Sub ReadAvailableStrategyJson(fileCostumerConfig As String)
Try
' ------------------------------- Carico DefaultConfiguration --------------------------------------------
' Recupero file AvailableStrategyPathJson
Dim sAvailableStrategyPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath() & "\" & AVAILABLESTRATEGYLIST_FILE & ".json"
' Controllo se il file esisite
If File.Exists(sAvailableStrategyPath) Then
' Leggo il contenuto del file JSON
Dim sAvailableStrategyPathJson As String = File.ReadAllText(sAvailableStrategyPath)
' Deserializza il JSON in un oggetto
m_JsonStrategyFeatureList = JsonConvert.DeserializeObject(Of ObservableCollection(Of JsonStrategyFeature))(sAvailableStrategyPathJson)
' Converti la lista JSON in StrategyFeature
m_AvailableStrategyList = New ObservableCollection(Of StrategyFeature)(m_JsonStrategyFeatureList.Select(Function(jsonFeature) New StrategyFeature(jsonFeature)))
' Leggi tutte le strategie presenti nelle feature
m_AvailableStrategyList.SelectMany(Function(strategy) strategy.TopologyList).
SelectMany(Function(topology) topology.StrategyList).ToList().ForEach(AddressOf ReadConfigurationStrategyJson)
' Leggi tutte le strategie presenti nelle feature per il file JSON
m_JsonStrategyFeatureList.SelectMany(Function(feature) feature.TopologyList).
SelectMany(Function(topology) topology.StrategyList).ToList().ForEach(AddressOf ReadConfigurationStrategyJson)
End If
' ------------------------------- Carico CustomConfigJson -------------------------------------------------
' Recupero file json CustomConfigJson
Dim sCustomerConfigurationFilePath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath() & "\" & fileCostumerConfig & ".json"
' Controllo se esiste
If File.Exists(sCustomerConfigurationFilePath) Then
' Leggo il file json
Dim sJsonCustomerConfigPath As String = File.ReadAllText(sCustomerConfigurationFilePath)
' Deserializza il JSON in un oggetto
m_CustomerConfigurationList = JsonConvert.DeserializeObject(Of ObservableCollection(Of StrategyFeature))(sJsonCustomerConfigPath)
' Controllo se le due liste sono uguali
If m_AvailableStrategyList.SequenceEqual(m_CustomerConfigurationList) Then
'MessageBox.Show("OK")
Else
If m_bMatchingJson Then
'CompareCollections(m_AvailableStrategyList, m_CustomerConfigurationList)
End If
End If
' Aggiorno la lista
m_AvailableStrategyList = m_CustomerConfigurationList
End If
' Controllo se presenti combo li trasformo e assegno al primo il valore selezionato
m_AvailableStrategyList.SelectMany(Function(strategy) strategy.TopologyList).
SelectMany(Function(topology) topology.StrategyList).ToList().
ForEach(Sub(strategyItem)
strategyItem.SetIndexList(strategyItem.nIndexInList)
strategyItem.ParameterList.Where(Function(param) param.sType = "combo" AndAlso param.Choices.Count > 0).ToList().
ForEach(Sub(param)
param.SelectedChoice = param.Choices.FirstOrDefault(Function(x) x.sValue = param.sValue)
NotifyPropertyChanged(NameOf(param.SelectedChoice))
End Sub)
End Sub)
Catch ex As Exception
EgtOutLog("Errore durante la lettura delle strategie JSON: " & ex.Message)
End Try
NotifyPropertyChanged(NameOf(AvailableStrategyList))
End Sub
'''
''' Funzione che trova le differenze tra le due liste
'''
''' Lista di default
''' Lista custom
Public Sub CompareCollections(AvailableStrategyList As ObservableCollection(Of StrategyFeature), CustomerConfigurationList As ObservableCollection(Of StrategyFeature))
' Lista delle differenze
Dim differences As New List(Of String)
' Trova gli elementi che differiscono tra le due collezioni
Dim strategyFeatureDifferences As IEnumerable(Of StrategyFeature) = AvailableStrategyList.Where(Function(x) Not CustomerConfigurationList.Any(Function(y) y.sName = x.sName AndAlso y.nPRC = x.nPRC AndAlso y.nGRP = x.nGRP)).
Union(CustomerConfigurationList.Where(Function(x) Not AvailableStrategyList.Any(Function(y) y.sName = x.sName AndAlso y.nPRC = x.nPRC AndAlso y.nGRP = x.nGRP)))
' Controllo differenze
If strategyFeatureDifferences.Any() Then
differences.Add("Differenze nelle strategie:")
differences.AddRange(strategyFeatureDifferences.Select(Function(strategyFeature) $"- {strategyFeature.sName}"))
End If
' Confronta gli elementi di TopologyList
For Each availableStrategy In AvailableStrategyList
Dim matchingStrategy As StrategyFeature = CustomerConfigurationList.FirstOrDefault(Function(x) x.sName = availableStrategy.sName)
If Not IsNothing(matchingStrategy) Then
Dim topologyDifferences As IEnumerable(Of Topology) = availableStrategy.TopologyList.Where(Function(t) Not matchingStrategy.TopologyList.Any(Function(y) y.sName = t.sName)).
Union(matchingStrategy.TopologyList.Where(Function(t) Not availableStrategy.TopologyList.Any(Function(y) y.sName = t.sName)))
' Controllo differenze
If topologyDifferences.Any() Then
differences.Add($"Differenze nelle topologie di {availableStrategy.sName}:")
differences.AddRange(topologyDifferences.Select(Function(topology) $" - {topology.sName}"))
End If
' Confronta gli elementi di StrategyList dentro TopologyList
For Each topology In availableStrategy.TopologyList
Dim matchingTopology As Topology = matchingStrategy.TopologyList.FirstOrDefault(Function(t) t.sName = topology.sName)
If Not IsNothing(matchingTopology) Then
Dim strategyListDifferences As IEnumerable(Of Strategy) = topology.StrategyList.Where(Function(s) Not matchingTopology.StrategyList.Any(Function(y) y.sStrategyID = s.sStrategyID)).
Union(matchingTopology.StrategyList.Where(Function(s) Not topology.StrategyList.Any(Function(y) y.sStrategyID = s.sStrategyID)))
' Controllo differenze
If strategyListDifferences.Any() Then
differences.Add($"Differenze nelle strategie di {topology.sName} dentro {availableStrategy.sName}:")
differences.AddRange(strategyListDifferences.Select(Function(s) $" - {s.sStrategyID}"))
End If
' Confronta gli elementi di ParameterList dentro StrategyList
For Each strategyItem In topology.StrategyList
Dim matchingStrategyItem = matchingTopology.StrategyList.FirstOrDefault(Function(s) s.sStrategyID = strategyItem.sStrategyID)
If Not IsNothing(matchingStrategyItem) Then
Dim parameterDifferences = strategyItem.ParameterList.Where(Function(p) Not matchingStrategyItem.ParameterList.Any(Function(y) y.sName = p.sName AndAlso y.sNameNge = p.sNameNge AndAlso y.sValue = p.sValue AndAlso y.sDescriptionShort = p.sDescriptionShort AndAlso y.sDescriptionLong = p.sDescriptionLong And y.sType = p.sType AndAlso y.sMessageId = p.sMessageId AndAlso y.sMinUserLevel = p.sMinUserLevel)).
Union(matchingStrategyItem.ParameterList.Where(Function(p) Not strategyItem.ParameterList.Any(Function(y) y.sName = p.sName AndAlso y.sNameNge = p.sNameNge AndAlso y.sValue = p.sValue AndAlso y.sDescriptionShort = p.sDescriptionShort AndAlso y.sDescriptionLong = p.sDescriptionLong And y.sType = p.sType AndAlso y.sMessageId = p.sMessageId AndAlso y.sMinUserLevel = p.sMinUserLevel)))
' Controllo differenze
If parameterDifferences.Any() Then
differences.Add($"Differenze nei parametri di {strategyItem.sStrategyID} dentro {topology.sName} dentro {availableStrategy.sName}:")
differences.AddRange(parameterDifferences.Select(Function(p) $" - {p.sName}"))
End If
' Confronta gli elementi di Choice dentro ParameterList
For Each parameter In strategyItem.ParameterList
Dim matchingParameter = matchingStrategyItem.ParameterList.FirstOrDefault(Function(p) p.sName = parameter.sName)
If Not IsNothing(matchingParameter) Then
Dim choiceDifferences = parameter.Choices.Where(Function(c) Not matchingParameter.Choices.Any(Function(y) y.sValue = c.sValue AndAlso y.sDescriptionShort = c.sDescriptionShort AndAlso y.sDescriptionLong = c.sDescriptionLong AndAlso y.sMessageId = c.sMessageId)).
Union(matchingParameter.Choices.Where(Function(c) Not parameter.Choices.Any(Function(y) y.sValue = c.sValue AndAlso y.sDescriptionShort = c.sDescriptionShort AndAlso y.sDescriptionLong = c.sDescriptionLong AndAlso y.sMessageId = c.sMessageId)))
' Controllo differenze
If choiceDifferences.Any() Then
differences.Add($"Differenze nelle scelte di {parameter.sName} dentro {strategyItem.sStrategyID} dentro {topology.sName} dentro {availableStrategy.sName}:")
differences.AddRange(choiceDifferences.Select(Function(c) $" - {c.sValue}"))
End If
End If
Next
End If
Next
End If
Next
End If
Next
' Mostra il messaggio con le differenze
Dim message As String = If(differences.Any(), String.Join(vbCrLf, differences), "Le due collezioni sono uguali.")
MessageBox.Show(message, "Confronto Collezioni", MessageBoxButton.OK, MessageBoxImage.Information)
' Setto il flag MatchingJson a 0
WriteMainPrivateProfileString(S_GENERAL, "MatchingJson", 0)
' Metto a false bMatchingJson
SetbMatchingJson(False)
End Sub
'''
''' Funzione che legge il file json delle strategie
'''
'''
Private Sub ReadConfigurationStrategyJson(SelectedStrategyItem As Object)
' Recupero file StrategyJson
Dim StrategyPath As String = Map.refMainWindowVM.MainWindowM.GetStandardDirPath() & "\" & SelectedStrategyItem.sStrategyID & "\" & SelectedStrategyItem.sStrategyID & ".json"
' Controllo se il file esiste
If Not File.Exists(StrategyPath) Then Return
' Leggo il contenuto del file JSON e deserializzo
Dim StrategyJson As String = File.ReadAllText(StrategyPath)
Dim strategyConfig As JsonStrategy = JsonConvert.DeserializeObject(Of JsonStrategy)(StrategyJson)
' Assegno ParamList per poter visualizzarla da interfaccia econtrollo di che tipo è se Strategy o JsonStrategy
If TypeOf SelectedStrategyItem Is Strategy Then
DirectCast(SelectedStrategyItem, Strategy).ParameterList = New ObservableCollection(Of GenericParameter)(strategyConfig.ParameterList.Select(Function(p) New GenericParameter(p)).ToList())
ElseIf TypeOf SelectedStrategyItem Is JsonStrategy Then
DirectCast(SelectedStrategyItem, JsonStrategy).ParameterList = strategyConfig.ParameterList
End If
End Sub
'''
''' Funzione per creare file json
'''
Friend Sub CreateCustumerConfigJsonFile(fileCostumerConfig As String)
Try
m_JsonStrategyFeatureList = New ObservableCollection(Of JsonStrategyFeature)(m_AvailableStrategyList.Select(AddressOf ConvertToJsonStrategy))
' Serializzazione in JSON
Dim AvailableStrategyListjsonFile As String = JsonConvert.SerializeObject(m_JsonStrategyFeatureList, Formatting.Indented)
' Scrittura su file
File.WriteAllText(Map.refMainWindowVM.MainWindowM.GetAISetupDirPath() & "\" & fileCostumerConfig & ".json", AvailableStrategyListjsonFile)
Catch ex As Exception
EgtOutLog("Errore durante la creazione del file JSON: " & ex.Message)
End Try
End Sub
'''
''' Funzione per convertire da AvailableStrategy a JsonAvailableStrategy
'''
'''
'''
Private Function ConvertToJsonStrategy(StrategyFeature As StrategyFeature) As JsonStrategyFeature
Return New JsonStrategyFeature With {
.sName = StrategyFeature.sName,
.nPRC = StrategyFeature.nPRC,
.nGRP = StrategyFeature.nGRP,
.TopologyList = New ObservableCollection(Of JsonTopology)(StrategyFeature.TopologyList.Select(AddressOf ConvertToJsonTopology))}
End Function
'''
''' Funzione per convertire da Topology a JsonTopology
'''
'''
'''
Private Function ConvertToJsonTopology(Topology As Topology) As JsonTopology
Return New JsonTopology With {
.sName = Topology.sName,
.StrategyList = New ObservableCollection(Of JsonStrategy)(Topology.StrategyList.Select(AddressOf ConvertToJsonStrategyConfiguration))
}
End Function
'''
''' Funzione per convertire da StrategyConfiguration a JsonStrategyConfiguration
'''
'''
'''
Private Function ConvertToJsonStrategyConfiguration(Strategy As Strategy) As JsonStrategy
Return New JsonStrategy With {
.sStrategyID = Strategy.sStrategyID,
.nIndexInList = Strategy.nIndexInList,
.bActive = Strategy.bActive,
.ParameterList = New ObservableCollection(Of JsonGenericParameter)(Strategy.ParameterList.Select(AddressOf ConvertToJsonParameter))}
End Function
'''
''' Funzione per convertire da GenericParameter a JsonGenericParameter
'''
'''
'''
Private Function ConvertToJsonParameter(GenericParameter As GenericParameter) As JsonGenericParameter
Return New JsonGenericParameter With {
.sName = GenericParameter.sName,
.sNameNge = GenericParameter.sNameNge,
.sValue = GenericParameter.sValue,
.sDescriptionShort = GenericParameter.sDescriptionShort,
.sDescriptionLong = GenericParameter.sDescriptionLong,
.sType = GenericParameter.sType,
.sMessageId = GenericParameter.sMessageId,
.sMinUserLevel = GenericParameter.sMinUserLevel,
.Choices = New ObservableCollection(Of JsonChoiceParameter)(GenericParameter.Choices.Select(AddressOf ConvertToJsonChoiceParameter))}
End Function
'''
''' Funzione per convertire da ChoicesParameter a JsonChoicesParameter
'''
'''
'''
Private Function ConvertToJsonChoiceParameter(ChoiceParameter As ChoiceParameter) As JsonChoiceParameter
Return New JsonChoiceParameter With {
.sValue = ChoiceParameter.sValue,
.sDescriptionShort = ChoiceParameter.sDescriptionShort,
.sDescriptionLong = ChoiceParameter.sDescriptionLong,
.sMessageId = ChoiceParameter.sMessageId}
End Function
'''
''' Funzione che permette di scegliere se il tipo è una checkbox, testo o combobox
'''
Private Sub GetTypeMode(SelectedStrategy As Strategy)
For Each ParamItem As GenericParameter In SelectedStrategy.ParameterList
Select Case ParamItem.sType
Case "b"
' Setta il valore per visualizzare la checkbox
ParamItem.SelTypeValue = 1
Case "combo"
' Setta il valore per visualizzare la combobox
ParamItem.SelTypeValue = 2
End Select
Next
End Sub
'''
''' Funzione che restituisce la lista dei file contenuti nella cartella AISetup
'''
''' Percorso AISetup
'''
Private Function GetFileNamesAISetup(AISetupPath As String) As ObservableCollection(Of String)
If Not Directory.Exists(AISetupPath) Then
EgtOutLog("La cartella specificata non esiste.")
Return New ObservableCollection(Of String)()
End If
' Ottieni i nomi dei file senza estensione
Return New ObservableCollection(Of String)(Directory.GetFiles(AISetupPath).Select(AddressOf Path.GetFileNameWithoutExtension))
End Function
'''
''' Funzione che salva il file CustomConfig Json
'''
Private Sub SaveJson()
' Determina il nome del file JSON
Dim fileCustomerConfigJson As String = If(String.IsNullOrEmpty(m_sSelectedAISetUp), CUSTOMERCONFIG_FILE, m_sSelectedAISetUp)
' Se l'elemento selezionato è vuoto assegno il default e lo aggiungo alla lista
If String.IsNullOrEmpty(m_sSelectedAISetUp) Then
m_sSelectedAISetUp = CUSTOMERCONFIG_FILE
m_sAISetUpList.Add(m_sSelectedAISetUp)
NotifyPropertyChanged(NameOf(sSelectedAISetUp))
NotifyPropertyChanged(NameOf(sAISetUpList))
End If
' Crea il file JSON
CreateCustumerConfigJsonFile(fileCustomerConfigJson)
' Se un file è stato selezionato, resetta il flag di modifica
SetbIsModifyStrategy(False)
End Sub
'''
''' Funzione che salva il file customconfig se sono presenti modifiche
'''
Friend Sub SaveCustomConfigJson()
' Controlla se il file JSON è stato modificato
If Not m_bIsModifyStrategy Then Return
' Chiede conferma per il salvataggio
If MessageBox.Show("Il file Json è stato modificato. Vuoi salvarlo?", EgtMsg(15003), MessageBoxButton.YesNo, MessageBoxImage.Information) = MessageBoxResult.Yes Then
SaveJson()
End If
End Sub
'''
''' Funzione che recupera le strategie filtrate
'''
Friend Sub GetStrategyProduction()
' Pulisco la lista
m_StrategyProductionList.Clear()
' Recupero Feature selezionata
Dim selFeature As BTLFeatureVM = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM
' Popolo la lista con le strategie
Dim AvailableStrategyItem As StrategyFeature = m_AvailableStrategyList.FirstOrDefault(Function(AvailableStrategy) selFeature.nPRC = AvailableStrategy.nPRC AndAlso selFeature.nSelGRP = AvailableStrategy.nGRP)
' Controllo se AvailableStrategyItem non è nullo
If Not IsNothing(AvailableStrategyItem) Then
' Se esiste, popola la lista con le strategie
m_StrategyProductionList = New ObservableCollection(Of Strategy)(AvailableStrategyItem.TopologyList.
SelectMany(Function(topology) topology.StrategyList).
Select(Function(strategy)
strategy.SetIndexList(strategy.nIndexInList)
Return strategy
End Function))
End If
NotifyPropertyChanged(NameOf(StrategyProductionList))
End Sub
#End Region ' Methods
#Region "COMMANDS"
#Region "AddSelectedStrategyCommand"
Public ReadOnly Property AddSelectedStrategyCommand As ICommand
Get
If m_AddSelectedStrategyCommand Is Nothing Then
m_AddSelectedStrategyCommand = New Command(AddressOf AddSelectedStrategyToActiveStrategy)
End If
Return m_AddSelectedStrategyCommand
End Get
End Property
'''
''' Funzione che permette di aggiungere la strategia da StrategyList a ActiveStrategyList
'''
Public Sub AddSelectedStrategyToActiveStrategy()
' Controllo se SelectedStrategy se è nullo esco
If IsNothing(m_SelectDeactivateStrategy) Then Return
' Setto a true booleano per modifica
SetbIsModifyStrategy(True)
' Aggiungo a ActiveStrategyList strategia selezionata
m_ActiveStrategyList.Add(m_SelectDeactivateStrategy)
' Setto indice per capire che la strategia è stata spostata in ActiveStrategyList
m_SelectDeactivateStrategy.SetIndexList(m_ActiveStrategyList.Count - 1)
' Rimuovo da StrategyList la strategia precedentemente selezionata
m_DeactivateStrategyList.Remove(m_SelectDeactivateStrategy)
' metto il SelectedStrategy della lista DeactivateStrategyList a nullo
SetSelectedStrategy(Nothing)
' seleziono l'ultimo elemento inserito
SetSelectedActiveStrategy(m_ActiveStrategyList.LastOrDefault())
NotifyPropertyChanged(NameOf(ActiveStrategyList))
NotifyPropertyChanged(NameOf(DeactivateStrategyList))
End Sub
#End Region ' AddSelectedStrategyCommand
#Region "RemoveSelectedStrategyCommand"
Public ReadOnly Property RemoveSelectedStrategyCommand As ICommand
Get
If m_RemoveSelectedStrategyCommand Is Nothing Then
m_RemoveSelectedStrategyCommand = New Command(AddressOf RemoveSelectedStrategyToActiveStrategy)
End If
Return m_RemoveSelectedStrategyCommand
End Get
End Property
'''
''' Funzione che rimuove la strategia da ActiveStrategyList e la riaggiunge a StrategyList
'''
Public Sub RemoveSelectedStrategyToActiveStrategy()
' Controllo se SelectedActiveStrategy se è nullo esco
If IsNothing(m_SelectedActiveStrategy) Then Return
' Aggiungo a ActiveStrategyList strategia selezionata
m_DeactivateStrategyList.Add(m_SelectedActiveStrategy)
' Setto indice per capire che la strategia è stata spostata in StrategyList
m_SelectedActiveStrategy.SetIndexList(-1)
' Rimuovo da StrategyList la strategia precedentemente selezionata
m_ActiveStrategyList.Remove(m_SelectedActiveStrategy)
' metto il SelectedStrategy della lista DeactivateStrategyList a nullo
SetSelectedActiveStrategy(Nothing)
' seleziono l'ultimo elemento inserito
SetSelectedStrategy(m_DeactivateStrategyList.LastOrDefault())
NotifyPropertyChanged(NameOf(ActiveStrategyList))
NotifyPropertyChanged(NameOf(DeactivateStrategyList))
End Sub
#End Region ' RemoveSelectedStrategyCommand
#Region "OpenFileNameCustomConfigCommand"
Public ReadOnly Property OpenFileNameCustomConfigCommand As ICommand
Get
If m_OpenFileNameCustomConfigCommand Is Nothing Then
m_OpenFileNameCustomConfigCommand = New Command(AddressOf OpenFileNameCustomConfig)
End If
Return m_OpenFileNameCustomConfigCommand
End Get
End Property
'''
''' Funzione che visualizza la textbox
'''
Public Sub OpenFileNameCustomConfig()
Dim SaveAsStrategyWnd As New SaveAsStrategyV With {
.DataContext = New SaveAsStrategyVM,
.Owner = Application.Current.MainWindow
}
SaveAsStrategyWnd.ShowDialog()
End Sub
#End Region ' OpenFileNameCustomConfigCommand
#Region "SaveCommand"
Public ReadOnly Property SaveCommand As ICommand
Get
If m_SaveCommand Is Nothing Then
m_SaveCommand = New Command(AddressOf Save)
End If
Return m_SaveCommand
End Get
End Property
'''
''' Funzione che salva il file json CustomerConfig
'''
Public Sub Save()
SaveJson()
End Sub
#End Region ' SaveCommand
#Region "MoveUpSelectedStrategyCommand"
Public ReadOnly Property MoveUpSelectedStrategyCommand As ICommand
Get
If m_MoveUpSelectedStrategyCommand Is Nothing Then
m_MoveUpSelectedStrategyCommand = New Command(AddressOf MoveUpSelectedStrategy)
End If
Return m_MoveUpSelectedStrategyCommand
End Get
End Property
'''
''' Funzione che permette di spostare in alto la strategia selezionata
'''
Public Sub MoveUpSelectedStrategy()
' Controllo se SelectedActiveStrategy se è nullo esco
If IsNothing(m_SelectedActiveStrategy) Then Return
' Recupero indice elemento selezionato in lista
Dim IndexActiveStrategy As Integer = m_ActiveStrategyList.IndexOf(m_SelectedActiveStrategy)
Dim NewIndexActiveStrategy As Integer = IndexActiveStrategy - 1
' Se l'indice è maggiore di 0
If IndexActiveStrategy > 0 Then
' Riattivo pulsante movedown
SetMoveDownSelectedStrategyVisibility(True)
' Muovo l'elemento selezionato sopra di 1
m_ActiveStrategyList.Move(IndexActiveStrategy, NewIndexActiveStrategy)
' Disabilito pulsante moveup se l'elemento è in cima
SetMoveUpSelectedStrategyVisibility(NewIndexActiveStrategy > 0)
End If
NotifyPropertyChanged(NameOf(ActiveStrategyList))
End Sub
#End Region ' MoveUpSelectedStrategyCommand
#Region "MoveDownSelectedStrategyCommand"
Public ReadOnly Property MoveDownSelectedStrategyCommand As ICommand
Get
If m_MoveDownSelectedStrategyCommand Is Nothing Then
m_MoveDownSelectedStrategyCommand = New Command(AddressOf MoveDownSelectedStrategy)
End If
Return m_MoveDownSelectedStrategyCommand
End Get
End Property
'''
''' Funzione che permette di spostare in basso la strategia selezionata
'''
Public Sub MoveDownSelectedStrategy()
' Controllo se SelectedActiveStrategy se è nullo esco
If IsNothing(m_SelectedActiveStrategy) Then Return
' Recupero indice elemento selezionato in lista
Dim IndexActiveStrategy As Integer = m_ActiveStrategyList.IndexOf(m_SelectedActiveStrategy)
Dim NewIndexActiveStrategy As Integer = IndexActiveStrategy + 1
' Se l'indice è maggiore di 0
If IndexActiveStrategy >= 0 Then
' Riattivo pulsante moveup
SetMoveUpSelectedStrategyVisibility(True)
' Muovo l'elemento selezionato sotto di 1
m_ActiveStrategyList.Move(IndexActiveStrategy, NewIndexActiveStrategy)
' Disabilito pulsante movedown se l'elemento è in fondo
SetMoveDownSelectedStrategyVisibility(NewIndexActiveStrategy < m_ActiveStrategyList.Count - 1)
End If
NotifyPropertyChanged(NameOf(ActiveStrategyList))
End Sub
#End Region ' MoveDownSelectedStrategyCommand
#Region "StrategyProductionCommand"
#Region "Ok_Command"
Public ReadOnly Property Ok_Command As ICommand
Get
If m_cmdOk Is Nothing Then
m_cmdOk = New Command(AddressOf Ok)
End If
Return m_cmdOk
End Get
End Property
Public Sub Ok()
Map.refProjectVM.SetSelManagerTab(ProjectVM.StrategyManagerTab.RAWPARTMANAGER)
' Abilito LeftPanel
Map.refProjectVM.SetOnlyProdLeftPanel_IsEnabled(True)
Map.refProjectVM.SetOnlyProdLeftPanel_Opacity(1)
End Sub
#End Region ' Ok_Command
#Region "Cancel_Command"
Public ReadOnly Property Cancel_Command As ICommand
Get
If m_cmdCancel Is Nothing Then
m_cmdCancel = New Command(AddressOf Cancel)
End If
Return m_cmdCancel
End Get
End Property
Public Sub Cancel()
Map.refProjectVM.SetSelManagerTab(ProjectVM.StrategyManagerTab.RAWPARTMANAGER)
' Abilito LeftPanel
Map.refProjectVM.SetOnlyProdLeftPanel_IsEnabled(True)
Map.refProjectVM.SetOnlyProdLeftPanel_Opacity(1)
End Sub
#End Region ' Cancel_Command
#End Region ' StrategyProductionCommand
#End Region ' Commands
End Class
'----------- Classe che fa riferimento alle Feature -----------
Public Class StrategyFeature
Inherits VMBase
#Region "FIELDS & PROPETIES"
Private m_sName As String
Public Property sName As String
Get
Return m_sName
End Get
Set(value As String)
m_sName = value
NotifyPropertyChanged(NameOf(sName))
End Set
End Property
Private m_nPRC As Integer
Public Property nPRC As Integer
Get
Return m_nPRC
End Get
Set(value As Integer)
m_nPRC = value
NotifyPropertyChanged(NameOf(nPRC))
End Set
End Property
Private m_nGRP As Integer
Public Property nGRP As Integer
Get
Return m_nGRP
End Get
Set(value As Integer)
m_nGRP = value
NotifyPropertyChanged(NameOf(nGRP))
End Set
End Property
Private m_TopologyList As New ObservableCollection(Of Topology)
Public Property TopologyList As ObservableCollection(Of Topology)
Get
Return m_TopologyList
End Get
Set(value As ObservableCollection(Of Topology))
m_TopologyList = value
NotifyPropertyChanged(NameOf(TopologyList))
End Set
End Property
#End Region ' Fields & Propeties
#Region "CONSTRUCTOR"
Sub New(JsonStrategyFeature As JsonStrategyFeature)
If IsNothing(JsonStrategyFeature) Then Return
m_sName = JsonStrategyFeature.sName
m_nPRC = JsonStrategyFeature.nPRC
m_nGRP = JsonStrategyFeature.nGRP
m_TopologyList = New ObservableCollection(Of Topology)(JsonStrategyFeature.TopologyList.Select(Function(jsonTopology) New Topology(jsonTopology)))
NotifyPropertyChanged(NameOf(TopologyList))
End Sub
#End Region ' Constructor
End Class
'----------- Classe che fa riferimento alle Topologie delle Feature -----------
Public Class Topology
Inherits VMBase
#Region "FIELDS & PROPETIES"
Friend Shared refUpdateSelTreeItem As Action(Of Topology)
Private m_sName As String
Public Property sName As String
Get
Return m_sName
End Get
Set(value As String)
m_sName = value
NotifyPropertyChanged(NameOf(sName))
End Set
End Property
Private m_bIsSelected As Boolean
Public Property IsSelected As Boolean
Get
Return m_bIsSelected
End Get
Set(value As Boolean)
m_bIsSelected = value
Map.refStrategyManagerVM.ActiveStrategyList.Clear()
Map.refStrategyManagerVM.DeactivateStrategyList.Clear()
refUpdateSelTreeItem(Me)
Dim ActiveStrategies As IEnumerable(Of Strategy) = Me.StrategyList.Where(Function(s) s.bActive)
Dim InactiveStrategies As IEnumerable(Of Strategy) = Me.StrategyList.Where(Function(s) Not s.bActive)
For Each strategy In ActiveStrategies
Map.refStrategyManagerVM.ActiveStrategyList.Add(strategy)
Next
For Each strategy In InactiveStrategies
Map.refStrategyManagerVM.DeactivateStrategyList.Add(strategy)
Next
NotifyPropertyChanged(NameOf(IsSelected))
End Set
End Property
' Seleziona l'elemento della lista StrategyList
Public m_SelectedStrategy As Strategy
Public Property SelectedStrategy As Strategy
Get
Return m_SelectedStrategy
End Get
Set(value As Strategy)
m_SelectedStrategy = value
NotifyPropertyChanged(NameOf(SelectedStrategy))
End Set
End Property
Private m_StrategyList As New ObservableCollection(Of Strategy)
Public Property StrategyList As ObservableCollection(Of Strategy)
Get
Return m_StrategyList
End Get
Set(value As ObservableCollection(Of Strategy))
m_StrategyList = value
NotifyPropertyChanged(NameOf(StrategyList))
End Set
End Property
#End Region ' Fields & Propeties
#Region "CONSTRUCTOR"
Sub New(JsonTopology As JsonTopology)
If IsNothing(JsonTopology) Then Return
m_sName = JsonTopology.sName
m_StrategyList = New ObservableCollection(Of Strategy)(JsonTopology.StrategyList.Select(Function(jsonStrategy) New Strategy(Me, jsonStrategy)))
NotifyPropertyChanged(NameOf(StrategyList))
End Sub
#End Region ' Constructor
End Class
'----------- Classe che fa alle Strategie delle Topologie delle Feature -----------
Public Class Strategy
Inherits VMBase
#Region "FIELDS & PROPETIES"
Private m_ParentTopology As Topology
Private m_sStrategyID As String
Public Property sStrategyID As String
Get
Return m_sStrategyID
End Get
Set(value As String)
m_sStrategyID = value
NotifyPropertyChanged(NameOf(sStrategyID))
End Set
End Property
Private m_nIndexInList As Integer = -1
Public Property nIndexInList As Integer
Get
Return m_nIndexInList
End Get
Set(value As Integer)
m_nIndexInList = value
NotifyPropertyChanged(NameOf(nIndexInList))
End Set
End Property
Friend Sub SetIndexList(value As Integer)
m_nIndexInList = value
If nIndexInList > -1 Then
m_bActive = True
Else
m_bActive = False
End If
NotifyPropertyChanged(NameOf(nIndexInList))
NotifyPropertyChanged(NameOf(bActive))
End Sub
Private m_bActive As Boolean
Public ReadOnly Property bActive As Boolean
Get
Return m_bActive
End Get
End Property
Private m_sImageStrategy As String = "pack://application:,,,/Resources/NewPage/LogoProvaStrategy.png"
Public Property sImageStrategy As String
Get
Return m_sImageStrategy
End Get
Set(value As String)
m_sImageStrategy = value
NotifyPropertyChanged(NameOf(sImageStrategy))
End Set
End Property
Private m_ParameterList As New ObservableCollection(Of GenericParameter)
Public Property ParameterList As ObservableCollection(Of GenericParameter)
Get
Return m_ParameterList
End Get
Set(value As ObservableCollection(Of GenericParameter))
m_ParameterList = value
NotifyPropertyChanged(NameOf(ParameterList))
End Set
End Property
#End Region ' Fields & Propeties
#Region "CONSTRUCTOR"
Sub New(ParentTopology As Topology, JsonStrategy As JsonStrategy)
m_ParentTopology = ParentTopology
If IsNothing(JsonStrategy) Then Return
m_sStrategyID = JsonStrategy.sStrategyID
m_nIndexInList = JsonStrategy.nIndexInList
m_bActive = JsonStrategy.bActive
m_ParameterList = New ObservableCollection(Of GenericParameter)(JsonStrategy.ParameterList.Select(Function(jsonParam) New GenericParameter(jsonParam)))
NotifyPropertyChanged(NameOf(ParameterList))
End Sub
#End Region ' Constructor
End Class
'----------- Classe che fa riferimento ai parametri delle Strategie -----------
Public Class GenericParameter
Inherits VMBase
#Region "FIELDS & PROPETIES"
Private m_ParentStrategy As Strategy
Private m_sName As String
Public Property sName As String
Get
Return m_sName
End Get
Set(value As String)
m_sName = value
NotifyPropertyChanged(NameOf(sName))
End Set
End Property
Private m_sNameNge As String
Public Property sNameNge As String
Get
Return m_sNameNge
End Get
Set(value As String)
m_sNameNge = value
NotifyPropertyChanged(NameOf(sNameNge))
End Set
End Property
Friend m_sValue As String
Public Property sValue As String
Get
Return m_sValue
End Get
Set(value As String)
m_sValue = value
NotifyPropertyChanged(NameOf(sValue))
End Set
End Property
Private m_sDescriptionShort As String
Public Property sDescriptionShort As String
Get
Return m_sDescriptionShort
End Get
Set(value As String)
m_sDescriptionShort = value
NotifyPropertyChanged(NameOf(sDescriptionShort))
End Set
End Property
Private m_sDescriptionLong As String
Public Property sDescriptionLong As String
Get
Return m_sDescriptionLong
End Get
Set(value As String)
m_sDescriptionLong = value
NotifyPropertyChanged(NameOf(sDescriptionLong))
End Set
End Property
Private m_sType As String
Public Property sType As String
Get
Return m_sType
End Get
Set(value As String)
m_sType = value
NotifyPropertyChanged(NameOf(sType))
End Set
End Property
Private m_sMessageId As String
Public Property sMessageId As String
Get
Return m_sMessageId
End Get
Set(value As String)
m_sMessageId = value
NotifyPropertyChanged(NameOf(sMessageId))
End Set
End Property
Private m_sMinUserLevel As Integer
Public Property sMinUserLevel As Integer
Get
Return m_sMinUserLevel
End Get
Set(value As Integer)
m_sMinUserLevel = value
NotifyPropertyChanged(NameOf(sMinUserLevel))
End Set
End Property
Private m_Choices As New ObservableCollection(Of ChoiceParameter)
Public Property Choices As ObservableCollection(Of ChoiceParameter)
Get
Return m_Choices
End Get
Set(value As ObservableCollection(Of ChoiceParameter))
m_Choices = value
NotifyPropertyChanged(NameOf(Choices))
End Set
End Property
' Seleziona elemento nella combobox Choices
Public m_SelectedChoice As ChoiceParameter
Public Property SelectedChoice As ChoiceParameter
Get
Return m_SelectedChoice
End Get
Set(value As ChoiceParameter)
m_SelectedChoice = value
If Not IsNothing(m_SelectedChoice) Then
m_sValue = m_SelectedChoice.sValue
End If
NotifyPropertyChanged(NameOf(SelectedChoice))
NotifyPropertyChanged(NameOf(sValue))
End Set
End Property
Friend m_SelTypeValue As Integer = 0
Public Property SelTypeValue As Integer
Get
Return m_SelTypeValue
End Get
Set(value As Integer)
m_SelTypeValue = value
NotifyPropertyChanged(NameOf(SelTypeValue))
End Set
End Property
#End Region ' Fields & Propeties
#Region "CONSTRUCTOR"
Sub New(JsonGenericParameter As JsonGenericParameter)
If IsNothing(JsonGenericParameter) Then Return
m_sName = JsonGenericParameter.sName
m_sNameNge = JsonGenericParameter.sNameNge
m_sValue = JsonGenericParameter.sValue
m_sDescriptionShort = JsonGenericParameter.sDescriptionShort
m_sDescriptionLong = JsonGenericParameter.sDescriptionLong
m_sType = JsonGenericParameter.sType
m_sMessageId = JsonGenericParameter.sMessageId
m_sMinUserLevel = JsonGenericParameter.sMinUserLevel
m_Choices = New ObservableCollection(Of ChoiceParameter)(JsonGenericParameter.Choices.Select(Function(jsonChoice) New ChoiceParameter(jsonChoice)))
NotifyPropertyChanged(NameOf(Choices))
End Sub
#End Region ' Constructor
End Class
'----------- Classe che fa riferimento ai parametri delle Scelte -----------
Public Class ChoiceParameter
Inherits VMBase
#Region "FIELD & PROPERTIES"
Private m_sValue As String
Public Property sValue As String
Get
Return m_sValue
End Get
Set(value As String)
m_sValue = value
NotifyPropertyChanged(NameOf(sValue))
End Set
End Property
Private m_sDescriptionShort As String
Public Property sDescriptionShort As String
Get
Return m_sDescriptionShort
End Get
Set(value As String)
m_sDescriptionShort = value
NotifyPropertyChanged(NameOf(sDescriptionShort))
End Set
End Property
Private m_sDescriptionLong As String
Public Property sDescriptionLong As String
Get
Return m_sDescriptionLong
End Get
Set(value As String)
m_sDescriptionLong = value
NotifyPropertyChanged(NameOf(sDescriptionLong))
End Set
End Property
Private m_sMessageId As String
Public Property sMessageId As String
Get
Return m_sMessageId
End Get
Set(value As String)
m_sMessageId = value
NotifyPropertyChanged(NameOf(sMessageId))
End Set
End Property
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Sub New(JsonChoiceParameter As JsonChoiceParameter)
If Not IsNothing(JsonChoiceParameter) Then
m_sValue = JsonChoiceParameter.sValue
m_sDescriptionShort = JsonChoiceParameter.sDescriptionShort
m_sDescriptionLong = JsonChoiceParameter.sDescriptionLong
m_sMessageId = JsonChoiceParameter.sMessageId
End If
End Sub
#End Region ' Constructor
End Class
'----------- Classe che fa riferimento alle Feature del file Json -----------
Public Class JsonStrategyFeature
Inherits VMBase
#Region "FIELDS & PROPETIES"
Private m_sName As String
Public Property sName As String
Get
Return m_sName
End Get
Set(value As String)
m_sName = value
NotifyPropertyChanged(NameOf(sName))
End Set
End Property
Private m_nPRC As Integer
Public Property nPRC As Integer
Get
Return m_nPRC
End Get
Set(value As Integer)
m_nPRC = value
NotifyPropertyChanged(NameOf(nPRC))
End Set
End Property
Private m_nGRP As Integer
Public Property nGRP As Integer
Get
Return m_nGRP
End Get
Set(value As Integer)
m_nGRP = value
NotifyPropertyChanged(NameOf(nGRP))
End Set
End Property
Private m_TopologyList As New ObservableCollection(Of JsonTopology)
Public Property TopologyList As ObservableCollection(Of JsonTopology)
Get
Return m_TopologyList
End Get
Set(value As ObservableCollection(Of JsonTopology))
m_TopologyList = value
NotifyPropertyChanged(NameOf(TopologyList))
End Set
End Property
#End Region ' Fields & Propeties
End Class
'----------- Classe che fa riferimento alle Topologie delle Feature del file Json -----------
Public Class JsonTopology
Inherits VMBase
#Region "FIELDS & PROPETIES"
Private m_sName As String
Public Property sName As String
Get
Return m_sName
End Get
Set(value As String)
m_sName = value
NotifyPropertyChanged(NameOf(sName))
End Set
End Property
Private m_StrategyList As New ObservableCollection(Of JsonStrategy)
Public Property StrategyList As ObservableCollection(Of JsonStrategy)
Get
Return m_StrategyList
End Get
Set(value As ObservableCollection(Of JsonStrategy))
m_StrategyList = value
NotifyPropertyChanged(NameOf(StrategyList))
End Set
End Property
#End Region ' Fields & Propeties
End Class
'----------- Classe che fa alle Strategie delle Topologie delle Feature del file Json -----------
Public Class JsonStrategy
Inherits VMBase
#Region "FIELDS & PROPETIES"
Private m_sStrategyID As String
Public Property sStrategyID As String
Get
Return m_sStrategyID
End Get
Set(value As String)
m_sStrategyID = value
NotifyPropertyChanged(NameOf(sStrategyID))
End Set
End Property
Private m_nIndexInList As Integer = -1
Public Property nIndexInList As Integer
Get
Return m_nIndexInList
End Get
Set(value As Integer)
m_nIndexInList = value
NotifyPropertyChanged(NameOf(nIndexInList))
End Set
End Property
Private m_bActive As Boolean
Public Property bActive As Boolean
Get
Return m_bActive
End Get
Set(value As Boolean)
m_bActive = value
NotifyPropertyChanged(NameOf(bActive))
End Set
End Property
Private m_ParameterList As New ObservableCollection(Of JsonGenericParameter)
Public Property ParameterList As ObservableCollection(Of JsonGenericParameter)
Get
Return m_ParameterList
End Get
Set(value As ObservableCollection(Of JsonGenericParameter))
m_ParameterList = value
NotifyPropertyChanged(NameOf(ParameterList))
End Set
End Property
#End Region ' Fields & Propeties
End Class
'----------- Classe che fa riferimento ai parametri delle Strategie nel file Json -----------
Public Class JsonGenericParameter
Inherits VMBase
#Region "FIELDS & PROPETIES"
Private m_sName As String
Public Property sName As String
Get
Return m_sName
End Get
Set(value As String)
m_sName = value
NotifyPropertyChanged(NameOf(sName))
End Set
End Property
Private m_sNameNge As String
Public Property sNameNge As String
Get
Return m_sNameNge
End Get
Set(value As String)
m_sNameNge = value
NotifyPropertyChanged(NameOf(sNameNge))
End Set
End Property
Private m_sValue As String
Public Property sValue As String
Get
Return m_sValue
End Get
Set(value As String)
m_sValue = value
NotifyPropertyChanged(NameOf(sValue))
End Set
End Property
Private m_sDescriptionShort As String
Public Property sDescriptionShort As String
Get
Return m_sDescriptionShort
End Get
Set(value As String)
m_sDescriptionShort = value
NotifyPropertyChanged(NameOf(sDescriptionShort))
End Set
End Property
Private m_sDescriptionLong As String
Public Property sDescriptionLong As String
Get
Return m_sDescriptionLong
End Get
Set(value As String)
m_sDescriptionLong = value
NotifyPropertyChanged(NameOf(sDescriptionLong))
End Set
End Property
Private m_sType As String
Public Property sType As String
Get
Return m_sType
End Get
Set(value As String)
m_sType = value
NotifyPropertyChanged(NameOf(sType))
End Set
End Property
Private m_sMessageId As String
Public Property sMessageId As String
Get
Return m_sMessageId
End Get
Set(value As String)
m_sMessageId = value
NotifyPropertyChanged(NameOf(sMessageId))
End Set
End Property
Private m_sMinUserLevel As Integer
Public Property sMinUserLevel As Integer
Get
Return m_sMinUserLevel
End Get
Set(value As Integer)
m_sMinUserLevel = value
NotifyPropertyChanged(NameOf(sMinUserLevel))
End Set
End Property
Private m_Choices As New ObservableCollection(Of JsonChoiceParameter)
Public Property Choices As ObservableCollection(Of JsonChoiceParameter)
Get
Return m_Choices
End Get
Set(value As ObservableCollection(Of JsonChoiceParameter))
m_Choices = value
NotifyPropertyChanged(NameOf(Choices))
End Set
End Property
#End Region ' Fields & Propeties
End Class
'----------- Classe che fa riferimento ai parametri delle Scelte nel file Json -----------
Public Class JsonChoiceParameter
Inherits VMBase
Private m_sValue As String
Public Property sValue As String
Get
Return m_sValue
End Get
Set(value As String)
m_sValue = value
NotifyPropertyChanged(NameOf(sValue))
End Set
End Property
Private m_sDescriptionShort As String
Public Property sDescriptionShort As String
Get
Return m_sDescriptionShort
End Get
Set(value As String)
m_sDescriptionShort = value
NotifyPropertyChanged(NameOf(sDescriptionShort))
End Set
End Property
Private m_sDescriptionLong As String
Public Property sDescriptionLong As String
Get
Return m_sDescriptionLong
End Get
Set(value As String)
m_sDescriptionLong = value
NotifyPropertyChanged(NameOf(sDescriptionLong))
End Set
End Property
Private m_sMessageId As String
Public Property sMessageId As String
Get
Return m_sMessageId
End Get
Set(value As String)
m_sMessageId = value
NotifyPropertyChanged(NameOf(sMessageId))
End Set
End Property
End Class