mirror of
https://github.com/KeymonSoft/Salma_Reparto.git
synced 2026-04-17 12:56:20 +00:00
121 lines
4.3 KiB
QBasic
121 lines
4.3 KiB
QBasic
B4A=true
|
|
Group=Default Group
|
|
ModulesStructureVersion=1
|
|
Type=Service
|
|
Version=10.2
|
|
@EndOfDesignText@
|
|
#Region Service Attributes
|
|
#StartAtBoot: False
|
|
#ExcludeFromLibrary: True
|
|
#End Region
|
|
|
|
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 skmt As SQL
|
|
Dim ruta As String
|
|
Private BTAdmin As BluetoothAdmin
|
|
Public BluetoothState As Boolean
|
|
Public rp As RuntimePermissions
|
|
Public FLP As FusedLocationProvider
|
|
Dim Timer1 As Timer
|
|
Dim Interval As Int = 30
|
|
'Para WebSockets
|
|
' Dim monitor As Timer 'Lo usamos para monitorear los servicios Tracker y PushService
|
|
' Dim monitorTicks As Int = 0
|
|
Dim trackerActividad As String = "501231235959"
|
|
Dim pushServiceActividad As String = "501231235959"
|
|
'Para los Logs
|
|
Private logs As StringBuilder
|
|
Private logcat As LogCat
|
|
Public SharedFolder As String 'Para actualizar apk
|
|
Dim cedisLocation As Location
|
|
Dim reqManager As DBRequestManager
|
|
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.
|
|
ruta = File.DirInternal 'Ruta de la base de datos por defecto.
|
|
' If File.ExternalWritable Then ruta = rp.GetSafeDirDefaultExternal("") 'Si podemos escribir a la tarjeta, cambiamos la ruta.
|
|
If Not(File.Exists(ruta, "kmt.db")) Then File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db") 'Si no existe el archivo de la base de datos, lo copiamos.
|
|
Log(ruta)
|
|
skmt.Initialize(ruta,"kmt.db", True)
|
|
' BTAdmin.Initialize("admin")
|
|
' If BTAdmin.IsEnabled = False Then
|
|
' If BTAdmin.Enable = False Then
|
|
' ToastMessageShow("Error enabling Bluetooth adapter.", True)
|
|
' Else
|
|
' ToastMessageShow("Enabling Bluetooth adapter...", False)
|
|
' End If
|
|
' Else
|
|
' BluetoothState = True
|
|
' End If
|
|
' reqManager.Initialize(Me, Main.server)
|
|
Timer1.Initialize("Timer1", Interval * 1000)
|
|
Timer1.Enabled = True
|
|
SharedFolder = rp.GetSafeDirDefaultExternal("")
|
|
cedisLocation.Initialize
|
|
cedisLocation.Latitude = "19.48118148992086"
|
|
cedisLocation.Longitude = "-99.15295579261536"
|
|
End Sub
|
|
|
|
Sub Service_Start (StartingIntent As Intent)
|
|
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
|
' StartService(PushService)
|
|
' monitor.Initialize("monitor", 30000)
|
|
' monitor.Enabled = True
|
|
End Sub
|
|
|
|
Sub Service_TaskRemoved
|
|
'This event will be raised when the user removes the app from the recent apps list.
|
|
End Sub
|
|
|
|
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
|
|
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
|
|
Return True
|
|
End Sub
|
|
|
|
Sub Service_Destroy
|
|
|
|
End Sub
|
|
|
|
Private Sub Timer1_Tick
|
|
' ToastMessageShow("Timer",False)
|
|
LogColor("Siguiente actualizacion " & DateTime.Time(DateTime.Now + Interval * 1000),Colors.Blue)
|
|
ENVIA_ULTIMA_GPS
|
|
End Sub
|
|
|
|
Sub ENVIA_ULTIMA_GPS
|
|
' Dim skmt As SQL
|
|
' Dim cmd As DBCommand
|
|
' Dim reqManager As DBRequestManager
|
|
' reqManager.Initialize(Me, Main.server)
|
|
' skmt.Initialize(ruta,"kmt.db", True)
|
|
'' Log("server: "&Main.server)
|
|
'
|
|
' skmt.Initialize(ruta,"kmt.db", True)
|
|
'
|
|
' If Main.logger Then Log("Iniciamos ENVIA_ULTIMA_GPS")
|
|
' DateTime.TimeFormat = "HHmmss"
|
|
' Main.ultimaActualizacionGPS = DateTime.Time(DateTime.Now)
|
|
' cmd.Initialize
|
|
' cmd.Name = "select_fechat"
|
|
' reqManager.ExecuteQuery(cmd , 0, "fechat")
|
|
'
|
|
' Dim cmd As DBCommand
|
|
' cmd.Initialize
|
|
' cmd.Name = "UPDATE_GUNA_ACTUALR2_GPS"
|
|
' cmd.Parameters = Array As Object(Main.montoActual,Main.clientestotal, Main.clientesventa,Main.clientesvisitados,Main.lat_gps,Main.lon_gps,Main.batt,0, 0, Main.ALMACEN,Main.rutapreventa )
|
|
' Log($"montoActual: ${Main.montoActual}, cTotal: ${Main.clientestotal}, cVenta: ${Main.clientesventa}, cVisitados: ${Main.clientesvisitados}, ${Main.lat_gps}, ${Main.lon_gps}, Batt: ${Main.batt}, 0, 0, 0, Almacen: ${Main.ALMACEN}, Ruta: ${Main.rutapreventa}"$)
|
|
'
|
|
' reqManager.ExecuteCommand(cmd, "inst_visitas")
|
|
''' If Main.logger Then Log("ubic_tiempo_real")
|
|
' skmt.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
|
|
' Timer1.Enabled = True
|
|
End Sub |