mirror of
https://github.com/KeymonSoft/Lanterna_H.git
synced 2026-04-17 12:56:20 +00:00
- Se cambio el sevidor a keymon.net - Se cambio el puerto al 1783
135 lines
4.7 KiB
QBasic
135 lines
4.7 KiB
QBasic
B4A=true
|
|
Group=Default Group
|
|
ModulesStructureVersion=1
|
|
Type=Service
|
|
Version=9.9
|
|
@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 skmt As SQL
|
|
Dim Logger As Boolean = False
|
|
' Dim DBReqServer As String = "http://keymon.lat:1782"
|
|
Dim DBReqServer As String = "http://192.99.93.204:1783"
|
|
' Dim DBReqServer As String = "http://keymon.lat:9000"
|
|
Dim server, ruta As String
|
|
'Para los Logs
|
|
Dim logs As StringBuilder
|
|
Private logcat As LogCat
|
|
Dim Logger As Boolean
|
|
Dim rutav As String = ""
|
|
Dim tipov As String = "VENTA"
|
|
Dim ticketActual, mesaActual, meseroActual, comensalesActuales, totalActual, mac_impresora As String
|
|
Dim formasDePago As Int = 1
|
|
Dim imprimirTicket As Boolean = False
|
|
Dim nivelActual As String
|
|
Dim catActual, subcatActual As String
|
|
Dim atrasPresionado As Boolean = False
|
|
Dim cargaMeseros As Boolean = False
|
|
Dim ticketFactura As Boolean
|
|
Dim muestraProgreso = 0
|
|
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.
|
|
If Logger Then LogColor("'/////////////////////////////////////////////////////////////////////////////////////////////", Colors.Green)
|
|
If Logger Then LogColor("'///////////////////////////////////// Iniciamos Starter /////////////////////////////////", Colors.Green)
|
|
If Logger Then LogColor("'/////////////////////////////////////////////////////////////////////////////////////////////", Colors.Green)
|
|
ruta = File.DirInternal
|
|
If File.Exists(ruta, "kmt.db") = False Then
|
|
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
|
End If
|
|
skmt.Initialize(ruta,"kmt.db", True)
|
|
'Para los Logs
|
|
#if RELEASE
|
|
logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
|
|
#end if
|
|
logs.Initialize
|
|
' DBReqServer = "http://keymon.lat:1782"
|
|
DBReqServer = "http://192.99.93.204:1783"
|
|
' DBReqServer = "http://keymon.lat:9000"
|
|
If Logger Then Log($"Starter reqManager server: ${DBReqServer}"$)
|
|
Logger = False
|
|
End Sub
|
|
|
|
Sub Service_Start (StartingIntent As Intent)
|
|
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
|
Subs.revisaBD
|
|
#if DEBUG
|
|
Logger = True
|
|
#else
|
|
Logger = False
|
|
#End If
|
|
Private c As Cursor = skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SERVER"))
|
|
' Log(c.RowCount)
|
|
If c.RowCount > 0 Then
|
|
c.Position = 0
|
|
DBReqServer = c.GetString("CAT_VA_VALOR")
|
|
Log("De base de datos -> " & DBReqServer)
|
|
End If
|
|
reqManager.Initialize(Me, DBReqServer)
|
|
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. 'Para los Logs
|
|
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
|
|
'wait for 500ms to allow the logs to be updated.
|
|
Log(">>>>>>>>> ERROR")
|
|
Dim jo As JavaObject
|
|
Dim l As Long = 500: jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l)) 'Sleep 500ms
|
|
logcat.LogCatStop
|
|
logs.Initialize
|
|
logs.Append(Application.LabelName & " Ver " & Application.VersionName & CRLF)
|
|
logs.Append(StackTrace)
|
|
Subs.revisaBD
|
|
Subs.errorLog.ExecNonQuery2("INSERT INTO errores(fecha, error) VALUES (?,?)", Array As Object (Subs.fechaKMT(DateTime.now), logs))
|
|
StartActivity(errorManager)
|
|
Return True
|
|
End Sub
|
|
|
|
Sub Service_Destroy
|
|
' Timer1.Enabled=False
|
|
If Logger Then LogColor("starter destroyed", Colors.red)
|
|
End Sub
|
|
|
|
Sub JobDone(Job As HttpJob)
|
|
LogColor("Starter - JobDone", Colors.Magenta)
|
|
If Job.Success = False Then
|
|
' ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
|
Else
|
|
If Logger Then LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211110
|
|
If Job.JobName = "DBRequest" Then
|
|
Dim result As DBResult = reqManager.HandleJob(Job)
|
|
If result.Tag = "updateKell_UTR" Then 'query tag
|
|
If Logger Then Subs.logJobDoneResultados(result)
|
|
End If
|
|
End If
|
|
End If
|
|
Job.Release
|
|
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
|
|
|
|
'Revisa que la conexion a la base de datos este bien.
|
|
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)
|
|
End Sub |