Hello. I have a real simple app that runs hidden (as a process) and every three minutes it connects to a MySQL database and performs some functions depending on the MySQL database results.
I use a Timer to accomplish this but the issue now is that many users are not able to logoff from their computers. If I kill my app from the process list then they will be able to logoff with no problems.
From the testing and troubleshooting I've done everything points to the timer running non-stop. I don't know how to get around this problem. Here's my code:
I use a Timer to accomplish this but the issue now is that many users are not able to logoff from their computers. If I kill my app from the process list then they will be able to logoff with no problems.
From the testing and troubleshooting I've done everything points to the timer running non-stop. I don't know how to get around this problem. Here's my code:
B4X:
Sub Globals
'Declare the global variables here.
Dim SQLUser(0) As string
ThisUser = ""
Seconds = 0
End Sub
Sub App_Start
'ErrorLabel(GottoSt)
'thr.New1(B4PObject(1))
Connection.New1
Reader.New1
Command.New1("", Connection.Value)
obj.New1(False)
obj.CreateNew("System.Environment" & obj.System_Mscorlib)
slUs = obj.RunMethod2("GetFolderPath", "LocalApplicationData", "System.Environment+SpecialFolder")
SQLUser() = StrSplit(slUs, "\")
uSpot = ArrayLen(SQLUser())-3
ThisUser = SQLUser(uSpot)
ThisUser = StrToLower(ThisUser)
obj.FromControl("frmMain")
frmMain.Show
Timer1.Enabled = True
Timer2.Enabled = True
Return
'GottoSt:
End Sub
Sub btnHide_Click
obj.SetProperty("Visible",False)
End Sub
Sub Timer1_Tick
btnHide_Click
Timer1.Enabled = False
CheckForNewOnes_Do
'StartProcess_Do
End Sub
Sub frmMain_Close
btnHide_Click
frmMain.CancelClose
End Sub
Sub Timer2_Tick
'Sleep(180)
'thr.Sleep(2000)
'CheckForNewOnes_Do
Seconds = Seconds + 1
If Seconds = 180 Then '300
CheckForNewOnes_Do
Seconds = 0
End If
DoEvents
End Sub
Sub CheckForNewOnes_Do
ErrorLabel(GottoEx)
Detttp = ""
Tttype = ""
Connection.Open("DSN=SupACCTdb;")
Connection.BeginTransaction(Command.Value)
Command.CommandText = "SELECT * FROM t_eMailsMngr"
Command.ExecuteTable("tbleMail", 0)
Connection.EndTransaction
Connection.Close
For i=0 To tbleMail.RowCount-1
verifier = tbleMail.Cell("email", i)
verifier = StrToLower(verifier)
If verifier = ThisUser Then
Detttp = tbleMail.Cell("Dept", i)
If Detttp <> "" Then
Tttype = "M"
End If
If Detttp = "Admin" Then
Tttype = "X"
End If
If Detttp = "NURSE" Then
Tttype = "N"
End If
End If
Next
If Detttp = "" Then
Connection.Open("DSN=SupACCTdb;")
Connection.BeginTransaction(Command.Value)
Command.CommandText = "SELECT * FROM t_eMailsSups"
Command.ExecuteTable("tbleMail", 0)
Connection.EndTransaction
Connection.Close
For i=0 To tbleMail.RowCount-1
verifier = tbleMail.Cell("email", i)
verifier = StrToLower(verifier)
If verifier = ThisUser Then
Detttp = tbleMail.Cell("Dept", i)
Tttype = "S"
End If
Next
End If
If Detttp = "" Then
Return
End If
Connection.Open("DSN=SupACCTdb;")
Connection.BeginTransaction(Command.Value)
Command.CommandText = "SELECT * FROM t_IncAccI"
Command.ExecuteTable("tblSQL", 0)
Connection.EndTransaction
Connection.Close
lblRv.Text = 0
lblRjc.Text = 0
If Tttype = "M" Then
tblSQL.Filter("")
tblSQL.Filter("Sec1Dept = '" & Detttp & "' AND FORMStatus = 'ToManager'")
lblRv.Text = tblSQL.RowCount
tblSQL.Filter("")
tblSQL.Filter("Sec1Dept = '" & Detttp & "' AND FORMStatus = 'RejectedToManager'")
lblRjc.Text = tblSQL.RowCount
End If
If Tttype = "S" Then
lblRv.Text = 0
tblSQL.Filter("")
tblSQL.Filter("Sec1Dept = '" & Detttp & "' AND FORMStatus = 'Rejected'")
lblRjc.Text = tblSQL.RowCount
End If
If Tttype = "X" Then
tblSQL.Filter("")
tblSQL.Filter("FORMStatus = 'ToSafety'")
lblRv.Text = tblSQL.RowCount
lblRjc.Text = 0
End If
If Tttype = "N" Then
tblSQL.Filter("")
tblSQL.Filter("FORMStatus = 'AcceptedToNurse'")
lblRv.Text = tblSQL.RowCount
lblRjc.Text = 0
End If
If lblRv.Text > 0 OR lblRjc.Text > 0 Then
obj.SetProperty("Visible",True)
lblDpt.Text = "Dept: " & Detttp
End If
'StartProcess_Do
Return
GottoEx:
'StartProcess_Do
End Sub