Android Question JobDone & RDC

biggiu

Member
Licensed User
Longtime User
Hello everyone, I have a new question ...
I am working with DRC Server and everything works fine.
The function jobdone verify the result of the query and based on the result I perform certain operations.
The problem is when I have to run queries on different tables.
For example, run the query with the sub

sub EseguiPrimaQuery

sub EseguiSecondaQuery

The problem is that jobdone did not have time to intercept the outcome of the first query of the first who must now work for the second.

Is there a way to wait until jobdone give the result of the first query before you can run the second?

I attach the code I'm using

Thank you all for your cooperation

B4X:
Sub Process_Globals
    Dim DBRM As DBRequestManager
    Dim CmdSql As DBCommand
    Dim SQLDAT As DBResult
End Sub

Sub Globals
    Dim BASE As Panel
    Dim B001 As ImageView
    Dim SE01 As Label
    Dim SE02 As Label
    Dim SE03 As Label
    Dim SE04 As Label
    Dim SE05 As Label
    Dim PR01 As Label
    Dim PR02 As Label
    Dim PR03 As Label
    Dim PR04 As Label
    Dim PR05 As Label
    Dim SP01 As Label
    Dim SP02 As Label
    Dim SP03 As Label
    Dim SP04 As Label
    Dim SP05 As Label
    Dim P001 As ImageView
    Dim LDATA As Label
    Dim LNAME As Label
    Dim LTIME As Label
    Dim L001 As Label
  
    '----- Parametro di Lavoro Eseguito
    Dim TipLav As Int
    Dim SqlSta As Boolean
    Dim JobSta As Boolean
  
    '----- Definizione Campi Records
    '
    '----- ANAZGR
    Dim aagcodi As String
     Dim aagraso As String

    '----- ANELCO
    Dim aeccosp As String
     Dim aeccose As String
     Dim aecprog As String
     Dim aecdamo As String
     Dim aecoreb As Int
     Dim aecpart As Int
    Dim aeccell    As String
    Dim aecorin    As Int
    Dim aecorfi    As Int
    Dim aecstat    As Boolean

    '----- ANSPDI
    Dim asdcodi As String
    Dim asddesc As String
    Dim asdstat As Boolean
    Dim asdse01 As String
    Dim asdse02 As String
    Dim asdse04 As String
    Dim asdse05 As String
    Dim asdse06 As String
    Dim asdse07 As String
    Dim asdse08 As String
    Dim asdse09 As String
    Dim asdse10 As String
  
End Sub

    Sub Activity_Create(FirstTime As Boolean)

        '----- Avvia Il Programma
        If FirstTime Then
            Activity.LoadLayout("mwnc1020")
            JobSta = False
            '----- Inizializza DBase
            GesConDba
            '----- Pulizia Maschera
            ClrMskAel
            '----- Set Parametri Code
            SetDatAel
        End If
          
    End Sub

    '--------------------------------'
    ' INIZIALIZZAZIONE DBASE SQLITE  '
    '--------------------------------'
    Sub GesConDba As Boolean
      
        Try
            '----- Composizione IP Server
            DG.NomFile = "http://" & DG.sqlpar.Get(1) & ":17178"
            DBRM.Initialize(Me, DG.nomfile)

        Catch
            Msgbox(LastException.Message,"ERRORE")
            Return False
        End Try
    End Sub

    '--------------------------------'
    ' PULIZIA MASCHERA VIDEO         '
    '--------------------------------'
    Sub ClrMskAel
        Try
            SE01.Text = ""
            SE02.Text = ""
            SE03.Text = ""
            SE04.Text = ""
            SE05.Text = ""
            PR01.Text = ""
            PR02.Text = ""
            PR03.Text = ""
            PR04.Text = ""
            PR05.Text = ""
            SP01.Text = ""
            SP02.Text = ""
            SP03.Text = ""
            SP04.Text = ""
            SP05.Text = ""
            LDATA.Text = ""
            LNAME.Text = ""
            LTIME.Text = ""
            L001.Text = ""
      
        Catch
            Msgbox(LastException.Message,"ERRORE")
            Return False
        End Try
    End Sub
  
  
    '--------------------------------'
    ' SETTAGGIO PARAMETRI CODE       '
    '--------------------------------'
    Sub SetDatAel
        Dim Oggi As Long
      
        Try
      
            '----- Imposta Data Odierna
            Oggi = DateTime.now
            LDATA.Text = DateTime.Date(Oggi)
            '----- Imposta Ora
            Oggi = DateTime.Now
            LTIME.text = DateTime.Time(Oggi)
            '----- Lettura Dati Aziendali
            GetAag
            '----- Lettura Sportelli Disponibili
            GetAsd
        Catch
            Msgbox(LastException.Message,"ERRORE")
            Return False
        End Try
    End Sub
  
    '--------------------------------'
    ' LETTURA SPORTELLI DISPONIBILI  '
    '--------------------------------'
    Sub GetAag As Boolean
        Try
      
            TipLav = 1
          
            CmdSql.Initialize
            CmdSql.Name = "SEL_KEY_AAG"
            CmdSql.Parameters = Array As Object("A001")
            DBRM.ExecuteQuery(CmdSql, 0,"A001")
        Catch
            Msgbox(LastException.Message,"ERRORE")
            Return False
        End Try
    End Sub

    '-----------------------------------'
    ' VISUALIZZA RAGIONE SOCIALE        '
    '-----------------------------------'
    Sub VisAag As Boolean
        Try
          
            '----- Verifica Esito Query
            If SqlSta = False Then
                Msgbox("DATI AZIENDALI NON DISPONIBILI","ERRORE")
                Return False
            End If
  
                 For Each records() As Object In SQLDAT.Rows
                     aagraso =  records(SQLDAT.Columns.Get("aag_raso"))
                    LNAME.Text = aagraso
                Next
          
        Catch
            Msgbox(LastException.Message,"ERRORE")
            Return False
        End Try
    End Sub
  
    '--------------------------------'
    ' LETTURA SPORTELLI DISPONIBILI  '
    '--------------------------------'
    Sub GetAsd As Boolean
        Try
      
            TipLav = 2
          
            CmdSql.Initialize
            CmdSql.Name = "SEL_ALL_ASD"
            CmdSql.Parameters = Array As Object("")
            DBRM.ExecuteQuery(CmdSql, 0,"")
        Catch
            Msgbox(LastException.Message,"ERRORE")
            Return False
        End Try
    End Sub
  
    '-----------------------------------'
    ' VISUALIZZA SPORTELLI DISPONIBILI  '
    '-----------------------------------'
    Sub VisAsd As Boolean
        Dim p As Int
        Try
          
            '----- Verifica Esito Query
            If SqlSta = False Then
                Msgbox("ANAGRAFICA SPORTELLI NON DISPONIBILE","ERRORE")
                Return False
            End If
  
            p = 1
          
                 For Each records() As Object In SQLDAT.Rows
                     asdcodi =  records(SQLDAT.Columns.Get("asd_codi"))
                    Select Case p
                        Case 1
                            SP01.Text = asdcodi  
                        Case 2
                            SP02.Text = asdcodi  
                        Case 3
                            SP03.Text = asdcodi  
                        Case 4
                            SP04.Text = asdcodi  
                        Case 5
                            SP05.Text = asdcodi  
                    End Select
                    p = p+1
                Next
          
        Catch
            Msgbox(LastException.Message,"ERRORE")
            Return False
        End Try
    End Sub

    '--------------------------------'
    ' VERIFICA ESITO OPERAZIONE      '
    '--------------------------------'
    Sub JobDone(Job As HttpJob)
  
        If Job.Success = False Then
            GesMsgErr
            SqlSta = False
        Else
             If Job.JobName = "DBRequest" Then
                   SQLDAT = DBRM.HandleJob(Job)
                SqlSta = True
                Select Case TipLav
                    Case 1
                        '----- Anagrafica Sportelli
                        VisAag
                    Case 2
                        '----- Anagrafica Sportelli
                        VisAsd
                    Case 3
                    Case 4
                End Select
               End If
         End If
    Job.Release
    JobSta = True
End Sub

  
    '--------------------------------'
    ' VERIFICA ESITO OPERAZIONE      '
    '--------------------------------'
    Sub GesMsgErr
        Dim MsgTxt As String
        Select Case TipLav
            Case 1
                '----- Lettura Anagrafica Sportelli
                MsgTxt = "ERRORE IN LETTURA ANAGRAFICA SPORTELLI"
        End Select
      
        Msgbox(MsgTxt,"ERRORE")
End Sub
  
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Start the second rdc call in the jobdone from the first call.

s there a way to wait until jobdone give the result of the first query before you can run the second?
No. You need to learn to live with that. That´s how android is designed. Eventdriven.
 
Upvote 0

biggiu

Member
Licensed User
Longtime User
So if I understand I have to concatenate all charts readings in cascade.
I read the first, if all goes well the second and so on until the end?

It seems to me a little barbaric.

You can not use quanche timer to scan these operations?
 
Upvote 0

biggiu

Member
Licensed User
Longtime User
Hi,
did you see the code I posted?
I can not run the query later before they know the outcome of the previous year.
After executing a query I must retrieve the table data, display them and go to the next query.
Can , you or others, give me some examples that can afford to do the requests from me?

Thank you all for your cooperation.
 
Upvote 0

biggiu

Member
Licensed User
Longtime User
I solved the mystery.
I just did some tests but the solution to the problem lies in the management of the parameter:
job.Tag

Analyzing this parameter you can figure out which DBRM.ExecuteQuery has been performed and then act accordingly.
At this point, as suggested DonManfred, no matter the execution sequence, as the result thereof.
Analyzing TAG can also detect if the query is not successful, and then issue the necessary signaling.

Now I will continue to do tests and figure out if what has been found is objectively applicable to all cases of possible work.

Thanks to all
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Now I will continue to do tests and figure out if what has been found is objectively applicable to all cases of possible work.
Most probably it is... Please note that you can use the Tag to store ANY Object you like. It does not must be a string. It can be a list or even a map too. In a map you can store as much info you want
 
Upvote 0
Top