This commit is contained in:
2023-11-06 19:54:13 -06:00
parent fd6d581422
commit 6489696bf3
5 changed files with 26 additions and 11 deletions

View File

@@ -4,7 +4,7 @@ ModulesStructureVersion=1
Type=Class
Version=6.8
@EndOfDesignText@
'Class module
''Class module
Sub Class_Globals
Private mTarget As Object
Type DBResult (Tag As Object, Columns As Map, Rows As List)
@@ -15,6 +15,8 @@ Sub Class_Globals
,T_DOUBLE = 6, T_BOOLEAN = 7, T_BLOB = 8 As Byte
Private VERSION As Float = 0.9
Private tempArray(1) As Object
Dim jobTagAnterior As String = "" 'Mod por CHV - 211109
Dim reqsList As List
End Sub
'Target - The module that handles JobDone (usually Me).
@@ -22,6 +24,7 @@ End Sub
Public Sub Initialize (Target As Object, ConnectorLink As String)
mTarget = Target
link = ConnectorLink
reqsList.Initialize
End Sub
'Sends a query request.
@@ -32,7 +35,8 @@ Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object)
Dim j As HttpJob
Dim ms As OutputStream
Dim out2 As OutputStream = StartJob(j,ms, Tag)
If reqsList.IsInitialized Then reqsList.Add(Tag)
WriteObject(Command.Name, out2)
WriteInt(Limit, out2)
WriteList(Command.Parameters, out2)
@@ -58,6 +62,7 @@ End Sub
'Similar to ExecuteBatch. Sends a single command.
Public Sub ExecuteCommand(Command As DBCommand, Tag As Object)
If reqsList.IsInitialized Then reqsList.Add(Tag)
ExecuteBatch(Array As DBCommand(Command), Tag)
End Sub
@@ -112,7 +117,7 @@ Private Sub WriteObject(o As Object, out As OutputStream)
Else If GetType(tempArray(0)) = "[B" Then
data = o
out.WriteBytes(Array As Byte(T_BLOB), 0, 1)
WriteInt(data.Length, out)
WriteInt(data.Length, out)
Else 'If o Is String Then (treat all other values as string)
out.WriteBytes(Array As Byte(T_STRING), 0, 1)
data = bc.StringToBytes(o, "UTF8")
@@ -185,7 +190,7 @@ End Sub
'Handles the Job result and returns a DBResult.
Public Sub HandleJob(Job As HttpJob) As DBResult
Dim start As Long = DateTime.Now
Dim start As Long = DateTime.Now 'ignore
Dim In As InputStream = Job.GetInputStream
Dim cs As CompressedStreams
In = cs.WrapInputStream(In, "gzip")
@@ -196,6 +201,8 @@ Public Sub HandleJob(Job As HttpJob) As DBResult
table.Columns.Initialize
table.rows.Initialize
table.Tag = Job.Tag
If jobTagAnterior <> Job.Tag Then LogColor("HandleJob: '"&Job.Tag&"'", Colors.Blue) 'Mod por CHV - 211109
jobTagAnterior = Job.Tag 'Mod por CHV - 211109
If method = "query" Then
Dim numberOfColumns As Int = ReadInt(In)
For i = 0 To numberOfColumns - 1
@@ -217,7 +224,7 @@ Public Sub HandleJob(Job As HttpJob) As DBResult
Next
End If
In.Close
Log("HandleJob: " & (DateTime.Now - start))
' Log("HandleJob: " & (DateTime.Now - start))'Comentado por CHV - 211112
Return table
End Sub
'Reads a file and returns the file as a bytes array.