Skip to content

Commit

Permalink
Deleted unnesessary parse function. Minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Bochkov committed Jan 11, 2017
1 parent c6a9ed6 commit a4fdd3b
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 196 deletions.
58 changes: 31 additions & 27 deletions EventLogLoaderManager/ServiceDescriptionClass.vb
Original file line number Diff line number Diff line change
Expand Up @@ -182,55 +182,59 @@ Public Class ServiceDescriptionClass
Dim Text = My.Computer.FileSystem.ReadAllText(TMP)
My.Computer.FileSystem.DeleteFile(TMP)

Dim Array = ParserServices.ParseString(Text)

Dim i = 0

For Each a In Array
If Not a Is Nothing Then
If a.Length = 11 And a(0).StartsWith("1.2.") Then
Dim ClusterSetting = ParserServices.ParseEventLogString(Text)

Dim DatabaseSettings = ParserServices.ParseEventLogString(ClusterSetting(2)) 'third element contains all database descriptions

For Each Row2 As String In DatabaseSettings

Dim IB = New Infobases
IB.Name = a(2).ToString
IB.GUID = a(1).ToString
IB.Description = a(3).ToString
IB.SizeEventLog = 0
If Row2.StartsWith("{") Then
'this is an infobase description
Dim DatabaseDescription = ParserServices.ParseEventLogString(Row2)

Try
Dim IB = New Infobases
IB.Name = DatabaseDescription(1).ToString
IB.GUID = DatabaseDescription(0).ToString
IB.Description = DatabaseDescription(2).ToString
IB.SizeEventLog = 0

Dim SizeLog As UInt64 = 0
Dim CatalogEventLog = Path.Combine(Path.Combine(Catalog, IB.GUID), "1Cv8Log\")
Try

IB.CatalogEventLog = CatalogEventLog
Dim SizeLog As UInt64 = 0
Dim CatalogEventLog = Path.Combine(Path.Combine(Catalog, IB.GUID), "1Cv8Log\")

If My.Computer.FileSystem.DirectoryExists(CatalogEventLog) Then
IB.CatalogEventLog = CatalogEventLog

If My.Computer.FileSystem.DirectoryExists(CatalogEventLog) Then


For Each File In My.Computer.FileSystem.GetFiles(CatalogEventLog)
Dim FI = My.Computer.FileSystem.GetFileInfo(File)
SizeLog = SizeLog + FI.Length
Next

IB.SizeEventLog = Math.Round(SizeLog / 1024 / 1024, 2)
For Each File In My.Computer.FileSystem.GetFiles(CatalogEventLog)
Dim FI = My.Computer.FileSystem.GetFileInfo(File)
SizeLog = SizeLog + FI.Length
Next

End If
IB.SizeEventLog = Math.Round(SizeLog / 1024 / 1024, 2)

Catch ex As Exception
End If

End Try
Catch ex As Exception

ReDim Preserve ArrayInfobases(i)
ArrayInfobases(i) = IB
End Try

i = i + 1
ReDim Preserve ArrayInfobases(i)
ArrayInfobases(i) = IB

i = i + 1

End If
End If

Next



System.Array.Sort(ArrayInfobases)

Catch ex As Exception
Expand Down
89 changes: 76 additions & 13 deletions EventLogLoaderService/EventLogProcessor.vb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ Public Class EventLogProcessor
Usr.Name = Name
Usr.Guid = Guid

'reference file in old evenlog format may contain duplicated values when object description has been changed (for example, user renamed)
If DictUsers.ContainsKey(Code) Then
DictUsers.Remove(Code)
End If

DictUsers.Add(Code, Usr)

End Sub
Expand Down Expand Up @@ -97,6 +102,11 @@ Public Class EventLogProcessor
MD.Name = Name
MD.Guid = Guid

'reference file in old evenlog format may contain duplicated values when object description has been changed (for example, user renamed)
If DictMetadata.ContainsKey(Code) Then
DictMetadata.Remove(Code)
End If

DictMetadata.Add(Code, MD)

End Sub
Expand Down Expand Up @@ -921,6 +931,8 @@ Public Class EventLogProcessor
DictMainPorts.Clear()
DictSecondPorts.Clear()

Dim LastProcessedObjectForDebug As String = ""

Try
Dim FileName = Path.Combine(Catalog, "1Cv8.lgf")

Expand All @@ -940,29 +952,34 @@ Public Class EventLogProcessor
SR.Close()
FS.Close()

Text = Text.Substring(Text.IndexOf("{"))

Dim ArrayLines = ParserServices.ParseString(Text)
Dim ObjectTexts = ParserServices.ParseEventlogString("{" + Text + "}")

For Each TextObject In ObjectTexts

LastProcessedObjectForDebug = TextObject

Dim a = ParserServices.ParseEventlogString(TextObject)

Dim i = 0
For Each a In ArrayLines
If Not a Is Nothing Then
Select Case a(1)
Select Case a(0)
Case "1"
AddUser(Convert.ToInt32(a(4)), a(2), a(3))
AddUser(Convert.ToInt32(a(3)), a(1), a(2))
Case "2"
AddComputer(Convert.ToInt32(a(3)), a(2))
AddComputer(Convert.ToInt32(a(2)), a(1))
Case "3"
AddApplication(Convert.ToInt32(a(3)), a(2))
AddApplication(Convert.ToInt32(a(2)), a(1))
Case "4"
AddEvent(Convert.ToInt32(a(3)), a(2))
AddEvent(Convert.ToInt32(a(2)), a(1))
Case "5"
AddMetadata(Convert.ToInt32(a(4)), a(2), a(3))
AddMetadata(Convert.ToInt32(a(3)), a(1), a(2))
Case "6"
AddServer(Convert.ToInt32(a(3)), a(2))
AddServer(Convert.ToInt32(a(2)), a(1))
Case "7"
AddMainPort(Convert.ToInt32(a(3)), a(2))
AddMainPort(Convert.ToInt32(a(2)), a(1))
Case "8"
AddSecondPort(Convert.ToInt32(a(3)), a(2))
AddSecondPort(Convert.ToInt32(a(2)), a(1))
'Case "9" - не видел этих в файле
'Case "10"
Case "11"
Expand All @@ -974,15 +991,61 @@ Public Class EventLogProcessor
End Select

End If



Next


'Dim ArrayLines = ParserServices.ParseString(Text)

'Dim i = 0
'For Each a In ArrayLines
' If Not a Is Nothing Then
' Select Case a(1)
' Case "1"
' AddUser(Convert.ToInt32(a(4)), a(2), a(3))
' Case "2"
' AddComputer(Convert.ToInt32(a(3)), a(2))
' Case "3"
' AddApplication(Convert.ToInt32(a(3)), a(2))
' Case "4"
' AddEvent(Convert.ToInt32(a(3)), a(2))
' Case "5"
' AddMetadata(Convert.ToInt32(a(4)), a(2), a(3))
' Case "6"
' AddServer(Convert.ToInt32(a(3)), a(2))
' Case "7"
' AddMainPort(Convert.ToInt32(a(3)), a(2))
' Case "8"
' AddSecondPort(Convert.ToInt32(a(3)), a(2))
' 'Case "9" - не видел этих в файле
' 'Case "10"
' Case "11"
' Case "12"
' Case "13"
' 'в числе последних трех должны быть статус транзакции и важность
' Case Else

' End Select

' End If
'Next

SaveReferenceValuesToDatabase()

End If

End If
Catch ex As Exception
Log.Error(ex, "Error occurred while working with reference file")

Dim AdditionalString = ""
If Not String.IsNullOrEmpty(LastProcessedObjectForDebug) Then
AdditionalString = "Attempted to process this object: " + LastProcessedObjectForDebug
End If

Log.Error(ex, "Error occurred while working with reference file. " + AdditionalString)

End Try


Expand Down
Loading

0 comments on commit a4fdd3b

Please sign in to comment.