'---------------------------
Sub JobDone(Job As HttpJob)
'---------------------------
' Variabili di appoggio -------------------------------------
Dim ls_cognome, ls_nome, ls_badge, ls_codice_badge, ls_cod_fiscale As String
Dim lf_saldo_credito, lf_costo1, lf_costo2, lf_costo3, lf_costo4 As Float
Dim ls_costo1, ls_costo2, ls_costo3, ls_costo4 As String
Dim li_litri As Int
Dim li_bonus1, li_bonus2, li_bonus3, li_bonus4 As Int
Dim ls_syncdate As String
Dim ld_syncdate As Long
Dim li_rows As Int
Dim ls_rows As String
Dim ls_free1, ls_free2, ls_free3, ls_free4 As String
DateTime.DateFormat = "dd-MM-yyyy HH:mm"
Dim ls_tag As String
If Job.Success = False Then
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Errore di sincronizzazione DB su server" & gs_server &"!", False)
Else
If Job.JobName = "DBRequest" Then
Dim result As DBResult = reqManager.HandleJob(Job)
'ls_tag = result.Tag
Select Case ls_tag
Case "Borsellino" 'query tag
li_rows = result.Rows.Size
If li_rows > 0 Then
' svuota db locale
s.ExecnonQuery("delete from utenti")
ls_rows = NumberFormat(li_rows, 0, 0)
Label_lv_server.text = "N.ro records Utenti su DB Server:" & ls_rows
'- Sync minisql locale -------------------------
lv_letture_server.Clear
For Each records() As Object In result.Row
ls_cod_fiscale = records(result.Columns.Get("cod_fiscale"))
ls_cognome = records(result.Columns.Get("cognome"))
ls_nome = records(result.Columns.Get("nome"))
ls_badge = records(result.Columns.Get("badge"))
ls_syncdate = records(result.Columns.Get("syncdate"))
DateTime.DateFormat= "yyyy-MM-dd HH:mm:ss"
' convert to date time
' my sql ritorna solo strsaldo_bonusinghe converte in date time
ld_syncdate = DateTime.DateParse(ls_syncdate)
' ... other columns.....
'Copy to local DB ---------------------
s.ExecNonQuery2("Insert into utenti (rowid, cod_fiscale, cognome, nome, badge) Values ( null,?,?,?,?)",Array As Object(ls_cod_fiscale, ls_cognome, ls_nome, ls_badge, ld_syncdate))
DateTime.DateFormat= "dd-MM-yyyy HH:mm"
ls_syncdate = DateTime.date(ld_syncdate)
lv_letture_server.AddTwoLines(ls_codice_badge & " - " & ls_cognome & " - " & ls_nome, _
"Credito:" & NumberFormat(lf_saldo_credito, 0, 2) & " Bonus:" & li_bonus1 & " - " & li_bonus2 & " - " & li_bonus3 & " - " & li_bonus4 & " Costo: " & NumberFormat(lf_costo1, 0, 2) & " - " & NumberFormat(lf_costo2, 0, 2) & " - " & NumberFormat(lf_costo3, 0, 2) & " - " & NumberFormat(lf_costo4, 0, 2) & " - Sync:" & ls_syncdate )
'Log(name)
Next
'Timercheckserverlist.Initialize("Timercheckserverlist", 360000)
leggi_borsellino_android
Else ' No rows
ToastMessageShow("Nessun record trovato",False)
'Return
End If
Case "Erogazioni"
li_rows = result.Rows.Size
ls_rows = NumberFormat(li_rows, 0, 0)
s.ExecnonQuery("delete from erogazioni_utenti ;")
ToastMessageShow("DB erogazioni Android sincronizzato su server: " & gs_server & Chr(10) & "Trasferite: " & ls_rows & " erogazioni!", False)'
lv_erogazioni.Clear
Label_lv_erogazioni.text = "N.ro records erogazioni non trasferite:" & ls_rows
Timersyncerogretry.enabled = False
Case "Errori"
li_rows = result.Rows.Size
ls_rows = NumberFormat(li_rows, 0, 0)
s.ExecnonQuery("delete from errors_log ;")
ToastMessageShow("DB log errori Android sincronizzato su server: " & gs_server & Chr(10) & "Trasferiti: " & li_rows & " errori!", False)'
leggi_errori_android
End Select
End If 'JOB
End If 'DB Request
Job.Release
End Sub