mirror of
https://github.com/KeymonSoft/Gabinete-Roit.git
synced 2026-04-21 21:29:26 +00:00
Commit inicial
This commit is contained in:
120
B4A/Starter.bas
Normal file
120
B4A/Starter.bas
Normal file
@@ -0,0 +1,120 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=9.85
|
||||
@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 reqManager As DBRequestManager
|
||||
Dim DBReqServer As String = "http://keymon.lat:1783" '"http://keymon.lat:1782" "http://10.0.0.205:1782" ""' CAMBIAR HACIA AFUERA O DENTRO DE LA OFNA
|
||||
Dim rutaBD As String = File.DirInternal
|
||||
Dim skmt As SQL
|
||||
Dim almacen As String
|
||||
' tracker
|
||||
Public rp As RuntimePermissions
|
||||
Public FLP As FusedLocationProvider
|
||||
Private flpStarted As Boolean
|
||||
Dim latitud, longitud As String
|
||||
Dim logger As Boolean = True
|
||||
Dim ultimaActualizacionGPS As String = 235959
|
||||
Dim Timer1 As Timer
|
||||
Dim Interval As Int = 3600
|
||||
Dim sDate, sTime As String
|
||||
Public gps As GPS
|
||||
Private bu As BatteryUtilities
|
||||
Dim batterystatus(11) As Int
|
||||
Dim bateria As Double
|
||||
Dim muestraProgreso = 0
|
||||
Dim ubicacionActual As Location
|
||||
Dim horain As String
|
||||
Dim horaout As String
|
||||
Dim horacomin As String
|
||||
Dim horacomout As String
|
||||
Dim trabaja As Int
|
||||
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.
|
||||
Timer1.Initialize("Timer1",Interval * 1000)
|
||||
Timer1.Enabled = True
|
||||
ubicacionActual.Initialize
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
||||
Subs.revisaBD
|
||||
reqManager.Initialize(Me, DBReqServer)
|
||||
If Not(skmt.IsInitialized) Then skmt.Initialize(rutaBD, "kmt.db", True)
|
||||
End Sub
|
||||
|
||||
Sub Service_TaskRemoved
|
||||
'This event will be raised when the user removes the app from the recent apps list.
|
||||
Timer1.Enabled = False
|
||||
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)
|
||||
' If logger Then Log("Siguiente actuaizacion " & DateTime.Time(DateTime.Now + Interval * 1000))
|
||||
ENVIA_ULTIMA_GPS
|
||||
' Log("trato de enviar")
|
||||
End Sub
|
||||
|
||||
Sub ENVIA_ULTIMA_GPS 'ignore
|
||||
If trabaja = 1 Then
|
||||
' DateTime.DateFormat = "dd/MM/yyyy"
|
||||
' DateTime.TimeFormat = "HH:mm:ss"
|
||||
' sDate=DateTime.Date(DateTime.Now)
|
||||
' sTime=DateTime.Time(DateTime.Now)
|
||||
Log("Iniciamos ENVIA_ULTIMA_GPS")
|
||||
Dim skmt As SQL
|
||||
Dim cmd As DBCommand
|
||||
Dim reqManager As DBRequestManager
|
||||
DateTime.TimeFormat = "HHmmss"
|
||||
ultimaActualizacionGPS = DateTime.Time(DateTime.Now)
|
||||
reqManager.Initialize(Me, DBReqServer)
|
||||
skmt.Initialize(File.DirInternal,"kmt.db", True)
|
||||
LogColor(latitud&","&longitud,Colors.Blue)
|
||||
|
||||
DateTime.DateFormat = "dd/MM/yyyy"
|
||||
DateTime.TimeFormat = "HH:mm:ss"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
If bateria = 0 Then bateria = 100
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "insert_ubicaprom_GABICO"
|
||||
cmd.Parameters = Array As Object(sDate &" " &sTime, B4XPages.MainPage.login.user, latitud,longitud,B4XPages.MainPage.principal.bateria,almacen,B4XPages.MainPage.login.nom_proyec,B4XPages.MainPage.login.sucursal,B4XPages.MainPage.login.suc_nom)
|
||||
' cmd.Parameters = Array As Object(sDate &" " &sTime, " ", latitud,longitud," ",almacen," "," "," ")
|
||||
reqManager.ExecuteCommand(cmd,"inst_GESTION_GPS")
|
||||
|
||||
'Reiniciamos el timer para cuando llamamos el Sub desde "seleccion"
|
||||
Timer1.Enabled = False
|
||||
Timer1.Interval = Interval * 1000
|
||||
Timer1.Enabled = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub reinicializaReqManager
|
||||
reqManager.Initialize(Me, DBReqServer)
|
||||
' B4XPages.MainPage.reqManager.Initialize(Me, server)
|
||||
If logger Then Log(DBReqServer)
|
||||
End Sub
|
||||
Reference in New Issue
Block a user