mirror of
https://github.com/KeymonSoft/jRDC-Multi.git
synced 2026-04-18 05:09:32 +00:00
- Se corrigio que no avisaba cuando el query no requeria parametros y si se enviaban (en el JSONHandler)
148 lines
7.2 KiB
QBasic
148 lines
7.2 KiB
QBasic
B4J=true
|
|
Group=Default Group
|
|
ModulesStructureVersion=1
|
|
Type=Class
|
|
Version=8.8
|
|
@EndOfDesignText@
|
|
'Handler class
|
|
Sub Class_Globals
|
|
Dim j As JSONGenerator
|
|
' Dim rdcc As RDCConnector
|
|
End Sub
|
|
|
|
Public Sub Initialize
|
|
|
|
End Sub
|
|
|
|
Sub Handle(req As ServletRequest, resp As ServletResponse)
|
|
Dim Command As String = req.GetParameter("command")
|
|
If Command = "" Then Command = "ping"
|
|
Log($"Command: ${Command}"$)
|
|
resp.ContentType = "text/html"
|
|
If Command = "reload" Then 'Reload config.properties
|
|
' rdcc.Initialize
|
|
Private estaDB As String = ""
|
|
' Log(Main.listaDeCP)
|
|
resp.Write($"<a href="/test">Test</a> | <a href="/manager?command=reload">Reload</a> | <a href="/manager?command=rpm2">Reiniciar</a> | <a href="/manager?command=reviveBow">Revive Bow</a> | </br></br>"$)
|
|
For i = 0 To Main.listaDeCP.Size - 1
|
|
Main.Connectors.Get(Main.listaDeCP.get(i)).As(RDCConnector).Initialize(Main.listaDeCP.get(i))
|
|
If Main.listaDeCP.get(i) <> "DB1" Then estaDB = "." & Main.listaDeCP.get(i) Else estaDB = ""
|
|
resp.Write($"Recargando config${estaDB}.properties ($DateTime{DateTime.Now})<br/>"$)
|
|
resp.Write($"Queries en config.properties: <b>${Main.Connectors.Get(Main.listaDeCP.get(i)).As(RDCConnector).commands.Size}</b><br/>"$)
|
|
resp.Write($"<b>JdbcUrl:</b> ${Main.Connectors.Get(Main.listaDeCP.get(i)).As(RDCConnector).config.Get("JdbcUrl")}</b><br/>"$)
|
|
resp.Write($"<b>User:</b> ${Main.Connectors.Get(Main.listaDeCP.get(i)).As(RDCConnector).config.Get("User")}</b><br/>"$)
|
|
resp.Write($"<b>ServerPort:</b> ${Main.srvr.Port}</b><br/><br/>"$)
|
|
Next
|
|
' Public shl As Shell
|
|
' shl.Initialize("shl11","cmd",Array("/c","restart.bat"))
|
|
' shl.WorkingDirectory = GlobalParameters.WorkingDirectory
|
|
' shl.Run(-1)
|
|
else If Command = "stop" Then
|
|
' Public shl As Shell
|
|
' shl.Initialize("shl","cmd",Array("/c","stop.bat"))
|
|
' shl.WorkingDirectory = GlobalParameters.WorkingDirectory
|
|
' shl.Run(-1)
|
|
else If Command = "rsx" Then 'Reiniciamos el servidor DBReq
|
|
resp.Write($"<a href="/test">Test</a> | <a href="/manager?command=reload">Reload</a> | <a href="/manager?command=rpm2">Reiniciar</a> | <a href="/manager?command=reviveBow">Revive Bow</a> | </br></br>"$)
|
|
Log($"Ejecutamos ${File.DirApp}\start.bat"$)
|
|
resp.Write($"Ejecutamos ${File.DirApp}\start.bat"$)
|
|
Public shl As Shell
|
|
shl.Initialize("shl","cmd",Array("/c",File.DirApp & "\start.bat " & Main.srvr.Port))
|
|
shl.WorkingDirectory = File.DirApp
|
|
shl.Run(-1)
|
|
else If Command = "rpm2" Then 'Reiniciamos el proceso DBReq en PM2
|
|
resp.Write($"<a href="/test">Test</a> | <a href="/manager?command=reload">Reload</a> | <a href="/manager?command=rpm2">Reiniciar</a> | <a href="/manager?command=reviveBow">Revive Bow</a> | </br></br>"$)
|
|
Log($"Ejecutamos ${File.DirApp}\reiniciaProcesoPM2.bat"$)
|
|
resp.Write($"Ejecutamos ${File.DirApp}\reiniciaProcesoPM2.bat"$)
|
|
Public shl As Shell
|
|
shl.Initialize("shl","cmd",Array("/c",File.DirApp & "\reiniciaProcesoPM2.bat " & Main.srvr.Port))
|
|
shl.WorkingDirectory = File.DirApp
|
|
shl.Run(-1)
|
|
else If Command = "reviveBow" Then 'Reiniciamos el proceso DBReq en PM2
|
|
resp.Write($"<a href="/test">Test</a> | <a href="/manager?command=reload">Reload</a> | <a href="/manager?command=rpm2">Reiniciar</a> | <a href="/manager?command=reviveBow">Revive Bow</a> | </br></br>"$)
|
|
Log($"Ejecutamos ${File.DirApp}\reiniciaProcesoBow.bat"$)
|
|
resp.Write($"Ejecutamos ${File.DirApp}\reiniciaProcesoBow.bat<br><br>"$)
|
|
resp.Write($"!!!BOW REINICIANDO!!!"$)
|
|
Public shl As Shell
|
|
shl.Initialize("shl","cmd",Array("/c",File.DirApp & "\reiniciaProcesoBow.bat " & Main.srvr.Port))
|
|
shl.WorkingDirectory = File.DirApp
|
|
shl.Run(-1)
|
|
else If Command = "paused" Then
|
|
GlobalParameters.IsPaused = 1
|
|
else If Command = "continue" Then
|
|
GlobalParameters.IsPaused = 0
|
|
else If Command = "logs" Then
|
|
If GlobalParameters.mpLogs.IsInitialized Then
|
|
j.Initialize(GlobalParameters.mpLogs)
|
|
j.ToString
|
|
resp.Write(j.ToString)
|
|
End If
|
|
else If Command = "block" Then
|
|
Dim BlockedConIP As String = req.GetParameter("IP")
|
|
If GlobalParameters.mpBlockConnection.IsInitialized Then
|
|
GlobalParameters.mpBlockConnection.Put(BlockedConIP,BlockedConIP)
|
|
End If
|
|
else If Command = "unblock" Then
|
|
Dim UnBlockedConIP As String = req.GetParameter("IP")
|
|
If GlobalParameters.mpBlockConnection.IsInitialized Then
|
|
GlobalParameters.mpBlockConnection.Remove(UnBlockedConIP)
|
|
End If
|
|
else if Command = "restartserver" Then
|
|
Log($"Ejecutamos ${File.DirApp}/restarServer.bat"$)
|
|
' Public shl As Shell
|
|
' shl.Initialize("shl","cmd",Array("/c","retartserver.bat"))
|
|
' shl.WorkingDirectory = GlobalParameters.WorkingDirectory
|
|
' shl.Run(-1)
|
|
else if Command = "snapshot" Then
|
|
Try
|
|
resp.ContentType = "image/png"
|
|
Dim robot, toolkit, rectangle, ImageIO As JavaObject
|
|
robot.InitializeNewInstance("java.awt.Robot", Null)
|
|
toolkit.InitializeStatic("java.awt.Toolkit")
|
|
Dim rectangle As JavaObject
|
|
rectangle.InitializeNewInstance("java.awt.Rectangle", Array As Object( _
|
|
toolkit.RunMethodJO("getDefaultToolkit", Null).RunMethod("getScreenSize", Null)))
|
|
Dim image As JavaObject = robot.RunMethod("createScreenCapture", Array As Object(rectangle))
|
|
ImageIO.InitializeStatic("javax.imageio.ImageIO").RunMethod("write", Array As Object( _
|
|
image, "png", resp.OutputStream)) 'the image is written to the response
|
|
Catch
|
|
resp.SendError(500, LastException.Message)
|
|
End Try
|
|
else if Command = "runatstartup" Then
|
|
'----- You Need to go to the folder on the server : C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
|
|
' ------ then right click - Properties - Security - Edit - Add --> "Everyone" then OK -- then check Full Control (Allow) -- OK
|
|
File.Copy("C:\jrdcinterface","startup.bat","C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp","startup.bat")
|
|
else if Command = "stoprunatstartup" Then
|
|
'----- You Need to go to the folder on the server : C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
|
|
' ------ then right click - Properties - Security - Edit - Add --> "Everyone" then OK -- then check Full Control (Allow) -- OK
|
|
File.Delete("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp","startup.bat")
|
|
else if Command = "totalrequests" Then
|
|
If GlobalParameters.mpTotalRequests.IsInitialized Then
|
|
j.Initialize(GlobalParameters.mpTotalRequests)
|
|
j.ToString
|
|
resp.Write(j.ToString)
|
|
End If
|
|
else if Command = "totalblocked" Then
|
|
If GlobalParameters.mpBlockConnection.IsInitialized Then
|
|
j.Initialize(GlobalParameters.mpBlockConnection)
|
|
j.ToString
|
|
resp.Write(j.ToString)
|
|
End If
|
|
else if Command = "totalcon" Then
|
|
If GlobalParameters.mpTotalConnections.IsInitialized Then
|
|
j.Initialize(GlobalParameters.mpTotalConnections)
|
|
j.ToString
|
|
resp.Write(j.ToString)
|
|
End If
|
|
else if Command = "ping" Then
|
|
resp.Write($"<a href="/test">Test</a> | <a href="/manager?command=reload">Reload</a> | <a href="/manager?command=rpm2">Reiniciar</a> | <a href="/manager?command=reviveBow">Revive Bow</a> | </br></br>"$)
|
|
resp.Write($"Pong"$)
|
|
End If
|
|
If GlobalParameters.mpLogs.IsInitialized Then GlobalParameters.mpLogs.Put(Command, "Manager : " & Command & " - Time : " & DateTime.Time(DateTime.Now))
|
|
End Sub
|
|
'Sub shl11_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
|
|
' If Success Then
|
|
' Log(Success)
|
|
' End If
|
|
'End Sub
|