mirror of
https://github.com/KeymonSoft/Monitor-Keymon.git
synced 2026-04-17 12:56:12 +00:00
- 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.
61 lines
2.1 KiB
QBasic
61 lines
2.1 KiB
QBasic
B4A=true
|
|
Group=Default Group
|
|
ModulesStructureVersion=1
|
|
Type=Service
|
|
Version=11
|
|
@EndOfDesignText@
|
|
#Region Service Attributes
|
|
#StartAtBoot: 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.
|
|
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 rp.HandleIntent(StartingIntent) Then Return
|
|
DateTime.DateFormat = "mm"
|
|
ultimaNoti = DateTime.Date(DateTime.now)
|
|
If Starter.logger Then LogColor($"Ultima notificación en el minuto ${ultimaNoti}"$, Colors.green)
|
|
End Sub
|
|
|
|
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 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 logger Then LogColor($"******** Revisamos el Monitor *******"$, Colors.red)
|
|
ultimaNoti = estaNoti
|
|
If logger Then Log($"Monitor activo: ${Not(IsPaused(Monitor))}"$)
|
|
If IsPaused(Monitor) And s.traeActivo Then StartService(Monitor)
|
|
End If
|
|
If logger Then LogColor("Monitor inicializado: " & Monitor.Timer1.IsInitialized, Colors.Magenta)
|
|
End Sub
|