mirror of
https://github.com/romanlryji/EventLogLoader.git
synced 2024-11-24 08:32:52 +02:00
custom names for ES fielnds
This commit is contained in:
parent
0aa1e0a51d
commit
d857ca7f12
45
EventLogLoaderManager/Form1.Designer.vb
generated
45
EventLogLoaderManager/Form1.Designer.vb
generated
@ -1,9 +1,9 @@
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
|
||||
Partial Class Form1
|
||||
Inherits System.Windows.Forms.Form
|
||||
|
||||
'Форма переопределяет dispose для очистки списка компонентов.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
<System.Diagnostics.DebuggerNonUserCode()>
|
||||
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
Try
|
||||
If disposing AndAlso components IsNot Nothing Then
|
||||
@ -20,7 +20,7 @@ Partial Class Form1
|
||||
'Примечание: следующая процедура является обязательной для конструктора форм Windows Forms
|
||||
'Для ее изменения используйте конструктор форм Windows Form.
|
||||
'Не изменяйте ее в редакторе исходного кода.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
<System.Diagnostics.DebuggerStepThrough()>
|
||||
Private Sub InitializeComponent()
|
||||
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
|
||||
Me.ListView = New System.Windows.Forms.ListView()
|
||||
@ -49,6 +49,8 @@ Partial Class Form1
|
||||
Me.LinkLabel1 = New System.Windows.Forms.LinkLabel()
|
||||
Me.LinkLabel3 = New System.Windows.Forms.LinkLabel()
|
||||
Me.Label5 = New System.Windows.Forms.Label()
|
||||
Me.UseSynonymsForFieldsNamesCheckBox = New System.Windows.Forms.CheckBox()
|
||||
Me.Label6 = New System.Windows.Forms.Label()
|
||||
Me.GroupBox1.SuspendLayout()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
@ -61,7 +63,7 @@ Partial Class Form1
|
||||
Me.ListView.GridLines = True
|
||||
Me.ListView.Location = New System.Drawing.Point(3, 20)
|
||||
Me.ListView.Name = "ListView"
|
||||
Me.ListView.Size = New System.Drawing.Size(744, 327)
|
||||
Me.ListView.Size = New System.Drawing.Size(746, 327)
|
||||
Me.ListView.TabIndex = 1
|
||||
Me.ListView.UseCompatibleStateImageBehavior = False
|
||||
Me.ListView.View = System.Windows.Forms.View.Details
|
||||
@ -107,7 +109,7 @@ Partial Class Form1
|
||||
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
|
||||
Me.ConnectionStringBox.Location = New System.Drawing.Point(123, 24)
|
||||
Me.ConnectionStringBox.Name = "ConnectionStringBox"
|
||||
Me.ConnectionStringBox.Size = New System.Drawing.Size(525, 20)
|
||||
Me.ConnectionStringBox.Size = New System.Drawing.Size(527, 20)
|
||||
Me.ConnectionStringBox.TabIndex = 2
|
||||
'
|
||||
'Label1
|
||||
@ -124,7 +126,7 @@ Partial Class Form1
|
||||
'Button4
|
||||
'
|
||||
Me.Button4.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
|
||||
Me.Button4.Location = New System.Drawing.Point(654, 24)
|
||||
Me.Button4.Location = New System.Drawing.Point(656, 24)
|
||||
Me.Button4.Name = "Button4"
|
||||
Me.Button4.Size = New System.Drawing.Size(75, 23)
|
||||
Me.Button4.TabIndex = 4
|
||||
@ -148,7 +150,7 @@ Partial Class Form1
|
||||
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
|
||||
Me.ESIndexNameTextBox.Location = New System.Drawing.Point(449, 74)
|
||||
Me.ESIndexNameTextBox.Name = "ESIndexNameTextBox"
|
||||
Me.ESIndexNameTextBox.Size = New System.Drawing.Size(199, 20)
|
||||
Me.ESIndexNameTextBox.Size = New System.Drawing.Size(156, 20)
|
||||
Me.ESIndexNameTextBox.TabIndex = 9
|
||||
'
|
||||
'DBType
|
||||
@ -183,7 +185,7 @@ Partial Class Form1
|
||||
Me.GroupBox1.ForeColor = System.Drawing.Color.Maroon
|
||||
Me.GroupBox1.Location = New System.Drawing.Point(4, 100)
|
||||
Me.GroupBox1.Name = "GroupBox1"
|
||||
Me.GroupBox1.Size = New System.Drawing.Size(750, 350)
|
||||
Me.GroupBox1.Size = New System.Drawing.Size(752, 350)
|
||||
Me.GroupBox1.TabIndex = 5
|
||||
Me.GroupBox1.TabStop = False
|
||||
Me.GroupBox1.Text = "Обнаруженные информационные базы 1С"
|
||||
@ -257,7 +259,7 @@ Partial Class Form1
|
||||
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
|
||||
Me.RepeatTime.Location = New System.Drawing.Point(449, 49)
|
||||
Me.RepeatTime.Name = "RepeatTime"
|
||||
Me.RepeatTime.Size = New System.Drawing.Size(199, 20)
|
||||
Me.RepeatTime.Size = New System.Drawing.Size(156, 20)
|
||||
Me.RepeatTime.TabIndex = 2
|
||||
'
|
||||
'Label4
|
||||
@ -274,7 +276,7 @@ Partial Class Form1
|
||||
'
|
||||
Me.LinkLabel2.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
|
||||
Me.LinkLabel2.AutoSize = True
|
||||
Me.LinkLabel2.Location = New System.Drawing.Point(660, 530)
|
||||
Me.LinkLabel2.Location = New System.Drawing.Point(662, 530)
|
||||
Me.LinkLabel2.Name = "LinkLabel2"
|
||||
Me.LinkLabel2.Size = New System.Drawing.Size(102, 13)
|
||||
Me.LinkLabel2.TabIndex = 20
|
||||
@ -313,11 +315,30 @@ Partial Class Form1
|
||||
Me.Label5.TabIndex = 22
|
||||
Me.Label5.Text = "Исходные коды (по GPL лицензии):"
|
||||
'
|
||||
'UseSynonymsForFieldsNamesCheckBox
|
||||
'
|
||||
Me.UseSynonymsForFieldsNamesCheckBox.AutoSize = True
|
||||
Me.UseSynonymsForFieldsNamesCheckBox.Location = New System.Drawing.Point(611, 77)
|
||||
Me.UseSynonymsForFieldsNamesCheckBox.Name = "UseSynonymsForFieldsNamesCheckBox"
|
||||
Me.UseSynonymsForFieldsNamesCheckBox.Size = New System.Drawing.Size(15, 14)
|
||||
Me.UseSynonymsForFieldsNamesCheckBox.TabIndex = 23
|
||||
Me.UseSynonymsForFieldsNamesCheckBox.UseVisualStyleBackColor = True
|
||||
'
|
||||
'Label6
|
||||
'
|
||||
Me.Label6.Location = New System.Drawing.Point(632, 72)
|
||||
Me.Label6.Name = "Label6"
|
||||
Me.Label6.Size = New System.Drawing.Size(117, 27)
|
||||
Me.Label6.TabIndex = 24
|
||||
Me.Label6.Text = "Использовать свои имена полей"
|
||||
'
|
||||
'Form1
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(766, 547)
|
||||
Me.ClientSize = New System.Drawing.Size(768, 547)
|
||||
Me.Controls.Add(Me.Label6)
|
||||
Me.Controls.Add(Me.UseSynonymsForFieldsNamesCheckBox)
|
||||
Me.Controls.Add(Me.Label5)
|
||||
Me.Controls.Add(Me.Label4)
|
||||
Me.Controls.Add(Me.LinkLabel2)
|
||||
@ -372,4 +393,6 @@ Partial Class Form1
|
||||
Friend WithEvents LinkLabel1 As LinkLabel
|
||||
Friend WithEvents LinkLabel3 As LinkLabel
|
||||
Friend WithEvents Label5 As Label
|
||||
Friend WithEvents UseSynonymsForFieldsNamesCheckBox As CheckBox
|
||||
Friend WithEvents Label6 As Label
|
||||
End Class
|
||||
|
@ -33,10 +33,73 @@ Public Class Form1
|
||||
End If
|
||||
End If
|
||||
|
||||
'Check synonyms list
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.Application) Then
|
||||
ConfigSetting.ESFieldSynonyms.Application = "Приложение"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.Comment) Then
|
||||
ConfigSetting.ESFieldSynonyms.Comment = "Комментарий"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.Computer) Then
|
||||
ConfigSetting.ESFieldSynonyms.Computer = "Компьютер"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.ConnectID) Then
|
||||
ConfigSetting.ESFieldSynonyms.ConnectID = "НомерСоединения"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.DatabaseName) Then
|
||||
ConfigSetting.ESFieldSynonyms.DatabaseName = "ИнформационнаяБаза"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.DataString) Then
|
||||
ConfigSetting.ESFieldSynonyms.DataString = "ПредставлениеДанных"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.DataStructure) Then
|
||||
ConfigSetting.ESFieldSynonyms.DataStructure = "СтруктураДанных"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.DataType) Then
|
||||
ConfigSetting.ESFieldSynonyms.DataType = "ТипДанных"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.DateTime) Then
|
||||
ConfigSetting.ESFieldSynonyms.DateTime = "ДатаВремя"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.EventType) Then
|
||||
ConfigSetting.ESFieldSynonyms.EventType = "ТипСобытия"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.Metadata) Then
|
||||
ConfigSetting.ESFieldSynonyms.Metadata = "Метаданные"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.PrimaryPort) Then
|
||||
ConfigSetting.ESFieldSynonyms.PrimaryPort = "ОсновнойПорт"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.RowID) Then
|
||||
ConfigSetting.ESFieldSynonyms.RowID = "НомерСтроки"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.SecondaryPort) Then
|
||||
ConfigSetting.ESFieldSynonyms.SecondaryPort = "ВторичныйПорт"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.Server) Then
|
||||
ConfigSetting.ESFieldSynonyms.Server = "СерверПриложений"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.ServerName) Then
|
||||
ConfigSetting.ESFieldSynonyms.ServerName = "Сервер1С"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.SessionDataSplitCode) Then
|
||||
ConfigSetting.ESFieldSynonyms.SessionDataSplitCode = "Разделитель"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.SessionNumber) Then
|
||||
ConfigSetting.ESFieldSynonyms.SessionNumber = "НомерСессии"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.Severity) Then
|
||||
ConfigSetting.ESFieldSynonyms.Severity = "УровеньСобытия"
|
||||
End If
|
||||
If String.IsNullOrEmpty(ConfigSetting.ESFieldSynonyms.UserName) Then
|
||||
ConfigSetting.ESFieldSynonyms.UserName = "ИмяПользователя"
|
||||
End If
|
||||
|
||||
ConnectionStringBox.Text = ConfigSetting.ConnectionString
|
||||
DBType.Text = ConfigSetting.DBType
|
||||
RepeatTime.Text = ConfigSetting.RepeatTime.ToString
|
||||
ESIndexNameTextBox.Text = ConfigSetting.ESIndexName
|
||||
UseSynonymsForFieldsNamesCheckBox.Checked = ConfigSetting.ESUseSynonymsForFieldsNames
|
||||
|
||||
End Sub
|
||||
|
||||
@ -74,10 +137,10 @@ Public Class Form1
|
||||
|
||||
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
|
||||
|
||||
Dim ConfigSetting = New ConfigSetting
|
||||
ConfigSetting.ConnectionString = ConnectionStringBox.Text.Trim
|
||||
ConfigSetting.DBType = DBType.Text.Trim
|
||||
ConfigSetting.ESIndexName = ESIndexNameTextBox.Text
|
||||
Dim NewConfigSetting = New ConfigSetting
|
||||
NewConfigSetting.ConnectionString = ConnectionStringBox.Text.Trim
|
||||
NewConfigSetting.DBType = DBType.Text.Trim
|
||||
NewConfigSetting.ESIndexName = ESIndexNameTextBox.Text
|
||||
|
||||
For Each Item As ListViewItem In ListView.Items
|
||||
If Item.Checked Then
|
||||
@ -88,16 +151,18 @@ Public Class Form1
|
||||
IBSetting.DatabaseCatalog = Item.SubItems(4).Text
|
||||
IBSetting.ESServerName = Item.SubItems(5).Text
|
||||
|
||||
ConfigSetting.Infobases.Add(IBSetting)
|
||||
NewConfigSetting.Infobases.Add(IBSetting)
|
||||
|
||||
End If
|
||||
Next
|
||||
|
||||
NewConfigSetting.ESUseSynonymsForFieldsNames = UseSynonymsForFieldsNamesCheckBox.Checked
|
||||
NewConfigSetting.ESFieldSynonyms = ConfigSetting.ESFieldSynonyms
|
||||
|
||||
Dim Rep = Convert.ToInt32(RepeatTime.Text)
|
||||
|
||||
ConfigSetting.RepeatTime = IIf(Rep = 0, 60, Rep)
|
||||
ConfigSettingsModule.SaveConfigSettingToFile(ConfigSetting, PathConfigFile)
|
||||
NewConfigSetting.RepeatTime = IIf(Rep = 0, 60, Rep)
|
||||
ConfigSettingsModule.SaveConfigSettingToFile(NewConfigSetting, PathConfigFile)
|
||||
|
||||
|
||||
Dim sc = New System.ServiceProcess.ServiceController("EventLog loader service")
|
||||
@ -470,8 +535,6 @@ Public Class Form1
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub LinkLabel2_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
|
||||
Process.Start("https://github.com/alekseybochkov/")
|
||||
End Sub
|
||||
@ -483,4 +546,5 @@ Public Class Form1
|
||||
Private Sub LinkLabel3_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked
|
||||
Process.Start("https://github.com/alekseybochkov/EventLogLoader/")
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
@ -10,14 +10,40 @@ Public Module ConfigSettingsModule
|
||||
Public Found As Boolean = False
|
||||
End Class
|
||||
|
||||
Class ElasticSearchFieldSynonymsClass
|
||||
Public ServerName As String
|
||||
Public DatabaseName As String
|
||||
Public RowID As String
|
||||
Public Severity As String
|
||||
Public DateTime As String
|
||||
Public ConnectID As String
|
||||
Public DataType As String
|
||||
Public SessionNumber As String
|
||||
Public DataStructure As String
|
||||
Public DataString As String
|
||||
Public Comment As String
|
||||
Public SessionDataSplitCode As String
|
||||
Public EventType As String
|
||||
Public Metadata As String
|
||||
Public Computer As String
|
||||
Public PrimaryPort As String
|
||||
Public Server As String
|
||||
Public SecondaryPort As String
|
||||
Public Application As String
|
||||
Public UserName As String
|
||||
End Class
|
||||
|
||||
Class ConfigSetting
|
||||
Public ConnectionString As String = ""
|
||||
Public DBType As String = ""
|
||||
Public RepeatTime As Integer = 0
|
||||
Public ESIndexName As String = ""
|
||||
Public ESUseSynonymsForFieldsNames As Boolean = False
|
||||
Public ESFieldSynonyms As ElasticSearchFieldSynonymsClass
|
||||
Public Infobases As List(Of InfobaseSetting)
|
||||
Sub New()
|
||||
Infobases = New List(Of InfobaseSetting)
|
||||
ESFieldSynonyms = New ElasticSearchFieldSynonymsClass
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
@ -220,6 +220,8 @@ Public Class EventLogProcessor
|
||||
Public ItIsMSSQL As Boolean = False
|
||||
Public ItIsMySQL As Boolean = False
|
||||
Public ItIsES As Boolean = False
|
||||
Public ESUseSynonymsForFieldsNames As Boolean = False
|
||||
Public ESFieldSynonyms As ElasticSearchFieldSynonymsClass = New ElasticSearchFieldSynonymsClass
|
||||
Public SleepTime As Integer = 60 * 1000 '1 минута
|
||||
|
||||
Public Log As NLog.Logger
|
||||
@ -845,7 +847,8 @@ Public Class EventLogProcessor
|
||||
Dim _current = New ElasticClient(_settings)
|
||||
|
||||
'Let's create proper array for ES
|
||||
Dim NewRecords As List(Of ESRecord) = New List(Of ESRecord)
|
||||
Dim NewRecords As List(Of Object) = New List(Of Object)
|
||||
|
||||
For Each EventRecord In EventsList
|
||||
Dim ESRecord = New ESRecord With {.ServerName = ESServerName, .DatabaseName = InfobaseName}
|
||||
ESRecord.RowID = EventRecord.RowID
|
||||
@ -868,7 +871,6 @@ Public Class EventLogProcessor
|
||||
ESRecord.DataStructure = EventRecord.DataStructure
|
||||
ESRecord.DataString = EventRecord.DataString
|
||||
ESRecord.Comment = EventRecord.Comment
|
||||
'ESRecord.EventTypeString = EventRecord.EventType - this is severity
|
||||
ESRecord.SessionDataSplitCode = EventRecord.SessionDataSplitCode
|
||||
|
||||
|
||||
@ -912,7 +914,38 @@ Public Class EventLogProcessor
|
||||
ESRecord.UserName = UserNameObj
|
||||
End If
|
||||
|
||||
NewRecords.Add(ESRecord)
|
||||
If ESUseSynonymsForFieldsNames Then
|
||||
|
||||
Dim ESRecordUserFields = New Dictionary(Of String, Object)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.ServerName, ESRecord.ServerName)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.DatabaseName, ESRecord.DatabaseName)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.RowID, ESRecord.RowID)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.Severity, ESRecord.Severity)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.DateTime, ESRecord.DateTime)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.ConnectID, ESRecord.ConnectID)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.DataType, ESRecord.DataType)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.SessionNumber, ESRecord.SessionNumber)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.DataStructure, ESRecord.DataStructure)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.DataString, ESRecord.DataString)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.Comment, ESRecord.Comment)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.SessionDataSplitCode, ESRecord.SessionDataSplitCode)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.EventType, ESRecord.EventType)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.Metadata, ESRecord.Metadata)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.Computer, ESRecord.Computer)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.PrimaryPort, ESRecord.PrimaryPort)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.Server, ESRecord.Server)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.SecondaryPort, ESRecord.SecondaryPort)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.Application, ESRecord.Application)
|
||||
ESRecordUserFields.Add(ESFieldSynonyms.UserName, ESRecord.UserName)
|
||||
|
||||
NewRecords.Add(ESRecordUserFields)
|
||||
|
||||
Else
|
||||
|
||||
NewRecords.Add(ESRecord)
|
||||
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
Dim Result = _current.IndexMany(NewRecords, ESIndexName, "event-log-record")
|
||||
@ -927,6 +960,66 @@ Public Class EventLogProcessor
|
||||
|
||||
End Sub
|
||||
|
||||
Sub LoadReferenceFromTheTextFile(FileName As String, ByRef LastProcessedObjectForDebug As String)
|
||||
|
||||
Dim FS As FileStream = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
|
||||
Dim SR As StreamReader = New StreamReader(FS)
|
||||
|
||||
'Dim TextFile = My.Computer.FileSystem.OpenTextFileReader(FileName)
|
||||
'Dim Text = TextFile.ReadToEnd()
|
||||
'TextFile.Close()
|
||||
Dim Text = SR.ReadToEnd()
|
||||
SR.Close()
|
||||
FS.Close()
|
||||
|
||||
Text = Text.Substring(Text.IndexOf("{"))
|
||||
|
||||
Dim ObjectTexts = ParserServices.ParseEventLogString("{" + Text + "}")
|
||||
|
||||
For Each TextObject In ObjectTexts
|
||||
|
||||
LastProcessedObjectForDebug = TextObject
|
||||
|
||||
Dim a = ParserServices.ParseEventLogString(TextObject)
|
||||
|
||||
If Not a Is Nothing Then
|
||||
Select Case a(0)
|
||||
Case "1"
|
||||
AddUser(Convert.ToInt32(a(3)), a(1), a(2))
|
||||
Case "2"
|
||||
AddComputer(Convert.ToInt32(a(2)), a(1))
|
||||
Case "3"
|
||||
AddApplication(Convert.ToInt32(a(2)), a(1))
|
||||
Case "4"
|
||||
AddEvent(Convert.ToInt32(a(2)), a(1))
|
||||
Case "5"
|
||||
AddMetadata(Convert.ToInt32(a(3)), a(1), a(2))
|
||||
Case "6"
|
||||
AddServer(Convert.ToInt32(a(2)), a(1))
|
||||
Case "7"
|
||||
AddMainPort(Convert.ToInt32(a(2)), a(1))
|
||||
Case "8"
|
||||
AddSecondPort(Convert.ToInt32(a(2)), a(1))
|
||||
'Case "9" - не видел этих в файле
|
||||
'Case "10"
|
||||
Case "11"
|
||||
Case "12"
|
||||
Case "13"
|
||||
'в числе последних трех должны быть статус транзакции и важность
|
||||
Case Else
|
||||
|
||||
End Select
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Next
|
||||
|
||||
SaveReferenceValuesToDatabase()
|
||||
|
||||
End Sub
|
||||
|
||||
Sub LoadReference()
|
||||
|
||||
'Clear all reference dictionaries
|
||||
@ -939,94 +1032,11 @@ Public Class EventLogProcessor
|
||||
DictMainPorts.Clear()
|
||||
DictSecondPorts.Clear()
|
||||
|
||||
Dim LastProcessedObjectForDebug As String = ""
|
||||
Dim FileName = Path.Combine(Catalog, "1Cv8.lgd")
|
||||
|
||||
Try
|
||||
Dim FileName = Path.Combine(Catalog, "1Cv8.lgf")
|
||||
|
||||
If My.Computer.FileSystem.FileExists(FileName) Then
|
||||
|
||||
Dim FI = My.Computer.FileSystem.GetFileInfo(FileName)
|
||||
|
||||
If FI.LastWriteTime >= LastReferenceUpdate Then
|
||||
|
||||
Dim FS As FileStream = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
|
||||
Dim SR As StreamReader = New StreamReader(FS)
|
||||
|
||||
'Dim TextFile = My.Computer.FileSystem.OpenTextFileReader(FileName)
|
||||
'Dim Text = TextFile.ReadToEnd()
|
||||
'TextFile.Close()
|
||||
Dim Text = SR.ReadToEnd()
|
||||
SR.Close()
|
||||
FS.Close()
|
||||
|
||||
Text = Text.Substring(Text.IndexOf("{"))
|
||||
|
||||
Dim ObjectTexts = ParserServices.ParseEventLogString("{" + Text + "}")
|
||||
|
||||
For Each TextObject In ObjectTexts
|
||||
|
||||
LastProcessedObjectForDebug = TextObject
|
||||
|
||||
Dim a = ParserServices.ParseEventLogString(TextObject)
|
||||
|
||||
If Not a Is Nothing Then
|
||||
Select Case a(0)
|
||||
Case "1"
|
||||
AddUser(Convert.ToInt32(a(3)), a(1), a(2))
|
||||
Case "2"
|
||||
AddComputer(Convert.ToInt32(a(2)), a(1))
|
||||
Case "3"
|
||||
AddApplication(Convert.ToInt32(a(2)), a(1))
|
||||
Case "4"
|
||||
AddEvent(Convert.ToInt32(a(2)), a(1))
|
||||
Case "5"
|
||||
AddMetadata(Convert.ToInt32(a(3)), a(1), a(2))
|
||||
Case "6"
|
||||
AddServer(Convert.ToInt32(a(2)), a(1))
|
||||
Case "7"
|
||||
AddMainPort(Convert.ToInt32(a(2)), a(1))
|
||||
Case "8"
|
||||
AddSecondPort(Convert.ToInt32(a(2)), a(1))
|
||||
'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
|
||||
|
||||
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
|
||||
|
||||
|
||||
Try
|
||||
|
||||
Dim FileName = Path.Combine(Catalog, "1Cv8.lgd")
|
||||
|
||||
If My.Computer.FileSystem.FileExists(FileName) Then
|
||||
If My.Computer.FileSystem.FileExists(FileName) Then
|
||||
|
||||
Try
|
||||
Dim Conn = New SQLite.SQLiteConnection("Data Source=" + FileName)
|
||||
Conn.Open()
|
||||
Dim Command = New SQLite.SQLiteCommand
|
||||
@ -1093,12 +1103,41 @@ Public Class EventLogProcessor
|
||||
Conn.Dispose()
|
||||
|
||||
SaveReferenceValuesToDatabase()
|
||||
Catch ex As Exception
|
||||
Log.Error(ex, "Error occurred while working with reference tables")
|
||||
End Try
|
||||
|
||||
Else
|
||||
|
||||
Dim LastProcessedObjectForDebug As String = ""
|
||||
FileName = Path.Combine(Catalog, "1Cv8.lgf")
|
||||
|
||||
If My.Computer.FileSystem.FileExists(FileName) Then
|
||||
|
||||
Try
|
||||
|
||||
Dim FI = My.Computer.FileSystem.GetFileInfo(FileName)
|
||||
|
||||
If FI.LastWriteTime >= LastReferenceUpdate Then
|
||||
|
||||
LoadReferenceFromTheTextFile(FileName, LastProcessedObjectForDebug)
|
||||
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
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
|
||||
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
Log.Error(ex, "Error occurred while working with reference tables")
|
||||
End Try
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
|
@ -63,6 +63,8 @@ Public Class EventLogLoaderService
|
||||
EventLogProcessorObj.ItIsES = ItIsES
|
||||
EventLogProcessorObj.ESIndexName = ConfigSettingObj.ESIndexName
|
||||
EventLogProcessorObj.ESServerName = IBConfig.ESServerName
|
||||
EventLogProcessorObj.ESUseSynonymsForFieldsNames = ConfigSettingObj.ESUseSynonymsForFieldsNames
|
||||
EventLogProcessorObj.ESFieldSynonyms = ConfigSettingObj.ESFieldSynonyms
|
||||
|
||||
ListOfProcessors.Add(EventLogProcessorObj)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user