- VERSION 1.01.01

- Commit inicial
This commit is contained in:
2025-09-17 11:10:39 -06:00
parent b671677579
commit 92db61b8f2
14 changed files with 4040 additions and 0 deletions

24
B4A/C_Principal.bas Normal file
View File

@@ -0,0 +1,24 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=12.8
@EndOfDesignText@
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
End Sub
'You can add more parameters here.
Public Sub Initialize As Object
Return Me
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

272
B4A/DBRequestManager.bas Normal file
View File

@@ -0,0 +1,272 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=6.8
@EndOfDesignText@
'Necesita la libreria RandomAccessFile
'Class module
Sub Class_Globals
Private mTarget As Object
Type DBResult (Tag As Object, Columns As Map, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
Private link As String
Private bc As ByteConverter
Private T_NULL = 0, T_STRING = 1, T_SHORT = 2, T_INT = 3, T_LONG = 4, T_FLOAT = 5 _
,T_DOUBLE = 6, T_BOOLEAN = 7, T_BLOB = 8 As Byte
Private VERSION As Float = 0.9
Private tempArray(1) As Object
Dim jobTagAnterior As String = "" 'Mod por CHV - 211027
End Sub
'Target - The module that handles JobDone (usually Me).
'ConnectorLink - URL of the Java server.
Public Sub Initialize (Target As Object, ConnectorLink As String)
mTarget = Target
link = ConnectorLink
End Sub
'Sends a query request.
'Command - Query name and parameters.
'Limit - Maximum rows to return or 0 for no limit.
'Tag - An object that will be returned in the result.
Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object)
Dim j As HttpJob
Dim ms As OutputStream
Dim out2 As OutputStream = StartJob(j,ms, Tag)
WriteObject(Command.Name, out2)
WriteInt(Limit, out2)
WriteList(Command.Parameters, out2)
out2.Close
j.PostBytes(link & "?method=query", ms.ToBytesArray)
End Sub
'Executes a batch of (non-select) commands.
'ListOfCommands - List of the commands that will be executes.
'Tag - An object that will be returned in the result.
Public Sub ExecuteBatch(ListOfCommands As List, Tag As Object)
Dim j As HttpJob
Dim ms As OutputStream
Dim out2 As OutputStream = StartJob(j,ms, Tag)
WriteInt(ListOfCommands.Size, out2)
For Each Command As DBCommand In ListOfCommands
WriteObject(Command.Name, out2)
WriteList(Command.Parameters, out2)
Next
out2.Close
j.PostBytes(link & "?method=batch", ms.ToBytesArray)
End Sub
'Similar to ExecuteBatch. Sends a single command.
Public Sub ExecuteCommand(Command As DBCommand, Tag As Object)
ExecuteBatch(Array As DBCommand(Command), Tag)
End Sub
Private Sub StartJob(j As HttpJob, MemoryStream As OutputStream, Tag As Object) As OutputStream
j.Initialize("DBRequest", mTarget)
j.Tag = Tag
MemoryStream.InitializeToBytesArray(0)
Dim compress As CompressedStreams
Dim out As OutputStream = compress.WrapOutputStream(MemoryStream, "gzip")
WriteObject(VERSION, out)
Return out
End Sub
Private Sub WriteList(Parameters As List, out As OutputStream)
Dim data() As Byte
If Parameters = Null Or Parameters.IsInitialized = False Then
Dim Parameters As List
Parameters.Initialize
End If
data = bc.IntsToBytes(Array As Int(Parameters.Size))
out.WriteBytes(data, 0, data.Length)
For Each o As Object In Parameters
WriteObject(o, out)
Next
End Sub
Private Sub WriteObject(o As Object, out As OutputStream)
Dim data() As Byte
tempArray(0) = o
If tempArray(0) = Null Then
out.WriteBytes(Array As Byte(T_NULL), 0, 1)
Else If tempArray(0) Is Short Then
out.WriteBytes(Array As Byte(T_SHORT), 0, 1)
data = bc.ShortsToBytes(Array As Short(o))
Else If tempArray(0) Is Int Then
out.WriteBytes(Array As Byte(T_INT), 0, 1)
data = bc.IntsToBytes(Array As Int(o))
Else If tempArray(0) Is Float Then
out.WriteBytes(Array As Byte(T_FLOAT), 0, 1)
data = bc.FloatsToBytes(Array As Float(o))
Else If tempArray(0) Is Double Then
out.WriteBytes(Array As Byte(T_DOUBLE), 0, 1)
data = bc.DoublesToBytes(Array As Double(o))
Else If tempArray(0) Is Long Then
out.WriteBytes(Array As Byte(T_LONG), 0, 1)
data = bc.LongsToBytes(Array As Long(o))
Else If tempArray(0) Is Boolean Then
out.WriteBytes(Array As Byte(T_BOOLEAN), 0, 1)
Dim b As Boolean = 0
Dim data(1) As Byte
If b Then data(0) = 1 Else data(0) = 0
Else If GetType(tempArray(0)) = "[B" Then
data = o
out.WriteBytes(Array As Byte(T_BLOB), 0, 1)
WriteInt(data.Length, out)
Else 'If o Is String Then (treat all other values as string)
out.WriteBytes(Array As Byte(T_STRING), 0, 1)
data = bc.StringToBytes(o, "UTF8")
WriteInt(data.Length, out)
End If
If data.Length > 0 Then out.WriteBytes(data, 0, data.Length)
End Sub
Private Sub ReadObject(In As InputStream) As Object
Dim data(1) As Byte
In.ReadBytes(data, 0, 1)
Select data(0)
Case T_NULL
Return Null
Case T_SHORT
Dim data(2) As Byte
Return bc.ShortsFromBytes(ReadBytesFully(In, data, data.Length))(0)
Case T_INT
Dim data(4) As Byte
Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
Case T_LONG
Dim data(8) As Byte
Return bc.LongsFromBytes(ReadBytesFully(In, data, data.Length))(0)
Case T_FLOAT
Dim data(4) As Byte
Return bc.FloatsFromBytes(ReadBytesFully(In, data, data.Length))(0)
Case T_DOUBLE
Dim data(8) As Byte
Return bc.DoublesFromBytes(ReadBytesFully(In, data, data.Length))(0)
Case T_BOOLEAN
Dim b As Byte = ReadByte(In)
Return b = 1
Case T_BLOB
Dim len As Int = ReadInt(In)
Dim data(len) As Byte
Return ReadBytesFully(In, data, data.Length)
Case Else
Dim len As Int = ReadInt(In)
Dim data(len) As Byte
ReadBytesFully(In, data, data.Length)
Return BytesToString(data, 0, data.Length, "UTF8")
End Select
End Sub
Private Sub ReadBytesFully(In As InputStream, Data() As Byte, Len As Int) As Byte()
Dim count = 0, read As Int
Do While count < Len And read > -1
read = In.ReadBytes(Data, count, Len - count)
count = count + read
Loop
Return Data
End Sub
Private Sub WriteInt(i As Int, out As OutputStream)
Dim data() As Byte
data = bc.IntsToBytes(Array As Int(i))
out.WriteBytes(data, 0, data.Length)
End Sub
Private Sub ReadInt(In As InputStream) As Int
Dim data(4) As Byte
Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
End Sub
Private Sub ReadByte(In As InputStream) As Byte
Dim data(1) As Byte
In.ReadBytes(data, 0, 1)
Return data(0)
End Sub
'Handles the Job result and returns a DBResult.
Public Sub HandleJob(Job As HttpJob) As DBResult
Dim start As Long = DateTime.Now
Dim In As InputStream = Job.GetInputStream
Dim cs As CompressedStreams
In = cs.WrapInputStream(In, "gzip")
Dim serverVersion As Float = ReadObject(In) 'ignore
Dim method As String = ReadObject(In)
Dim table As DBResult
table.Initialize
table.Columns.Initialize
table.rows.Initialize
table.Tag = Job.Tag
If jobTagAnterior <> Job.Tag Then LogColor("HandleJob: '"&Job.Tag&"'", Colors.Blue) 'Mod por CHV - 211023
jobTagAnterior = Job.Tag 'Mod por CHV - 211023
If method = "query" Then
Dim numberOfColumns As Int = ReadInt(In)
For i = 0 To numberOfColumns - 1
table.Columns.Put(ReadObject(In), i)
Next
Do While ReadByte(In) = 1
Dim rowObjects(numberOfColumns) As Object
table.rows.Add(rowObjects)
For col = 0 To numberOfColumns - 1
Dim o As Object = ReadObject(In)
rowObjects(col) = o
Next
Loop
Else If method = "batch" Then
table.Columns.Put("AffectedRows", 0)
Dim rows As Int = ReadInt(In)
For i = 0 To rows - 1
table.rows.Add(Array As Object(ReadInt(In)))
Next
End If
In.Close
' Log("HandleJob: " & (DateTime.Now - start))
Return table
End Sub
'Reads a file and returns the file as a bytes array.
Public Sub FileToBytes(Dir As String, FileName As String) As Byte()
Dim out As OutputStream
out.InitializeToBytesArray(0)
Dim In As InputStream = File.OpenInput(Dir, FileName)
File.Copy2(In, out)
out.Close
Return out.ToBytesArray
End Sub
'Converts an image to a bytes array (for BLOB fields).
Public Sub ImageToBytes(Image As Bitmap) As Byte()
Dim out As OutputStream
out.InitializeToBytesArray(0)
Image.WriteToStream(out, 100, "JPEG")
out.Close
Return out.ToBytesArray
End Sub
'Converts a bytes array to an image (for BLOB fields).
Public Sub BytesToImage(bytes() As Byte) As Bitmap
Dim In As InputStream
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
Dim bmp As Bitmap
bmp.Initialize2(In)
Return bmp
End Sub
'Prints the table to the logs.
Public Sub PrintTable(Table As DBResult)
Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size)
Dim sb As StringBuilder
sb.Initialize
For Each col In Table.Columns.Keys
sb.Append(col).Append(TAB)
Next
Log(sb.ToString)
For Each row() As Object In Table.Rows
Dim sb As StringBuilder
sb.Initialize
For Each record As Object In row
sb.Append(record).Append(TAB)
Next
ToastMessageShow(sb.ToString, True)
Next
End Sub

1158
B4A/EscPosPrinter.bas Normal file

File diff suppressed because it is too large Load Diff

105
B4A/Estacionamiento.b4a Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,24 @@
ModuleBookmarks0=
ModuleBookmarks1=
ModuleBookmarks2=
ModuleBookmarks3=
ModuleBookmarks4=
ModuleBookmarks5=
ModuleBookmarks6=
ModuleBreakpoints0=
ModuleBreakpoints1=
ModuleBreakpoints2=
ModuleBreakpoints3=
ModuleBreakpoints4=
ModuleBreakpoints5=
ModuleBreakpoints6=
ModuleClosedNodes0=6
ModuleClosedNodes1=
ModuleClosedNodes2=
ModuleClosedNodes3=
ModuleClosedNodes4=
ModuleClosedNodes5=
ModuleClosedNodes6=
NavigationStack=B4XMainPage,AjustarInterfaz,111,6,B4XMainPage,b_rescan_Click,654,2,B4XMainPage,b_tar_in_Click,619,6,B4XMainPage,b_resacep_Click,668,0,B4XMainPage,b_resdia_Click,661,6,B4XMainPage,b_salida_LongClick,188,0,Diseñador Visual,MainPage.bal,-100,6,B4XMainPage,b_entrada_Click,145,2,B4XMainPage,b_salida_Click,163,6,B4XMainPage,b_Tarifa_Click,607,4,B4XMainPage,b_tar_can_Click,614,1
SelectedBuild=0
VisibleModules=1,3,6,2,5,4

BIN
B4A/Files/alert2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

BIN
B4A/Files/mainpage.bal Normal file

Binary file not shown.

226
B4A/FirebaseMessaging.bas Normal file
View File

@@ -0,0 +1,226 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Service
Version=10.2
@EndOfDesignText@
'///////////////////////////////////////////////////////////////////////////////////////
'/// Agregar estas lineas al editor de manifiestos
'
' CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
' CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
' CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
' CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
'
'/// Agregar modulo de servicio nuevo FirebaseMessaging y copiar este modulo
'
'/// Bajar el archivo google-services.json de la consola de Firebase (https://console.firebase.google.com/)
'/// El nombre de la app en el archivo json tiene que ser el mismo que el nombre del paquete (Proyecto/Conf de Compilacion/Paquete)
'
'/// En Starter agregar esta linea
'
' Sub Service_Create
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
' End Sub
'
'/// En Main en Sub Process_Globals agregar esta linea
'
' Private const API_KEY As String = "AAAAv__xxxxxxxxxxxxx-xxxxxxxxxxxxxx-xxxxxxxxxxxx"
'
'/// Esta llave se consigue igualmente en la consola de Firebase, configuracion de proyecto, Cloud Messaging,
'/// es la clave de servidor.
'///
'/// Se necesitan agregar las librerías: FirebaseAnalitics, FirebaseNotifications, JSON y OkHttpUtils2
'/// ... JSON es necesario si se van a enviar mensajes, si solo se van a recibir, no es necesario.
'
'///////////////////////////////////////////////////////////////////////////////////////
Sub Process_Globals
Private fm As FirebaseMessaging
Private const API_KEY As String = "AAAAv1qt3Lk:APA91bECIR-pHn6ul53eYyoVlpPuOo85RO-0zcAgEXwE7vqw8DFSbBtCaCINiqWQAkBBZXxHtQMdpU6B-jHIqgFKVL196UgwHv0Gw6_IgmipfV_NiItjzlH9d2QNpGLp9y_JUKVjUEhP" 'Api_Key cheveguerra@gmail.com/Pusher
Dim locRequest As String
' Dim phn As Phone
Dim pe As PhoneEvents
Dim c As Cursor
Public GZip As GZipStrings
Dim Sprvsr As String = "Sprv-Cedex" ' El topico al que se mandan los mensajes push
Dim Subscrito As String
Dim au As String 'ignore
End Sub
Sub Service_Create
fm.Initialize("fm") 'Inicializamos FirebaseMessaging
pe.Initialize("pe") 'Para obtener la bateria
End Sub
Public Sub SubscribeToTopics
' fm.SubscribeToTopic("Trckr") 'Topico general Keymon
fm.SubscribeToTopic("Trckr") 'Tracker Global
' Log("Suscrito al tracker global")
fm.SubscribeToTopic("Trckr-Cedex") 'Topico de Guna
If "Cdx_"&B4XPages.MainPage.usuario <> Subscrito Then
fm.SubscribeToTopic("Cdx_"&B4XPages.MainPage.usuario) 'Propio (you can subscribe to more topics)
fm.UnsubscribeFromTopic(Subscrito) 'Unsubscribe from topic
End If
' Log("Subscrito a "&"Cdx_"&B4XPages.MainPage.usuario)
Subscrito = "Cdx_"&B4XPages.MainPage.usuario
' Log(fm.token)
' fm.UnsubscribeFromTopic("Sprvsr") 'Unsubscribe from topic
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
Sleep(0)
Service.StopAutomaticForeground 'remove if not using B4A v8+.
StartServiceAt(Me, DateTime.Now + 15 * DateTime.TicksPerMinute, True) 'Iniciamos servicio cada XX minutos
End Sub
Sub fm_MessageArrived (Message As RemoteMessage)
Log("Message arrived")
Log($"Message data: ${Message.GetData}"$)
' getPhnId
If Message.GetData.ContainsKey("t") Then
Dim tipos As List = Regex.Split(",",Message.GetData.Get("t"))
If tipos.IndexOf("pu") <> -1 Or tipos.IndexOf("au") <> -1 Then 'Si es una peticion de ubicacion
Log("Es una peticion de ubicacion")
locRequest="Activa"
Log("Llamamos StartFLPSmall")
CallSubDelayed(Tracker, "StartFLPSmall")
CallSubDelayed(Tracker, "StartFLP")
End If
If tipos.IndexOf("au") <> -1 Then 'Si es una actualizacion de ubicacion
au = 1
End If
If tipos.IndexOf("ping") <> -1 Then 'Si es un ping
Log("Es un ping")
Log("Mandamos pong")
Dim params As Map = CreateMap("topic":Sprvsr,"title":"pong", "body":B4XPages.MainPage.usuario&" - Recibi mensaje "&Message.GetData.Get("title"), "t":"pong")
SendMessage(params)
End If
If tipos.IndexOf("bgps") <> -1 Then 'Si es una instruccion de borrar archivo gps
Log("Es una instruccion de borrar archivo gps")
Log("Borramos archivo gps")
borramosArchivoGPS
End If
If tipos.IndexOf("dr") <> -1 Then 'Si es una peticion de ruta gps
Log("Es una peticion de Ruta GPS")
Dim rutaGpsCmp As String = dameRuta
Dim params As Map = CreateMap("topic":Sprvsr,"title":"ruta", "body":B4XPages.MainPage.usuario&" - Recibi mensaje "&Message.GetData.Get("title"), "t":"ruta", "r":rutaGpsCmp)
SendMessage(params)
End If
If tipos.IndexOf("bgps2") <> -1 Then 'Si es una instruccion de borrar DB gps
Log("Es una instruccion de borrar BD gps")
Log("Borramos BD gps")
borraGPSHist
End If
If tipos.IndexOf("pu") = -1 And tipos.IndexOf("au") = -1 And tipos.IndexOf("ping") = -1 And tipos.IndexOf("dr") = -1 Then
Log("No es ping ni solicitud de ubicacion o ruta, entonces no hacemos nada")
End If
End If
' Dim n As Notification
' n.Initialize
' n.Icon = "icon"
' n.SetInfo("Guna", "Guna", Main)
' n.Notify(1)
End Sub
Sub Service_Destroy
End Sub
Sub SendMessage(params As Map)
Dim topic As String= params.Get("topic")
Dim title As String= params.Get("title")
Dim body As String= params.Get("body")
Dim tipo As String= params.Get("t")
If params.ContainsKey("r") Then
Log("Con ruta")
Dim rutaGpsCmp As String= params.Get("r")
Else
Log("Sin ruta")
Dim rutaGpsCmp As String = ""
End If
Dim Job As HttpJob
Job.Initialize("fcm", Me)
Dim m As Map = CreateMap("to": $"/topics/${topic}"$)
Dim data As Map = CreateMap("title":title, "body":body, "d":B4XPages.MainPage.usuario, "t":tipo, "b":B4XPages.MainPage.batt, "mt":B4XPages.MainPage.montoActual, "r":rutaGpsCmp, "v":B4XPages.MainPage.v)
m.Put("data", data)
Dim jg As JSONGenerator
jg.Initialize(m)
Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
Job.GetRequest.SetContentType("application/json;charset=UTF-8")
Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
Log(m) 'ignore
End Sub
Sub mandamosLoc(coords As String)
' Log("Iniciamos mandamosLoc "&coords)
' Log("locRequest="&locRequest)
If locRequest="Activa" Then 'Si hay solicitud de ubicacion, entonces la mandamos ...
Dim params As Map = CreateMap("topic":Sprvsr,"title":"ubicacionRecibida", "body":coords, "t":"u")
SendMessage(params)
locRequest="Enviada"
CallSubDelayed(Tracker,"CreateLocationRequest")
End If
End Sub
Sub guardaInfoEnArchivo(coords As String) 'ignore 'Escribimos coordenadas y fecha a un archivo de texto
Log("Guardamos ubicacion en BD")
Dim latlon() As String = Regex.Split(",", coords)
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO RUTA_GPS(FECHA, LAT, LON) VALUES (?,?,?)", Array As Object (latlon(2),latlon(0),latlon(1)))
End Sub
Sub borramosArchivoGPS
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "gps.txt", False)
Dim s As String = ""
Dim t() As Byte = s.GetBytes("UTF-8")
out.WriteBytes(t, 0, t.Length)
out.Close
End Sub
Sub pe_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
B4XPages.MainPage.batt=Level
End Sub
Sub compress(str As String) As String
' Compression
Private su As StringUtils
Dim compressed() As Byte = GZip.compress(str)
Log($"CompressedBytesLength: ${compressed.Length}"$)
Dim base64 As String = su.EncodeBase64(compressed)
Log($"CompressedBytes converted to base64 Length: ${base64.Length}"$)
Log($"CompressedBytes converted to base64: ${base64}"$)
Return base64
End Sub
Sub decompress(base64 As String) As String 'ignore
' Decompression
Private su As StringUtils
Dim decompressedbytes() As Byte = su.DecodeBase64(base64)
Log($"decompressedbytesLength: ${decompressedbytes.Length}"$)
Dim bc As ByteConverter
Dim uncompressed As String = bc.StringFromBytes(decompressedbytes,"UTF8")
Log($"uncompressedLength: ${uncompressed.Length}"$) ' 6163 Bytes
Log($"Decompressed String = ${uncompressed}"$)
Return uncompressed
End Sub
Sub dameRuta As String
Log("dameRuta")
Dim c As Cursor
c = B4XPages.MainPage.skmt.ExecQuery("select LAT, LON from RUTA_GPS order by FECHA desc limit 390")
c.Position = 0
Dim ruta2 As String = ""
If c.RowCount>0 Then
For i=0 To c.RowCount -1
c.Position=i
ruta2=ruta2&CRLF&c.GetString("LAT")&","&c.GetString("LON")
Next
End If
c.Close
Return compress(ruta2)
End Sub
Sub borraGPSHist
c = B4XPages.MainPage.skmt.ExecQuery("delete FROM RUTA_GPS")
End Sub

128
B4A/Starter.bas Normal file
View File

@@ -0,0 +1,128 @@
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 gps As GPS
Dim ph As Phone
Public rp As RuntimePermissions
Public FLP As FusedLocationProvider
' Private flpStarted As Boolean
Dim reqManager As DBRequestManager
Dim server As String = "http://187.189.244.154:1782"
' Dim server As String = "http://10.0.0.205:1782"
Dim Timer1 As Timer
Dim Interval As Int = 30
Dim ruta As String = File.DirInternal
'Para los Logs
Private logs As StringBuilder
Private logcat As LogCat
Dim logger As Boolean = False
Dim marcaCel As String = ph.manufacturer
Dim muestraProgreso = 0
Private BTAdmin As BluetoothAdmin
Dim MAC_IMPRESORA As String
Dim ubicacionActual As Location
Dim enVenta As Boolean = False
Dim VarX As Int = 0
Private BTAdmin As BluetoothAdmin
Public BluetoothState As Boolean
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.
' gps.Initialize("GPS")
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics") 'Para Push FirebaseMessaging
' BTAdmin.Initialize("admin")
' Timer1.Initialize("Timer1", Interval * 1000)
' Timer1.Enabled = True
'' 'Para los Logs
' #if RELEASE
' logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
' #end if
' logs.Initialize
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics") 'Para Push FirebaseMessaging
' ubicacionActual.Initialize
'End Sub
Private Sub BTAdmin_StateChanged (NewState As Int, OldState As Int)
If logger Then Log("BT state changed: " & NewState)
BluetoothState = NewState = BTAdmin.STATE_ON
' StateChanged
End Sub
'Sub Service_Start (StartingIntent As Intent)
' Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
' Subs.revisaBD
' Log(marcaCel)
' reqManager.Initialize(Me, server)
'End Sub
'Private Sub Timer1_Tick
'' Log("Next run " & DateTime.Time(DateTime.Now + Interval * 1000))
' ENVIA_ULTIMA_GPS
'End Sub
Sub GPS_LocationChanged (Location1 As Location)
' CallSub2(Main, "GPS_LocationChanged", Location1)
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
Sub Service_Destroy
End Sub
'Sub ENVIA_ULTIMA_GPS
' LogColor("Iniciamos ENVIA_ULTIMA_GPS", Colors.Magenta)
' Dim skmt As SQL
' Dim cmd As DBCommand
' skmt.Initialize(ruta,"kmt.db", True)
'' cmd.Initialize
'' cmd.Name = "select_fechat"
'' B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "fechat")
' Dim cmd As DBCommand
' cmd.Initialize
' cmd.Name = "UPDATE_GUNA_ACTUAL2_GPS"
' cmd.Parameters = Array As Object(B4XPages.MainPage.montoActual, B4XPages.MainPage.clientestotal, B4XPages.MainPage.clientesventa,B4XPages.MainPage.clientesvisitados,B4XPages.MainPage.lat_gps,B4XPages.MainPage.lon_gps,B4XPages.MainPage.batt,0, 0, 0,B4XPages.MainPage.ALMACEN,B4XPages.MainPage.rutapreventa)
'' Log($"montoActual: ${B4XPages.MainPage.montoActual}, cTotal: ${B4XPages.MainPage.clientestotal}, cVenta: ${B4XPages.MainPage.clientesventa}, cVisitados: ${B4XPages.MainPage.clientesvisitados}, ${B4XPages.MainPage.lat_gps}, ${B4XPages.MainPage.lon_gps}, Batt: ${B4XPages.MainPage.batt}, 0, 0, 0, Almacen: ${B4XPages.MainPage.ALMACEN}, Ruta: ${B4XPages.MainPage.rutapreventa}"$)
' reqManager.ExecuteCommand(cmd, "inst_visitas")
' 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 "seleccion"
' Timer1.Enabled = False
' Timer1.Interval = Interval * 1000
' Timer1.Enabled = True
'End Sub
'Para los Logs
Private Sub logcat_LogCatData (Buffer() As Byte, Length As Int)
logs.Append(BytesToString(Buffer, 0, Length, "utf8"))
If logs.Length > 4000 Then
logs.Remove(0, logs.Length - 2000) 'Obtenemos log de 2000 ~ 4000 chars
End If
End Sub
''Return true to allow the OS default exceptions handler to handle the uncaught exception. 'Para los Logs
'Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
' 'wait for 500ms to allow the logs to be updated.
' Dim jo As JavaObject
' Dim l As Long = 500: jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l)) 'Sleep 500ms
' logcat.LogCatStop
' logs.Append(StackTrace)
' Subs.revisaBD
' Subs.errorLog.ExecNonQuery2("INSERT INTO errores(fecha, error) VALUES (?,?)", Array As Object (Subs.fechaKMT(DateTime.now), logs))
' Return True
'End Sub

1388
B4A/Subs.bas Normal file

File diff suppressed because it is too large Load Diff