mirror of
https://github.com/KeymonSoft/ADM2.git
synced 2026-04-17 19:36:33 +00:00
VERSION 6.01.20
- Se agrego un "mandaPendientes" en bitacora para cuando por problemas de red no se puede enviar el evento.
This commit is contained in:
@@ -16,15 +16,19 @@ Sub Class_Globals
|
||||
Dim motivoNoVenta, motivoNoVisita As String
|
||||
Dim banderaGeoCerca As String
|
||||
Private reqManager As DBRequestManager
|
||||
Private mpCorriendo As Boolean = False
|
||||
Dim enviandoInfo As Boolean = False
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize (vCallback As Object, vEventName As String, vRoot As B4XView, db1 As SQL, DBReq As DBRequestManager) As Object
|
||||
Public Sub Initialize (vCallback As Object, vEventName As String, vRoot As B4XView, db1 As SQL, DBReqServer As String) As Object
|
||||
db = db1
|
||||
Root2 = vRoot
|
||||
reqManager = DBReq
|
||||
' reqManager = DBReq
|
||||
reqManager.Initialize(Me, DBReqServer)
|
||||
db.ExecNonQuery("CREATE TABLE IF NOT EXISTS BITACORAGPS(fechab TEXT, usuariob TEXT, almacenb TEXT, rutab TEXT, eventob TEXT, clienteb TEXT, iniciob TEXT, finb TEXT, latitudb TEXT, longitudb TEXT, precision TEXT, motivonoventa TEXT, motivonovisita TEXT, BAN_GEOB TEXT)")
|
||||
agregaColumna("BITACORAGPS", "BAN_GEOB", "TEXT")
|
||||
agregaColumna("BITACORAGPS", "enviado", "TEXT")
|
||||
contadorIniciarVenta = 0
|
||||
cargamosPanel
|
||||
Return Me
|
||||
@@ -58,8 +62,10 @@ Sub mandaBitacora(fechab As String, usuariob As String, almacenb As String, ruta
|
||||
If eventob = "Carga día" Then nombreCliente = "CARGA DIA"
|
||||
If eventob = "Carga día suplencia" Then nombreCliente = traeRutasSup
|
||||
If eventob <> "Termina Venta" Then
|
||||
Log(56)
|
||||
db.ExecNonQuery($"INSERT INTO BITACORAGPS (fechab, usuariob , almacenb , rutab , eventob , clienteb , iniciob , finb , latitudb, longitudb , precision , motivonoventa , motivonovisita, BAN_GEOB) VALUES ('${fechab}' ,'${usuariob}' , '${almacenb}' , '${rutab}' , '${eventob}' , '${clienteb}' , '${iniciob}' , '${finb}' , '${latitudb}' , '${longitudb}' , '${precisionb}' , '${motivoNoVentab}' , '${motivoNoVisitab}', '${BAN_GEOB}')"$)
|
||||
Else
|
||||
Log(57)
|
||||
Private e As Cursor = db.ExecQuery($"select fechab from BITACORAGPS where usuariob = '${usuariob}' and almacenb = '${almacenb}' and rutab = '${rutab}' and clienteb = '${clienteb}' and eventob = 'Inicia Venta' order by fechab desc"$)
|
||||
If e.RowCount > 0 Then
|
||||
e.Position = 0
|
||||
@@ -70,16 +76,19 @@ Sub mandaBitacora(fechab As String, usuariob As String, almacenb As String, ruta
|
||||
else if eventob = "No Venta" Then
|
||||
Log("-- NV")
|
||||
db.ExecNonQuery($"update BITACORAGPS set finb = '${finb}', iniciob = '${finb}', motivonoventa = '${motivoNoVentab}', motivonovisita = '${motivoNoVisitab}' where rutab = '${rutab}' and almacenb = '${almacenb}' and usuariob = '${usuariob}' and clienteb = '${clienteb}' and fechab = '${e.GetString("fechab")}' "$)
|
||||
Log($"update BITACORAGPS set finb = '${finb}', iniciob = '${finb}', motivonoventa = '${motivoNoVentab}', motivonovisita = '${motivoNoVisitab}' where rutab = '${rutab}' and almacenb = '${almacenb}' and usuariob = '${usuariob}' and clienteb = '${clienteb}' and fechab = '${e.GetString("fechab")}' "$)
|
||||
cmd.Parameters = Array As Object(finb, motivoNoVentab, motivoNoVisitab, rutab, almacenb, usuariob, clienteb, "Inicia Venta", e.GetString("fechab"))
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
If eventob <> "Inicia Venta" Then
|
||||
Log(58)
|
||||
Private c As Cursor = db.ExecQuery($"select * from BITACORAGPS where usuariob = '${usuariob}' and almacenb = '${almacenb}' and rutab = '${rutab}' and clienteb = '${clienteb}' order by fechab desc"$)
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
cmd.Parameters = Array As Object(c.GetString("almacenb"), c.GetString("usuariob"), c.GetString("rutab"), c.GetString("eventob"), c.GetString("clienteb"), nombreCliente, c.GetString("iniciob"), c.GetString("finb"), c.GetString("latitudb"), c.GetString("longitudb"), c.GetString("precision"), c.GetString("motivonoventa"), c.GetString("motivonovisita"), c.GetString("fechab"), c.GetString("BAN_GEOB"))
|
||||
reqManager.ExecuteCommand(cmd , "mandaBitacora")
|
||||
reqManager.ExecuteCommand(cmd , $"mandaBitacora_${clienteb}_${eventob}"$)
|
||||
enviandoInfo = True
|
||||
End If
|
||||
End If
|
||||
' Log("Mandamos bitacora")
|
||||
@@ -236,5 +245,58 @@ Sub JobDone(Job As HttpJob)
|
||||
LogColor("Error: " & Job.ErrorMessage, Colors.red)
|
||||
Else 'If Job Success then ...
|
||||
' Log("JOBDONE SUCCESS")
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim RESULT As DBResult = reqManager.HandleJob(Job)
|
||||
If RESULT.Tag.As(String).StartsWith("mandaBitacora") Then
|
||||
For Each records() As Object In RESULT.Rows
|
||||
Private temp() As String = Regex.Split("_", RESULT.Tag)
|
||||
If temp.Length > 2 Then
|
||||
Private cliente As String = temp(1)
|
||||
Private evento As String = temp(2)
|
||||
Log(cliente)
|
||||
Log(evento)
|
||||
db.ExecNonQuery($"update BITACORAGPS set enviado = 1 where clienteb = '${cliente}' and eventob = '${evento}'"$)
|
||||
Log("==========================REGISTROS="&RESULT.Rows.size)
|
||||
For Each k As String In RESULT.Columns.Keys
|
||||
Log(RESULT.Tag & ": " & k & ": " & records(RESULT.Columns.Get(k)))
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
enviandoInfo = False
|
||||
End If
|
||||
End If
|
||||
' mandaBitacora
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub mandaPendientes
|
||||
LogColor("==> Entramos a mandaPendientes", Colors.red)
|
||||
If Not(enviandoInfo) Then
|
||||
Log("mpCorriendo=" & mpCorriendo)
|
||||
mpCorriendo = True
|
||||
Private ep As Cursor = db.ExecQuery("select * from BITACORAGPS where enviado is null")
|
||||
Log("PENDIENTES: " & ep.RowCount)
|
||||
Dim cmd As DBCommand
|
||||
If ep.RowCount > 0 Then
|
||||
For i = 0 To ep.RowCount - 1
|
||||
ep.Position = i
|
||||
Log($"Mandamos ${ep.GetString("clienteb")}, ${ep.GetString("eventob")}"$)
|
||||
' mandaBitacora(ep.GetString("fechab"), ep.GetString("usuariob"), ep.GetString("almacenb"), ep.GetString("rutab"), ep.GetString("eventob"), ep.GetString("clienteb"), ep.GetString("iniciob"), ep.GetString("finb"), ep.GetString("latitudb"), ep.GetString("longitudb"), ep.GetString("precision"), ep.GetString("motivonoventa"), ep.GetString("motivonovisita"), ep.GetString("BAN_GEOB"))
|
||||
Private nombreCliente As String = traeNombreCliente(ep.GetString("clienteb"))
|
||||
Private eventob As String = ep.GetString("eventob")
|
||||
If eventob = "Llega a almacen" Then
|
||||
nombreCliente = "BOLETA"
|
||||
End If
|
||||
If eventob = "Salida almacen" Then nombreCliente = "CHECKLIST"
|
||||
If eventob = "Fin Día" Then nombreCliente = "FIN DIA"
|
||||
If eventob = "Carga día" Then nombreCliente = "CARGA DIA"
|
||||
If eventob = "Carga día suplencia" Then nombreCliente = traeRutasSup
|
||||
cmd.Initialize
|
||||
cmd.Name = "mandaBitacora_ADM3"
|
||||
cmd.Parameters = Array As Object(ep.GetString("almacenb"), ep.GetString("usuariob"), ep.GetString("rutab"), ep.GetString("eventob"), ep.GetString("clienteb"), nombreCliente, ep.GetString("iniciob"), ep.GetString("finb"), ep.GetString("latitudb"), ep.GetString("longitudb"), ep.GetString("precision"), ep.GetString("motivonoventa"), ep.GetString("motivonovisita"), ep.GetString("fechab"), ep.GetString("BAN_GEOB"))
|
||||
reqManager.ExecuteCommand(cmd , $"mandaBitacora_${ep.GetString("clienteb")}_${ep.GetString("eventob")}"$)
|
||||
Next
|
||||
mpCorriendo = False
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
Reference in New Issue
Block a user