Hello! I'm currently running in to an issue where I need to loop through a specific log file until a string of text occurs, which indiciates that I can continue on with the application. Here is my code and logic:
Dim process As New Process()
Dim serverLog As String
Dim instance As String
Dim server As String
Dim list As New ArrayList()
server = cmdTextbox1.Text
instance = cmdInstance.Text
Dim rdsLog As String = "\\" & server & "\c$\rds\server\" & instance & "\log\server.log"
Dim i As Integer
Dim ItemList As New ArrayList()
process.StartInfo.UseShellExecute = False
process.StartInfo.RedirectStandardOutput = True
process.StartInfo.RedirectStandardError = True
process.StartInfo.CreateNoWindow = True
process.StartInfo.FileName = FileName
process.StartInfo.Arguments = Arguments
process.Start()
Dim output As String = process.StandardOutput.ReadToEnd()
serverLog = output
Dim resultQuery As String
Dim query As String = "select count(*) from " & rdsLog & " where text like '%Server has been started in Online Mode%'"
Dim parser As New LogQueryClass
Dim rsLp As ILogRecordset
Dim rowLp As ILogRecord
resultQuery = 0
Do While resultQuery = 0
rsLp = parser.Execute(query)
Do While Not rsLp.atEnd
rowLp = rsLp.getRecord
ItemList.Add(rowLp.getValue(i))
rsLp.moveNext()
Loop
rsLp.close()
resultQuery = ItemList(i)
Loop
If resultQuery = 0 Then
MsgBox("Not started")
Else
MsgBox(" " & server & "\" & instance & " has STARTED")
End If
This works fine if the logfile already contains the string of text, however it's not re-iterating through the recordset to check and see if that value exists. There is probably a much simpler way to accomplish this. Thank you for your time!