diff --git a/DemoVB/Form1.vb b/DemoVB/Form1.vb
index f91b70e..c082d80 100644
--- a/DemoVB/Form1.vb
+++ b/DemoVB/Form1.vb
@@ -10,670 +10,681 @@ Imports WeebDoorCreator.SDK
Public Class Form1
- ' caricamento del NEXT STACK da redis (come oggetto)
- ' PROD http : https://iis01.egalware.com/WDC/SRV/
- ' DEV: https : https://localhost:7043/
- Dim baseIp As String = "iis01.egalware.com"
- Dim baseUrl As String = "https://iis01.egalware.com/WDC/SRV/"
- Dim codPost As String = "WRK001" ' nome macchina calcolo
- Dim risultatoPing As PingReply = Nothing
+ ' caricamento del NEXT STACK da redis (come oggetto)
+ ' PROD http : https://iis01.egalware.com/WDC/SRV/
+ ' DEV: https : https://localhost:7043/
+ Dim baseIp As String = "iis01.egalware.com"
+ Dim baseUrl As String = "https://iis01.egalware.com/WDC/SRV/"
+ Dim codPost As String = "WRK001" ' nome macchina calcolo
+ Dim risultatoPing As PingReply = Nothing
- Dim currWDC As WDC = New WDC(baseIp, baseUrl, codPost)
+ Dim currWDC As WDC = New WDC(baseIp, baseUrl, codPost)
- Dim m_bStopProcess As Boolean = False
+ Dim m_bStopProcess As Boolean = False
- Private m_MaxCamInstances As Integer = 1
- Public Sub SetMaxCamInstances(value As Integer)
- m_MaxCamInstances = value
- End Sub
+ Private m_MaxCamInstances As Integer = 1
+ Public Sub SetMaxCamInstances(value As Integer)
+ m_MaxCamInstances = value
+ End Sub
- Dim m_ExecutionThread As Thread
- Dim m_bExecutionThreadStoped As Boolean = False
+ Dim m_ExecutionThread As Thread
+ Dim m_bExecutionThreadStoped As Boolean = False
- Private Sub btnTestPing_Click(sender As Object, e As EventArgs) Handles btnTestPing.Click
- ' chiamo test ping...
- risultatoPing = currWDC.testPing
- lblpingTest.Text = risultatoPing.Status.ToString()
- End Sub
+ Private Sub btnTestPing_Click(sender As Object, e As EventArgs) Handles btnTestPing.Click
+ ' chiamo test ping...
+ risultatoPing = currWDC.testPing
+ lblpingTest.Text = risultatoPing.Status.ToString()
+ End Sub
- Private Sub btnTestAlive_Click(sender As Object, e As EventArgs) Handles btnTestAlive.Click
- Dim answ As String = ""
- If (currWDC.testAlive) Then
- lblTestAlive.Text = "Server Alive!!!"
- Else
- lblTestAlive.Text = "Alive test failed!"
- End If
- End Sub
+ Private Sub btnTestAlive_Click(sender As Object, e As EventArgs) Handles btnTestAlive.Click
+ Dim answ As String = ""
+ If (currWDC.testAlive) Then
+ lblTestAlive.Text = "Server Alive!!!"
+ Else
+ lblTestAlive.Text = "Alive test failed!"
+ End If
+ End Sub
- Dim idxSim As Integer = 0
+ Dim idxSim As Integer = 0
- Private Sub StopProcess_Click(sender As Object, e As EventArgs) Handles StopProcess.Click
- m_bStopProcess = True
- While Not m_bExecutionThreadStoped
- Thread.Sleep(10)
- End While
- m_ExecutionThread = Nothing
- End Sub
+ Private Sub StopProcess_Click(sender As Object, e As EventArgs) Handles StopProcess.Click
+ m_bStopProcess = True
+ While Not m_bExecutionThreadStoped
+ Thread.Sleep(10)
+ End While
+ m_ExecutionThread = Nothing
+ End Sub
- Private Structure MyProc
- Public bEnable As Boolean
- Public Proc As Process
- Public Thread As Thread
- Public nBar As Integer
- End Structure
+ Private Structure MyProc
+ Public bEnable As Boolean
+ Public Proc As Process
+ Public Thread As Thread
+ Public nBar As Integer
+ End Structure
- Dim ThreadList As Thread()
+ Dim ThreadList As Thread()
- Private Sub ThreadFunction()
+ Private Sub ThreadFunction()
- Dim sExePath As String = "c:\EgtProg\EgtEngine\EgtEngineR32.exe"
- Dim sCurrDdfDir As String = "c:\EgtData\WebDoor\Ddf"
+ Dim sExePath As String = "c:\EgtProg\EgtEngine\EgtEngineR32.exe"
+ Dim sCurrDdfDir As String = "c:\EgtData\WebDoor\Ddf"
- While Not m_bStopProcess
+ While Not m_bStopProcess
- ' se c'e' qualcosa da processare
- If currWDC.numTask2proc > 0 Then
+ ' se c'e' qualcosa da processare
+ If currWDC.numTask2proc > 0 Then
- Dim LastRequest As Dictionary(Of String, String) = currWDC.queueList(1)
- If LastRequest.Count > 0 Then
+ Dim LastRequest As Dictionary(Of String, String) = currWDC.queueList(1)
+ If LastRequest.Count > 0 Then
- Dim Item As KeyValuePair(Of String, String) = LastRequest.First()
- Dim bOk As Boolean = Not IsNothing(Item)
- If bOk Then
+ Dim Item As KeyValuePair(Of String, String) = LastRequest.First()
+ Dim bOk As Boolean = Not IsNothing(Item)
+ If bOk Then
- ' scrivo ddf
- Dim sDdfPath As String = sCurrDdfDir & "\" & Item.Key & ".ddf"
- Try
- File.WriteAllText(sDdfPath, Item.Value)
- Catch ex As Exception
- bOk = False
- End Try
+ ' scrivo ddf
+ Dim sDdfPath As String = sCurrDdfDir & "\" & Item.Key & ".ddf"
+ Try
+ File.WriteAllText(sDdfPath, Item.Value)
+ Catch ex As Exception
+ bOk = False
+ End Try
- If bOk Then
-
- ' eseguo calcolo
- Dim Proc As New Process()
- Proc.StartInfo.FileName = sExePath
- Proc.StartInfo.Arguments = """C:\EgtData\WebDoor\Main.lua""" & " """ & sDdfPath & """"
- Proc.StartInfo.UseShellExecute = False
-
- If Proc.Start() Then
-
- While Not Proc.HasExited
- Thread.Sleep(1)
- End While
- Dim procResults As New List(Of CalcResultDTO)
- Dim currRes As New CalcResultDTO
-
- ' verifico esistenza file svg e lo carico
- Dim sSvgPath As String = Path.ChangeExtension(sDdfPath, "svg")
- bOk = File.Exists(sSvgPath)
- Dim sSvgContent As String = ""
If bOk Then
- Try
- sSvgContent = File.ReadAllText(sSvgPath)
- Catch ex As Exception
- bOk = False
- sSvgContent = ""
- End Try
+
+ ' eseguo calcolo
+ Dim Proc As New Process()
+ Proc.StartInfo.FileName = sExePath
+ Proc.StartInfo.Arguments = """C:\EgtData\WebDoor\Main.lua""" & " """ & sDdfPath & """"
+ Proc.StartInfo.UseShellExecute = False
+
+ If Proc.Start() Then
+
+ While Not Proc.HasExited
+ Thread.Sleep(1)
+ End While
+ Dim procResults As New List(Of CalcResultDTO)
+ Dim currRes As New CalcResultDTO
+ Dim fContent As String = ""
+ ' verifico esistenza file svg e lo carico
+ bOk = GetFileContent(Path.ChangeExtension(sDdfPath, "svg"), fContent)
+ ' invio risposta
+ currRes.Validated = Proc.ExitCode = 0 AndAlso bOk
+ currRes.DoorIdVers = Item.Key
+ ' se NON fosse validato --> messo il messaggio...
+ If (currRes.Validated) Then
+ currRes.SvgGen = fContent
+ Else
+ bOk = GetFileContent(Path.ChangeExtension(sDdfPath, "txt"), fContent)
+ currRes.ErrorMsg = fContent
+ End If
+
+ procResults.Add(currRes)
+ Dim respPut As String = currWDC.SendProcResults(procResults)
+
+ End If
+
End If
-
- ' invio risposta
- currRes.Validated = Proc.ExitCode = 0 AndAlso bOk
- currRes.DoorIdVers = Item.Key
- currRes.SvgGen = sSvgContent
- procResults.Add(currRes)
- Dim respPut As String = currWDC.SendProcResults(procResults)
-
- End If
-
- End If
- End If
+ End If
+ End If
End If
- End If
- End While
+ End While
- End Sub
+ End Sub
- Private Sub ExecutionProcess()
- ' recupero Id dei DDF
- Dim sDdfRoot As String = "c:\EgtData\WebDoor\Ddf"
- Dim sCurrDdfDir As String = ""
- Dim nDdfId As Integer = 1
+ Private Function GetFileContent(ByVal filePath As String, ByRef fileContent As String) As Boolean
- ' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI)
- Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, m_MaxCamInstances)
- Dim bStopMainProcess As Boolean = False
- Dim n30SecCounter As Integer = 0
- While Not bStopMainProcess
- bStopMainProcess = m_bStopProcess
- Dim bOk As Boolean = False
- While Not bOk
- ' ogni 30 secondi
- If n30SecCounter = 30 OrElse n30SecCounter = 0 Then
- ' verifica connessione
- Dim risultatoPing As PingReply = currWDC.testPing
- bOk = risultatoPing.Status = IPStatus.Success
- If bOk Then
- bOk = currWDC.testAlive
- End If
- Else bOk = True
+ Dim bOk As Boolean = File.Exists(filePath)
+ If bOk Then
+ Try
+ fileContent = File.ReadAllText(filePath)
+ Catch ex As Exception
+ bOk = False
+ fileContent = ""
+ End Try
+ End If
+ Return bOk
+ End Function
+
+
+ Private Sub ExecutionProcess()
+ ' recupero Id dei DDF
+ Dim sDdfRoot As String = "c:\EgtData\WebDoor\Ddf"
+ Dim sCurrDdfDir As String = ""
+ Dim nDdfId As Integer = 1
+
+ ' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI)
+ Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, m_MaxCamInstances)
+ Dim bStopMainProcess As Boolean = False
+ Dim n30SecCounter As Integer = 0
+ While Not bStopMainProcess
+ bStopMainProcess = m_bStopProcess
+ Dim bOk As Boolean = False
+ While Not bOk
+ ' ogni 30 secondi
+ If n30SecCounter = 30 OrElse n30SecCounter = 0 Then
+ ' verifica connessione
+ Dim risultatoPing As PingReply = currWDC.testPing
+ bOk = risultatoPing.Status = IPStatus.Success
+ If bOk Then
+ bOk = currWDC.testAlive
+ End If
+ Else bOk = True
+ End If
+ ' se connessione non ok o processo fermato, fermo i thread
+ If Not bOk OrElse bStopMainProcess Then
+ If Not IsNothing(ThreadList) AndAlso ThreadList.Count > 0 AndAlso Not IsNothing(ThreadList(0)) Then
+ ' li fermo
+ m_bStopProcess = True
+ ' verifico siano terminati
+ Dim bOneNotEnded As Boolean = True
+ While bOneNotEnded
+ bOneNotEnded = False
+ For Each Thread In ThreadList
+ If Thread.IsAlive Then
+ bOneNotEnded = True
+ End If
+ Next
+ End While
+ ' pulisco la lista
+ For ThreadIndex = 0 To ThreadList.Count - 1
+ ThreadList(ThreadIndex) = Nothing
+ Next
+ End If
+ If bStopMainProcess Then
+ m_bExecutionThreadStoped = True
+ Return
+ End If
+ End If
+ If Not bOk Then Thread.Sleep(10)
+ End While
+
+ If bOk AndAlso (IsNothing(ThreadList) OrElse ThreadList.Count = 0 OrElse IsNothing(ThreadList(0))) Then
+ ThreadList = New Thread(nMaxThread - 1) {}
+ For nThreadIndex = 0 To nMaxThread - 1
+ ThreadList(nThreadIndex) = New Thread(Sub()
+ ThreadFunction()
+ End Sub)
+ ThreadList(nThreadIndex).SetApartmentState(ApartmentState.STA)
+ ' avvio thread di gestione della macchina che avvia la connessione
+ ThreadList(nThreadIndex).Start()
+ Thread.Sleep(10)
+ Next
End If
- ' se connessione non ok o processo fermato, fermo i thread
- If Not bOk OrElse bStopMainProcess Then
- If Not IsNothing(ThreadList) AndAlso ThreadList.Count > 0 AndAlso Not IsNothing(ThreadList(0)) Then
- ' li fermo
- m_bStopProcess = True
- ' verifico siano terminati
- Dim bOneNotEnded As Boolean = True
- While bOneNotEnded
- bOneNotEnded = False
- For Each Thread In ThreadList
- If Thread.IsAlive Then
- bOneNotEnded = True
- End If
- Next
- End While
- ' pulisco la lista
- For ThreadIndex = 0 To ThreadList.Count - 1
- ThreadList(ThreadIndex) = Nothing
- Next
- End If
- If bStopMainProcess Then
- m_bExecutionThreadStoped = True
- Return
- End If
+ If n30SecCounter <= 30 Then
+ n30SecCounter += 1
+ Else
+ n30SecCounter = 1
End If
- If Not bOk Then Thread.Sleep(10)
- End While
+ Thread.Sleep(1000)
+ End While
- If bOk AndAlso (IsNothing(ThreadList) OrElse ThreadList.Count = 0 OrElse IsNothing(ThreadList(0))) Then
- ThreadList = New Thread(nMaxThread - 1) {}
- For nThreadIndex = 0 To nMaxThread - 1
- ThreadList(nThreadIndex) = New Thread(Sub()
- ThreadFunction()
- End Sub)
- ThreadList(nThreadIndex).SetApartmentState(ApartmentState.STA)
- ' avvio thread di gestione della macchina che avvia la connessione
- ThreadList(nThreadIndex).Start()
- Thread.Sleep(10)
+ End Sub
+
+ Private Sub StartProcess_Click(sender As Object, e As EventArgs) Handles StartProcess.Click
+ m_bStopProcess = False
+ m_ExecutionThread = New Thread(Sub()
+ ExecutionProcess()
+ End Sub)
+
+ m_ExecutionThread.SetApartmentState(ApartmentState.STA)
+ ' avvio thread di gestione della macchina che avvia la connessione
+ m_ExecutionThread.Start()
+
+ '' recupero Id dei DDF
+ 'Dim sDdfRoot As String = "c:\EgtData\WebDoor\Ddf"
+ 'Dim sCurrDdfDir As String = ""
+ 'Dim nDdfId As Integer = 1
+
+ '' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI)
+ 'Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, m_MaxCamInstances)
+ 'Dim bStopMainProcess As Boolean = False
+ 'Dim n30SecCounter As Integer = 0
+ 'While Not bStopMainProcess
+ ' bStopMainProcess = m_bStopProcess
+ ' Dim bOk As Boolean = False
+ ' While Not bOk
+ ' ' ogni 30 secondi
+ ' If n30SecCounter = 30 OrElse n30SecCounter = 0 Then
+ ' ' verifica connessione
+ ' Dim risultatoPing As PingReply = currWDC.testPing
+ ' bOk = risultatoPing.Status = IPStatus.Success
+ ' If bOk Then
+ ' bOk = currWDC.testAlive
+ ' End If
+ ' Else bOk = True
+ ' End If
+ ' ' se connessione non ok o processo fermato, fermo i thread
+ ' If Not bOk OrElse bStopMainProcess Then
+ ' If Not IsNothing(ThreadList) AndAlso ThreadList.Count > 0 Then
+ ' ' li fermo
+ ' m_bStopProcess = True
+ ' ' verifico siano terminati
+ ' Dim bOneNotEnded As Boolean = True
+ ' While bOneNotEnded
+ ' bOneNotEnded = False
+ ' For Each Thread In ThreadList
+ ' If Thread.IsAlive Then
+ ' bOneNotEnded = True
+ ' Exit For
+ ' End If
+ ' Next
+ ' End While
+ ' ' pulisco la lista
+ ' For Each Thread In ThreadList
+ ' Thread = Nothing
+ ' Next
+ ' End If
+ ' If bStopMainProcess Then Return
+ ' End If
+ ' If Not bOk Then Thread.Sleep(10)
+ ' End While
+
+ ' If bOk AndAlso (IsNothing(ThreadList) OrElse ThreadList.Count = 0) Then
+ ' ThreadList = New Thread(nMaxThread - 1) {}
+ ' For nThreadIndex = 0 To nMaxThread - 1
+ ' ThreadList(nThreadIndex) = New Thread(Sub()
+ ' ThreadFunction()
+ ' End Sub)
+ ' ThreadList(nThreadIndex).SetApartmentState(ApartmentState.STA)
+ ' ' avvio thread di gestione della macchina che avvia la connessione
+ ' ThreadList(nThreadIndex).Start()
+ ' Next
+ ' End If
+ ' If n30SecCounter <= 30 Then
+ ' n30SecCounter += 1
+ ' Else
+ ' n30SecCounter = 1
+ ' End If
+ ' Thread.Sleep(1000)
+ 'End While
+
+ 'Dim DdfDirs As String() = Directory.GetDirectories(sDdfRoot)
+ 'If DdfDirs.Count = 0 Then
+ ' sCurrDdfDir = sDdfRoot & "\0"
+ ' Directory.CreateDirectory(sCurrDdfDir)
+ ' nDdfId = 0
+ 'Else
+
+ ' nDdfId = Directory.EnumerateFiles(DdfDirs(DdfDirs.Count - 1)).Max(Of Integer)(Function(x)
+ ' Dim nDirId As Integer = 0
+ ' If Integer.TryParse(x, nDirId) Then
+ ' Return nDirId
+ ' Else
+ ' Return 0
+ ' End If
+ ' End Function)
+ ' If (nDdfId + 1) Mod 100 = 0 Then
+ ' sCurrDdfDir = sDdfRoot & "\" & nDdfId + 1
+ ' Directory.CreateDirectory(sCurrDdfDir)
+ ' nDdfId = 0
+ ' End If
+ 'End If
+
+
+
+
+ ' ' Lancio in parallelo più processi (senza superare il numero di core logici presenti)
+ ' Dim vProc As MyProc() = New MyProc(nMaxThread - 1) {}
+ ' For j As Integer = 0 To nMaxThread - 1
+ ' vProc(j).nBar = -1
+ ' vProc(j).bEnable = True
+ ' Next
+
+ ' While Not m_bStopProcess
+
+ ' For j As Integer = 0 To nMaxThread - 1
+ ' If Not vProc(j).bEnable Then Continue For
+ ' Dim bDone As Boolean = False
+
+ ' If vProc(j).nBar = -1 Then
+
+ ' ' se c'e' qualcosa da processare
+ ' If currWDC.numTask2proc > 0 Then
+
+ ' Dim LastRequest As Dictionary(Of String, String) = currWDC.queueList(1)
+
+
+
+ ' If vBar(nCurrBar).bBarOk Then
+ ' vProc(j).Proc = New Process()
+ ' vProc(j).Proc.StartInfo.FileName = ExePath
+ ' If bIsEdit Then
+ ' vProc(j).Proc.StartInfo.Arguments = """" & vBar(nCurrBar).sBarPath & """"
+ ' Else
+ ' vProc(j).Proc.StartInfo.Arguments = """" & vBar(nCurrBar).sBarPath & """ " &
+ ' """" & vBar(nCurrBar).nProjType & """ " &
+ ' """" & vBar(nCurrBar).nMachineName & """ " & vBar(nCurrBar).nCmdType
+ ' End If
+ ' vProc(j).Proc.StartInfo.UseShellExecute = False
+
+ ' If vProc(j).Proc.Start() Then
+ ' vProc(j).nBar = nCurrBar
+ ' nCurrBar += 1
+ ' nActProc += 1
+ ' End If
+ ' Else
+ ' If vBar(nCurrBar).nCmdType = CmdTypes.CHECK OrElse vBar(nCurrBar).nCmdType = CmdTypes.CHECKGEN Then
+ ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(nCurrBar))) 'ProcessResults(vBar(nCurrBar))
+ ' ElseIf vBar(nCurrBar).nCmdType = CmdTypes.GENERATE Then
+ ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(nCurrBar))) 'ProcessResults(vBar(nCurrBar))
+ ' 'RaiseEvent Calc_ProcessEnd(Nothing, New CalcProcessEndEventArgs(vBar(nCurrBar))) 'ProcessResults(vBar(nCurrBar))
+ ' End If
+ ' bDone = True
+ ' nCurrBar += 1
+ ' End If
+ ' End If
+ ' Else
+
+ ' If vProc(j).Proc.HasExited Then
+ ' ' se terminato con successo
+ ' If vProc(j).Proc.ExitCode = 0 Then
+ ' ' salvo il risultato
+ ' If vBar(vProc(j).nBar).nCmdType = CmdTypes.CHECK OrElse vBar(vProc(j).nBar).nCmdType = CmdTypes.CHECKGEN Then
+ ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(vProc(j).nBar))) ' ProcessResults(vBar(vProc(j).nBar))
+ ' ElseIf vBar(vProc(j).nBar).nCmdType = CmdTypes.GENERATE Then
+ ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(vProc(j).nBar))) ' ProcessResults(vBar(vProc(j).nBar))
+ ' 'RaiseEvent Calc_ProcessEnd(Nothing, New CalcProcessEndEventArgs(vBar(vProc(j).nBar))) 'ProcessResults(vBar(nCurrBar))
+ ' End If
+ ' bDone = True
+ ' vProc(j).nBar = -1
+ ' nActProc -= 1
+ ' ' se superato il numero di processi eseguibili in parallelo
+ ' ElseIf vProc(j).Proc.ExitCode = 1 Then
+ ' ' aggiungo il pezzo in coda
+ ' If numBars + nShiftBar < numBars + nMaxThread Then
+ ' vBar(numBars + nShiftBar) = vBar(vProc(j).nBar)
+ ' nShiftBar += 1
+ ' End If
+ ' ' disabilito il processo
+ ' vProc(j).bEnable = False
+ ' vProc(j).nBar = -1
+ ' nActProc -= 1
+ ' ' altrimenti (errore generico di esecuzione)
+ ' Else
+ ' ' salvo il risultato
+ ' If vBar(vProc(j).nBar).nCmdType = CmdTypes.CHECK OrElse vBar(vProc(j).nBar).nCmdType = CmdTypes.CHECKGEN Then
+ ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(vProc(j).nBar))) ' ProcessResults(vBar(vProc(j).nBar))
+ ' ElseIf vBar(vProc(j).nBar).nCmdType = CmdTypes.GENERATE Then
+ ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(vProc(j).nBar))) ' ProcessResults(vBar(vProc(j).nBar))
+ ' 'RaiseEvent Calc_ProcessEnd(Nothing, New CalcProcessEndEventArgs(vBar(vProc(j).nBar))) 'ProcessResults(vBar(nCurrBar))
+ ' End If
+ ' bDone = True
+ ' vProc(j).nBar = -1
+ ' nActProc -= 1
+ ' End If
+ ' Else
+ ' vProc(j).Proc.Refresh()
+ ' End If
+ ' End If
+
+ ' If bDone Then
+ ' ' se sono in simulazione
+ ' If bIsSimulation Then
+ ' Dim sOriPath As String = Path.ChangeExtension(vBar(0).sBarPath, ".ori.bwe")
+ ' ' se file modificato a mano
+ ' If File.GetLastWriteTime(sOriPath) < File.GetLastWriteTime(vBar(0).sBarPath) Then
+ ' ' aggiorno progetto
+ ' If File.Exists(vBar(0).sBarPath) Then File.Copy(vBar(0).sBarPath, sOriPath, True)
+
+ ' ' messaggio di lancio verifica
+ ' callback(50, "Verifying modifications...", bCancel)
+ ' ' lancio verifica
+ ' System.Threading.Thread.Sleep(500)
+
+ ' Dim Proc As New Process()
+ ' Proc.StartInfo.FileName = ExePath
+ ' Proc.StartInfo.Arguments = """" & vBar(0).sBarPath & """ " &
+ ' """" & vBar(0).nProjType & """ " &
+ '"""" & vBar(0).nMachineName & """ " & CmdTypes.CHECKGEN
+ ' Proc.StartInfo.UseShellExecute = False
+
+ ' If Proc.Start() Then
+ ' Dim ProgressValue As Integer = 50
+ ' While Not Proc.HasExited
+ ' Proc.Refresh()
+ ' If ProgressValue < 90 Then ProgressValue += 0.001
+ ' callback(ProgressValue, "Verifying modifications...", bCancel)
+ ' Thread.Sleep(1)
+ ' End While
+ ' ' se terminato con successo
+ ' If Proc.ExitCode = 0 Then
+ ' ' salvo il risultato
+ ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(0)))
+ ' Thread.Sleep(500)
+ ' End If
+ ' End If
+ ' End If
+ ' ' messaggio di completamento simulazione
+ ' callback(0, "Simulation closing", bCancel)
+ ' ElseIf bIsEdit Then
+ ' ' ricarico il progetto
+ ' Dim Result As CalcEndEventArgs.Results
+ ' If bAllKO Then
+ ' Result = CalcEndEventArgs.Results.ERROR_
+ ' ElseIf bIsEdit Then
+ ' Result = CalcEndEventArgs.Results.EDIT
+ ' Else
+ ' Result = CalcEndEventArgs.Results.OK
+ ' End If
+ ' RaiseEvent Calc_Ended(Nothing, New CalcEndEventArgs(CmdTypes.EDIT, Result))
+ ' Return
+ ' Else
+ ' ' Dialog con Progress Bar
+ ' nDoneBar += 1
+ ' dProgress = 1 / numBars * nDoneBar
+ ' Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture)
+ ' callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel)
+ ' End If
+ ' If bCancel Then
+ ' ' fine
+ ' callback(1, "", bCancel)
+ ' ' riabilito interfaccia
+ ' RaiseEvent Calc_Ended(Nothing, New CalcEndEventArgs(CmdTypes.CHECKGEN, CalcEndEventArgs.Results.OK))
+ ' Return
+ ' End If
+ ' nPgsCurrBar = 0
+ ' nPgsClock = 0
+ ' Else
+ ' ' se non sono in simulazione
+ ' If Not bIsSimulation AndAlso Not bIsEdit Then
+ ' ' aggiorno conteggio
+ ' If nPgsClock >= 100 AndAlso nPgsCurrBar < 149 Then
+ ' nPgsCurrBar += 1
+ ' dProgress = 1 / numBars * nDoneBar + 1 / numBars / 150 * nPgsCurrBar
+ ' Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture)
+ ' callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel)
+ ' nPgsClock = 0
+ ' End If
+ ' End If
+ ' End If
+ ' nPgsClock += 1
+ ' Thread.Sleep(1)
+ ' Next
+
+
+
+
+
+
+
+
+ ' End While
+
+ ' m_bStopProcess = False
+
+
+
+
+
+
+ ' Dim num2proc As Integer
+ ' Dim queueStatus As New Dictionary(Of String, Long)
+ ' Dim queueList As New Dictionary(Of String, String)
+ ' Dim procResults As New List(Of CalcResultDTO)
+ ' Dim respPut As String
+ ' Dim fileName As String
+ ' Dim fileCont As String
+
+ ' queueStatus = currWDC.queueStatus
+ ' Dim sb As StringBuilder
+ ' sb = New StringBuilder
+ ' sb.Append(txtOut.Text)
+ ' sb.AppendLine("----------------------------")
+ ' For Each item As KeyValuePair(Of String, Long) In queueStatus
+ ' sb.AppendLine($"{item.Key} | Found {item.Value} items")
+ ' Next
+ ' sb.AppendLine("----------------------------")
+ ' sb.AppendLine()
+ ' txtOut.Text = sb.ToString()
+
+ ' ' recupero numero da processare
+ ' num2proc = currWDC.numTask2proc
+ ' If (num2proc > 0) Then
+
+ ' sb.AppendLine("----------------------------")
+ ' ' mi prendo la lista dei primi 10 max e processo...
+ ' queueList = currWDC.queueList(10)
+ ' For Each item As KeyValuePair(Of String, String) In queueList
+ ' fileCont = ""
+ ' idxSim = idxSim + 1
+ ' If (idxSim > 3) Then
+ ' idxSim = 0
+ ' End If
+ ' fileName = Path.Combine("temp", $"Logo{idxSim:00}.svg")
+ ' If (File.Exists(fileName)) Then
+ ' fileCont = File.ReadAllText(fileName)
+ ' End If
+
+ ' ' mi limito a mostrare codice + contenuto DDF... dovrebbe processare invero...
+ ' sb.AppendLine("--------------------------------------------------------")
+ ' sb.AppendLine($"DoorId.Vers: {item.Key}")
+ ' sb.AppendLine("DDF:")
+ ' sb.AppendLine("--------")
+ ' sb.AppendLine(item.Value)
+ ' sb.AppendLine("--------------------------------------------------------")
+ ' sb.AppendLine()
+
+ ' ' scrivo ddf
+ ' File.WriteAllText(sCurrDdfDir & "\" & nDdfId, item.Value)
+
+ ' ' eseguo calcolo
+
+
+ ' ' costruisco risposta finta di processing con esito true + SVG
+ ' Dim currRes As New CalcResultDTO
+ ' currRes.Validated = True
+ ' currRes.DoorIdVers = item.Key
+ ' currRes.SvgGen = fileCont
+ ' procResults.Add(currRes)
+ ' Next
+ ' sb.AppendLine("----------------------------")
+ ' sb.AppendLine()
+
+ ' ' rendo la risposta...
+ ' respPut = currWDC.SendProcResults(procResults)
+ ' sb.AppendLine()
+ ' sb.AppendLine("----------------------------")
+ ' sb.AppendLine("Esito invio risposta al server:")
+ ' sb.AppendLine()
+ ' sb.AppendLine(respPut)
+ ' sb.AppendLine("----------------------------")
+
+ ' txtOut.Text = sb.ToString()
+
+ ' End If
+
+ End Sub
+
+ Private Sub btnFullTest_Click(sender As Object, e As EventArgs) Handles btnFullTest.Click
+
+ Dim num2proc As Integer
+ Dim queueStatus As New Dictionary(Of String, Long)
+ Dim queueList As New Dictionary(Of String, String)
+ Dim procResults As New List(Of CalcResultDTO)
+ Dim respPut As String
+ Dim fileName As String
+ Dim fileCont As String
+
+ queueStatus = currWDC.queueStatus
+ Dim sb As StringBuilder
+ sb = New StringBuilder
+ sb.AppendLine("----------------------------")
+ For Each item As KeyValuePair(Of String, Long) In queueStatus
+ sb.AppendLine($"{item.Key} | Found {item.Value} items")
+ Next
+ sb.AppendLine("----------------------------")
+ sb.AppendLine()
+ txtOut.Text = sb.ToString()
+ ' recupero numero da processare
+ num2proc = currWDC.numTask2proc
+ If (num2proc > 0) Then
+
+ sb.AppendLine("----------------------------")
+ ' mi prendo la lista dei primi 10 max e processo...
+ queueList = currWDC.queueList(10)
+ For Each item As KeyValuePair(Of String, String) In queueList
+ fileCont = ""
+ idxSim = idxSim + 1
+ If (idxSim > 3) Then
+ idxSim = 0
+ End If
+ fileName = Path.Combine("temp", $"Logo{idxSim:00}.svg")
+ If (File.Exists(fileName)) Then
+ fileCont = File.ReadAllText(fileName)
+ End If
+
+ ' mi limito a mostrare codice + contenuto DDF... dovrebbe processare invero...
+ sb.AppendLine("--------------------------------------------------------")
+ sb.AppendLine($"DoorId.Vers: {item.Key}")
+ sb.AppendLine("DDF:")
+ sb.AppendLine("--------")
+ sb.AppendLine(item.Value)
+ sb.AppendLine("--------------------------------------------------------")
+ sb.AppendLine()
+
+ ' costruisco risposta finta di processing con esito true + SVG
+ Dim currRes As New CalcResultDTO
+ currRes.Validated = True
+ currRes.DoorIdVers = $"{item.Key}.{item.Value}"
+ currRes.SvgGen = fileCont
+ procResults.Add(currRes)
Next
- End If
- If n30SecCounter <= 30 Then
- n30SecCounter += 1
- Else
- n30SecCounter = 1
- End If
- Thread.Sleep(1000)
- End While
-
- End Sub
-
- Private Sub StartProcess_Click(sender As Object, e As EventArgs) Handles StartProcess.Click
- m_bStopProcess = False
- m_ExecutionThread = New Thread(Sub()
- ExecutionProcess()
- End Sub)
-
- m_ExecutionThread.SetApartmentState(ApartmentState.STA)
- ' avvio thread di gestione della macchina che avvia la connessione
- m_ExecutionThread.Start()
-
- '' recupero Id dei DDF
- 'Dim sDdfRoot As String = "c:\EgtData\WebDoor\Ddf"
- 'Dim sCurrDdfDir As String = ""
- 'Dim nDdfId As Integer = 1
-
- '' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI)
- 'Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, m_MaxCamInstances)
- 'Dim bStopMainProcess As Boolean = False
- 'Dim n30SecCounter As Integer = 0
- 'While Not bStopMainProcess
- ' bStopMainProcess = m_bStopProcess
- ' Dim bOk As Boolean = False
- ' While Not bOk
- ' ' ogni 30 secondi
- ' If n30SecCounter = 30 OrElse n30SecCounter = 0 Then
- ' ' verifica connessione
- ' Dim risultatoPing As PingReply = currWDC.testPing
- ' bOk = risultatoPing.Status = IPStatus.Success
- ' If bOk Then
- ' bOk = currWDC.testAlive
- ' End If
- ' Else bOk = True
- ' End If
- ' ' se connessione non ok o processo fermato, fermo i thread
- ' If Not bOk OrElse bStopMainProcess Then
- ' If Not IsNothing(ThreadList) AndAlso ThreadList.Count > 0 Then
- ' ' li fermo
- ' m_bStopProcess = True
- ' ' verifico siano terminati
- ' Dim bOneNotEnded As Boolean = True
- ' While bOneNotEnded
- ' bOneNotEnded = False
- ' For Each Thread In ThreadList
- ' If Thread.IsAlive Then
- ' bOneNotEnded = True
- ' Exit For
- ' End If
- ' Next
- ' End While
- ' ' pulisco la lista
- ' For Each Thread In ThreadList
- ' Thread = Nothing
- ' Next
- ' End If
- ' If bStopMainProcess Then Return
- ' End If
- ' If Not bOk Then Thread.Sleep(10)
- ' End While
-
- ' If bOk AndAlso (IsNothing(ThreadList) OrElse ThreadList.Count = 0) Then
- ' ThreadList = New Thread(nMaxThread - 1) {}
- ' For nThreadIndex = 0 To nMaxThread - 1
- ' ThreadList(nThreadIndex) = New Thread(Sub()
- ' ThreadFunction()
- ' End Sub)
- ' ThreadList(nThreadIndex).SetApartmentState(ApartmentState.STA)
- ' ' avvio thread di gestione della macchina che avvia la connessione
- ' ThreadList(nThreadIndex).Start()
- ' Next
- ' End If
- ' If n30SecCounter <= 30 Then
- ' n30SecCounter += 1
- ' Else
- ' n30SecCounter = 1
- ' End If
- ' Thread.Sleep(1000)
- 'End While
-
- 'Dim DdfDirs As String() = Directory.GetDirectories(sDdfRoot)
- 'If DdfDirs.Count = 0 Then
- ' sCurrDdfDir = sDdfRoot & "\0"
- ' Directory.CreateDirectory(sCurrDdfDir)
- ' nDdfId = 0
- 'Else
-
- ' nDdfId = Directory.EnumerateFiles(DdfDirs(DdfDirs.Count - 1)).Max(Of Integer)(Function(x)
- ' Dim nDirId As Integer = 0
- ' If Integer.TryParse(x, nDirId) Then
- ' Return nDirId
- ' Else
- ' Return 0
- ' End If
- ' End Function)
- ' If (nDdfId + 1) Mod 100 = 0 Then
- ' sCurrDdfDir = sDdfRoot & "\" & nDdfId + 1
- ' Directory.CreateDirectory(sCurrDdfDir)
- ' nDdfId = 0
- ' End If
- 'End If
-
-
-
-
- ' ' Lancio in parallelo più processi (senza superare il numero di core logici presenti)
- ' Dim vProc As MyProc() = New MyProc(nMaxThread - 1) {}
- ' For j As Integer = 0 To nMaxThread - 1
- ' vProc(j).nBar = -1
- ' vProc(j).bEnable = True
- ' Next
-
- ' While Not m_bStopProcess
-
- ' For j As Integer = 0 To nMaxThread - 1
- ' If Not vProc(j).bEnable Then Continue For
- ' Dim bDone As Boolean = False
-
- ' If vProc(j).nBar = -1 Then
-
- ' ' se c'e' qualcosa da processare
- ' If currWDC.numTask2proc > 0 Then
-
- ' Dim LastRequest As Dictionary(Of String, String) = currWDC.queueList(1)
-
-
-
- ' If vBar(nCurrBar).bBarOk Then
- ' vProc(j).Proc = New Process()
- ' vProc(j).Proc.StartInfo.FileName = ExePath
- ' If bIsEdit Then
- ' vProc(j).Proc.StartInfo.Arguments = """" & vBar(nCurrBar).sBarPath & """"
- ' Else
- ' vProc(j).Proc.StartInfo.Arguments = """" & vBar(nCurrBar).sBarPath & """ " &
- ' """" & vBar(nCurrBar).nProjType & """ " &
- ' """" & vBar(nCurrBar).nMachineName & """ " & vBar(nCurrBar).nCmdType
- ' End If
- ' vProc(j).Proc.StartInfo.UseShellExecute = False
-
- ' If vProc(j).Proc.Start() Then
- ' vProc(j).nBar = nCurrBar
- ' nCurrBar += 1
- ' nActProc += 1
- ' End If
- ' Else
- ' If vBar(nCurrBar).nCmdType = CmdTypes.CHECK OrElse vBar(nCurrBar).nCmdType = CmdTypes.CHECKGEN Then
- ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(nCurrBar))) 'ProcessResults(vBar(nCurrBar))
- ' ElseIf vBar(nCurrBar).nCmdType = CmdTypes.GENERATE Then
- ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(nCurrBar))) 'ProcessResults(vBar(nCurrBar))
- ' 'RaiseEvent Calc_ProcessEnd(Nothing, New CalcProcessEndEventArgs(vBar(nCurrBar))) 'ProcessResults(vBar(nCurrBar))
- ' End If
- ' bDone = True
- ' nCurrBar += 1
- ' End If
- ' End If
- ' Else
-
- ' If vProc(j).Proc.HasExited Then
- ' ' se terminato con successo
- ' If vProc(j).Proc.ExitCode = 0 Then
- ' ' salvo il risultato
- ' If vBar(vProc(j).nBar).nCmdType = CmdTypes.CHECK OrElse vBar(vProc(j).nBar).nCmdType = CmdTypes.CHECKGEN Then
- ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(vProc(j).nBar))) ' ProcessResults(vBar(vProc(j).nBar))
- ' ElseIf vBar(vProc(j).nBar).nCmdType = CmdTypes.GENERATE Then
- ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(vProc(j).nBar))) ' ProcessResults(vBar(vProc(j).nBar))
- ' 'RaiseEvent Calc_ProcessEnd(Nothing, New CalcProcessEndEventArgs(vBar(vProc(j).nBar))) 'ProcessResults(vBar(nCurrBar))
- ' End If
- ' bDone = True
- ' vProc(j).nBar = -1
- ' nActProc -= 1
- ' ' se superato il numero di processi eseguibili in parallelo
- ' ElseIf vProc(j).Proc.ExitCode = 1 Then
- ' ' aggiungo il pezzo in coda
- ' If numBars + nShiftBar < numBars + nMaxThread Then
- ' vBar(numBars + nShiftBar) = vBar(vProc(j).nBar)
- ' nShiftBar += 1
- ' End If
- ' ' disabilito il processo
- ' vProc(j).bEnable = False
- ' vProc(j).nBar = -1
- ' nActProc -= 1
- ' ' altrimenti (errore generico di esecuzione)
- ' Else
- ' ' salvo il risultato
- ' If vBar(vProc(j).nBar).nCmdType = CmdTypes.CHECK OrElse vBar(vProc(j).nBar).nCmdType = CmdTypes.CHECKGEN Then
- ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(vProc(j).nBar))) ' ProcessResults(vBar(vProc(j).nBar))
- ' ElseIf vBar(vProc(j).nBar).nCmdType = CmdTypes.GENERATE Then
- ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(vProc(j).nBar))) ' ProcessResults(vBar(vProc(j).nBar))
- ' 'RaiseEvent Calc_ProcessEnd(Nothing, New CalcProcessEndEventArgs(vBar(vProc(j).nBar))) 'ProcessResults(vBar(nCurrBar))
- ' End If
- ' bDone = True
- ' vProc(j).nBar = -1
- ' nActProc -= 1
- ' End If
- ' Else
- ' vProc(j).Proc.Refresh()
- ' End If
- ' End If
-
- ' If bDone Then
- ' ' se sono in simulazione
- ' If bIsSimulation Then
- ' Dim sOriPath As String = Path.ChangeExtension(vBar(0).sBarPath, ".ori.bwe")
- ' ' se file modificato a mano
- ' If File.GetLastWriteTime(sOriPath) < File.GetLastWriteTime(vBar(0).sBarPath) Then
- ' ' aggiorno progetto
- ' If File.Exists(vBar(0).sBarPath) Then File.Copy(vBar(0).sBarPath, sOriPath, True)
-
- ' ' messaggio di lancio verifica
- ' callback(50, "Verifying modifications...", bCancel)
- ' ' lancio verifica
- ' System.Threading.Thread.Sleep(500)
-
- ' Dim Proc As New Process()
- ' Proc.StartInfo.FileName = ExePath
- ' Proc.StartInfo.Arguments = """" & vBar(0).sBarPath & """ " &
- ' """" & vBar(0).nProjType & """ " &
- '"""" & vBar(0).nMachineName & """ " & CmdTypes.CHECKGEN
- ' Proc.StartInfo.UseShellExecute = False
-
- ' If Proc.Start() Then
- ' Dim ProgressValue As Integer = 50
- ' While Not Proc.HasExited
- ' Proc.Refresh()
- ' If ProgressValue < 90 Then ProgressValue += 0.001
- ' callback(ProgressValue, "Verifying modifications...", bCancel)
- ' Thread.Sleep(1)
- ' End While
- ' ' se terminato con successo
- ' If Proc.ExitCode = 0 Then
- ' ' salvo il risultato
- ' RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(0)))
- ' Thread.Sleep(500)
- ' End If
- ' End If
- ' End If
- ' ' messaggio di completamento simulazione
- ' callback(0, "Simulation closing", bCancel)
- ' ElseIf bIsEdit Then
- ' ' ricarico il progetto
- ' Dim Result As CalcEndEventArgs.Results
- ' If bAllKO Then
- ' Result = CalcEndEventArgs.Results.ERROR_
- ' ElseIf bIsEdit Then
- ' Result = CalcEndEventArgs.Results.EDIT
- ' Else
- ' Result = CalcEndEventArgs.Results.OK
- ' End If
- ' RaiseEvent Calc_Ended(Nothing, New CalcEndEventArgs(CmdTypes.EDIT, Result))
- ' Return
- ' Else
- ' ' Dialog con Progress Bar
- ' nDoneBar += 1
- ' dProgress = 1 / numBars * nDoneBar
- ' Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture)
- ' callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel)
- ' End If
- ' If bCancel Then
- ' ' fine
- ' callback(1, "", bCancel)
- ' ' riabilito interfaccia
- ' RaiseEvent Calc_Ended(Nothing, New CalcEndEventArgs(CmdTypes.CHECKGEN, CalcEndEventArgs.Results.OK))
- ' Return
- ' End If
- ' nPgsCurrBar = 0
- ' nPgsClock = 0
- ' Else
- ' ' se non sono in simulazione
- ' If Not bIsSimulation AndAlso Not bIsEdit Then
- ' ' aggiorno conteggio
- ' If nPgsClock >= 100 AndAlso nPgsCurrBar < 149 Then
- ' nPgsCurrBar += 1
- ' dProgress = 1 / numBars * nDoneBar + 1 / numBars / 150 * nPgsCurrBar
- ' Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture)
- ' callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel)
- ' nPgsClock = 0
- ' End If
- ' End If
- ' End If
- ' nPgsClock += 1
- ' Thread.Sleep(1)
- ' Next
-
-
-
-
-
-
-
-
- ' End While
-
- ' m_bStopProcess = False
-
-
-
-
-
-
- ' Dim num2proc As Integer
- ' Dim queueStatus As New Dictionary(Of String, Long)
- ' Dim queueList As New Dictionary(Of String, String)
- ' Dim procResults As New List(Of CalcResultDTO)
- ' Dim respPut As String
- ' Dim fileName As String
- ' Dim fileCont As String
-
- ' queueStatus = currWDC.queueStatus
- ' Dim sb As StringBuilder
- ' sb = New StringBuilder
- ' sb.Append(txtOut.Text)
- ' sb.AppendLine("----------------------------")
- ' For Each item As KeyValuePair(Of String, Long) In queueStatus
- ' sb.AppendLine($"{item.Key} | Found {item.Value} items")
- ' Next
- ' sb.AppendLine("----------------------------")
- ' sb.AppendLine()
- ' txtOut.Text = sb.ToString()
-
- ' ' recupero numero da processare
- ' num2proc = currWDC.numTask2proc
- ' If (num2proc > 0) Then
-
- ' sb.AppendLine("----------------------------")
- ' ' mi prendo la lista dei primi 10 max e processo...
- ' queueList = currWDC.queueList(10)
- ' For Each item As KeyValuePair(Of String, String) In queueList
- ' fileCont = ""
- ' idxSim = idxSim + 1
- ' If (idxSim > 3) Then
- ' idxSim = 0
- ' End If
- ' fileName = Path.Combine("temp", $"Logo{idxSim:00}.svg")
- ' If (File.Exists(fileName)) Then
- ' fileCont = File.ReadAllText(fileName)
- ' End If
-
- ' ' mi limito a mostrare codice + contenuto DDF... dovrebbe processare invero...
- ' sb.AppendLine("--------------------------------------------------------")
- ' sb.AppendLine($"DoorId.Vers: {item.Key}")
- ' sb.AppendLine("DDF:")
- ' sb.AppendLine("--------")
- ' sb.AppendLine(item.Value)
- ' sb.AppendLine("--------------------------------------------------------")
- ' sb.AppendLine()
-
- ' ' scrivo ddf
- ' File.WriteAllText(sCurrDdfDir & "\" & nDdfId, item.Value)
-
- ' ' eseguo calcolo
-
-
- ' ' costruisco risposta finta di processing con esito true + SVG
- ' Dim currRes As New CalcResultDTO
- ' currRes.Validated = True
- ' currRes.DoorIdVers = item.Key
- ' currRes.SvgGen = fileCont
- ' procResults.Add(currRes)
- ' Next
- ' sb.AppendLine("----------------------------")
- ' sb.AppendLine()
-
- ' ' rendo la risposta...
- ' respPut = currWDC.SendProcResults(procResults)
- ' sb.AppendLine()
- ' sb.AppendLine("----------------------------")
- ' sb.AppendLine("Esito invio risposta al server:")
- ' sb.AppendLine()
- ' sb.AppendLine(respPut)
- ' sb.AppendLine("----------------------------")
-
- ' txtOut.Text = sb.ToString()
-
- ' End If
-
- End Sub
-
- Private Sub btnFullTest_Click(sender As Object, e As EventArgs) Handles btnFullTest.Click
-
- Dim num2proc As Integer
- Dim queueStatus As New Dictionary(Of String, Long)
- Dim queueList As New Dictionary(Of String, String)
- Dim procResults As New List(Of CalcResultDTO)
- Dim respPut As String
- Dim fileName As String
- Dim fileCont As String
-
- queueStatus = currWDC.queueStatus
- Dim sb As StringBuilder
- sb = New StringBuilder
- sb.AppendLine("----------------------------")
- For Each item As KeyValuePair(Of String, Long) In queueStatus
- sb.AppendLine($"{item.Key} | Found {item.Value} items")
- Next
- sb.AppendLine("----------------------------")
- sb.AppendLine()
- txtOut.Text = sb.ToString()
- ' recupero numero da processare
- num2proc = currWDC.numTask2proc
- If (num2proc > 0) Then
-
- sb.AppendLine("----------------------------")
- ' mi prendo la lista dei primi 10 max e processo...
- queueList = currWDC.queueList(10)
- For Each item As KeyValuePair(Of String, String) In queueList
- fileCont = ""
- idxSim = idxSim + 1
- If (idxSim > 3) Then
- idxSim = 0
- End If
- fileName = Path.Combine("temp", $"Logo{idxSim:00}.svg")
- If (File.Exists(fileName)) Then
- fileCont = File.ReadAllText(fileName)
- End If
-
- ' mi limito a mostrare codice + contenuto DDF... dovrebbe processare invero...
- sb.AppendLine("--------------------------------------------------------")
- sb.AppendLine($"DoorId.Vers: {item.Key}")
- sb.AppendLine("DDF:")
- sb.AppendLine("--------")
- sb.AppendLine(item.Value)
- sb.AppendLine("--------------------------------------------------------")
+ sb.AppendLine("----------------------------")
sb.AppendLine()
- ' costruisco risposta finta di processing con esito true + SVG
- Dim currRes As New CalcResultDTO
- currRes.Validated = True
- currRes.DoorIdVers = $"{item.Key}.{item.Value}"
- currRes.SvgGen = fileCont
- procResults.Add(currRes)
- Next
- sb.AppendLine("----------------------------")
- sb.AppendLine()
+ ' rendo la risposta...
+ respPut = currWDC.SendProcResults(procResults)
+ sb.AppendLine()
+ sb.AppendLine("----------------------------")
+ sb.AppendLine("Esito invio risposta al server:")
+ sb.AppendLine()
+ sb.AppendLine(respPut)
+ sb.AppendLine("----------------------------")
- ' rendo la risposta...
- respPut = currWDC.SendProcResults(procResults)
- sb.AppendLine()
- sb.AppendLine("----------------------------")
- sb.AppendLine("Esito invio risposta al server:")
- sb.AppendLine()
- sb.AppendLine(respPut)
- sb.AppendLine("----------------------------")
+ txtOut.Text = sb.ToString()
+ End If
- txtOut.Text = sb.ToString()
- End If
+ End Sub
- End Sub
+ Private Sub btnResetQueue_Click(sender As Object, e As EventArgs) Handles btnResetQueue.Click
+ currWDC.ResetQueue()
+ txtOut.Text = "Queue Resetted!"
+ End Sub
- Private Sub btnResetQueue_Click(sender As Object, e As EventArgs) Handles btnResetQueue.Click
- currWDC.ResetQueue()
- txtOut.Text = "Queue Resetted!"
- End Sub
+ Private Sub btnQueueStatus_Click(sender As Object, e As EventArgs) Handles btnQueueStatus.Click
- Private Sub btnQueueStatus_Click(sender As Object, e As EventArgs) Handles btnQueueStatus.Click
-
- Dim queueStatus As New Dictionary(Of String, Long)
- queueStatus = currWDC.queueStatus
- Dim sb As StringBuilder
- sb = New StringBuilder
- sb.AppendLine("----------------------------")
- For Each item As KeyValuePair(Of String, Long) In queueStatus
- sb.AppendLine($"{item.Key} | Found {item.Value} items")
- Next
- sb.AppendLine("----------------------------")
- sb.AppendLine()
- txtOut.Text = sb.ToString()
- End Sub
+ Dim queueStatus As New Dictionary(Of String, Long)
+ queueStatus = currWDC.queueStatus
+ Dim sb As StringBuilder
+ sb = New StringBuilder
+ sb.AppendLine("----------------------------")
+ For Each item As KeyValuePair(Of String, Long) In queueStatus
+ sb.AppendLine($"{item.Key} | Found {item.Value} items")
+ Next
+ sb.AppendLine("----------------------------")
+ sb.AppendLine()
+ txtOut.Text = sb.ToString()
+ End Sub
End Class
diff --git a/WebDoorCreator.API/Controllers/QueueController.cs b/WebDoorCreator.API/Controllers/QueueController.cs
index da489a7..9498d25 100644
--- a/WebDoorCreator.API/Controllers/QueueController.cs
+++ b/WebDoorCreator.API/Controllers/QueueController.cs
@@ -37,6 +37,9 @@ namespace WebDoorCreator.API.Controllers
var actProc = await QDataServ.NumRequestProcessing();
answ.Add("processing", actProc);
+ var actErr = await QDataServ.NumRequestErrors();
+ answ.Add("errors", actErr);
+
var actDone = await QDataServ.NumRequestDone();
answ.Add("done", actDone);
return answ;
@@ -88,6 +91,9 @@ namespace WebDoorCreator.API.Controllers
var actProc = await QDataServ.RequestProcessing();
answ.Add("processing", actProc);
+ var actErr = await QDataServ.RequestErr();
+ answ.Add("errors", actErr);
+
var actDone = await QDataServ.RequestDone();
answ.Add("done", actDone);
return answ;
diff --git a/WebDoorCreator.Core/Constants.cs b/WebDoorCreator.Core/Constants.cs
index 198d564..98d4199 100644
--- a/WebDoorCreator.Core/Constants.cs
+++ b/WebDoorCreator.Core/Constants.cs
@@ -19,6 +19,7 @@ namespace WebDoorCreator.Core
// REDIS KEY Dati correnti x QueueMan
public static readonly string LAST_CALC_REQ_KEY = $"{BASE_HASH}:Current:LastCalcReq";
public static readonly string LAST_CALC_DONE_KEY = $"{BASE_HASH}:Current:LastCalcDone";
+ public static readonly string CALC_REQ_ERRS = $"{BASE_HASH}:CalcRequests:Errors";
public static readonly string CALC_REQ_PEND = $"{BASE_HASH}:CalcRequests:Pending";
public static readonly string CALC_REQ_PROC = $"{BASE_HASH}:CalcRequests:Processing";
public static readonly string CALC_REQ_DONE = $"{BASE_HASH}:CalcRequests:Completed";
diff --git a/WebDoorCreator.Data/Services/QueueDataService.cs b/WebDoorCreator.Data/Services/QueueDataService.cs
index fba0070..7a39262 100644
--- a/WebDoorCreator.Data/Services/QueueDataService.cs
+++ b/WebDoorCreator.Data/Services/QueueDataService.cs
@@ -102,6 +102,25 @@ namespace WebDoorCreator.Data.Services
return numReq;
}
+ ///
+ /// Get # of calculation request with errors
+ ///
+ public async Task NumRequestErrors()
+ {
+ long numReq = 0;
+ string source = "REDIS";
+ Dictionary dictResult = new Dictionary();
+ // cerco da cache
+ RedisKey currKey = new RedisKey(Constants.CALC_REQ_ERRS);
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ numReq = await redisDb.HashLengthAsync(currKey);
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"NumRequestErrors | {source} in: {ts.TotalMilliseconds} ms");
+ return numReq;
+ }
+
///
/// Get # of calculation request pending
///
@@ -208,6 +227,56 @@ namespace WebDoorCreator.Data.Services
return numReq;
}
+ ///
+ /// Get Queue request with errors
+ ///
+ /// Dictionary of DoorId, saveVersNumb
+ public async Task> RequestErr()
+ {
+ string source = "REDIS";
+ long numReq = 0;
+ Dictionary dictResult = new Dictionary();
+ // cerco da cache
+ RedisKey currKey = new RedisKey(Constants.CALC_REQ_ERRS);
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ numReq = redisDb.HashLength(currKey);
+ if (numReq > 0)
+ {
+ var rawData = await redisDb.HashGetAllAsync(currKey);
+ foreach (var item in rawData)
+ {
+ dictResult.Add($"{item.Name}", $"{item.Value}");
+ }
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"RequestErr | {source} in: {ts.TotalMilliseconds} ms");
+ return dictResult;
+ }
+
+ ///
+ /// Rimuove hash record errori
+ ///
+ /// Dictionary of DoorId, saveVersNumb
+ public async Task RequestErrRemove(string doorId)
+ {
+ RedisKey currKey = new RedisKey(Constants.CALC_REQ_ERRS);
+ bool fatto = await RedHashRemove(currKey, doorId);
+ return fatto;
+ }
+
+ ///
+ /// Upsert record errori
+ ///
+ /// Dictionary of DoorId, saveVersNumb
+ public async Task RequestErrUpsert(string doorId, string vers)
+ {
+ RedisKey currKey = new RedisKey(Constants.CALC_REQ_ERRS);
+ long numReq = await RedHashUpsert(currKey, doorId, vers);
+ return numReq;
+ }
+
///
/// Get Queue request pending
///
@@ -327,6 +396,15 @@ namespace WebDoorCreator.Data.Services
await RequestProcessingRemove(item.Name!);
fatto = true;
}
+ // cerco le richieste con errori
+ currKey = new RedisKey(Constants.CALC_REQ_ERRS);
+ rawData = await redisDb.HashGetAllAsync(currKey);
+ foreach (var item in rawData)
+ {
+ await RequestPendingUpsert(item.Name!, item.Value!);
+ await RequestErrRemove(item.Name!);
+ fatto = true;
+ }
// cerco le richieste processed
currKey = new RedisKey(Constants.CALC_REQ_DONE);
rawData = await redisDb.HashGetAllAsync(currKey);
@@ -357,22 +435,32 @@ namespace WebDoorCreator.Data.Services
string sCurrVers = "";
foreach (var calcTask in calcResults)
{
- // solo se risultato valido...
+ RedisKey currSvgKey = new RedisKey("");
+ var doorData = calcTask.DoorIdVers.Split(".");
+ sDoorId = doorData.Length > 0 ? doorData[0] : "";
+ sCurrVers = doorData.Length > 0 ? doorData[1] : "";
+ // se valido salvo SVG...
if (calcTask.Validated)
{
// salvo in area REDIS
- var doorData = calcTask.DoorIdVers.Split(".");
- sDoorId = doorData.Length > 0 ? doorData[0] : "";
- sCurrVers = doorData.Length > 0 ? doorData[1] : "";
- RedisKey currSvgKey = new RedisKey($"{Constants.CALC_REQ_SVG_CACHE}:{sDoorId}:{sCurrVers}");
+ currSvgKey = new RedisKey($"{Constants.CALC_REQ_SVG_CACHE}:{sDoorId}:{sCurrVers}");
await redisDb.StringSetAsync(currSvgKey, calcTask.SvgGen, DayLongCache);
- // invio il FINTO messaggio di ritorno...
- string retMess = $"{sDoorId}:{sCurrVers}";
- CalcDonePipe.saveAndSendMessage(Constants.LAST_CALC_DONE_KEY, retMess);
- // sposto tra le 2 code
+ // sposto tra le code
await RequestProcessingRemove(sDoorId);
await RequestDoneUpsert(sDoorId, sCurrVers);
}
+ // altrimenti salvo errore e metto in coda errori
+ else
+ {
+ // salvo in area REDIS
+ currSvgKey = new RedisKey($"{Constants.CALC_REQ_ERRS}:{sDoorId}:{sCurrVers}");
+ await redisDb.StringSetAsync(currSvgKey, calcTask.ErrorMsg, DayLongCache);
+ // sposto tra le 2 code
+ await RequestProcessingRemove(sDoorId);
+ await RequestErrUpsert(sDoorId, sCurrVers);
+ }
+ // invio il messaggio di ritorno...
+ CalcDonePipe.saveAndSendMessage(Constants.LAST_CALC_DONE_KEY, calcTask.DoorIdVers);
}
}
return answ;
@@ -425,30 +513,6 @@ namespace WebDoorCreator.Data.Services
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"SendCalcReq | DoorId: {DoorId} enqueued in: {ts.TotalMilliseconds} ms");
-
-#if false
- // FIXME TODO!!!! levare quando ci sarà il vero sw in esecuzione...
-
- // simulazione ritorno dati...
- string fileName = Path.Combine("temp", $"Logo{idxSim:00}.svg");
- if (File.Exists(fileName))
- {
- // update indici
- idxSim++;
- idxSim = idxSim % 4;
- // leggo file
- string svgCont = File.ReadAllText(fileName);
- // salvo in area REDIS
- RedisKey currSvgKey = new RedisKey($"{Constants.CALC_REQ_SVG_CACHE}:{sDoorId}:{sCurrVers}");
- await redisDb.StringSetAsync(currSvgKey, svgCont, DayLongCache);
- }
- // simulo attesa segnalazione messaggio porta calcolata
- await Task.Delay(300);
- string retMess = $"{sDoorId}:{sCurrVers}";
- // invio il FINTO messaggio di ritorno...
- CalcDonePipe.saveAndSendMessage(Constants.LAST_CALC_DONE_KEY, retMess);
-#endif
-
return currVers;
}
@@ -458,13 +522,14 @@ namespace WebDoorCreator.Data.Services
/// Dictionary of DoorId, saveVersNumb
public async Task> TakeProcessingItems(int numItems)
{
- int maxTake = 10;
+ int maxTake = Math.Min(10, numItems);
long numReq = 0;
Dictionary dictResult = new Dictionary();
// cerco da cache
RedisKey currKey = new RedisKey(Constants.CALC_REQ_PEND);
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
+ // calcolo il totale delle richieste pending
numReq = redisDb.HashLength(currKey);
if (numReq > 0)
{