OK, from a newbie
I need to read a MySQL database on the cloud and then flag all the records successfully processed in the local SQLite dbms.
Basic flow:
1. read all records not yet read
2. Post the data in the local SQLite database.
3. Flag the successful records on the cloud so they will not be read again.
-- Variables declared already --
' *************************************
Sub LoadData
ProgressDialogShow("Fetching list of records")
ExecuteRemoteQuery("SELECT comm_key, comm_data FROM blouwater where site_b = 0", "DATA_LIST")
End Sub
' *************************************
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("https://batchman.co.za/android/rserver.php", Query)
End Sub
' *************************************
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success Then
Dim res As String
Dim parser As JSONParser
Dim DATA As List
Dim m As Map
res = Job.GetString
Log("Response from server: " )
Log( res)
parser.Initialize(res)
DATA = parser.NextArray 'returns a list with maps
For i = 0 To DATA.Size - 1
m = DATA.Get(i)
Starter.SQL.ExecNonQuery( m.Get("comm_data") )
==> lRead.Add(m.Get("comm_key") ) ' save the record key to be updated
Next
Else
Log(Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
***************
On completion of JobDone I now need to flag a field in the MySQL database as true so ti will not be 'selected' again.
==> here I save the key of the MySQL record -- I know I am not checking for success of the NonQuery yet. Although it might be possible to update the MySQL here I would rater do all local posting and then update the cloud.
At this stage I do not know how to 'raise an event' once 'JobDone' is complete.
Any Ideas?
Adie
I need to read a MySQL database on the cloud and then flag all the records successfully processed in the local SQLite dbms.
Basic flow:
1. read all records not yet read
2. Post the data in the local SQLite database.
3. Flag the successful records on the cloud so they will not be read again.
-- Variables declared already --
' *************************************
Sub LoadData
ProgressDialogShow("Fetching list of records")
ExecuteRemoteQuery("SELECT comm_key, comm_data FROM blouwater where site_b = 0", "DATA_LIST")
End Sub
' *************************************
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("https://batchman.co.za/android/rserver.php", Query)
End Sub
' *************************************
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success Then
Dim res As String
Dim parser As JSONParser
Dim DATA As List
Dim m As Map
res = Job.GetString
Log("Response from server: " )
Log( res)
parser.Initialize(res)
DATA = parser.NextArray 'returns a list with maps
For i = 0 To DATA.Size - 1
m = DATA.Get(i)
Starter.SQL.ExecNonQuery( m.Get("comm_data") )
==> lRead.Add(m.Get("comm_key") ) ' save the record key to be updated
Next
Else
Log(Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
***************
On completion of JobDone I now need to flag a field in the MySQL database as true so ti will not be 'selected' again.
==> here I save the key of the MySQL record -- I know I am not checking for success of the NonQuery yet. Although it might be possible to update the MySQL here I would rater do all local posting and then update the cloud.
At this stage I do not know how to 'raise an event' once 'JobDone' is complete.
Any Ideas?
Adie