|
|
|
@@ -31,8 +31,6 @@ Public Class StrategyManagerVM
|
|
|
|
|
End Set
|
|
|
|
|
End Property
|
|
|
|
|
|
|
|
|
|
#Region "bMatchingJson"
|
|
|
|
|
|
|
|
|
|
' Controllo se le due liste sono uguali
|
|
|
|
|
Private m_bMatchingJson As Boolean = True
|
|
|
|
|
Friend ReadOnly Property bMatchingJson As Boolean
|
|
|
|
@@ -45,10 +43,6 @@ Public Class StrategyManagerVM
|
|
|
|
|
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)
|
|
|
|
@@ -73,65 +67,6 @@ Public Class StrategyManagerVM
|
|
|
|
|
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)
|
|
|
|
@@ -144,10 +79,6 @@ Public Class StrategyManagerVM
|
|
|
|
|
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
|
|
|
|
@@ -165,98 +96,9 @@ Public Class StrategyManagerVM
|
|
|
|
|
''' <param name="Item">Elemento dell'albero</param>
|
|
|
|
|
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
|
|
|
|
@@ -281,10 +123,6 @@ Public Class StrategyManagerVM
|
|
|
|
|
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
|
|
|
|
@@ -314,11 +152,6 @@ Public Class StrategyManagerVM
|
|
|
|
|
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)
|
|
|
|
@@ -342,8 +175,6 @@ Public Class StrategyManagerVM
|
|
|
|
|
NotifyPropertyChanged(NameOf(StrategyProductionPath))
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region ' StrategyProduction
|
|
|
|
|
|
|
|
|
|
#Region "Messages"
|
|
|
|
|
|
|
|
|
|
Public ReadOnly Property SaveToolTip As String
|
|
|
|
@@ -395,163 +226,6 @@ Public Class StrategyManagerVM
|
|
|
|
|
|
|
|
|
|
#Region "METHODS"
|
|
|
|
|
|
|
|
|
|
''' <summary>
|
|
|
|
|
''' Funzione che legge il file json AVAILABLESTRATEGYLIST
|
|
|
|
|
''' </summary>
|
|
|
|
|
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 esiste
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
''' <summary>
|
|
|
|
|
''' Funzione che trova le differenze tra le due liste
|
|
|
|
|
''' </summary>
|
|
|
|
|
''' <param name="AvailableStrategyList">Lista di default</param>
|
|
|
|
|
''' <param name="CustomerConfigurationList">Lista custom</param>
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
''' <summary>
|
|
|
|
|
''' Funzione che legge il file json delle strategie
|
|
|
|
|
''' </summary>
|
|
|
|
|
''' <param name="SelectedStrategyItem"></param>
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
''' <summary>
|
|
|
|
|
''' Funzione per creare file json
|
|
|
|
|
''' </summary>
|
|
|
|
@@ -636,48 +310,18 @@ Public Class StrategyManagerVM
|
|
|
|
|
.sMessageId = ChoiceParameter.sMessageId}
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
''' <summary>
|
|
|
|
|
''' Funzione che permette di scegliere se il tipo è una checkbox, testo o combobox
|
|
|
|
|
''' </summary>
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
''' <summary>
|
|
|
|
|
''' Funzione che restituisce la lista dei file contenuti nella cartella AISetup
|
|
|
|
|
''' </summary>
|
|
|
|
|
''' <param name="AISetupPath">Percorso AISetup</param>
|
|
|
|
|
''' <returns></returns>
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
''' <summary>
|
|
|
|
|
''' Funzione che salva il file CustomConfig Json
|
|
|
|
|
''' </summary>
|
|
|
|
|
Private Sub SaveJson()
|
|
|
|
|
' Determina il nome del file JSON
|
|
|
|
|
Dim fileCustomerConfigJson As String = If(String.IsNullOrEmpty(m_sSelectedAISetUp), CUSTOMERCONFIG_FILE, m_sSelectedAISetUp)
|
|
|
|
|
Dim fileCustomerConfigJson As String = If(Not IsNothing(m_SelStrategySetup), CUSTOMERCONFIG_FILE, m_SelStrategySetup.sName)
|
|
|
|
|
' 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))
|
|
|
|
|
If IsNothing(m_SelStrategySetup) Then
|
|
|
|
|
m_SelStrategySetup.sName = CUSTOMERCONFIG_FILE
|
|
|
|
|
m_StrategySetupList.Add(m_SelStrategySetup)
|
|
|
|
|
NotifyPropertyChanged(NameOf(SelStrategySetup.sName))
|
|
|
|
|
NotifyPropertyChanged(NameOf(StrategySetupList))
|
|
|
|
|
End If
|
|
|
|
|
' Crea il file JSON
|
|
|
|
|
CreateCustumerConfigJsonFile(fileCustomerConfigJson)
|
|
|
|
@@ -740,21 +384,14 @@ Public Class StrategyManagerVM
|
|
|
|
|
''' </summary>
|
|
|
|
|
Public Sub AddSelectedStrategyToActiveStrategy()
|
|
|
|
|
' Controllo se SelectedStrategy se è nullo esco
|
|
|
|
|
If IsNothing(m_SelectDeactivateStrategy) Then Return
|
|
|
|
|
If IsNothing(m_SelTreeItem.SelAvailableStrategy) 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))
|
|
|
|
|
m_SelTreeItem.SelAvailableStrategy.SetIndexList(m_SelTreeItem.StrategyList.Count - 1)
|
|
|
|
|
' Aggiorno le liste
|
|
|
|
|
m_SelTreeItem.AvailableStrategyList_View.Refresh()
|
|
|
|
|
m_SelTreeItem.ActiveStrategyList_View.Refresh()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region ' AddSelectedStrategyCommand
|
|
|
|
@@ -775,19 +412,12 @@ Public Class StrategyManagerVM
|
|
|
|
|
''' </summary>
|
|
|
|
|
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)
|
|
|
|
|
If IsNothing(m_SelTreeItem.SelActiveStrategy) Then Return
|
|
|
|
|
' 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))
|
|
|
|
|
m_SelTreeItem.SelActiveStrategy.SetIndexList(-1)
|
|
|
|
|
' Aggiorno le liste
|
|
|
|
|
m_SelTreeItem.AvailableStrategyList_View.Refresh()
|
|
|
|
|
m_SelTreeItem.ActiveStrategyList_View.Refresh()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region ' RemoveSelectedStrategyCommand
|
|
|
|
@@ -852,20 +482,13 @@ Public Class StrategyManagerVM
|
|
|
|
|
''' </summary>
|
|
|
|
|
Public Sub MoveUpSelectedStrategy()
|
|
|
|
|
' Controllo se SelectedActiveStrategy se è nullo esco
|
|
|
|
|
If IsNothing(m_SelectedActiveStrategy) Then Return
|
|
|
|
|
If IsNothing(m_SelTreeItem.SelActiveStrategy) 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))
|
|
|
|
|
Dim IndexActiveStrategy As Integer = m_SelTreeItem.ActiveStrategyList_View.CurrentPosition
|
|
|
|
|
' Muovo l'elemento selezionato sopra di 1
|
|
|
|
|
m_SelTreeItem.ActiveStrategyList_View.MoveCurrentToPosition(IndexActiveStrategy - 1)
|
|
|
|
|
' Aggiorno la lista
|
|
|
|
|
m_SelTreeItem.ActiveStrategyList_View.Refresh()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region ' MoveUpSelectedStrategyCommand
|
|
|
|
@@ -885,21 +508,13 @@ Public Class StrategyManagerVM
|
|
|
|
|
''' Funzione che permette di spostare in basso la strategia selezionata
|
|
|
|
|
''' </summary>
|
|
|
|
|
Public Sub MoveDownSelectedStrategy()
|
|
|
|
|
' Controllo se SelectedActiveStrategy se è nullo esco
|
|
|
|
|
If IsNothing(m_SelectedActiveStrategy) Then Return
|
|
|
|
|
If IsNothing(m_SelTreeItem.SelActiveStrategy) 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))
|
|
|
|
|
Dim IndexActiveStrategy As Integer = m_SelTreeItem.ActiveStrategyList_View.CurrentPosition
|
|
|
|
|
' Muovo l'elemento selezionato sopra di 1
|
|
|
|
|
m_SelTreeItem.ActiveStrategyList_View.MoveCurrentToPosition(IndexActiveStrategy + 1)
|
|
|
|
|
' Aggiorno la lista
|
|
|
|
|
m_SelTreeItem.ActiveStrategyList_View.Refresh()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region ' MoveDownSelectedStrategyCommand
|
|
|
|
|