Sub AddLoadRecs
Dim i,j As Int
Dim c, d As Cursor
Dim commands,commandsdet As List
commands.Initialize
commandsdet.Initialize
If DefCM.Sql1.ExecQuerySingleResult("SELECT count(name) FROM sqlite_master WHERE type='table' AND name ='loadmast'") = 0 Then
' do nothing
Else
Try
c = DefCM.SQL1.ExecQuery("Select * from loadmast where sent = 0")
' Log(" ----------- ---- Loadmast records: "&c.RowCount)
For i = 0 To c.RowCount -1
c.Position = i
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "load_mast"
Dim pkk As Long
pkk = c.GetLong("pk")
cmd.Parameters = Array As Object(c.GetLong("pk"),c.GetInt("loadtype"),c.GetInt("acttype"),c.GetLong("recdate"),c.GetInt("drvid"),c.GetString("trkid"),c.GetString("trl1id"),c.GetString("trl2id"),c.GetString("trl3id"),c.GetLong("load_dur"),c.GetLong("wait_dur"),c.GetString("rectype"),c.GetDouble("lat"),c.GetDouble("lon"),c.GetString("place"),c.GetInt("compid"),c.GetInt("sent"),c.GetDouble("odom"),c.GetDouble("fuel"),c.GetString("sourceid"),c.GetString("swver"),c.GetString("comment"))
commands.Add(cmd)
' Log("added Load mast rec: "&i)
d = DefCM.SQL1.ExecQuery("Select * from loaddet where mastid = "&pkk)
For j = 0 To d.RowCount -1
d.Position = j
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "load_det"
cmd.Parameters = Array As Object(d.GetLong("mastid"),d.GetInt("ival1") , d.GetInt("ival2") , d.GetInt("ival3") , d.GetString("sval1") , d.GetString("sval2") , d.GetString("sval3"),d.GetDouble("dval1") ,d.GetDouble("dval2"),d.GetInt("compid") )
commandsdet.Add(cmd)
' Log("load detail: "&d.GetLong("mastid"))
Next
d.Close
Next
c.Close
If commandsdet.Size > 0 Then
LogCM.reqManager.myloaddet = commandsdet
LogCM.reqManager.mytaglddet = "load_det"
LogCM.reqManager.IsConnectedLoaddet ' (checks to see that there is an internet connection - then calls ExecuteBatch)
End If
If commands.Size > 0 Then
LogCM.reqManager.myloadmast = commands
LogCM.reqManager.mytagldmast = "load_mast"
LogCM.reqManager.IsConnectedLoadmast ' (checks to see that there is an internet connection - then calls ExecuteBatch)
Else
' ToastMessageShow(" No Load Records to Send...",False)
' AddLogRecs ' send logs if no load records to send....
End If
Catch
Log("Table LoadMast doesn't exist or other error")
If c.IsInitialized Then
c.Close
End If
' AddLogRecs ' send logs if no load records to send....
End Try
End If
End Sub