mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-21 11:59:13 +00:00
14/9/23 - Clase Subs y otros
- Se agrego la clase Subs - Se cambió "skmt" por "db" - Se arreglo el reqmanager que no se reinicaba bien cuando se cambiaba en el engrane. - Se agregó dbInit a C_Subs, que inicializa la BD.
This commit is contained in:
@@ -13,8 +13,9 @@ Sub Process_Globals
|
||||
'These global variables will be declared once when the application starts.
|
||||
'These variables can be accessed from all modules.
|
||||
Public rp As RuntimePermissions
|
||||
Dim s As C_Subs
|
||||
Dim reqManager As DBRequestManager
|
||||
Dim skmt, errorLog As SQL
|
||||
Dim db, errorLog As SQL
|
||||
Dim ruta As String
|
||||
Public BluetoothState As Boolean
|
||||
Dim btAdmin As BluetoothAdmin
|
||||
@@ -45,7 +46,7 @@ Sub Process_Globals
|
||||
Dim ultimaActualizacionGPS As String = 235959 '
|
||||
Dim fechaRuta As String 'ignore
|
||||
Dim tiempos As Map
|
||||
Dim Logger As Boolean
|
||||
Dim Logger As Boolean = False
|
||||
Dim ultimaActividad As String = ""
|
||||
Dim boleta As String = 0
|
||||
Dim sesion As Map
|
||||
@@ -55,6 +56,7 @@ End Sub
|
||||
Sub Service_Create
|
||||
'This is the program entry point.
|
||||
'This is a good place to load resources that are not specific to a single activity.
|
||||
s.Initialize 'Inicializamos la clase Subs
|
||||
If Logger Then LogColor("'/////////////////////////////////////////////////////////////////////////////////////////////", Colors.Green)
|
||||
If Logger Then LogColor("'///////////////////////////////////// Iniciamos Starter /////////////////////////////////", Colors.Green)
|
||||
If Logger Then LogColor("'/////////////////////////////////////////////////////////////////////////////////////////////", Colors.Green)
|
||||
@@ -63,34 +65,32 @@ Sub Service_Create
|
||||
GPS.Initialize("GPS")
|
||||
ubicacionActual.Initialize
|
||||
pe.Initialize("pe") 'Para obtener la bateria
|
||||
ruta = File.DirInternal
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
db = s.dbInit 'Inicializamos BD.
|
||||
server = "http://keymon.lat:1782"
|
||||
Private c As Cursor = db.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = 'SERVER'"$)
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
server = c.GetString("CAT_VA_VALOR")
|
||||
End If
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
c.Close
|
||||
reqManager.Initialize(Me, server) 'Inicializamos reqManager.
|
||||
If Logger Then Log($"Starter reqManager server: ${server}"$)
|
||||
'Para los Logs
|
||||
#if RELEASE
|
||||
logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
|
||||
logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
|
||||
#end if
|
||||
logs.Initialize
|
||||
server = "http://keymon.lat:1782"
|
||||
' server = "http://10.0.0.205:1782"
|
||||
' server = "http://11.0.0.231:1782"
|
||||
If Logger Then Log($"Starter reqManager server: ${server}"$)
|
||||
Logger = False
|
||||
sesion.Initialize
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
||||
reqManager.Initialize(Me, server)
|
||||
Subs.revisaBD
|
||||
#if DEBUG
|
||||
Logger = True
|
||||
#else
|
||||
Logger = False
|
||||
#End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Service_TaskRemoved
|
||||
@@ -136,17 +136,17 @@ End Sub
|
||||
|
||||
Sub ENVIA_ULTIMA_GPS
|
||||
If Logger Then Log("Iniciamos ENVIA_ULTIMA_GPS")
|
||||
If Not(skmt.IsInitialized) Then skmt.Initialize(ruta,"kmt.db", True)
|
||||
If Not(db.IsInitialized) Then db.Initialize(ruta,"kmt.db", True)
|
||||
DateTime.TimeFormat = "HHmmss"
|
||||
ultimaActualizacionGPS = DateTime.Time(DateTime.Now)
|
||||
Private s As Cursor = skmt.ExecQuery2("select CAT_VA_VALOR as semana from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SEMANA")) 'Traemos la semana.
|
||||
If s.RowCount> 0 Then
|
||||
s.Position=0
|
||||
Private laSemana As String = s.GetString("semana")
|
||||
Private s1 As Cursor = db.ExecQuery2("select CAT_VA_VALOR as semana from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SEMANA")) 'Traemos la semana.
|
||||
If s1.RowCount> 0 Then
|
||||
s1.Position=0
|
||||
Private laSemana As String = s1.GetString("semana")
|
||||
Else
|
||||
Private laSemana As String = ""
|
||||
End If
|
||||
Private cpv As Cursor = skmt.ExecQuery2("select count(*) as CUANTOS from kmt_info where CAT_CL_DIAS_VISITA = (SELECT CAT_VA_VALOR FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?) and cat_cl_codigo <> 0 AND CAT_CL_TIPO_RUTA IN (?,?) ORDER BY CAT_CL_NUM_SERIEFISICO", Array As String("DIA_VISITA", laSemana, "SEMANAL"))'Traemos los clientes a visitar hoy.
|
||||
Private cpv As Cursor = db.ExecQuery2("select count(*) as CUANTOS from kmt_info where CAT_CL_DIAS_VISITA = (SELECT CAT_VA_VALOR FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?) and cat_cl_codigo <> 0 AND CAT_CL_TIPO_RUTA IN (?,?) ORDER BY CAT_CL_NUM_SERIEFISICO", Array As String("DIA_VISITA", laSemana, "SEMANAL"))'Traemos los clientes a visitar hoy.
|
||||
cpv.Position=0
|
||||
Private clientesVisitaHoy As String = cpv.GetString("CUANTOS")
|
||||
If lat_gps = 0 Or lat_gps = Null Then 'Si latitud es CERO o NULL traemos las ultimas coordenadas de la base de datos.
|
||||
@@ -154,14 +154,14 @@ Sub ENVIA_ULTIMA_GPS
|
||||
lat_gps = coords.Get(0)
|
||||
lon_gps = coords.Get(1)
|
||||
End If
|
||||
s.Close
|
||||
s1.Close
|
||||
cpv.Close
|
||||
Private rtec, ping, salty As String
|
||||
' Log(Application.VersionName)
|
||||
Subs.dameClientesFueraDeFrecuencia
|
||||
Private h As Cursor
|
||||
For Each i As String In Array As String ("RTEC", "PING", "SALTY SNACKS")
|
||||
h=skmt.ExecQuery2("Select sum(PE_COSTO_TOT) As MONTO_DIA from pedido where PE_CLIENTE <> 0 and pe_proid in (Select CAT_GP_ID from cat_gunaprod2 where CAT_GP_TIPO = ? )", Array As String(i))
|
||||
h=db.ExecQuery2("Select sum(PE_COSTO_TOT) As MONTO_DIA from pedido where PE_CLIENTE <> 0 and pe_proid in (Select CAT_GP_ID from cat_gunaprod2 where CAT_GP_TIPO = ? )", Array As String(i))
|
||||
Private x As String = 0
|
||||
If h.RowCount > 0 Then
|
||||
h.Position = 0
|
||||
@@ -182,7 +182,7 @@ Sub ENVIA_ULTIMA_GPS
|
||||
reqManager.ExecuteCommand(cmd,"updateKell_UTR")
|
||||
' If Logger Then Log(reqManager)
|
||||
' If Logger Then Log("++ ++ ++ Envia_Ultima GPS - Inst_visitas - server: "& server)
|
||||
skmt.ExecNonQuery2("Update cat_variables set CAT_VA_VALOR = ? WHERE CAT_VA_DESCRIPCION = ?" , Array As String(DateTime.Time(DateTime.Now),"HoraIngreso"))
|
||||
db.ExecNonQuery2("Update cat_variables set CAT_VA_VALOR = ? WHERE CAT_VA_DESCRIPCION = ?" , Array As String(DateTime.Time(DateTime.Now),"HoraIngreso"))
|
||||
'Reiniciamos el timer para cuando llamamos el Sub desde otra actividad
|
||||
Timer1.Enabled = False
|
||||
Timer1.Interval = Interval * 1000
|
||||
@@ -190,6 +190,7 @@ Sub ENVIA_ULTIMA_GPS
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
Log("JOBDONE STARTER")
|
||||
If Job.Success = False Then
|
||||
' ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Else
|
||||
@@ -220,5 +221,5 @@ End Sub
|
||||
Sub revisaBD 'ignore
|
||||
If Logger Then Log("revisaBD")
|
||||
If Not(File.Exists(ruta, "kmt.db")) Then File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
If Not(skmt.IsInitialized) Then skmt.Initialize(ruta, "kmt.db", True)
|
||||
If Not(db.IsInitialized) Then db.Initialize(ruta, "kmt.db", True)
|
||||
End Sub
|
||||
|
||||
Reference in New Issue
Block a user