4/11/23 - Cambios en JobDone de Principal y DBRequestManager.

This commit is contained in:
2023-11-04 23:29:51 -06:00
parent f8ca701a0e
commit b929a7dc86
4 changed files with 24 additions and 24 deletions

View File

@@ -934,13 +934,15 @@ Sub cargar_Click
End Sub End Sub
Sub JobDone(Job As HttpJob) Sub JobDone(Job As HttpJob)
' If Job.JobName = "DBRequest" Then If B4XPages.MainPage.reqManager.reqsList.IsInitialized Then 'Si tenemos lista de requests, la procesamos.
' Dim RESULT As DBResult = B4XPages.MainPage.reqManager.HandleJob(Job) If B4XPages.MainPage.reqManager.reqsList.IndexOf(Job.tag) <> -1 Then
' Log($"Tag: ${RESULT.tag}, success=${Job.Success}"$) B4XPages.MainPage.reqManager.reqsList.RemoveAt(B4XPages.MainPage.reqManager.reqsList.IndexOf(Job.tag))
' End If LogColor($">>>>>> Quitamos ${Job.tag}"$, Colors.Blue)
End If
LogColor(">>>>>> " & B4XPages.MainPage.reqManager.reqsList.Size & " - " & B4XPages.MainPage.reqManager.reqsList, Colors.Blue)
End If
If Job.Success = False Then If Job.Success = False Then
'ToastMessageShow("Error: " & Job.ErrorMessage, True) LogColor("Error: " & Job.tag & " : " & Job.ErrorMessage, Colors.red)
If Job.ErrorMessage = "STREAM" Then If Job.ErrorMessage = "STREAM" Then
If CARGA = "SUBIR" Then If CARGA = "SUBIR" Then
PB2.Progress = PB2.Progress + PORCENTAJE PB2.Progress = PB2.Progress + PORCENTAJE

View File

@@ -4,9 +4,7 @@ ModulesStructureVersion=1
Type=Class Type=Class
Version=6.8 Version=6.8
@EndOfDesignText@ @EndOfDesignText@
'Necesita la libreria RandomAccessFile ''Class module
'Class module
Sub Class_Globals Sub Class_Globals
Private mTarget As Object Private mTarget As Object
Type DBResult (Tag As Object, Columns As Map, Rows As List) Type DBResult (Tag As Object, Columns As Map, Rows As List)
@@ -17,7 +15,8 @@ Sub Class_Globals
,T_DOUBLE = 6, T_BOOLEAN = 7, T_BLOB = 8 As Byte ,T_DOUBLE = 6, T_BOOLEAN = 7, T_BLOB = 8 As Byte
Private VERSION As Float = 0.9 Private VERSION As Float = 0.9
Private tempArray(1) As Object Private tempArray(1) As Object
Dim jobTagAnterior As String = "" 'Mod por CHV - 211027 Dim jobTagAnterior As String = "" 'Mod por CHV - 211109
Dim reqsList As List
End Sub End Sub
'Target - The module that handles JobDone (usually Me). 'Target - The module that handles JobDone (usually Me).
@@ -25,6 +24,7 @@ End Sub
Public Sub Initialize (Target As Object, ConnectorLink As String) Public Sub Initialize (Target As Object, ConnectorLink As String)
mTarget = Target mTarget = Target
link = ConnectorLink link = ConnectorLink
reqsList.Initialize
End Sub End Sub
'Sends a query request. 'Sends a query request.
@@ -35,7 +35,8 @@ Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object)
Dim j As HttpJob Dim j As HttpJob
Dim ms As OutputStream Dim ms As OutputStream
Dim out2 As OutputStream = StartJob(j,ms, Tag) Dim out2 As OutputStream = StartJob(j,ms, Tag)
If reqsList.IsInitialized Then reqsList.Add(Tag)
WriteObject(Command.Name, out2) WriteObject(Command.Name, out2)
WriteInt(Limit, out2) WriteInt(Limit, out2)
WriteList(Command.Parameters, out2) WriteList(Command.Parameters, out2)
@@ -61,6 +62,7 @@ End Sub
'Similar to ExecuteBatch. Sends a single command. 'Similar to ExecuteBatch. Sends a single command.
Public Sub ExecuteCommand(Command As DBCommand, Tag As Object) Public Sub ExecuteCommand(Command As DBCommand, Tag As Object)
If reqsList.IsInitialized Then reqsList.Add(Tag)
ExecuteBatch(Array As DBCommand(Command), Tag) ExecuteBatch(Array As DBCommand(Command), Tag)
End Sub End Sub
@@ -115,7 +117,7 @@ Private Sub WriteObject(o As Object, out As OutputStream)
Else If GetType(tempArray(0)) = "[B" Then Else If GetType(tempArray(0)) = "[B" Then
data = o data = o
out.WriteBytes(Array As Byte(T_BLOB), 0, 1) 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) Else 'If o Is String Then (treat all other values as string)
out.WriteBytes(Array As Byte(T_STRING), 0, 1) out.WriteBytes(Array As Byte(T_STRING), 0, 1)
data = bc.StringToBytes(o, "UTF8") data = bc.StringToBytes(o, "UTF8")
@@ -188,7 +190,7 @@ End Sub
'Handles the Job result and returns a DBResult. 'Handles the Job result and returns a DBResult.
Public Sub HandleJob(Job As HttpJob) As 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 In As InputStream = Job.GetInputStream
Dim cs As CompressedStreams Dim cs As CompressedStreams
In = cs.WrapInputStream(In, "gzip") In = cs.WrapInputStream(In, "gzip")
@@ -199,8 +201,8 @@ Public Sub HandleJob(Job As HttpJob) As DBResult
table.Columns.Initialize table.Columns.Initialize
table.rows.Initialize table.rows.Initialize
table.Tag = Job.Tag table.Tag = Job.Tag
If jobTagAnterior <> Job.Tag Then LogColor("HandleJob: '"&Job.Tag&"'", Colors.Blue) 'Mod por CHV - 211023 If jobTagAnterior <> Job.Tag Then LogColor("HandleJob: '"&Job.Tag&"'", Colors.Blue) 'Mod por CHV - 211109
jobTagAnterior = Job.Tag 'Mod por CHV - 211023 jobTagAnterior = Job.Tag 'Mod por CHV - 211109
If method = "query" Then If method = "query" Then
Dim numberOfColumns As Int = ReadInt(In) Dim numberOfColumns As Int = ReadInt(In)
For i = 0 To numberOfColumns - 1 For i = 0 To numberOfColumns - 1
@@ -222,10 +224,9 @@ Public Sub HandleJob(Job As HttpJob) As DBResult
Next Next
End If End If
In.Close In.Close
' Log("HandleJob: " & (DateTime.Now - start)) ' Log("HandleJob: " & (DateTime.Now - start))'Comentado por CHV - 211112
Return table Return table
End Sub End Sub
'Reads a file and returns the file as a bytes array. 'Reads a file and returns the file as a bytes array.
Public Sub FileToBytes(Dir As String, FileName As String) As Byte() Public Sub FileToBytes(Dir As String, FileName As String) As Byte()
Dim out As OutputStream Dim out As OutputStream
@@ -235,7 +236,6 @@ Public Sub FileToBytes(Dir As String, FileName As String) As Byte()
out.Close out.Close
Return out.ToBytesArray Return out.ToBytesArray
End Sub End Sub
'Converts an image to a bytes array (for BLOB fields). 'Converts an image to a bytes array (for BLOB fields).
Public Sub ImageToBytes(Image As Bitmap) As Byte() Public Sub ImageToBytes(Image As Bitmap) As Byte()
Dim out As OutputStream Dim out As OutputStream
@@ -244,7 +244,6 @@ Public Sub ImageToBytes(Image As Bitmap) As Byte()
out.Close out.Close
Return out.ToBytesArray Return out.ToBytesArray
End Sub End Sub
'Converts a bytes array to an image (for BLOB fields). 'Converts a bytes array to an image (for BLOB fields).
Public Sub BytesToImage(bytes() As Byte) As Bitmap Public Sub BytesToImage(bytes() As Byte) As Bitmap
Dim In As InputStream Dim In As InputStream
@@ -253,7 +252,6 @@ Public Sub BytesToImage(bytes() As Byte) As Bitmap
bmp.Initialize2(In) bmp.Initialize2(In)
Return bmp Return bmp
End Sub End Sub
'Prints the table to the logs. 'Prints the table to the logs.
Public Sub PrintTable(Table As DBResult) Public Sub PrintTable(Table As DBResult)
Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size) Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size)

View File

@@ -156,7 +156,7 @@ Module9=C_NoVenta
NumberOfFiles=46 NumberOfFiles=46
NumberOfLibraries=33 NumberOfLibraries=33
NumberOfModules=27 NumberOfModules=27
Version=11.5 Version=12.5
@EndOfDesignText@ @EndOfDesignText@
#Region Project Attributes #Region Project Attributes
#ApplicationLabel: Intmex v1 #ApplicationLabel: Intmex v1

View File

@@ -58,14 +58,14 @@ ModuleClosedNodes0=
ModuleClosedNodes1= ModuleClosedNodes1=
ModuleClosedNodes10= ModuleClosedNodes10=
ModuleClosedNodes11= ModuleClosedNodes11=
ModuleClosedNodes12= ModuleClosedNodes12=6
ModuleClosedNodes13=9,11,15 ModuleClosedNodes13=9,11,15
ModuleClosedNodes14=9,10 ModuleClosedNodes14=9,10
ModuleClosedNodes15= ModuleClosedNodes15=
ModuleClosedNodes16= ModuleClosedNodes16=
ModuleClosedNodes17= ModuleClosedNodes17=
ModuleClosedNodes18= ModuleClosedNodes18=
ModuleClosedNodes19=3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 ModuleClosedNodes19=
ModuleClosedNodes2= ModuleClosedNodes2=
ModuleClosedNodes20= ModuleClosedNodes20=
ModuleClosedNodes21= ModuleClosedNodes21=
@@ -82,6 +82,6 @@ ModuleClosedNodes6=
ModuleClosedNodes7= ModuleClosedNodes7=
ModuleClosedNodes8=1 ModuleClosedNodes8=1
ModuleClosedNodes9= ModuleClosedNodes9=
NavigationStack=C_RespaldoDiario,Class_Globals,0,0,C_RespaldoDiario,Initialize,23,6,B4XMainPage,ocultaProgreso,653,0,B4XMainPage,Entrar_LongClick,676,0,B4XMainPage,i_engrane_LongClick,672,0,B4XMainPage,lv_server_ItemClick,681,0,B4XMainPage,b_regesar_Click,669,0,C_Principal,JobDone,1015,0,C_Productos,lv_prodsPedido_ItemLongClick,774,0,C_Principal,Subir_Click,584,0 NavigationStack=B4XMainPage,b_regesar_Click,669,0,C_Productos,lv_prodsPedido_ItemLongClick,774,0,C_Principal,B4XPage_Created,235,0,C_RespaldoDiario,Initialize,11,6,C_Principal,Class_Globals,12,0,C_Principal,B4XPage_Appear,480,0,C_Principal,Subir_Click,654,0,DBRequestManager,Initialize,22,0,DBRequestManager,PrintTable,267,0,C_Principal,JobDone,934,0
SelectedBuild=0 SelectedBuild=0
VisibleModules=2,25,23,12,15,13,4,26,14,8 VisibleModules=2,25,23,12,15,13,4,26,14,8