mirror of
https://github.com/KeymonSoft/Monitor-Keymon.git
synced 2026-04-17 12:56:12 +00:00
- VERSION 5.04.22
- Se agregó que guarde en base de datos el estatus de "Activo", asi si se desactiva el servicio, cuando se reinicia, o el sistema lo mata y luego reinicia, mantiene el estatus seleccionado.
This commit is contained in:
@@ -179,6 +179,19 @@ Sub B4XPage_Appear
|
||||
b_notifAccess.Text = "Permisos Activos"
|
||||
End If
|
||||
CallSubDelayed(Monitor, "Timer1_Tick")
|
||||
If Not(s.traeActivo) Then
|
||||
cd1.Initialize(Colors.red, 10dip)
|
||||
b_monitorActivo.Background = cd1
|
||||
b_monitorActivo.Text = "Monitor Apagado"
|
||||
l_status.Text = "Monitor Apagado"
|
||||
b_ping.Text = "En pausa"
|
||||
Monitor.Timer1.Enabled = False
|
||||
Else
|
||||
cd1.Initialize(Colors.RGB(16, 141, 0), 10dip)
|
||||
b_monitorActivo.Background = cd1
|
||||
b_monitorActivo.Text = "Monitor Activo"
|
||||
l_status.Text = "Monitor Activo"
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
@@ -207,20 +220,27 @@ End Sub
|
||||
|
||||
Private Sub b_monitorActivo_Click
|
||||
If logger Then Log(Starter.DBReqServer)
|
||||
If Starter.monitorActivo Then
|
||||
Log("YYY: " & Starter.monitorActivo)
|
||||
If s.traeActivo Then
|
||||
cd1.Initialize(Colors.red, 10dip)
|
||||
b_monitorActivo.Background = cd1
|
||||
b_monitorActivo.Text = "Monitor Apagado"
|
||||
l_status.Text = "Monitor Apagado"
|
||||
Starter.monitorActivo = False
|
||||
' Starter.monitorActivo = False
|
||||
s.notiHigh("Con internet ✅", $"Monitor APAGADO ❌"$, Monitor.nid, Main)
|
||||
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where nombre = ?", Array As Object ("monitorActivo"))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(nombre, valor) VALUES (?,?)", Array As Object ("monitorActivo","0"))
|
||||
Monitor.Timer1.Enabled = False
|
||||
b_ping.Text = "En pausa"
|
||||
Else
|
||||
cd1.Initialize(Colors.RGB(16, 141, 0), 10dip)
|
||||
b_monitorActivo.Background = cd1
|
||||
b_monitorActivo.Text = "Monitor Activo"
|
||||
l_status.Text = "Monitor Activo"
|
||||
CallSubDelayed(Monitor, "Timer1_Tick")
|
||||
Starter.monitorActivo = True
|
||||
' Starter.monitorActivo = True
|
||||
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where nombre = ?", Array As Object ("monitorActivo"))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(nombre, valor) VALUES (?,?)", Array As Object ("monitorActivo","1"))
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -550,3 +550,23 @@ Sub CheckAndRequestNotificationPermission As ResumableSub
|
||||
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean) 'change to Activity_PermissionResult if non-B4XPages.
|
||||
Return Result
|
||||
End Sub
|
||||
|
||||
' Revisa en CAT_VARIABLES el valor de "monitorActivo"
|
||||
' - Regresa verdadero si encuentra 1
|
||||
' - Regresa falso si encuentra 0
|
||||
Sub traeActivo As Boolean
|
||||
Private c As Cursor = Starter.skmt.ExecQuery("select valor from cat_variables where nombre = 'monitorActivo'")
|
||||
Private monitorActivo As Boolean = True
|
||||
If c.RowCount > 0 Then
|
||||
For i = 0 To c.RowCount - 1
|
||||
c.Position = i
|
||||
' Log("xxxx: " & c.GetString("valor"))
|
||||
If c.GetString("valor") = "0" Then
|
||||
monitorActivo = False
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
' Log(c.RowCount)
|
||||
' Log("monitorActivo: " & monitorActivo)
|
||||
Return monitorActivo
|
||||
End Sub
|
||||
@@ -46,7 +46,7 @@ Version=12.8
|
||||
#Region Project Attributes
|
||||
#ApplicationLabel: Monitor Keymon
|
||||
#VersionCode: 1
|
||||
#VersionName: 4.12.14
|
||||
#VersionName: 5.04.22
|
||||
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||
#SupportedOrientations: portrait
|
||||
#CanInstallToExternalStorage: False
|
||||
|
||||
@@ -15,13 +15,13 @@ ModuleBreakpoints5=
|
||||
ModuleBreakpoints6=
|
||||
ModuleBreakpoints7=
|
||||
ModuleClosedNodes0=
|
||||
ModuleClosedNodes1=2
|
||||
ModuleClosedNodes1=4
|
||||
ModuleClosedNodes2=
|
||||
ModuleClosedNodes3=32,34
|
||||
ModuleClosedNodes4=
|
||||
ModuleClosedNodes5=5
|
||||
ModuleClosedNodes6=
|
||||
ModuleClosedNodes7=
|
||||
NavigationStack=NotificationService,Process_Globals,11,0,Starter,Service_Start,37,1,Monitor,Service_Create,36,1,NotificationService,Service_Create,13,1,NotificationService,MonitorKeymon_NotificationPosted,31,0,NotificationService,Service_Start,19,1,C_Subs,notiLowReturn,464,1,C_Subs,notiHigh,432,0,Monitor,Service_Start,40,0,B4XMainPage,B4XPage_Created,78,0
|
||||
NavigationStack=NotificationService,Service_Create,15,0,NotificationService,Service_Destroy,33,0,B4XMainPage,b_ping_Click,301,0,B4XMainPage,B4XPage_Appear,145,6,NotificationService,MonitorKeymon_NotificationPosted,52,6,C_Subs,traeActivo,563,0,Starter,Service_Start,46,0,Starter,Process_Globals,20,0,B4XMainPage,b_monitorActivo_Click,227,6,Monitor,probamosConexion,65,0,Monitor,Service_Create,29,0
|
||||
SelectedBuild=0
|
||||
VisibleModules=1,7,3,5,4,6
|
||||
|
||||
@@ -14,16 +14,18 @@ Sub Process_Globals
|
||||
Dim rp As ReplyAuto
|
||||
Dim activo As Boolean = True
|
||||
Dim ultimaNoti As String
|
||||
Dim s As C_Subs
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
' Log(963)
|
||||
s.Initialize
|
||||
rp.Initialize("MonitorKeymon")
|
||||
If Starter.logger Then Log("**************** Iniciamos Monitor Keymon ***********************")
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
if starter.logger then Log("Monitor - NotificationService Start")
|
||||
If Starter.logger Then Log("Monitor - NotificationService Start")
|
||||
If rp.HandleIntent(StartingIntent) Then Return
|
||||
DateTime.DateFormat = "mm"
|
||||
ultimaNoti = DateTime.Date(DateTime.now)
|
||||
@@ -34,22 +36,25 @@ Sub Service_Destroy
|
||||
|
||||
End Sub
|
||||
|
||||
' Cuando entre una notificación, revisamos que el servicio del monitor este funcionando, si no esta funcionando
|
||||
' y "monitorActivo" es verdadero, entonces lo iniciamos.
|
||||
Sub MonitorKeymon_NotificationPosted (SBN As StatusBarNotification)
|
||||
' Log("|" & ultimaNoti & "|")
|
||||
Private logger As Boolean = False
|
||||
If ultimaNoti = "" Then ultimaNoti = 0
|
||||
DateTime.DateFormat = "mm"
|
||||
Private estaNoti As String = DateTime.Date(DateTime.now)
|
||||
' Log("|" & estaNoti & "|")
|
||||
If estaNoti > 60 Then estaNoti = estaNoti - 60
|
||||
' Log("|" & estaNoti & "|")
|
||||
If Starter.logger Then LogColor("Diferencia de tiempo entre notis = " & (estaNoti - ultimaNoti), Colors.blue)
|
||||
If Starter.logger Then LogColor($"Esta noti en el minuto ${DateTime.Date(DateTime.now)}, ultima noti = ${ultimaNoti}"$, Colors.green)
|
||||
If Starter.logger Then Log(SBN.PackageName)
|
||||
If logger Then LogColor("Diferencia de tiempo entre notis = " & (estaNoti - ultimaNoti), Colors.blue)
|
||||
If logger Then LogColor($"Esta noti en el minuto ${DateTime.Date(DateTime.now)}, ultima noti = ${ultimaNoti}"$, Colors.green)
|
||||
If logger Then Log(SBN.PackageName)
|
||||
If (ultimaNoti + 2) < estaNoti Then '3 minutos
|
||||
If Starter.logger Then LogColor($"******** Revisamos el Monitor *******"$, Colors.red)
|
||||
If logger Then LogColor($"******** Revisamos el Monitor *******"$, Colors.red)
|
||||
ultimaNoti = estaNoti
|
||||
If Starter.logger Then Log($"Monitor activo: ${Not(IsPaused(Monitor))}"$)
|
||||
If IsPaused(Monitor) Then StartService(Monitor)
|
||||
If logger Then Log($"Monitor activo: ${Not(IsPaused(Monitor))}"$)
|
||||
If IsPaused(Monitor) And s.traeActivo Then StartService(Monitor)
|
||||
End If
|
||||
If Starter.logger Then LogColor("Monitor inicializado: " & Monitor.Timer1.IsInitialized, Colors.Magenta)
|
||||
If logger Then LogColor("Monitor inicializado: " & Monitor.Timer1.IsInitialized, Colors.Magenta)
|
||||
End Sub
|
||||
|
||||
@@ -33,9 +33,10 @@ End Sub
|
||||
Sub Service_Create
|
||||
s.Initialize
|
||||
Interval = s.traeIntervaloDeBD
|
||||
' Interval = 10
|
||||
timeout = s.traeTimeoutDeBD
|
||||
Timer1.Initialize("Timer1", Interval * 1000)
|
||||
Timer1.Enabled = True
|
||||
If s.traeActivo Then Timer1.Enabled = True Else Timer1.Enabled = False
|
||||
#if not(DEBUG)
|
||||
logger = False
|
||||
#end if
|
||||
@@ -60,7 +61,7 @@ End Sub
|
||||
Sub Timer1_Tick
|
||||
' Log("Next run " & DateTime.Time(DateTime.Now + Interval * 1000))
|
||||
' Log("Monitor Timer_Tick")
|
||||
If Starter.monitorActivo Then
|
||||
If s.traeActivo Then
|
||||
DateTime.DateFormat = "dd/MM HH:mm:ss"
|
||||
If B4XPages.IsInitialized Then B4XPages.MainPage.l_ultimoPing.Text = $"Último ping: ${DateTime.Date(DateTime.now)}"$
|
||||
probamosConexion
|
||||
|
||||
Reference in New Issue
Block a user