520da5abe9
- Cambiato nome cartella progetto da Test a Tray - Modificati Service e Console per compilare - gestito ordine di compilazione - aggiunta copia dopo compilazione su Core
74 lines
3.1 KiB
VB.net
74 lines
3.1 KiB
VB.net
Imports EgwMultiEngineManager.Core
|
|
Imports EgwMultiEngineManager.Data
|
|
Imports Newtonsoft.Json
|
|
Imports StackExchange.Redis
|
|
|
|
Module MainModule
|
|
|
|
Private Const Chn_EgwEngineInput As String = "EgwEngineInput"
|
|
Private Const Chn_EgwEngineOutput As String = "EgwEngineOutput"
|
|
|
|
Private m_sDataRoot As String = String.Empty
|
|
Friend ReadOnly Property sDataRoot As String
|
|
Get
|
|
Return m_sDataRoot
|
|
End Get
|
|
End Property
|
|
|
|
Private m_ExecProcessManager As ExecProcessManager
|
|
|
|
Private m_stopWatch As New Stopwatch()
|
|
|
|
' Riferimento al gestore del server Redis
|
|
Private m_RedisManager As RedisManager
|
|
Friend ReadOnly Property RedisManager As RedisManager
|
|
Get
|
|
Return m_RedisManager
|
|
End Get
|
|
End Property
|
|
|
|
Private OutputChn As New RedisChannel(Chn_EgwEngineOutput, RedisChannel.PatternMode.Auto)
|
|
|
|
Sub Main()
|
|
' Impostazione path radice per i dati
|
|
m_sDataRoot = System.AppDomain.CurrentDomain.BaseDirectory
|
|
IniFile.SetIniFile(m_sDataRoot & "\EgwMultiEngineManagerConsole.ini")
|
|
Dim sCamExePath As String = ""
|
|
GetMainPrivateProfileString(S_GENERAL, K_CAMEXEPATH, "", sCamExePath)
|
|
System.Console.WriteLine("CAMExePath = " & sCamExePath)
|
|
Dim sMainLuaPath As String = ""
|
|
GetMainPrivateProfileString(S_GENERAL, K_MAINPIPELUA, "", sMainLuaPath)
|
|
System.Console.WriteLine("MainPipeLua = " & sMainLuaPath)
|
|
Dim nMaxCamInstances As Integer = GetMainPrivateProfileInt(S_GENERAL, K_MAXCAMINSTANCES, nMaxCamInstances)
|
|
System.Console.WriteLine("MaxCAMInstances = " & nMaxCamInstances)
|
|
m_ExecProcessManager = New ExecProcessManager(1, EXECENVIRONMENTS.WINDOW, sCamExePath, sMainLuaPath, nMaxCamInstances, ExecProcessManager.ReturnModes.EVENT_, False)
|
|
m_ExecProcessManager.StartExecutionThread()
|
|
AddHandler m_ExecProcessManager.m_AnswerReceived, AddressOf ExecProcessManager_AnswerReceived
|
|
Dim sConnection As String = "localhost"
|
|
GetMainPrivateProfileString(S_GENERAL, K_REDISCONNECTION, "", sConnection)
|
|
System.Console.WriteLine("RedisConnection = " & sConnection)
|
|
If String.IsNullOrWhiteSpace(sConnection) Then
|
|
System.Console.WriteLine("Redis connection string is empty!")
|
|
Else
|
|
m_RedisManager = New RedisManager(sConnection)
|
|
m_RedisManager.SubscribeChannel(Chn_EgwEngineInput, AddressOf EgwEngineInputHandler)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ExecProcessManager_AnswerReceived(Answer As AnswerDTO)
|
|
m_RedisManager.Subscriber.Publish(OutputChn, JsonConvert.SerializeObject(Answer))
|
|
m_stopWatch.Stop()
|
|
' Format and display the TimeSpan value.
|
|
Dim elapsedTime As String = String.Format("{0:N3}", m_stopWatch.Elapsed.TotalMilliseconds)
|
|
System.Console.WriteLine("Send answer in " & elapsedTime & "ms")
|
|
End Sub
|
|
|
|
Private Sub EgwEngineInputHandler(RedisChannel As RedisChannel, RedisValue As RedisValue)
|
|
System.Console.WriteLine("Received value from channel " & RedisChannel.ToString())
|
|
m_stopWatch.Restart()
|
|
Dim Request As QuestionDTO = JsonConvert.DeserializeObject(Of QuestionDTO)(RedisValue)
|
|
m_ExecProcessManager.ArgumentsEnqueue(Request)
|
|
End Sub
|
|
|
|
End Module
|