EgtDOORCreator :
- correzioni varie per decrementare sempre il conteggio di istanza all'uscita.
This commit is contained in:
@@ -1018,6 +1018,7 @@ Public Class AssemblyManagerVM
|
||||
' TERMINO TUTTO SUBITO
|
||||
EgtOutLog("Scrittura file '.ddf' terminata")
|
||||
EgtExit()
|
||||
Map.refMainWindowVM.MainWindowModel.ReleaseInstance()
|
||||
Application.Current.Shutdown(0)
|
||||
Return True
|
||||
End If
|
||||
|
||||
@@ -133,10 +133,9 @@ Public Class CompoType
|
||||
End Sub
|
||||
|
||||
Public Function LoadListTemplate() As Boolean
|
||||
FolderList.Clear()
|
||||
m_HardwareFolderList.Clear()
|
||||
m_FrameFolderList.Clear()
|
||||
m_FolderList.Clear()
|
||||
m_FrameFolderList.Clear()
|
||||
m_HardwareFolderList.Clear()
|
||||
GetDirectoryCompoModel(m_Path, m_FolderList, m_FrameFolderList, m_HardwareFolderList)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
@@ -118,8 +118,6 @@ Friend Class MainWindowModel
|
||||
EgtLuaRequire(sLuaBaseLib)
|
||||
' Imposto path IniFile
|
||||
EgtSetIniFile(IniFile.m_sIniFile)
|
||||
' Imposto la modalità di lettura dei file ddf
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
@@ -132,7 +130,7 @@ Friend Class MainWindowModel
|
||||
Private Sub ManageIstance()
|
||||
Dim bCreated As Boolean
|
||||
Try
|
||||
m_objMutex = New Mutex(False, "Global\EgtDOORCreator", bCreated)
|
||||
m_objMutex = New Mutex(True, "Global\EgtDOORCreator", bCreated)
|
||||
Catch
|
||||
bCreated = False
|
||||
End Try
|
||||
@@ -141,20 +139,36 @@ Friend Class MainWindowModel
|
||||
m_nInstance = 1
|
||||
' Aggiorno stato istanze attive
|
||||
WriteMainPrivateProfileString(S_GENERAL, K_INSTANCES, m_nInstance.ToString)
|
||||
' Rilascio il possesso del mutex
|
||||
m_objMutex.ReleaseMutex()
|
||||
Else
|
||||
' Leggo il massimo numero di istanze ammesse
|
||||
Const MAX_INST As Integer = 32
|
||||
Dim nMaxInst As Integer = GetMainPrivateProfileInt(S_GENERAL, K_MAXINST, 1)
|
||||
nMaxInst = Max(1, Min(nMaxInst, 32))
|
||||
' Cerco il primo indice di istanza libero (max 32)
|
||||
Dim nTmp As Integer = GetMainPrivateProfileInt(S_GENERAL, K_INSTANCES, 0)
|
||||
m_nInstance = 1
|
||||
Dim nMask As Integer = 1
|
||||
While (nTmp And nMask) <> 0 And m_nInstance <= m_nInstance
|
||||
m_nInstance += 1
|
||||
nMask *= 2
|
||||
End While
|
||||
' Se l'indice supera il massimo
|
||||
If m_nInstance > nMaxInst Then
|
||||
nMaxInst = Max(1, Min(nMaxInst, MAX_INST))
|
||||
' Richiedo il possesso del mutex
|
||||
Dim bOk As Boolean = False
|
||||
If m_objMutex.WaitOne(500) Then
|
||||
' Cerco il primo indice di istanza libero (max 32)
|
||||
Dim nTmp As Integer = GetMainPrivateProfileInt(S_GENERAL, K_INSTANCES, 0)
|
||||
m_nInstance = 1
|
||||
Dim nMask As Integer = 1
|
||||
While (nTmp And nMask) <> 0 And m_nInstance <= m_nInstance
|
||||
m_nInstance += 1
|
||||
nMask *= 2
|
||||
End While
|
||||
' Se nuova istanza nei limiti
|
||||
If m_nInstance <= nMaxInst Then
|
||||
bOk = True
|
||||
' Aggiorno stato istanze attive
|
||||
nTmp += (1 << (m_nInstance - 1))
|
||||
WriteMainPrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString())
|
||||
End If
|
||||
' Rilascio il possesso del mutex
|
||||
m_objMutex.ReleaseMutex()
|
||||
End If
|
||||
' Se non è possibile continuare
|
||||
If Not bOk Then
|
||||
' porto in primo piano la prima istanza
|
||||
Dim bFound As Boolean = False
|
||||
' processi del programma a 32 bit
|
||||
@@ -178,13 +192,21 @@ Friend Class MainWindowModel
|
||||
Next
|
||||
End If
|
||||
' esco dal programma
|
||||
End
|
||||
Environment.Exit(1)
|
||||
End If
|
||||
' Aggiorno stato istanze attive
|
||||
nTmp += (1 << (m_nInstance - 1))
|
||||
WriteMainPrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString())
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Friend Sub ReleaseInstance()
|
||||
' Aggiorno istanze usate
|
||||
Dim bOk As Boolean = m_objMutex.WaitOne(1000)
|
||||
Dim nTmp As Integer = GetMainPrivateProfileInt(S_GENERAL, K_INSTANCES, 0)
|
||||
nTmp -= (1 << (m_nInstance - 1))
|
||||
WriteMainPrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString())
|
||||
If bOk Then m_objMutex.ReleaseMutex()
|
||||
' Rilascio mutex
|
||||
If Not IsNothing(m_objMutex) Then m_objMutex.Close()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Funzione che cancella tutti i file in un direttorio o lo crea se non esiste
|
||||
|
||||
@@ -8,7 +8,11 @@ Public Class MainWindowVM
|
||||
|
||||
' Modello del MainWindow (classe vera e propria)
|
||||
Private m_MainWindowModel As New MainWindowModel
|
||||
|
||||
Friend ReadOnly Property MainWindowModel As MainWindowModel
|
||||
Get
|
||||
Return m_MainWindowModel
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property Instance As Integer
|
||||
Get
|
||||
Return m_MainWindowModel.m_nInstance
|
||||
@@ -435,7 +439,6 @@ Public Class MainWindowVM
|
||||
End If
|
||||
Map.refHardwarePageVM.CurrHardware.DeleteTempFile()
|
||||
End If
|
||||
Utility.UnLockDir()
|
||||
Case Else
|
||||
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) AndAlso Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.IsModified Then
|
||||
Dim sText As String = String.Format(EgtMsg(50109), Path.GetFileNameWithoutExtension(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.Name))
|
||||
@@ -467,9 +470,15 @@ Public Class MainWindowVM
|
||||
Not String.IsNullOrWhiteSpace(Map.refAssemblyManagerVM.CurrProject.Name) Then
|
||||
WriteMainPrivateProfileString(S_LAUNCHERWINDOW, K_LASTPROJECT, Map.refAssemblyManagerVM.CurrProject.Name)
|
||||
End If
|
||||
|
||||
' Terminazione generale di EgtInterface
|
||||
EgtExit()
|
||||
Application.Current.MainWindow.Close()
|
||||
' Libero eventuale porta bloccata
|
||||
Utility.UnLockDir()
|
||||
' Aggiorno istanze usate
|
||||
m_MainWindowModel.ReleaseInstance()
|
||||
' Chiudo la finestra principale del programma
|
||||
Application.Current.MainWindow.Close()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -1008,6 +1008,7 @@ Public Class ProjectManagerVM
|
||||
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nNothingSelected
|
||||
If OptionModule.AdjustDDT Then
|
||||
EgtExit()
|
||||
Map.refMainWindowVM.MainWindowModel.ReleaseInstance()
|
||||
Application.Current.Shutdown(3)
|
||||
End If
|
||||
Return
|
||||
|
||||
@@ -111,6 +111,7 @@ Module RegexFunction
|
||||
WriteMainPrivateProfileString(S_LAUNCHERWINDOW, K_LAUNCHER, (OptionModule.m_SelectedOptionLauncher + LoOpenOnce).ToString())
|
||||
' esco dall'applicazione
|
||||
EgtExit()
|
||||
Map.refMainWindowVM.MainWindowModel.ReleaseInstance()
|
||||
Application.Current.MainWindow.Close()
|
||||
End
|
||||
Else
|
||||
|
||||
+33
-31
@@ -626,70 +626,66 @@ Public Module Utility
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Friend Sub GetDirectoryCompoFiles(DirectoryPath As String, ByRef FileList As ObservableCollection(Of String), bRemoveNge As Boolean)
|
||||
RecursiveGetDirectoryCompoFiles(DirectoryPath, DirectoryPath, FileList, bRemoveNge)
|
||||
End Sub
|
||||
|
||||
' csotruisco le liste dei file
|
||||
Friend Sub GetDirectoryCompoModel(HardwareDirPath As String, FolderList As ObservableCollection(Of CompoBrandDir), Optional FrameFolderList As ObservableCollection(Of CompoBrandDir) = Nothing, Optional HardwareFolderList As ObservableCollection(Of CompoBrandDir) = Nothing)
|
||||
'FrameFolderList = New ObservableCollection(Of CompoBrandDir)
|
||||
' costruisco le liste dei file
|
||||
Friend Sub GetDirectoryCompoModel(HardwareDirPath As String, FolderList As ObservableCollection(Of CompoBrandDir),
|
||||
Optional FrameFolderList As ObservableCollection(Of CompoBrandDir) = Nothing,
|
||||
Optional HardwareFolderList As ObservableCollection(Of CompoBrandDir) = Nothing)
|
||||
' Nome del direttorio dei componenti
|
||||
Dim BaseDirName As String = Path.GetFileName(HardwareDirPath)
|
||||
' Carico l'elenco dei file contenuti nei sottodirettori
|
||||
Dim FolderArray() As String = Directory.GetDirectories(HardwareDirPath)
|
||||
Dim CurrFolder As CompoBrandDir = Nothing
|
||||
For Each Folder In FolderArray
|
||||
Folder = Folder.Replace("/", "\")
|
||||
CurrFolder = New CompoBrandDir(Folder, BaseDirName)
|
||||
GetDirectoryCompoFiles(Folder, CurrFolder.ModelFileList, False)
|
||||
Dim CurrGenFolder As CompoBrandDir = New CompoBrandDir(Folder, BaseDirName)
|
||||
GetDirectoryCompoFiles(Folder, CurrGenFolder.ModelFileList, False)
|
||||
' genero le liste per il DoorCreator
|
||||
If CurrFolder.ModelFileList.Count > 0 Then
|
||||
If CurrGenFolder.ModelFileList.Count > 0 Then
|
||||
If Folder.ToLower.Contains(FRAME_FOLDER) Then
|
||||
FrameFolderList.Add(CurrFolder)
|
||||
'If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then HardwareFolderList.Add(CurrFolder)
|
||||
If Not IsNothing(FrameFolderList) Then FrameFolderList.Add(CurrGenFolder)
|
||||
Else
|
||||
FolderList.Add(CurrFolder)
|
||||
FolderList.Add(CurrGenFolder)
|
||||
End If
|
||||
End If
|
||||
' genero le liste per l'HardwareManager
|
||||
CurrFolder = New CompoBrandDir(Folder, BaseDirName)
|
||||
If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then
|
||||
HardwareFolderList.Add(CurrFolder)
|
||||
Else
|
||||
' solo se non sono in modlità assemblato non carcico gli elenchi ".frame"
|
||||
If Not Folder.ToLower.Contains(FRAME_FOLDER) Then
|
||||
HardwareFolderList.Add(CurrFolder)
|
||||
If Not IsNothing(HardwareFolderList) Then
|
||||
Dim CurrHardFolder As CompoBrandDir = New CompoBrandDir(Folder, BaseDirName)
|
||||
GetDirectoryCompoFiles(Folder, CurrHardFolder.ModelFileList, True)
|
||||
If OptionModule.m_ConfigurationSoftware = ConfigType.Assembly Then
|
||||
HardwareFolderList.Add(CurrHardFolder)
|
||||
Else
|
||||
' solo se non sono in modalità assemblato non carico gli elenchi ".frame"
|
||||
If Not Folder.ToLower.Contains(FRAME_FOLDER) Then
|
||||
HardwareFolderList.Add(CurrHardFolder)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
GetDirectoryCompoFiles(Folder, CurrFolder.ModelFileList, True)
|
||||
Next
|
||||
' Carico l'elenco dei file contenuti nella radice del direttorio
|
||||
' Carico l'elenco dei file contenuti nel direttorio
|
||||
Dim FileArray() As String = Directory.GetFiles(HardwareDirPath)
|
||||
CurrFolder = Nothing
|
||||
Dim CurrFolder As CompoBrandDir = Nothing
|
||||
Dim CurrFrameFolder As CompoBrandDir = Nothing
|
||||
Dim CurrHardwareFolder As CompoBrandDir = Nothing
|
||||
For Each File In FileArray
|
||||
File = File.Replace("/", "\")
|
||||
If Not Path.GetExtension(File).ToLower = INI_EXTENSION And Not Path.GetExtension(File).ToLower = TEMPL_EXTENSION And
|
||||
(Path.GetExtension(File).ToLower = LUA_EXTENSION Or Path.GetExtension(File).ToLower = NGE_EXTENSION) And
|
||||
Dim sExt As String = Path.GetExtension(File).ToLower
|
||||
If (sExt = LUA_EXTENSION Or sExt = NGE_EXTENSION) And
|
||||
Not File.Contains(MATCHING_FILE_NAME) And Not File.ToLower().Contains("currhardware") Then
|
||||
If File.Contains(FRAME_FOLDER) Then
|
||||
If IsNothing(CurrFrameFolder) Then
|
||||
' CurrFrameFolder = New CompoBrandDir(Path.GetFileName(HardwareDirPath), BaseDirName & FRAME_FOLDER)
|
||||
CurrFrameFolder = New CompoBrandDir(HardwareDirPath, BaseDirName & FRAME_FOLDER)
|
||||
FrameFolderList.Add(CurrFrameFolder)
|
||||
If Not IsNothing(FrameFolderList) Then FrameFolderList.Add(CurrFrameFolder)
|
||||
End If
|
||||
CurrFrameFolder.ModelFileList.Add(If(Path.GetExtension(File).ToLower = NGE_EXTENSION, Path.GetFileName(File), Path.GetFileNameWithoutExtension(File)))
|
||||
Else
|
||||
If IsNothing(CurrFolder) Then
|
||||
' CurrFolder = New CompoBrandDir(Path.GetFileName(HardwareDirPath), BaseDirName)
|
||||
CurrFolder = New CompoBrandDir(HardwareDirPath, BaseDirName)
|
||||
FolderList.Add(CurrFolder)
|
||||
End If
|
||||
CurrFolder.ModelFileList.Add(If(Path.GetExtension(File).ToLower = NGE_EXTENSION, Path.GetFileName(File), Path.GetFileNameWithoutExtension(File)))
|
||||
If Not File.Contains(NGE_EXTENSION) Then
|
||||
If IsNothing(CurrHardwareFolder) Then
|
||||
' CurrHardwareFolder = New CompoBrandDir(Path.GetFileName(HardwareDirPath), BaseDirName)
|
||||
CurrHardwareFolder = New CompoBrandDir(HardwareDirPath, BaseDirName)
|
||||
HardwareFolderList.Add(CurrHardwareFolder)
|
||||
If Not IsNothing(HardwareFolderList) Then HardwareFolderList.Add(CurrHardwareFolder)
|
||||
End If
|
||||
CurrHardwareFolder.ModelFileList.Add(If(Path.GetExtension(File).ToLower = NGE_EXTENSION, Path.GetFileName(File), Path.GetFileNameWithoutExtension(File)))
|
||||
End If
|
||||
@@ -698,11 +694,17 @@ Public Module Utility
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Friend Sub GetDirectoryCompoFiles(DirectoryPath As String, ByRef FileList As ObservableCollection(Of String), bRemoveNge As Boolean)
|
||||
RecursiveGetDirectoryCompoFiles(DirectoryPath, DirectoryPath, FileList, bRemoveNge)
|
||||
End Sub
|
||||
|
||||
Private Sub RecursiveGetDirectoryCompoFiles(DirectoryPath As String, BaseDirectory As String, ByRef FileList As ObservableCollection(Of String), bRemoveNge As Boolean)
|
||||
' File nei sottodirettori
|
||||
Dim SubDir() As String = Directory.GetDirectories(DirectoryPath)
|
||||
For Index = 0 To SubDir.Count - 1
|
||||
RecursiveGetDirectoryCompoFiles(SubDir(Index), BaseDirectory, FileList, bRemoveNge)
|
||||
Next
|
||||
' File nel direttorio
|
||||
Dim Files() As String = Directory.GetFiles(DirectoryPath)
|
||||
For Index = 0 To Files.Count - 1
|
||||
Dim FileExt As String = Path.GetExtension(Files(Index).ToLower())
|
||||
|
||||
Reference in New Issue
Block a user