Dim firstLine As Int32
Dim lastLine As Int32
Dim numLines As Int32
Dim numDisplayedLines As Int16
Dim displayedQueueText As StringPrivate Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
DiplayActivityLog(sender, e, lastLine, numDisplayedLines)
DisplayQueue()
DisplayDisables()
End SubPrivate Sub DiplayActivityLog(ByVal sender As System.Object, ByVal e As System.EventArgs, ByRef lastLine As Int32, ByRef numDisplayedLines As Int16)
Dim sqlQueryConnection As New SqlConnection(MIISSYNC_CONNECTION_STRING)
Dim rowReader As SqlDataReader
Dim countLines As Int16 = 0
Dim dbLastLine As Int32
sqlQueryConnection.Open()
Dim lastentryQuery As New SqlCommand(“select top 1 item from ” & ACTIVITY_LOG & ” order by item desc”, sqlQueryConnection)
rowReader = lastentryQuery.ExecuteReader
While rowReader.Read()
dbLastLine = rowReader.GetInt32(0)
End While
rowReader.Close()
If dbLastLine > lastLine Then
If numDisplayedLines > 0 AndAlso numDisplayedLines < MAX_DISPLAY_LINES Then
Dim sqlQuery As New SqlCommand(“select * from ” & ACTIVITY_LOG & ” where item > ” & lastLine & ” order by item”, sqlQueryConnection)
rowReader = sqlQuery.ExecuteReader
While rowReader.Read()
DisplayLogLine(sender, e, countLines, rowReader)
End While
rowReader.Close()
numDisplayedLines = numDisplayedLines + countLines
Me.RTB_Log.SelectionLength = 0
Me.RTB_Log.SelectionStart = Me.RTB_Log.Text.Length
Me.RTB_Log.ScrollToCaret()
Else
Me.RTB_Log.Clear()
Dim sqlQuery As New SqlCommand(“select * from ” & ACTIVITY_LOG & ” where item > ” & dbLastLine – MIN_DISPLAY_LINES & ” order by item”, sqlQueryConnection)
rowReader = sqlQuery.ExecuteReader
While rowReader.Read()
DisplayLogLine(sender, e, countLines, rowReader)
End While
rowReader.Close()
numDisplayedLines = countLines
Me.RTB_Log.SelectionLength = 0
Me.RTB_Log.SelectionStart = Me.RTB_Log.Text.Length
Me.RTB_Log.ScrollToCaret()
End If
End If
sqlQueryConnection.Close()
End Sub
Private Sub DisplayLogLine(ByVal sender As System.Object, ByVal e As System.EventArgs, ByRef countLines As Int32, ByVal lines As SqlDataReader)
Dim strLogLine As String = lines.GetString(2)
Me.RTB_Log.AppendText((lines.GetString(1) & “, ” & strLogLine) & vbCrLf)
If strLogLine.IndexOf(“warning”) > 0 Then
RTB_Log.Find(strLogLine)
RTB_Log.SelectionColor() = System.Drawing.Color.Orange
ElseIf strLogLine.IndexOf(“error”) > 0 Or strLogLine.IndexOf(“failed”) > 0 Or strLogLine.IndexOf(“stopped”) > 0 Then
RTB_Log.Find(strLogLine)
RTB_Log.SelectionColor() = System.Drawing.Color.Red
Else
RTB_Log.Find(strLogLine)
RTB_Log.SelectionColor() = System.Drawing.Color.Black
End If
lastLine = lines.GetInt32(0)
countLines = countLines + 1
End Sub
Private Sub DisplayQueue()
Dim sqlQueryConnection As New SqlConnection(MIISSYNC_CONNECTION_STRING)
Dim rowReader As SqlDataReader
Dim newQueueText As String
sqlQueryConnection.Open()
Dim queueQuery As New SqlCommand(“select * from ” & QUEUE & ” order by priority”, sqlQueryConnection)
rowReader = queueQuery.ExecuteReader
While rowReader.Read()
newQueueText = newQueueText & rowReader.GetString(0) & “, ” & rowReader.GetString(1) & vbCrLf
End While
If newQueueText <> displayedQueueText Then
Me.Txt_Queue.Clear()
Me.Txt_Queue.AppendText(newQueueText)
displayedQueueText = newQueueText
End If
rowReader.Close()
sq lQueryConnection.Close()
End Sub
Private Sub DisplayDisables()
Dim sqlQueryConnection As New SqlConnection(MIISSYNC_CONNECTION_STRING)
Dim rowReader As SqlDataReader
sqlQueryConnection.Open()
Dim sqlQuery As New SqlCommand(“select uid,status, archive_status from ” & DISABLES & ” where archive_status <> ‘done’”, sqlQueryConnection)
rowReader = sqlQuery.ExecuteReader
Me.Txt_Disables.Clear()
While rowReader.Read()
Me.Txt_Disables.AppendText(rowReader.GetString(0) & “, ” & rowReader.GetString(1) & “, ” & rowReader.GetString(2) & vbCrLf)
End While
rowReader.Close()
sqlQueryConnection.Close()
End Sub