96 lines
2.9 KiB
VB.net
96 lines
2.9 KiB
VB.net
Imports System.IO
|
|
|
|
''' <summary>
|
|
''' Class that create the association Name/IniPath for the machine
|
|
''' </summary>
|
|
Public Class Machine
|
|
|
|
Private m_sName As String
|
|
Public ReadOnly Property Name As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
End Property
|
|
|
|
Private m_DirPath As String
|
|
Public ReadOnly Property DirPath As String
|
|
Get
|
|
Return m_DirPath
|
|
End Get
|
|
End Property
|
|
|
|
Private m_IniPath As String
|
|
Public ReadOnly Property IniPath As String
|
|
Get
|
|
Return m_IniPath
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(sDirPath As String, sIniPath As String)
|
|
If Not String.IsNullOrWhiteSpace(sDirPath) Then
|
|
m_sName = Path.GetFileName(sDirPath)
|
|
m_DirPath = sDirPath
|
|
m_IniPath = sIniPath
|
|
Else
|
|
m_sName = String.Empty
|
|
m_DirPath = String.Empty
|
|
m_IniPath = String.Empty
|
|
End If
|
|
End Sub
|
|
|
|
Public Shared Function MachineListInit(sMachinesRootDir As String, MachineList As IList(Of Machine)) As Boolean
|
|
' Se direttorio base macchine non definito o non esiste, ritorno
|
|
If String.IsNullOrWhiteSpace(sMachinesRootDir) OrElse
|
|
Not Directory.Exists(sMachinesRootDir) Then
|
|
MachineList = Nothing
|
|
Return False
|
|
End If
|
|
|
|
' NUOVA funzione per recuperare macchine da direttori differenti da quello attuale
|
|
'EgtMachDir??...(sMachinesRootDir)
|
|
|
|
' Cerco le macchine
|
|
Dim Machines As String() = Directory.GetDirectories(sMachinesRootDir)
|
|
For i As Integer = 0 To Machines.Count - 1
|
|
Dim PathIni As String = Machines(i) & "\" & Path.GetFileName(Machines(i)) & ".ini"
|
|
If File.Exists(PathIni) Then
|
|
MachineList.Add(New Machine(Machines(i), PathIni))
|
|
End If
|
|
Next
|
|
|
|
Return True
|
|
End Function
|
|
|
|
Public Shared Function SearchMachine(sName As String, MachineList As IList(Of Machine), ByRef FoundMachine As Machine) As Boolean
|
|
For Each Machine In MachineList
|
|
If String.Compare( Machine.Name, sName, True) = 0 Then
|
|
FoundMachine = Machine
|
|
Return True
|
|
End If
|
|
Next
|
|
FoundMachine = Nothing
|
|
Return False
|
|
End Function
|
|
|
|
Public Shared Function SearchMachineIni(sName As String, MachineList As IList(Of Machine), ByRef FoundedIni As String) As Boolean
|
|
For Each Machine In MachineList
|
|
If Machine.Name = sName Then
|
|
FoundedIni = Machine.IniPath
|
|
Return True
|
|
End If
|
|
Next
|
|
FoundedIni = String.Empty
|
|
Return False
|
|
End Function
|
|
|
|
Public Shared Function ExistsMachine(sName As String, MachineList As IList(Of Machine)) As Boolean
|
|
For Each Machine In MachineList
|
|
If Machine.Name = sName Then
|
|
Return True
|
|
End If
|
|
Next
|
|
Return False
|
|
End Function
|
|
|
|
End Class
|