B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Service
Version=11.5
@EndOfDesignText@
#Region  Service Attributes 
	#StartAtBoot: False
	
#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 timer As Timer
'	Dim reqManager As DBRequestManager
End Sub

Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
	Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
	timer.Initialize("Timer", 5000)
	timer.Enabled = True
	Starter.reqManager.Initialize(Me, Starter.server)
End Sub

Private Sub Timer_Tick
'	ToastMessageShow("Timer",False)
'	Log("Next run " & DateTime.Time(DateTime.Now + Interval * 1000))
	testJobdone
End Sub

Sub testJobdone
	Dim cmd As DBCommand
	cmd.Initialize
	cmd.Name = "select_fechat"
	Starter.reqManager.ExecuteQuery(cmd , 0, "fechat")
	Log("sent......")
End Sub

Sub JobDone(Job As HttpJob)
	If Job.Success = False Then
'		ToastMessageShow("Error: " & Job.ErrorMessage, True)
		Log("Success NOT")
	Else
		LogColor("JobDone: '" & Starter.reqManager.HandleJob(Job).tag & "' - Registros: " & Starter.reqManager.HandleJob(Job).Rows.Size, Colors.Green)  'Mod por CHV - 211110
		If Job.JobName = "DBRequest" Then
			Dim result As DBResult = Starter.reqManager.HandleJob(Job)
			If result.Tag = "select_fechat" Then 'query tag
				For Each records() As Object In result.Rows
					For Each k As String In result.Columns.Keys
						Log("select_fechat: " & k & ": " & records(result.Columns.Get(k)))
					Next
				Next
			End If
		End If
	End If
	Job.Release
End Sub

Sub Service_Destroy

End Sub
