最佳爬log

Imports System.IO
Module Module1

Public Structure NewRmsLog
Public TimeOne As String
Public TimeTwo As String
Public TimeThree As String
Public TimeFour As String
Public ProcessId As String
Public ThreadId As Integer
Public TraceId As Integer
Public IpAddress As String
Public PortNumber As Integer
Public ServerHostName As String
Public ServerName As String
Public KeyId As String
Public TxName As String
End Structure
Sub Main()
Using sr As New StreamReader("G:\RMS_LOG.log")
Using sw As New StreamWriter("test.csv")
Dim line As String = 1
Dim i As Integer = 0
Dim t As Integer = 0
Dim x As Integer = 1
Dim test As Boolean = True
Dim MyArray(100000) As NewRmsLog

line = sr.ReadLine
Dim a() As String = Split(line, "|")

MyArray(x).TxName = a(9)
MyArray(x).ProcessId = a(1)
MyArray(x).ThreadId = a(2)
MyArray(x).TraceId = a(3)
MyArray(x).IpAddress = a(4)
MyArray(x).PortNumber = a(5)
MyArray(x).ServerHostName = a(6)
MyArray(x).ServerName = a(7)
MyArray(x).KeyId = a(8)
MyArray(x).TimeOne = a(0)

While (line <> Nothing)

line = sr.ReadLine
If line = Nothing Then
Exit While
End If
Dim b() As String = Split(line, "|")

'MyArray(x).TxName = b(9)
'MyArray(x).ProcessId = b(1)
'MyArray(x).ThreadId = b(2)
'MyArray(x).TraceId = b(3)
'MyArray(x).IpAddress = b(4)
'MyArray(x).PortNumber = b(5)
'MyArray(x).ServerHostName = b(6)
'MyArray(x).ServerName = b(7)
'MyArray(x).KeyId = b(8)

If b(9) = MyArray(x).TxName And b(2) = MyArray(x).ThreadId Then

If test = True Then
MyArray(x).TxName = b(9)
MyArray(x).ProcessId = b(1)
MyArray(x).ThreadId = b(2)
MyArray(x).TraceId = b(3)
MyArray(x).IpAddress = b(4)
MyArray(x).PortNumber = b(5)
MyArray(x).ServerHostName = b(6)
MyArray(x).ServerName = b(7)
MyArray(x).KeyId = b(8)
ElseIf test = False Then
MyArray(t).TxName = b(9)
MyArray(t).ProcessId = b(1)
MyArray(t).ThreadId = b(2)
MyArray(t).TraceId = b(3)
MyArray(t).IpAddress = b(4)
MyArray(t).PortNumber = b(5)
MyArray(t).ServerHostName = b(6)
MyArray(t).ServerName = b(7)
MyArray(t).KeyId = b(8)
End If


If MyArray(x).TraceId = 2 Then
MyArray(x).TimeTwo = b(0)
ElseIf MyArray(x).TraceId = 3 Then
If test = False Then
MyArray(t).TimeFour = b(0)
sw.WriteLine(MyArray(t).TxName & "," & MyArray(t).ProcessId & "," & MyArray(t).ThreadId & "," & MyArray(t).TraceId & "," & MyArray(t).IpAddress & "," & MyArray(t).PortNumber & "," & MyArray(t).ServerHostName & "," & MyArray(t).ServerName & "," & MyArray(t).TimeOne & "," & MyArray(t).TimeTwo & "," & MyArray(t).TimeThree & "," & MyArray(t).TimeFour)
ElseIf test = True Then
MyArray(x).TimeThree = b(0)
End If
ElseIf MyArray(x).TraceId = 4 Then
If test = False Then
MyArray(t).TimeFour = b(0)
ElseIf test = True Then
MyArray(x).TimeFour = b(0)
End If
sw.WriteLine(MyArray(x).TxName & "," & MyArray(x).ProcessId & "," & MyArray(x).ThreadId & "," & MyArray(x).TraceId & "," & MyArray(x).IpAddress & "," & MyArray(x).PortNumber & "," & MyArray(x).ServerHostName & "," & MyArray(x).ServerName & "," & MyArray(x).TimeOne & "," & MyArray(x).TimeTwo & "," & MyArray(x).TimeThree & "," & MyArray(x).TimeFour)
End If
End If
test = True
If b(9) <> MyArray(x).TxName Or b(2) <> MyArray(x).ThreadId Then

If b(3) = 2 Then
't = x

t = x - 1
MyArray(x).TimeThree = b(0)

For i = 0 To x - 2
t -= 1
If MyArray(t).TxName = b(9) And MyArray(t).ThreadId = b(2) Then
MyArray(t).TimeTwo = b(0)
test = False
Exit For

End If
Next

'For i = 0 To x - 1
' t -= 1
' If MyArray(t).TxName = b(9) And MyArray(t).ThreadId = b(2) Then
' MyArray(t).TimeTwo = b(0)
' Exit For
' End If
'Next
End If

If b(3) = 3 Then
x += 1
t = x - 1
MyArray(x).TimeThree = b(0)

For i = 0 To x - 2
t -= 1
If MyArray(t).TxName = b(9) And MyArray(t).ThreadId = b(2) Then
MyArray(t).TimeThree = b(0)
test = False
Exit For

End If
Next
'MyArray(x).TimeThree = b(0)

End If

If b(3) = 4 Then
x += 1
t = x - 1
For i = 0 To x - 2
t -= 1
If MyArray(t).TxName = b(9) And MyArray(t).ThreadId = b(2) Then
MyArray(t).TimeFour = b(0)
test = False
Exit For
End If
Next
If test = False Then
sw.WriteLine(MyArray(t).TxName & "," & MyArray(t).ProcessId & "," & MyArray(t).ThreadId & "," & MyArray(t).TraceId & "," & MyArray(t).IpAddress & "," & MyArray(t).PortNumber & "," & MyArray(t).ServerHostName & "," & MyArray(t).ServerName & "," & MyArray(t).TimeOne & "," & MyArray(t).TimeTwo & "," & MyArray(t).TimeThree & "," & MyArray(t).TimeFour)
End If
End If

If b(3) = 1 Then
x += 1
MyArray(x).TimeOne = b(0)
End If
'If b(3) = 3 Then
' MyArray(x).TimeThree = b(0)
'End If
'If test = True Then
MyArray(x).TxName = b(9)
MyArray(x).ProcessId = b(1)
MyArray(x).ThreadId = b(2)
MyArray(x).TraceId = b(3)
MyArray(x).IpAddress = b(4)
MyArray(x).PortNumber = b(5)
MyArray(x).ServerHostName = b(6)
MyArray(x).ServerName = b(7)
MyArray(x).KeyId = b(8)
'ElseIf test = False Then
' MyArray(t).TxName = b(9)
' MyArray(t).ProcessId = b(1)
' MyArray(t).ThreadId = b(2)
' MyArray(t).TraceId = b(3)
' MyArray(t).IpAddress = b(4)
' MyArray(t).PortNumber = b(5)
' MyArray(t).ServerHostName = b(6)
' MyArray(t).ServerName = b(7)
' MyArray(t).KeyId = b(8)
'End If
'MyArray(x).TimeOne = b(0)

'If b(3) = 1 Then
' MyArray(x).TimeOne = b(0)
'End If
'If b(3) = 3 Then
' MyArray(x).TimeThree = b(0)
'End If

End If
End While
'For x = 0 To 100000
' line = sr.ReadLine
' Dim a() As String = Split(line, "|")
' line = sr.ReadLine
' Dim b() As String = Split(line, "|")

' If line = Nothing Then Thenm
' Exit For
' End If

' If MyArray(x).ThreadId = MyArray(x - 1).ThreadId And MyArray(x).TxName = MyArray(x - 1).TxName Then
' If a(3) = 1 Then
' MyArray(x).TxName = a(9)
' MyArray(x).ProcessId = a(1)
' MyArray(x).ThreadId = a(2)
' MyArray(x).TraceId = a(3)
' MyArray(x).IpAddress = a(4)
' MyArray(x).PortNumber = a(5)
' MyArray(x).ServerHostName = a(6)
' MyArray(x).ServerName = a(7)
' MyArray(x).KeyId = a(8)
' MyArray(x).TimeOne = a(0)
' If a(3) = 2 Then
' MyArray(x).TimeTwo = a(0)
' End If
' If a(3) = 3 Then
' MyArray(x).TimeThree = a(0)
' End If
' If a(3) = 4 Then
' MyArray(x).TimeFour = a(0)
' sw.WriteLine(MyArray(x).TxName & "," & MyArray(x).ProcessId & "," & MyArray(x).ThreadId & "," & MyArray(x).TraceId & "," & MyArray(x).IpAddress & "," & MyArray(x).PortNumber & "," & MyArray(x).ServerHostName & "," & MyArray(x).ServerName & "," & MyArray(x).TimeOne & "," & MyArray(x).TimeTwo & "," & MyArray(x).TimeThree & "," & MyArray(x).TimeFour & "," &)
' 5End If
' End If
' ElseIf MyArray(x).ThreadId <> MyArray(x - 1).ThreadId And MyArray(x).TxName <> MyArray(x - 1).TxName Then

' End If
' 'For i = 0 To 9
' ' Select Case i
' ''
' ' Case 1
' ' MyArray(x).ProcessId = a(i)
' ' Case 2
' ' MyArray(x).ThreadId = a(i)
' ' Case 3
' ' MyArray(x).TraceId = a(i)
' ' If a(i) = 1 Then
' ' MyArray(x).TimeOne = a(0)
' ' ElseIf a(i) = 2 Then
' ' MyArray(x).TimeTwo = a(0)
' ' ElseIf a(i) = 3 Then
' ' MyArray(x).TimeThree = a(0)
' ' ElseIf a(i) = 4 Then
' ' MyArray(x).TimeFour = a(0)
' ' End If
' ' Case 4
' ' MyArray(x).IpAddress = a(i)
' ' Case 5
' ' MyArray(x).PortNumber = a(i)
' ' Case 6
' ' MyArray(x).ServerHostName = a(i)
' ' Case 7
' ' MyArray(x).ServerName = a(i)
' ' Case 8
' ' MyArray(x).KeyId = a(i)
' ' Case 9
' ' MyArray(x).TxName = a(i)

' ' End Select
'Next

 

'For i = 0 To 9
' Select Case i
' 'Case 0
' ' MyArray(x).TimeOne = a(i)
' Case 1
' MyArray(x).ProcessId = a(i)
' Case 2
' MyArray(x).ThreadId = a(i)
' Case 3
' MyArray(x).TraceId = a(i)
' If a(i) = 1 Then
' MyArray(x).TimeOne = a(0)
' ElseIf a(i) = 2 Then
' MyArray(x).TimeTwo = a(0)
' ElseIf a(i) = 3 Then
' MyArray(x).TimeThree = a(0)
' ElseIf a(i) = 4 Then
' MyArray(x).TimeFour = a(0)
' End If
' Case 4
' MyArray(x).IpAddress = a(i)
' Case 5
' MyArray(x).PortNumber = a(i)
' Case 6
' MyArray(x).ServerHostName = a(i)
' Case 7
' MyArray(x).ServerName = a(i)
' Case 8
' MyArray(x).KeyId = a(i)
' Case 9
' MyArray(x).TxName = a(i)

' End Select
'Next

 

'Console.WriteLine(MyArray(0).TxName)
'Console.ReadLine()


End Using
End Using

End Sub

End Module

posted @ 2021-01-29 04:46  最云间  阅读(56)  评论(0)    收藏  举报