2/9/23 - NotificationService, RespaldoDiario y DBReqServer.

- Se agregó el servicio "NotificationService" para interceptar notificaciones y por medio de un mensaje de WhatsApp (#NS http://10.0.0.205:1782), cambiar el servidor de DBReq.
- Se agregó la clase de RespaldoDiario.
- Se estandarizó el DBreqServer en Starter.DBReqServer.
This commit is contained in:
2023-09-23 23:41:19 -06:00
parent 9a78f72525
commit 2b7cd5c3b5
9 changed files with 107 additions and 62 deletions

View File

@@ -24,6 +24,7 @@ Version=9.85
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Dim s As C_Subs
Public login As B4XMainPage
Public principal As C_Principal
Public clientes As C_Clientes
@@ -59,7 +60,7 @@ Sub Class_Globals
Dim batt As Int
Dim skmt As SQL
Dim montoActual, clientesTotal, clientesVenta, clientesVisitados,almacen, rutaPreventa As String
Dim server, fechaRuta As String
Dim DBReqServer, fechaRuta As String
Dim Logger As Boolean
Dim mac_impresora As String
Dim Phn As PhoneId
@@ -108,6 +109,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.GetManager.LogEvents = True
Root = Root1
Root.LoadLayout("login")
s.Initialize(Me, "Subs")
B4XPages.SetTitle(Me, "Intmex Preventa")
login.Initialize
B4XPages.AddPage("Login", login)
@@ -175,7 +177,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
C.Close
' server = "http://keymon.com.mx:1782"
'server = "http://201.99.139.28:1783"
' reqManager.Initialize(Me, server)
' reqManager.Initialize(Me, DBReqServer)
l_version.Text = Application.VersionName
'este codigo es para lo del menu
' PopupMenu.Initialize("PopupMenu", b_menu)
@@ -254,8 +256,8 @@ Sub B4XPage_Appear
Dim ph As Phone 'Get Id Device
Dim DeviceID As String = ph.GetSettings("android_id").ToUpperCase
LogColor($"////////////////// DeviceID: ${DeviceID} ////////////////// "$, Colors.Blue)
server = Starter.server
reqManager.Initialize(Me, Starter.server)
DBReqServer = Starter.DBReqServer
reqManager.Initialize(Me, Starter.DBReqServer)
tgl.Initialize()
If Not(Starter.gps.GPSEnabled) Then
ToastMessageShow("Es necesario tener el GPS encendido", True)
@@ -292,6 +294,26 @@ Sub B4XPage_Appear
'Obtenemos el usuario registrado
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
dameUsuario
If Not(s.CheckNotificationAccess) Then
Msgbox2Async($"Se necesita acceso a las notificaciones, haga clic en "Aceptar" y en la siguiente pantalla permita el acceso a la aplicación "${Application.LabelName}"."$, "Permisos necesarios", "Aceptar", "Cancelar", "", Null, True)
Wait For Msgbox_Result (resultado As Int)
If resultado = DialogResponse.POSITIVE Then
Dim In As Intent
In.Initialize("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS", "")
StartActivity(In)
End If
' Private cd1 As ColorDrawable
' cd1.Initialize(Colors.red, 10dip)
' b_notifAccess.Background = cd1
' b_notifAccess.TextColor = Colors.White
' b_notifAccess.Text = "Activar Permisos"
Else
' Private cd1 As ColorDrawable
' cd1.Initialize(Colors.RGB(109, 221, 101), 10dip)
' b_notifAccess.Background = cd1
' b_notifAccess.TextColor = Colors.White
' b_notifAccess.Text = "Permisos Activos"
End If
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
@@ -321,11 +343,11 @@ Sub Entrar_Click
IMEI = PP.GetSettings("android_id")
End If
' Log("IMEI = " & IMEI)
If user.Text = "ALTERNO" Then
c=skmt.ExecQuery2("select CAT_CO_CONFIGURACION, CAT_CO_RESULTADO from CAT_CODIGOS where CAT_CO_PONDERACION =1 AND CAT_CO_ACCION = ?", Array As String("SERVER"))
c.Position =0
server = c.GetString("CAT_CO_CONFIGURACION")
DBReqServer = c.GetString("CAT_CO_CONFIGURACION")
alterno = c.GetString("CAT_CO_RESULTADO")
c.Close
If alterno = 1 Then
@@ -337,10 +359,10 @@ Sub Entrar_Click
End If
c=skmt.ExecQuery2("select CAT_CO_CONFIGURACION, CAT_CO_RESULTADO from CAT_CODIGOS where CAT_CO_PONDERACION =1 AND CAT_CO_ACCION = ?", Array As String("SERVER"))
c.Position =0
server = c.GetString("CAT_CO_CONFIGURACION")
user.Text = server
DBReqServer = c.GetString("CAT_CO_CONFIGURACION")
user.Text = DBReqServer
c.Close
' reqManager.Initialize(Me, server)
' reqManager.Initialize(Me, DBReqServer)
else if user.Text = "KMTS1" Then
skmt.ExecNonQuery("delete from usuarioa")
skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(user.Text, pass.Text))
@@ -641,7 +663,8 @@ Sub i_engrane_Click
ime.HideKeyboard
lv_server.AddSingleLine("http://keymon.lat:1782")
If user.Text = "KMTS1" Then lv_server.AddSingleLine("http://10.0.0.205:1782")
l_server.Text = Starter.server
' lv_server.AddSingleLine("http://40.123.36.38:1782")
l_server.Text = Starter.DBReqServer
Subs.panelVisible(p_appUpdate,0,0)
If user.Text.trim = "KMTS1" Then b_importarBD.Visible = True Else b_importarBD.Visible = False
End Sub
@@ -659,9 +682,10 @@ Sub Entrar_LongClick
End Sub
Private Sub lv_server_ItemClick (Position As Int, Value As Object)
Starter.server = Value
Starter.DBReqServer = Value
l_server.Text = Value
Starter.reqManager.Initialize(Me, Value)
Starter.reinicializaReqManager(Value)
' Starter.reqManager.Initialize(Me, Value)
ToastMessageShow("Servidor modificado", False)
End Sub