From ef775058ddd2cac9699e91d13b6f283c17345e58 Mon Sep 17 00:00:00 2001 From: Alex Bochkov Date: Fri, 23 Dec 2016 14:40:08 -0800 Subject: [PATCH 1/7] ES --- EventLogLoaderManager/Form1.Designer.vb | 6 +++--- EventLogLoaderManager/Form1.vb | 7 +++++-- EventLogLoaderService/Service1.vb | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/EventLogLoaderManager/Form1.Designer.vb b/EventLogLoaderManager/Form1.Designer.vb index cf274f6..e6b074e 100644 --- a/EventLogLoaderManager/Form1.Designer.vb +++ b/EventLogLoaderManager/Form1.Designer.vb @@ -107,9 +107,9 @@ Partial Class Form1 Me.Label1.ForeColor = System.Drawing.Color.Maroon Me.Label1.Location = New System.Drawing.Point(8, 9) Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(507, 17) + Me.Label1.Size = New System.Drawing.Size(450, 17) Me.Label1.TabIndex = 3 - Me.Label1.Text = "Строка соединения с базой данных MS SQL для записи событий ЖР" + Me.Label1.Text = "Строка соединения с базой данных для записи событий ЖР" ' 'Button4 ' @@ -157,7 +157,7 @@ Partial Class Form1 'DBType ' Me.DBType.FormattingEnabled = True - Me.DBType.Items.AddRange(New Object() {"MS SQL Server", "MySQL"}) + Me.DBType.Items.AddRange(New Object() {"MS SQL Server", "MySQL", "ElasticSearch"}) Me.DBType.Location = New System.Drawing.Point(9, 29) Me.DBType.Name = "DBType" Me.DBType.Size = New System.Drawing.Size(112, 21) diff --git a/EventLogLoaderManager/Form1.vb b/EventLogLoaderManager/Form1.vb index 7144068..30bbacd 100644 --- a/EventLogLoaderManager/Form1.vb +++ b/EventLogLoaderManager/Form1.vb @@ -386,11 +386,15 @@ Public Class Form1 objConn.Open() Dim command As New MySqlCommand("SELECT 1", objConn) command.ExecuteReader() - Else + ElseIf DBType.Text = "MSSQL" Then Dim objConn As New SqlConnection(ConnectionStringBox.Text.Trim) objConn.Open() Dim command As New SqlCommand("SELECT 1", objConn) command.ExecuteReader() + ElseIf DBType.Text = "ElasticSearch" Then + + + End If MsgBox("Подключение выполнено успешно!", , Text) @@ -493,5 +497,4 @@ Public Class Form1 End Sub - End Class diff --git a/EventLogLoaderService/Service1.vb b/EventLogLoaderService/Service1.vb index 02ca5d5..d16d5f6 100644 --- a/EventLogLoaderService/Service1.vb +++ b/EventLogLoaderService/Service1.vb @@ -519,8 +519,9 @@ Public Class EventLogLoaderService Public LastEventNumber83 As Integer = 0 Public ConnectionString As String - Public ItIsMSSQL As String - Public ItIsMySQL As String + Public ItIsMSSQL As Boolean + Public ItIsMySQL As Boolean + Public ItIsES As Boolean Sub CreateStr(ByRef Str As String, LastLvl As Integer, Arr() As Object) From bdf8b47353555c30868d4565a2fbbd428e2a8fbd Mon Sep 17 00:00:00 2001 From: Alex Bochkov Date: Fri, 23 Dec 2016 15:13:30 -0800 Subject: [PATCH 2/7] .net35 --- EventLogLoader/EventLogLoaderDebug.vbproj | 7 ++- .../My Project/Application.Designer.vb | 2 +- .../My Project/Resources.Designer.vb | 25 ++++----- .../My Project/Settings.Designer.vb | 52 +++++++++---------- EventLogLoader/app.config | 8 +-- EventLogLoaderManager/App.config | 9 +++- .../EventLogLoaderManager.vbproj | 27 +++++++--- EventLogLoaderManager/Form1.vb | 12 +++-- .../My Project/Application.Designer.vb | 2 +- .../My Project/Resources.Designer.vb | 34 ++++++------ .../My Project/Settings.Designer.vb | 52 +++++++++---------- EventLogLoaderManager/packages.config | 9 ++-- .../EventLogLoaderService.vbproj | 4 ++ EventLogLoaderService/packages.config | 1 + IniFile/IniFile.vbproj | 3 +- IniFile/My Project/Application.Designer.vb | 2 +- IniFile/My Project/Resources.Designer.vb | 25 ++++----- IniFile/My Project/Settings.Designer.vb | 52 +++++++++---------- Installer/Installer.vbproj | 3 +- Installer/My Project/Application.Designer.vb | 2 +- Installer/My Project/Resources.Designer.vb | 25 ++++----- Installer/My Project/Settings.Designer.vb | 52 +++++++++---------- Parser/My Project/Application.Designer.vb | 2 +- Parser/My Project/Resources.Designer.vb | 25 ++++----- Parser/My Project/Settings.Designer.vb | 52 +++++++++---------- Parser/Parser.vbproj | 3 +- Service1C/My Project/Application.Designer.vb | 2 +- Service1C/My Project/Resources.Designer.vb | 25 ++++----- Service1C/My Project/Settings.Designer.vb | 52 +++++++++---------- Service1C/Service1C.vbproj | 3 +- 30 files changed, 306 insertions(+), 266 deletions(-) diff --git a/EventLogLoader/EventLogLoaderDebug.vbproj b/EventLogLoader/EventLogLoaderDebug.vbproj index 8129712..59135fc 100644 --- a/EventLogLoader/EventLogLoaderDebug.vbproj +++ b/EventLogLoader/EventLogLoaderDebug.vbproj @@ -14,7 +14,7 @@ EventLogLoader 512 Console - v2.0 + v3.5 false 16534656 publish\ @@ -32,6 +32,7 @@ false true true + AnyCPU @@ -131,7 +132,9 @@ - + + Designer + diff --git a/EventLogLoader/My Project/Application.Designer.vb b/EventLogLoader/My Project/Application.Designer.vb index c2f75be..88dd01c 100644 --- a/EventLogLoader/My Project/Application.Designer.vb +++ b/EventLogLoader/My Project/Application.Designer.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:4.0.30319.17626 +' Runtime Version:4.0.30319.42000 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. diff --git a/EventLogLoader/My Project/Resources.Designer.vb b/EventLogLoader/My Project/Resources.Designer.vb index 7f60314..addedb1 100644 --- a/EventLogLoader/My Project/Resources.Designer.vb +++ b/EventLogLoader/My Project/Resources.Designer.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:4.0.30319.17626 +' Runtime Version:4.0.30319.42000 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. @@ -11,6 +11,7 @@ Option Strict On Option Explicit On +Imports System Namespace My.Resources @@ -21,20 +22,20 @@ Namespace My.Resources ''' ''' A strongly-typed resource class, for looking up localized strings, etc. ''' - _ + _ Friend Module Resources - + Private resourceMan As Global.System.Resources.ResourceManager - + Private resourceCulture As Global.System.Globalization.CultureInfo - + ''' ''' Returns the cached ResourceManager instance used by this class. ''' - _ + _ Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager Get If Object.ReferenceEquals(resourceMan, Nothing) Then @@ -44,17 +45,17 @@ Namespace My.Resources Return resourceMan End Get End Property - + ''' ''' Overrides the current thread's CurrentUICulture property for all ''' resource lookups using this strongly typed resource class. ''' - _ + _ Friend Property Culture() As Global.System.Globalization.CultureInfo Get Return resourceCulture End Get - Set(ByVal value As Global.System.Globalization.CultureInfo) + Set resourceCulture = value End Set End Property diff --git a/EventLogLoader/My Project/Settings.Designer.vb b/EventLogLoader/My Project/Settings.Designer.vb index fb2c8e6..fb18d61 100644 --- a/EventLogLoader/My Project/Settings.Designer.vb +++ b/EventLogLoader/My Project/Settings.Designer.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:4.0.30319.17626 +' Runtime Version:4.0.30319.42000 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. @@ -13,42 +13,42 @@ Option Explicit On Namespace My - - _ + + _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) - + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + #Region "My.Settings Auto-Save Functionality" #If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean + Private Shared addedHandler As Boolean - Private Shared addedHandlerLockObject As New Object + Private Shared addedHandlerLockObject As New Object - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub #End If #End Region - + Public Shared ReadOnly Property [Default]() As MySettings Get - + #If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If #End If Return defaultInstance End Get diff --git a/EventLogLoader/app.config b/EventLogLoader/app.config index 9f37032..fda5440 100644 --- a/EventLogLoader/app.config +++ b/EventLogLoader/app.config @@ -1,8 +1,8 @@ - + - - + + - \ No newline at end of file + diff --git a/EventLogLoaderManager/App.config b/EventLogLoaderManager/App.config index 24693d8..6739954 100644 --- a/EventLogLoaderManager/App.config +++ b/EventLogLoaderManager/App.config @@ -1,6 +1,11 @@ - + - \ No newline at end of file + + + + + + diff --git a/EventLogLoaderManager/EventLogLoaderManager.vbproj b/EventLogLoaderManager/EventLogLoaderManager.vbproj index ed37e56..f61a4c5 100644 --- a/EventLogLoaderManager/EventLogLoaderManager.vbproj +++ b/EventLogLoaderManager/EventLogLoaderManager.vbproj @@ -13,7 +13,7 @@ EventLogLoaderManager 512 WindowsForms - v2.0 + v3.5 publish\ true Disk @@ -29,7 +29,9 @@ false false true - c6eed167 + + + AnyCPU @@ -67,12 +69,20 @@ Untitled - 5.ico - - False - ..\packages\MySql.Data.6.9.5\lib\net20\MySql.Data.dll + + ..\packages\Newtonsoft.Json.9.0.1\lib\net35\Newtonsoft.Json.dll + True + + ..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net20\System.Data.SQLite.dll + True + + + ..\packages\System.Data.SQLite.Linq.1.0.104.0\lib\net20\System.Data.SQLite.Linq.dll + True + @@ -144,6 +154,7 @@ + MyApplicationCodeGenerator Application.Designer.vb @@ -194,12 +205,12 @@ - + - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - \ No newline at end of file diff --git a/IniFile/My Project/Application.Designer.vb b/IniFile/My Project/Application.Designer.vb deleted file mode 100644 index 88dd01c..0000000 --- a/IniFile/My Project/Application.Designer.vb +++ /dev/null @@ -1,13 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - diff --git a/IniFile/My Project/Application.myapp b/IniFile/My Project/Application.myapp deleted file mode 100644 index 758895d..0000000 --- a/IniFile/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - false - false - 0 - true - 0 - 1 - true - diff --git a/IniFile/My Project/AssemblyInfo.vb b/IniFile/My Project/AssemblyInfo.vb deleted file mode 100644 index e61675c..0000000 --- a/IniFile/My Project/AssemblyInfo.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' Общие сведения об этой сборке предоставляются следующим набором -' атрибутов. Отредактируйте значения этих атрибутов, чтобы изменить -' общие сведения об этой сборке. - -' Проверьте значения атрибутов сборки - - - - - - - - - - -'Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM - - -' Сведения о версии сборки состоят из следующих четырех значений: -' -' Основной номер версии -' Дополнительный номер версии -' Номер построения -' Редакция -' -' Можно задать все значения или принять номер построения и номер редакции по умолчанию, -' используя "*", как показано ниже: -' - - - diff --git a/IniFile/My Project/Resources.Designer.vb b/IniFile/My Project/Resources.Designer.vb deleted file mode 100644 index e765033..0000000 --- a/IniFile/My Project/Resources.Designer.vb +++ /dev/null @@ -1,63 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - -Imports System - -Namespace My.Resources - - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. - ''' - ''' A strongly-typed resource class, for looking up localized strings, etc. - ''' - _ - Friend Module Resources - - Private resourceMan As Global.System.Resources.ResourceManager - - Private resourceCulture As Global.System.Globalization.CultureInfo - - ''' - ''' Returns the cached ResourceManager instance used by this class. - ''' - _ - Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager - Get - If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("IniFile.Resources", GetType(Resources).Assembly) - resourceMan = temp - End If - Return resourceMan - End Get - End Property - - ''' - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. - ''' - _ - Friend Property Culture() As Global.System.Globalization.CultureInfo - Get - Return resourceCulture - End Get - Set - resourceCulture = value - End Set - End Property - End Module -End Namespace diff --git a/IniFile/My Project/Resources.resx b/IniFile/My Project/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/IniFile/My Project/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/IniFile/My Project/Settings.Designer.vb b/IniFile/My Project/Settings.Designer.vb deleted file mode 100644 index 162a192..0000000 --- a/IniFile/My Project/Settings.Designer.vb +++ /dev/null @@ -1,73 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - _ - Partial Friend NotInheritable Class MySettings - Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) - -#Region "My.Settings Auto-Save Functionality" -#If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub -#End If -#End Region - - Public Shared ReadOnly Property [Default]() As MySettings - Get - -#If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If -#End If - Return defaultInstance - End Get - End Property - End Class -End Namespace - -Namespace My - - _ - Friend Module MySettingsProperty - - _ - Friend ReadOnly Property Settings() As Global.IniFile.My.MySettings - Get - Return Global.IniFile.My.MySettings.Default - End Get - End Property - End Module -End Namespace diff --git a/IniFile/My Project/Settings.settings b/IniFile/My Project/Settings.settings deleted file mode 100644 index 85b890b..0000000 --- a/IniFile/My Project/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Installer/Class1.vb b/Installer/Class1.vb deleted file mode 100644 index e57c998..0000000 --- a/Installer/Class1.vb +++ /dev/null @@ -1,220 +0,0 @@ -Imports System -Imports System.Runtime.InteropServices -Namespace ObjTec.Services - Friend Class NativeMethods - Private Sub New() - End Sub - _ - Friend Shared Function OpenSCManager(machineName As String, databaseName As String, dwAccess As UInteger) As IntPtr - End Function - _ - Friend Shared Function CreateService(hSCManager As IntPtr, lpServiceName As String, lpDisplayName As String, dwDesiredAccess As UInteger, dwServiceType As UInteger, dwStartType As UInteger, _ - dwErrorControl As UInteger, lpBinaryPathName As String, lpLoadOrderGroup As String, lpdwTagId As UInteger, lpDependencies As String, lpServiceStartName As String, _ - lpPassword As String) As IntPtr - End Function - _ - Friend Shared Function ChangeServiceConfig(hService As IntPtr, dwServiceType As UInteger, dwStartType As UInteger, dwErrorControl As UInteger, _ - lpBinaryPathName As String, lpLoadOrderGroup As String, lpdwTagId As UInteger, lpDependencies As String, lpServiceStartName As String, _ - lpPassword As String, lpDisplayName As String) As IntPtr - End Function - _ - Friend Shared Function CloseServiceHandle(scHandle As IntPtr) As Boolean - End Function - _ - Friend Shared Function StartService(hService As IntPtr, dwNumServiceArgs As Integer, lpServiceArgVectors As String()) As Boolean - End Function - _ - Friend Shared Function OpenService(scHandle As IntPtr, lpSvcName As String, dwNumServiceArgs As Integer) As IntPtr - End Function - _ - Friend Shared Function DeleteService(svHandle As IntPtr) As Integer - End Function - End Class - Public Class ServiceInstaller - Public Shared Function InstallService(svcPath As String, svcName As String, svcDispName As String, lpDependencies As String, User As String, Password As String) As Boolean - Dim SC_MANAGER_CREATE_SERVICE As UInteger = &H2 - Dim SC_MANAGER_ALL_ACCESS As UInteger = &HF003F - Dim SERVICE_WIN32_OWN_PROCESS As UInteger = &H10 - Dim SERVICE_ERROR_NORMAL As UInteger = &H1 - Dim STANDARD_RIGHTS_REQUIRED As UInteger = &HF0000 - Dim SERVICE_QUERY_CONFIG As UInteger = &H1 - Dim SERVICE_CHANGE_CONFIG As UInteger = &H2 - Dim SERVICE_QUERY_STATUS As UInteger = &H4 - Dim SERVICE_ENUMERATE_DEPENDENTS As UInteger = &H8 - Dim SERVICE_START As UInteger = &H10 - Dim SERVICE_STOP As UInteger = &H20 - Dim SERVICE_PAUSE_CONTINUE As UInteger = &H40 - Dim SERVICE_INTERROGATE As UInteger = &H80 - Dim SERVICE_USER_DEFINED_CONTROL As UInteger = &H100 - Dim SERVICE_ALL_ACCESS As UInteger = (STANDARD_RIGHTS_REQUIRED Or SERVICE_QUERY_CONFIG Or SERVICE_CHANGE_CONFIG Or SERVICE_QUERY_STATUS Or SERVICE_ENUMERATE_DEPENDENTS Or SERVICE_START Or SERVICE_STOP Or SERVICE_PAUSE_CONTINUE Or SERVICE_INTERROGATE Or SERVICE_USER_DEFINED_CONTROL) - Dim SERVICE_AUTO_START As UInteger = &H2 - Dim sc_handle As IntPtr = NativeMethods.OpenSCManager(Nothing, Nothing, SC_MANAGER_ALL_ACCESS) - If Not sc_handle.Equals(IntPtr.Zero) Then - Dim sv_handle As IntPtr = NativeMethods.CreateService(sc_handle, svcName, svcDispName, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, _ - SERVICE_ERROR_NORMAL, svcPath, Nothing, 0, lpDependencies, User, IIf(Password = "", Nothing, Password)) - If sv_handle.Equals(IntPtr.Zero) Then - 'Console.WriteLine(Marshal.GetLastWin32Error()) - NativeMethods.CloseServiceHandle(sv_handle) - NativeMethods.CloseServiceHandle(sc_handle) - Return False - Else - 'Dim test As Boolean = NativeMethods.StartService(sv_handle, 0, Nothing) - NativeMethods.CloseServiceHandle(sv_handle) - 'If Not test Then - ' Return False - 'End If - NativeMethods.CloseServiceHandle(sc_handle) - Return True - End If - Else - Return False - End If - End Function - - Public Shared Function TestConnection() As Boolean - - Dim SC_MANAGER_CREATE_SERVICE As UInteger = &H2 - Dim SC_MANAGER_ALL_ACCESS As UInteger = &HF003F - Dim SERVICE_WIN32_OWN_PROCESS As UInteger = &H10 - Dim SERVICE_ERROR_NORMAL As UInteger = &H1 - Dim STANDARD_RIGHTS_REQUIRED As UInteger = &HF0000 - Dim SERVICE_QUERY_CONFIG As UInteger = &H1 - Dim SERVICE_CHANGE_CONFIG As UInteger = &H2 - Dim SERVICE_QUERY_STATUS As UInteger = &H4 - Dim SERVICE_ENUMERATE_DEPENDENTS As UInteger = &H8 - Dim SERVICE_START As UInteger = &H10 - Dim SERVICE_STOP As UInteger = &H20 - Dim SERVICE_PAUSE_CONTINUE As UInteger = &H40 - Dim SERVICE_INTERROGATE As UInteger = &H80 - Dim SERVICE_USER_DEFINED_CONTROL As UInteger = &H100 - Dim SERVICE_ALL_ACCESS As UInteger = (STANDARD_RIGHTS_REQUIRED Or SERVICE_QUERY_CONFIG Or SERVICE_CHANGE_CONFIG Or SERVICE_QUERY_STATUS Or SERVICE_ENUMERATE_DEPENDENTS Or SERVICE_START Or SERVICE_STOP Or SERVICE_PAUSE_CONTINUE Or SERVICE_INTERROGATE Or SERVICE_USER_DEFINED_CONTROL) - Dim SERVICE_AUTO_START As UInteger = &H2 - Dim sc_handle As IntPtr = NativeMethods.OpenSCManager(Nothing, Nothing, SC_MANAGER_ALL_ACCESS) - - If Not sc_handle.Equals(IntPtr.Zero) Then - Return True - Else - Return False - End If - - End Function - - Public Shared Function ChangeServiceParameters(svcPath As String, svcName As String, svcDispName As String, lpDependencies As String, User As String, Password As String) As Boolean - Dim SC_MANAGER_CREATE_SERVICE As UInteger = &H2 - Dim SC_MANAGER_ALL_ACCESS As UInteger = &HF003F - Dim SERVICE_WIN32_OWN_PROCESS As UInteger = &H10 - Dim SERVICE_ERROR_NORMAL As UInteger = &H1 - Dim STANDARD_RIGHTS_REQUIRED As UInteger = &HF0000 - Dim SERVICE_QUERY_CONFIG As UInteger = &H1 - Dim SERVICE_CHANGE_CONFIG As UInteger = &H2 - Dim SERVICE_QUERY_STATUS As UInteger = &H4 - Dim SERVICE_ENUMERATE_DEPENDENTS As UInteger = &H8 - Dim SERVICE_START As UInteger = &H10 - Dim SERVICE_STOP As UInteger = &H20 - Dim SERVICE_PAUSE_CONTINUE As UInteger = &H40 - Dim SERVICE_INTERROGATE As UInteger = &H80 - Dim SERVICE_USER_DEFINED_CONTROL As UInteger = &H100 - Dim SERVICE_ALL_ACCESS As UInteger = (STANDARD_RIGHTS_REQUIRED Or SERVICE_QUERY_CONFIG Or SERVICE_CHANGE_CONFIG Or SERVICE_QUERY_STATUS Or SERVICE_ENUMERATE_DEPENDENTS Or SERVICE_START Or SERVICE_STOP Or SERVICE_PAUSE_CONTINUE Or SERVICE_INTERROGATE Or SERVICE_USER_DEFINED_CONTROL) - Dim SERVICE_AUTO_START As UInteger = &H2 - - - Dim GENERIC_WRITE As UInteger = &H40000000 - Dim sc_hndl As IntPtr = NativeMethods.OpenSCManager(Nothing, Nothing, GENERIC_WRITE) - If sc_hndl.ToInt32() <> 0 Then - Dim svc_hndl As IntPtr = NativeMethods.OpenService(sc_hndl, svcName, SC_MANAGER_ALL_ACCESS) - If svc_hndl.ToInt32() <> 0 Then - - Dim i As Integer = NativeMethods.ChangeServiceConfig(svc_hndl, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, _ - SERVICE_ERROR_NORMAL, svcPath, Nothing, 0, lpDependencies, User, IIf(Password = "", Nothing, Password), svcDispName) - ''ErrorCode = i - NativeMethods.CloseServiceHandle(svc_hndl) - If i <> 0 Then - NativeMethods.CloseServiceHandle(sc_hndl) - Return True - Else - NativeMethods.CloseServiceHandle(sc_hndl) - Return False - End If - - Else - Return False - End If - Else - Return False - End If - - End Function - Public Shared Function UninstallService(svcName As String) As Boolean - Dim GENERIC_WRITE As UInteger = &H40000000 - Dim sc_hndl As IntPtr = NativeMethods.OpenSCManager(Nothing, Nothing, GENERIC_WRITE) - If sc_hndl.ToInt32() <> 0 Then - Dim DELETE As Integer = &H10000 - Dim svc_hndl As IntPtr = NativeMethods.OpenService(sc_hndl, svcName, DELETE) - If svc_hndl.ToInt32() <> 0 Then - Dim i As Integer = NativeMethods.DeleteService(svc_hndl) - NativeMethods.CloseServiceHandle(svc_hndl) - If i <> 0 Then - NativeMethods.CloseServiceHandle(sc_hndl) - Return True - Else - NativeMethods.CloseServiceHandle(sc_hndl) - Return False - End If - Else - Return False - End If - Else - Return False - End If - End Function - - Public Shared Function GetErrorDescription(ErrorNumber As Integer) As String - - Dim Desc = "" - - 'If Procedure = "DeleteService" Then ' OpenService OpenSCManager ChangeServiceConfig CreateService - - 'End If - - If ErrorNumber = 5 Then - 'ERROR_ACCESS_DENIED - Desc = "The handle does not have access to the service." - ElseIf ErrorNumber = 1059 Then - 'ERROR_CIRCULAR_DEPENDENCY - Desc = "A circular service dependency was specified." - ElseIf ErrorNumber = 1065 Then - 'ERROR_DATABASE_DOES_NOT_EXIST - Desc = "The specified database does not exist." - ElseIf ErrorNumber = 1078 Then - 'ERROR_DUPLICATE_SERVICE_NAME - Desc = "The display name already exists in the service control manager database either as a service name or as another display name." - ElseIf ErrorNumber = 6 Then - 'ERROR_INVALID_HANDLE --------------- - Desc = "The handle to the specified service control manager database is invalid." - ElseIf ErrorNumber = 123 Then - 'ERROR_INVALID_NAME - Desc = "The specified service name is invalid." - ElseIf ErrorNumber = 87 Then - 'ERROR_INVALID_PARAMETER - Desc = "A parameter that was specified is invalid." - ElseIf ErrorNumber = 1057 Then - 'ERROR_INVALID_SERVICE_ACCOUNT - Desc = "The account name does not exist, or a service is specified to share the same binary file as an already installed service but with an account name that is not the same as the installed service." - ElseIf ErrorNumber = 1060 Then - 'ERROR_SERVICE_DOES_NOT_EXIST - Desc = "The specified service does not exist." - ElseIf ErrorNumber = 1072 Then - 'ERROR_SERVICE_MARKED_FOR_DELETE - Desc = "The service has been marked for deletion." - ElseIf ErrorNumber = 1073 Then - 'ERROR_SERVICE_EXISTS - Desc = "The specified service already exists in this database." - End If - - GetErrorDescription = "№ " + ErrorNumber.ToString + " - " + Desc - - End Function - - End Class -End Namespace - diff --git a/Installer/Installer.vbproj b/Installer/Installer.vbproj deleted file mode 100644 index 25a7471..0000000 --- a/Installer/Installer.vbproj +++ /dev/null @@ -1,107 +0,0 @@ - - - - Debug - AnyCPU - - - - - {593952E2-6C95-4496-BFD5-C8C64DF78DE5} - Library - Installer - Installer - 512 - Windows - v3.5 - - - - true - full - true - true - bin\Debug\ - Installer.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - pdbonly - false - true - true - bin\Release\ - Installer.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - True - Application.myapp - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - VbMyResourcesResXFileCodeGenerator - Resources.Designer.vb - My.Resources - Designer - - - - - MyApplicationCodeGenerator - Application.Designer.vb - - - SettingsSingleFileGenerator - My - Settings.Designer.vb - - - - - \ No newline at end of file diff --git a/Installer/My Project/Application.Designer.vb b/Installer/My Project/Application.Designer.vb deleted file mode 100644 index 88dd01c..0000000 --- a/Installer/My Project/Application.Designer.vb +++ /dev/null @@ -1,13 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - diff --git a/Installer/My Project/Application.myapp b/Installer/My Project/Application.myapp deleted file mode 100644 index 758895d..0000000 --- a/Installer/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - false - false - 0 - true - 0 - 1 - true - diff --git a/Installer/My Project/AssemblyInfo.vb b/Installer/My Project/AssemblyInfo.vb deleted file mode 100644 index 7552397..0000000 --- a/Installer/My Project/AssemblyInfo.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' Общие сведения об этой сборке предоставляются следующим набором -' атрибутов. Отредактируйте значения этих атрибутов, чтобы изменить -' общие сведения об этой сборке. - -' Проверьте значения атрибутов сборки - - - - - - - - - - -'Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM - - -' Сведения о версии сборки состоят из следующих четырех значений: -' -' Основной номер версии -' Дополнительный номер версии -' Номер построения -' Редакция -' -' Можно задать все значения или принять номер построения и номер редакции по умолчанию, -' используя "*", как показано ниже: -' - - - diff --git a/Installer/My Project/Resources.Designer.vb b/Installer/My Project/Resources.Designer.vb deleted file mode 100644 index d54b846..0000000 --- a/Installer/My Project/Resources.Designer.vb +++ /dev/null @@ -1,63 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - -Imports System - -Namespace My.Resources - - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. - ''' - ''' A strongly-typed resource class, for looking up localized strings, etc. - ''' - _ - Friend Module Resources - - Private resourceMan As Global.System.Resources.ResourceManager - - Private resourceCulture As Global.System.Globalization.CultureInfo - - ''' - ''' Returns the cached ResourceManager instance used by this class. - ''' - _ - Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager - Get - If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Installer.Resources", GetType(Resources).Assembly) - resourceMan = temp - End If - Return resourceMan - End Get - End Property - - ''' - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. - ''' - _ - Friend Property Culture() As Global.System.Globalization.CultureInfo - Get - Return resourceCulture - End Get - Set - resourceCulture = value - End Set - End Property - End Module -End Namespace diff --git a/Installer/My Project/Resources.resx b/Installer/My Project/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/Installer/My Project/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Installer/My Project/Settings.Designer.vb b/Installer/My Project/Settings.Designer.vb deleted file mode 100644 index 03f8186..0000000 --- a/Installer/My Project/Settings.Designer.vb +++ /dev/null @@ -1,73 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - _ - Partial Friend NotInheritable Class MySettings - Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) - -#Region "My.Settings Auto-Save Functionality" -#If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub -#End If -#End Region - - Public Shared ReadOnly Property [Default]() As MySettings - Get - -#If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If -#End If - Return defaultInstance - End Get - End Property - End Class -End Namespace - -Namespace My - - _ - Friend Module MySettingsProperty - - _ - Friend ReadOnly Property Settings() As Global.Installer.My.MySettings - Get - Return Global.Installer.My.MySettings.Default - End Get - End Property - End Module -End Namespace diff --git a/Installer/My Project/Settings.settings b/Installer/My Project/Settings.settings deleted file mode 100644 index 85b890b..0000000 --- a/Installer/My Project/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Parser/Class1.vb b/Parser/Class1.vb deleted file mode 100644 index f92937a..0000000 --- a/Parser/Class1.vb +++ /dev/null @@ -1,191 +0,0 @@ -Namespace ParserServices - - Public Class ParsesClass - - Public Shared Function ParseString(Text As String) - - Dim Array(0) - - If Not Text = "" Then - - Dim RowArr(2) - - Dim j = 0 - Dim OpenBlock = False - Dim Level = 0 - - For i = 0 To Text.Length - 1 - - Dim Simb = Text.Substring(i, 1) - Dim SubStr = "" - - If OpenBlock Then - If Simb = """" Then - OpenBlock = False - End If - Else - If Simb = "{" Then - Level = Level + 1 - SubStr = "НачалоУровня" - ElseIf Simb = "}" Then - Level = Level - 1 - SubStr = "ОкончаниеУровня" - ElseIf Simb = """" Then - OpenBlock = True - ElseIf Simb = "," Then - SubStr = "Разделитель" - End If - End If - - If Not SubStr = "" Then - ReDim Preserve Array(j) - ReDim RowArr(2) - RowArr(0) = i - RowArr(1) = SubStr - RowArr(2) = Level - - Array(j) = RowArr - j = j + 1 - End If - - - Next - End If - - Dim ArrayBases(0) - Dim ArrayRow(2) - Dim ArrayLines(0) - - If Array.Length > 1 Then - - Dim ArrayLevel(10) As Integer - Dim ArrayValue(0) - - Dim Level = 0 - ' Dim CountLines = 0 - Dim LastVal = 0 - Dim StrLevel = "" - - For Each a In Array - - Select Case a(1) - Case "НачалоУровня" - - If Not StrLevel = "" Then - ArrayValue(0) = StrLevel - ArrayLines(ArrayLines.Length - 1) = ArrayValue - ReDim Preserve ArrayLines(ArrayLines.Length) - End If - - - ' CountLines = CountLines + 1 - ArrayLevel(Level) = ArrayLevel(Level) + 1 - Level = Level + 1 - - StrLevel = "" - For j = 0 To Level - 1 - StrLevel = IIf(StrLevel = "", "", StrLevel + ".") + ArrayLevel(j).ToString - Next - - ReDim ArrayValue(0) - - Case "ОкончаниеУровня" - - Dim TextStr = Text.Substring(LastVal + 1, a(0) - LastVal - 1) - TextStr = TextStr.Replace("""""", """") - If TextStr = """" Then TextStr = "" - - If TextStr.StartsWith("""") And TextStr.EndsWith("""") Then - TextStr = TextStr.Substring(1, TextStr.Length - 2) - End If - 'If Not TextStr = "" Then - ReDim Preserve ArrayValue(ArrayValue.Length) - ArrayValue(ArrayValue.Length - 1) = TextStr - 'End If - - - ArrayValue(0) = StrLevel - ArrayLines(ArrayLines.Length - 1) = ArrayValue - ReDim Preserve ArrayLines(ArrayLines.Length) - - 'ArrayLevel(Level) = ArrayLevel(Level) - 1 - ArrayLevel(Level) = 0 - Level = Level - 1 - - ReDim ArrayValue(0) - - StrLevel = "" - For j = 0 To Level - 1 - StrLevel = IIf(StrLevel = "", "", StrLevel + ".") + ArrayLevel(j).ToString - Next - - - Case "Разделитель" - - Dim TextStr = Text.Substring(LastVal + 1, a(0) - LastVal - 1) - TextStr = TextStr.Replace("""""", """") - If TextStr = """" Then TextStr = "" - - If TextStr.StartsWith("""") And TextStr.EndsWith("""") Then - TextStr = TextStr.Substring(1, TextStr.Length - 2) - End If - - 'If Not TextStr = "" Then - ReDim Preserve ArrayValue(ArrayValue.Length) - ArrayValue(ArrayValue.Length - 1) = TextStr - 'End If - - End Select - - LastVal = a(0) - - Next - End If - - Return ArrayLines - - End Function - - Public Shared Function ParseEventlogString(Text As String) - - Dim ArrayLines(0) - - Dim Text2 = Text.Substring(1, IIf(Text.EndsWith(","), Text.Length - 3, Text.Length - 2)) + "," - - Dim Str = "" - - Dim Delim = Text2.IndexOf(",") - Dim i = 0 - - While Delim > 0 - Str = Str + Text2.Substring(0, Delim) - Text2 = Text2.Substring(Delim + 1) - - If CountSubstringInString(Str, "{") = CountSubstringInString(Str, "}") _ - And Math.IEEERemainder(CountSubstringInString(Str, """"), 2) = 0 Then - - ReDim Preserve ArrayLines(i) - ArrayLines(i) = Str.Trim - i = i + 1 - Str = "" - Else - Str = Str + "," - End If - - Delim = Text2.IndexOf(",") - - End While - - Return ArrayLines - - End Function - - Shared Function CountSubstringInString(Str As String, SubStr As String) - - CountSubstringInString = (Str.Length - Str.Replace(SubStr, "").Length) / SubStr.Length - - End Function - - End Class - -End Namespace diff --git a/Parser/My Project/Application.Designer.vb b/Parser/My Project/Application.Designer.vb deleted file mode 100644 index 88dd01c..0000000 --- a/Parser/My Project/Application.Designer.vb +++ /dev/null @@ -1,13 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - diff --git a/Parser/My Project/Application.myapp b/Parser/My Project/Application.myapp deleted file mode 100644 index 758895d..0000000 --- a/Parser/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - false - false - 0 - true - 0 - 1 - true - diff --git a/Parser/My Project/AssemblyInfo.vb b/Parser/My Project/AssemblyInfo.vb deleted file mode 100644 index 457c4b6..0000000 --- a/Parser/My Project/AssemblyInfo.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' Общие сведения об этой сборке предоставляются следующим набором -' атрибутов. Отредактируйте значения этих атрибутов, чтобы изменить -' общие сведения об этой сборке. - -' Проверьте значения атрибутов сборки - - - - - - - - - - -'Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM - - -' Сведения о версии сборки состоят из следующих четырех значений: -' -' Основной номер версии -' Дополнительный номер версии -' Номер построения -' Редакция -' -' Можно задать все значения или принять номер построения и номер редакции по умолчанию, -' используя "*", как показано ниже: -' - - - diff --git a/Parser/My Project/Resources.Designer.vb b/Parser/My Project/Resources.Designer.vb deleted file mode 100644 index f92e45d..0000000 --- a/Parser/My Project/Resources.Designer.vb +++ /dev/null @@ -1,63 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - -Imports System - -Namespace My.Resources - - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. - ''' - ''' A strongly-typed resource class, for looking up localized strings, etc. - ''' - _ - Friend Module Resources - - Private resourceMan As Global.System.Resources.ResourceManager - - Private resourceCulture As Global.System.Globalization.CultureInfo - - ''' - ''' Returns the cached ResourceManager instance used by this class. - ''' - _ - Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager - Get - If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Parser.Resources", GetType(Resources).Assembly) - resourceMan = temp - End If - Return resourceMan - End Get - End Property - - ''' - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. - ''' - _ - Friend Property Culture() As Global.System.Globalization.CultureInfo - Get - Return resourceCulture - End Get - Set - resourceCulture = value - End Set - End Property - End Module -End Namespace diff --git a/Parser/My Project/Resources.resx b/Parser/My Project/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/Parser/My Project/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Parser/My Project/Settings.Designer.vb b/Parser/My Project/Settings.Designer.vb deleted file mode 100644 index a27e252..0000000 --- a/Parser/My Project/Settings.Designer.vb +++ /dev/null @@ -1,73 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - _ - Partial Friend NotInheritable Class MySettings - Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) - -#Region "My.Settings Auto-Save Functionality" -#If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub -#End If -#End Region - - Public Shared ReadOnly Property [Default]() As MySettings - Get - -#If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If -#End If - Return defaultInstance - End Get - End Property - End Class -End Namespace - -Namespace My - - _ - Friend Module MySettingsProperty - - _ - Friend ReadOnly Property Settings() As Global.Parser.My.MySettings - Get - Return Global.Parser.My.MySettings.Default - End Get - End Property - End Module -End Namespace diff --git a/Parser/My Project/Settings.settings b/Parser/My Project/Settings.settings deleted file mode 100644 index 85b890b..0000000 --- a/Parser/My Project/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Parser/Parser.vbproj b/Parser/Parser.vbproj deleted file mode 100644 index 21aa455..0000000 --- a/Parser/Parser.vbproj +++ /dev/null @@ -1,107 +0,0 @@ - - - - Debug - AnyCPU - - - - - {3164BFA8-8AC5-4BC2-965A-15D40B6316AA} - Library - Parser - Parser - 512 - Windows - v3.5 - - - - true - full - true - true - bin\Debug\ - Parser.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - pdbonly - false - true - true - bin\Release\ - Parser.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - True - Application.myapp - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - VbMyResourcesResXFileCodeGenerator - Resources.Designer.vb - My.Resources - Designer - - - - - MyApplicationCodeGenerator - Application.Designer.vb - - - SettingsSingleFileGenerator - My - Settings.Designer.vb - - - - - \ No newline at end of file diff --git a/Service1C/Class1.vb b/Service1C/Class1.vb deleted file mode 100644 index aab98b0..0000000 --- a/Service1C/Class1.vb +++ /dev/null @@ -1,248 +0,0 @@ -Imports System.IO -Imports EventLogLoaderService - -Public Class ServiceDescriptionClass - Public Name As String - Public DisplayName As String - Public Description As String - Public PathName As String - Public User As String - - Public Debug As Boolean = False - Public ExeFile As String = "" - Public ClusterFiles As String = "" - Public PortAgent As Integer = 1540 - Public PortMngr As Integer = 1541 - Public PortProcessBegin As Integer = 1560 - Public PortProcessEnd As Integer = 1591 - - Public Structure Infobases - Dim Name As String - Dim Description As String - Dim GUID As String - Dim SizeEventLog As Integer - Dim CatalogEventLog As String - End Structure - - Public ArrayInfobases() As Infobases - - Sub ParsePath() - - Dim PathNameTemp = PathName.ToLower - - If PathNameTemp.Contains("-debug") _ - Or PathNameTemp.Contains("/debug") Then - - Debug = True - - PathNameTemp = PathNameTemp.Replace("-debug", "") - PathNameTemp = PathNameTemp.Replace("/debug", "") - - End If - - Dim Ind = PathNameTemp.IndexOf("ragent.exe") - If Ind > 0 Then - ExeFile = PathNameTemp.Substring(0, Ind + 10) - ExeFile = ExeFile.Replace("""", "") - - PathNameTemp = PathNameTemp.Substring(Ind + 11) - End If - - Ind = PathNameTemp.IndexOf("-regport") - If Ind > 0 Then - - Dim PortStr = "" - Dim i = 0 - Dim Simb = PathNameTemp.Substring(Ind + 8 + i, 1) - - While "0123456789 ".Contains(Simb) - - PortStr = PortStr + Simb - i = i + 1 - Simb = PathNameTemp.Substring(Ind + 8 + i, 1) - - End While - - Try - PortMngr = Convert.ToInt32(PortStr) - Catch ex As Exception - - End Try - - End If - - Ind = PathNameTemp.IndexOf("-port") - If Ind > 0 Then - - Dim PortStr = "" - Dim i = 0 - Dim Simb = PathNameTemp.Substring(Ind + 5 + i, 1) - - While "0123456789 ".Contains(Simb) - - PortStr = PortStr + Simb - i = i + 1 - Simb = PathNameTemp.Substring(Ind + 5 + i, 1) - - End While - - Try - PortAgent = Convert.ToInt32(PortStr) - Catch ex As Exception - - End Try - - End If - - Ind = PathNameTemp.IndexOf("-range") - If Ind > 0 Then - - Dim PortStr = "" - Dim i = 0 - Dim Simb = PathNameTemp.Substring(Ind + 6 + i, 1) - - While "0123456789 :".Contains(Simb) - - PortStr = PortStr + Simb - i = i + 1 - Simb = PathNameTemp.Substring(Ind + 6 + i, 1) - - End While - - Try - - Ind = PortStr.IndexOf(":") - PortProcessBegin = Convert.ToInt32(PortStr.Substring(0, Ind)) - PortProcessEnd = Convert.ToInt32(PortStr.Substring(Ind + 1)) - - Catch ex As Exception - - End Try - - End If - - Ind = PathNameTemp.IndexOf("-d") - If Ind > 0 Then - - Dim PathStr = PathNameTemp.Substring(Ind + 2) - Dim Simb = PathStr.Substring(0, 1) - - While " """.Contains(Simb) - - PathStr = PathStr.Substring(2) - Simb = PathStr.Substring(1, 1) - - End While - - Ind = PathStr.IndexOf("""") - If Ind > 0 Then - ClusterFiles = PathStr.Substring(0, Ind) - - End If - - End If - - - 'А теперь финт ушами - ищем полученные строки в иходной строке и вырезаем оттуда с корректным регистром - Ind = PathName.ToLower.IndexOf(ExeFile) - If Ind > 0 Then - ExeFile = PathName.Substring(Ind, ExeFile.Length) - End If - - Ind = PathName.ToLower.IndexOf(ClusterFiles) - If Ind > 0 Then - ClusterFiles = PathName.Substring(Ind, ClusterFiles.Length) - End If - - '"C:\Program Files\1cv82\8.2.17.153\bin\ragent.exe" -debug -srvc -agent - '-regport 2541 -port 2540 -range 2560:2591 -d "C:\Program Files\1cv82\srvinfo" - - End Sub - - Sub GetInfobases() - - Try - Dim Catalog = Path.Combine(ClusterFiles, "reg_" + PortMngr.ToString) - - Dim TMP = My.Computer.FileSystem.GetTempFileName() - - '8.2 - Dim ConfFilePath As String = Path.Combine(Catalog, "1CV8Reg.lst") - If My.Computer.FileSystem.FileExists(ConfFilePath) Then - My.Computer.FileSystem.CopyFile(ConfFilePath, TMP, True) - - End If - - '8.3 - ConfFilePath = Path.Combine(Catalog, "1CV8Clst.lst") - If My.Computer.FileSystem.FileExists(ConfFilePath) Then - My.Computer.FileSystem.CopyFile(ConfFilePath, TMP, True) - End If - - 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 IB = New Infobases - IB.Name = a(2).ToString - IB.GUID = a(1).ToString - IB.Description = a(3).ToString - IB.SizeEventLog = 0 - - Try - - Dim SizeLog As UInt64 = 0 - Dim CatalogEventLog = Path.Combine(Path.Combine(Catalog, IB.GUID), "1Cv8Log\") - - 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) - - End If - - Catch ex As Exception - - End Try - - ReDim Preserve ArrayInfobases(i) - ArrayInfobases(i) = IB - - i = i + 1 - - - End If - End If - Next - - - System.Array.Sort(ArrayInfobases) - - Catch ex As Exception - - End Try - - - - - - - - End Sub - -End Class \ No newline at end of file diff --git a/Service1C/My Project/Application.Designer.vb b/Service1C/My Project/Application.Designer.vb deleted file mode 100644 index 88dd01c..0000000 --- a/Service1C/My Project/Application.Designer.vb +++ /dev/null @@ -1,13 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - diff --git a/Service1C/My Project/Application.myapp b/Service1C/My Project/Application.myapp deleted file mode 100644 index 758895d..0000000 --- a/Service1C/My Project/Application.myapp +++ /dev/null @@ -1,10 +0,0 @@ - - - false - false - 0 - true - 0 - 1 - true - diff --git a/Service1C/My Project/AssemblyInfo.vb b/Service1C/My Project/AssemblyInfo.vb deleted file mode 100644 index 23f7b58..0000000 --- a/Service1C/My Project/AssemblyInfo.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports System -Imports System.Reflection -Imports System.Runtime.InteropServices - -' Общие сведения об этой сборке предоставляются следующим набором -' атрибутов. Отредактируйте значения этих атрибутов, чтобы изменить -' общие сведения об этой сборке. - -' Проверьте значения атрибутов сборки - - - - - - - - - - -'Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM - - -' Сведения о версии сборки состоят из следующих четырех значений: -' -' Основной номер версии -' Дополнительный номер версии -' Номер построения -' Редакция -' -' Можно задать все значения или принять номер построения и номер редакции по умолчанию, -' используя "*", как показано ниже: -' - - - diff --git a/Service1C/My Project/Resources.Designer.vb b/Service1C/My Project/Resources.Designer.vb deleted file mode 100644 index df0d0a5..0000000 --- a/Service1C/My Project/Resources.Designer.vb +++ /dev/null @@ -1,63 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - -Imports System - -Namespace My.Resources - - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. - ''' - ''' A strongly-typed resource class, for looking up localized strings, etc. - ''' - _ - Friend Module Resources - - Private resourceMan As Global.System.Resources.ResourceManager - - Private resourceCulture As Global.System.Globalization.CultureInfo - - ''' - ''' Returns the cached ResourceManager instance used by this class. - ''' - _ - Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager - Get - If Object.ReferenceEquals(resourceMan, Nothing) Then - Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Service1C.Resources", GetType(Resources).Assembly) - resourceMan = temp - End If - Return resourceMan - End Get - End Property - - ''' - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. - ''' - _ - Friend Property Culture() As Global.System.Globalization.CultureInfo - Get - Return resourceCulture - End Get - Set - resourceCulture = value - End Set - End Property - End Module -End Namespace diff --git a/Service1C/My Project/Resources.resx b/Service1C/My Project/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/Service1C/My Project/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Service1C/My Project/Settings.Designer.vb b/Service1C/My Project/Settings.Designer.vb deleted file mode 100644 index db42904..0000000 --- a/Service1C/My Project/Settings.Designer.vb +++ /dev/null @@ -1,73 +0,0 @@ -'------------------------------------------------------------------------------ -' -' This code was generated by a tool. -' Runtime Version:4.0.30319.42000 -' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. -' -'------------------------------------------------------------------------------ - -Option Strict On -Option Explicit On - - -Namespace My - - _ - Partial Friend NotInheritable Class MySettings - Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) - -#Region "My.Settings Auto-Save Functionality" -#If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean - - Private Shared addedHandlerLockObject As New Object - - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub -#End If -#End Region - - Public Shared ReadOnly Property [Default]() As MySettings - Get - -#If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If -#End If - Return defaultInstance - End Get - End Property - End Class -End Namespace - -Namespace My - - _ - Friend Module MySettingsProperty - - _ - Friend ReadOnly Property Settings() As Global.Service1C.My.MySettings - Get - Return Global.Service1C.My.MySettings.Default - End Get - End Property - End Module -End Namespace diff --git a/Service1C/My Project/Settings.settings b/Service1C/My Project/Settings.settings deleted file mode 100644 index 85b890b..0000000 --- a/Service1C/My Project/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Service1C/Service1C.vbproj b/Service1C/Service1C.vbproj deleted file mode 100644 index 61f93bb..0000000 --- a/Service1C/Service1C.vbproj +++ /dev/null @@ -1,113 +0,0 @@ - - - - Debug - AnyCPU - - - - - {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F} - Library - Service1C - Service1C - 512 - Windows - v3.5 - - - - true - full - true - true - bin\Debug\ - Service1C.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - pdbonly - false - true - true - bin\Release\ - Service1C.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - On - - - Binary - - - Off - - - On - - - - - - - - - - - - - - - - - - - True - Application.myapp - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - VbMyResourcesResXFileCodeGenerator - Resources.Designer.vb - My.Resources - Designer - - - - - MyApplicationCodeGenerator - Application.Designer.vb - - - SettingsSingleFileGenerator - My - Settings.Designer.vb - - - - - {F7EF5930-B310-4697-B522-2325EAF247F2} - EventLogLoaderService - - - - - \ No newline at end of file From f9518e1a22106c6a385bc72b97c48244da986c2e Mon Sep 17 00:00:00 2001 From: Alex Bochkov Date: Sun, 25 Dec 2016 14:23:08 -0800 Subject: [PATCH 5/7] .net45 --- EventLogLoader/EventLogLoaderDebug.vbproj | 26 +-- EventLogLoader/app.config | 19 ++- EventLogLoader/packages.config | 7 - EventLogLoaderManager/AboutBox.Designer.vb | 2 +- EventLogLoaderManager/AboutBox.resx | 4 +- EventLogLoaderManager/App.config | 6 +- .../EventLogLoaderManager.vbproj | 35 +--- .../My Project/AssemblyInfo.vb | 22 +-- .../My Project/Resources.Designer.vb | 10 -- .../My Project/Resources.resx | 6 +- EventLogLoaderManager/packages.config | 6 +- .../EventLogLoaderService.vbproj | 51 ++++-- .../My Project/Application.Designer.vb | 2 +- .../My Project/Resources.Designer.vb | 25 +-- .../My Project/Settings.Designer.vb | 52 +++--- EventLogLoaderService/Service1.vb | 157 +++++++++++------- EventLogLoaderService/app.config | 27 ++- EventLogLoaderService/packages.config | 14 +- 18 files changed, 250 insertions(+), 221 deletions(-) delete mode 100644 EventLogLoader/packages.config diff --git a/EventLogLoader/EventLogLoaderDebug.vbproj b/EventLogLoader/EventLogLoaderDebug.vbproj index 7275f4f..7561397 100644 --- a/EventLogLoader/EventLogLoaderDebug.vbproj +++ b/EventLogLoader/EventLogLoaderDebug.vbproj @@ -14,9 +14,10 @@ EventLogLoader 512 Console - v3.5 + v4.5 false - 16534656 + + publish\ true Disk @@ -44,6 +45,7 @@ EventLogLoader.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 true + false x86 @@ -54,6 +56,7 @@ bin\Release\ EventLogLoader.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + false On @@ -80,19 +83,8 @@ false - - False - ..\packages\MySql.Data.6.9.5\lib\net20\MySql.Data.dll - - - False - ..\packages\System.Data.SQLite.Core.1.0.94.0\lib\net20\System.Data.SQLite.dll - - - ..\packages\System.Data.SQLite.Linq.1.0.94.1\lib\net20\System.Data.SQLite.Linq.dll - @@ -147,7 +139,6 @@ My Settings.Designer.vb - @@ -177,13 +168,6 @@ - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - +
+ + + + + + + + + + + - - + + + + + \ No newline at end of file diff --git a/EventLogLoaderService/packages.config b/EventLogLoaderService/packages.config index ec2ad8b..8c214b8 100644 --- a/EventLogLoaderService/packages.config +++ b/EventLogLoaderService/packages.config @@ -1,8 +1,12 @@  - - - - - + + + + + + + + + \ No newline at end of file From 0273181cf0f66867be4818d31f08b002ce1c0d28 Mon Sep 17 00:00:00 2001 From: Alex Bochkov Date: Sun, 25 Dec 2016 16:08:24 -0800 Subject: [PATCH 6/7] WIP --- EventLogLoader/Module1.vb | 4 +- .../EventLogLoaderService.vbproj | 1 + EventLogLoaderService/EventLogProcessor.vb | 1397 ++++++++++++++ EventLogLoaderService/Service1.vb | 1647 +---------------- 4 files changed, 1494 insertions(+), 1555 deletions(-) create mode 100644 EventLogLoaderService/EventLogProcessor.vb diff --git a/EventLogLoader/Module1.vb b/EventLogLoader/Module1.vb index 2a2bb8e..cca439f 100644 --- a/EventLogLoader/Module1.vb +++ b/EventLogLoader/Module1.vb @@ -5,11 +5,11 @@ Module Module1 Dim Service = New EventLogLoaderService.EventLogLoaderService Service.SubStart() - Console.WriteLine("Служба запущена") + Console.WriteLine("Service has been started") Console.ReadKey() Service.SubStop() - Console.WriteLine("Служба остановлена") + Console.WriteLine("Service has been stopped") End Sub diff --git a/EventLogLoaderService/EventLogLoaderService.vbproj b/EventLogLoaderService/EventLogLoaderService.vbproj index 5aa09e4..d0cb7cf 100644 --- a/EventLogLoaderService/EventLogLoaderService.vbproj +++ b/EventLogLoaderService/EventLogLoaderService.vbproj @@ -125,6 +125,7 @@ + True diff --git a/EventLogLoaderService/EventLogProcessor.vb b/EventLogLoaderService/EventLogProcessor.vb new file mode 100644 index 0000000..ed646be --- /dev/null +++ b/EventLogLoaderService/EventLogProcessor.vb @@ -0,0 +1,1397 @@ +Imports System.Data.SqlClient +Imports System.Globalization +Imports System.IO +Imports MySql.Data.MySqlClient +Imports Nest +Imports Newtonsoft.Json + +Public Class EventLogProcessor +#Region "Reference classes" + Structure User + Dim Code As Integer + Dim Name As String + Dim Guid As String + End Structure + + Structure Metadata + Dim Code As Integer + Dim Name As String + Dim Guid As String + End Structure + + Structure Computer + Dim Code As Integer + Dim Name As String + End Structure + + Structure Application + Dim Code As Integer + Dim Name As String + End Structure + + Structure EventType + Dim Code As Integer + Dim Name As String + End Structure + + Structure Server + Dim Code As Integer + Dim Name As String + End Structure + + Structure MainPort + Dim Code As Integer + Dim Name As String + End Structure + + Structure SecondPort + Dim Code As Integer + Dim Name As String + End Structure + + Sub AddUser(Code As Integer, Guid As String, Name As String) + + Dim Usr = New User + Usr.Code = Code + Usr.Name = Name + Usr.Guid = Guid + + DictUsers.Add(Code, Usr) + + End Sub + + Sub AddComputer(Code As Integer, Name As String) + + Dim Item = New Computer + Item.Code = Code + Item.Name = Name + + DictComputers.Add(Code, Item) + + End Sub + + Sub AddApplication(Code As Integer, Name As String) + + Dim Item = New Application + Item.Code = Code + Item.Name = Name + + DictApplications.Add(Code, Item) + + End Sub + + Sub AddEvent(Code As Integer, Name As String) + + Dim Item = New EventType + Item.Code = Code + Item.Name = Name + + DictEvents.Add(Code, Item) + + End Sub + + Sub AddMetadata(Code As Integer, Guid As String, Name As String) + + Dim MD = New Metadata + MD.Code = Code + MD.Name = Name + MD.Guid = Guid + + DictMetadata.Add(Code, MD) + + End Sub + + Sub AddServer(Code As Integer, Name As String) + + Dim Item = New Server + Item.Code = Code + Item.Name = Name + + DictServers.Add(Code, Item) + + End Sub + + Sub AddMainPort(Code As Integer, Name As String) + + Dim Item = New MainPort + Item.Code = Code + If String.IsNullOrEmpty(Name) Then + Item.Name = "" + Else + Item.Name = Name + End If + + + DictMainPorts.Add(Code, Item) + + End Sub + + Sub AddSecondPort(Code As Integer, Name As String) + + Dim Item = New SecondPort + Item.Code = Code + If String.IsNullOrEmpty(Name) Then + Item.Name = "" + Else + Item.Name = Name + End If + + DictSecondPorts.Add(Code, Item) + + End Sub + +#End Region + + Class ReadParameters + Public InfobaseId As Integer + Public CurrentPosition As Long + Public CurrentFilename As String + Public LastEventNumber83 As Long + End Class + + Class OneEventRecord + Public RowID As Integer + Public DateTime As Date + Public TransactionStatus As String + Public Transaction As String + Public TransactionStartTime As Date + Public TransactionMark As Int64 + Public UserName As Integer + Public ComputerName As Integer + Public AppName As Integer + Public Field2 As String + Public EventID As Integer + Public EventType As String + Public Comment As String + Public MetadataID As Integer + Public DataStructure As String + Public DataString As String + Public ServerID As Integer + Public MainPortID As Integer + Public SecondPortID As Integer + Public Seance As Integer + Public Field7 As String + Public Field8 As String + End Class + + Class ESRecord + Public DateTime As Date + Public Computer As Computer + Public Application As Application + Public Metadata As Metadata + Public UserName As User + End Class + + Public EventsList As List(Of OneEventRecord) = New List(Of OneEventRecord) + + + Public InfobaseName As String + Public InfobaseGuid As String + Public InfobaseID As Integer = 0 + Public ConnectionString As String = "" + Public ItIsMSSQL As Boolean = False + Public ItIsMySQL As Boolean = False + Public ItIsES As Boolean = False + Public SleepTime As Integer = 60 * 1000 '1 минута + + Public Log As NLog.Logger + + Public Catalog As String + Dim CurrentPosition As Int64 = 0 + Dim CurrentFilename As String = "" + Dim LastEventNumber83 As Integer = 0 + + Dim DictUsers As Dictionary(Of Integer, User) = New Dictionary(Of Integer, User) + Dim DictComputers As Dictionary(Of Integer, Computer) = New Dictionary(Of Integer, Computer) + Dim DictApplications As Dictionary(Of Integer, Application) = New Dictionary(Of Integer, Application) + Dim DictEvents As Dictionary(Of Integer, EventType) = New Dictionary(Of Integer, EventType) + Dim DictMetadata As Dictionary(Of Integer, Metadata) = New Dictionary(Of Integer, Metadata) + Dim DictServers As Dictionary(Of Integer, Server) = New Dictionary(Of Integer, Server) + Dim DictMainPorts As Dictionary(Of Integer, MainPort) = New Dictionary(Of Integer, MainPort) + Dim DictSecondPorts As Dictionary(Of Integer, SecondPort) = New Dictionary(Of Integer, SecondPort) + + Public LastReferenceUpdate As DateTime + + Public Sub SaveReferenceValuesToDatabase() + + If ItIsMSSQL Then + Dim objConn As New SqlConnection(ConnectionString) + objConn.Open() + + '--------------------------------------------------------------------------------------------------------- + Dim command As New SqlCommand("IF NOT EXISTS (select * from [dbo].[Applications] where [Code] = @v1 AND [InfobaseCode] = @v3) " + + "INSERT INTO [dbo].[Applications] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1, @v2)", objConn) + + For Each Item In DictApplications + Try + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Value.Code + command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Value.Name + command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "IF NOT EXISTS (select * from [dbo].[Computers] where [Code] = @v1 AND [InfobaseCode] = @v3) " + + "INSERT INTO [dbo].[Computers] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1,@v2)" + + For Each Item In DictComputers + Try + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Value.Code + command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Value.Name + command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "IF NOT EXISTS (select * from [dbo].[EventsType] where [Code] = @v1 AND [InfobaseCode] = @v3) " + + "INSERT INTO [dbo].[EventsType] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1,@v2)" + + For Each Item In DictEvents + Try + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Value.Code + command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Value.Name + command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "IF NOT EXISTS (select * from [dbo].[MainPorts] where [Code] = @v1 AND [InfobaseCode] = @v3) " + + "INSERT INTO [dbo].[MainPorts] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1,@v2)" + + For Each Item In DictMainPorts + Try + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Value.Code + command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Value.Name + command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "IF NOT EXISTS (select * from [dbo].[Metadata] where [Code] = @v1 AND [InfobaseCode] = @v4) " + + "INSERT INTO [dbo].[Metadata] ([InfobaseCode],[Code],[Name],[Guid]) VALUES(@v4, @v1,@v2,@v3)" + + For Each Item In DictMetadata + Try + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Value.Code + command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Value.Name + command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Char)).Value = Item.Value.Guid + command.Parameters.Add(New SqlParameter("@v4", SqlDbType.Int)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "IF NOT EXISTS (select * from [dbo].[Users] where [Code] = @v1 AND [InfobaseCode] = @v4) " + + "INSERT INTO [dbo].[Users] ([InfobaseCode],[Code],[Name],[Guid]) VALUES(@v4, @v1,@v2,@v3)" + + For Each Item In DictUsers + Try + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Value.Code + command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Value.Name + command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Char)).Value = Item.Value.Guid + command.Parameters.Add(New SqlParameter("@v4", SqlDbType.Int)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "IF NOT EXISTS (select * from [dbo].[SecondPorts] where [Code] = @v1 AND [InfobaseCode] = @v3) " + + "INSERT INTO [dbo].[SecondPorts] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1,@v2)" + + For Each Item In DictSecondPorts + Try + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Value.Code + command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Value.Name + command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "IF NOT EXISTS (select * from [dbo].[Servers] where [Code] = @v1 AND [InfobaseCode] = @v3) " + + "INSERT INTO [dbo].[Servers] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1,@v2)" + + For Each Item In DictServers + Try + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Value.Code + command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Value.Name + command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "IF NOT EXISTS (select * from [dbo].[Infobases] where [Guid] = @v0) " + + "INSERT INTO [dbo].[Infobases] ([Guid],[Code],[Name]) VALUES(@v0,@v1,@v2)" + + + Try + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v0", SqlDbType.Char)).Value = InfobaseGuid + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = InfobaseID + command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = InfobaseName + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + + command.Dispose() + objConn.Close() + objConn.Dispose() + + ElseIf ItIsMySQL Then + + Dim objConn = New MySql.Data.MySqlClient.MySqlConnection(ConnectionString) + objConn.Open() + + Dim command As New MySqlCommand("REPLACE INTO `Applications`(`InfobaseCode`, `Code`, `Name`) VALUES(@v3, @v1, @v2)", objConn) + + For Each Item In DictApplications + Try + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Value.Code + command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Value.Name + command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "REPLACE INTO `Computers` (`InfobaseCode`,`Code`,`Name`) VALUES(@v3, @v1, @v2)" + + For Each Item In DictComputers + Try + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Value.Code + command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Value.Name + command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "REPLACE INTO `EventsType` (`InfobaseCode`,`Code`,`Name`) VALUES(@v3, @v1,@v2)" + + For Each Item In DictEvents + Try + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Value.Code + command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Value.Name + command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "REPLACE INTO `MainPorts` (`InfobaseCode`,`Code`,`Name`) VALUES(@v3, @v1,@v2)" + + For Each Item In DictMainPorts + Try + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Value.Code + command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Value.Name + command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "REPLACE INTO `Metadata` (`InfobaseCode`,`Code`,`Name`,`Guid`) VALUES(@v4, @v1,@v2,@v3)" + + For Each Item In DictMetadata + Try + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Value.Code + command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Value.Name + command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.VarChar)).Value = Item.Value.Guid + command.Parameters.Add(New MySqlParameter("@v4", MySqlDbType.Int32)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "REPLACE INTO `Users` (`InfobaseCode`,`Code`,`Name`,`Guid`) VALUES(@v4, @v1,@v2,@v3)" + + For Each Item In DictUsers + Try + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Value.Code + command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Value.Name + command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.VarChar)).Value = Item.Value.Guid + command.Parameters.Add(New MySqlParameter("@v4", MySqlDbType.Int32)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "REPLACE INTO `SecondPorts` (`InfobaseCode`,`Code`,`Name`) VALUES(@v3, @v1,@v2)" + + For Each Item In DictSecondPorts + Try + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Value.Code + command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Value.Name + command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "REPLACE INTO `Servers` (`InfobaseCode`,`Code`,`Name`) VALUES(@v3, @v1,@v2)" + + For Each Item In DictServers + Try + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Value.Code + command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Value.Name + command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + Next + + '--------------------------------------------------------------------------------------------------------- + command.CommandText = "REPLACE INTO `Infobases` (`Guid`,`Code`,`Name`) VALUES(@v0,@v1,@v2)" + + Try + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v0", MySqlDbType.VarChar)).Value = InfobaseGuid + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = InfobaseID + command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = InfobaseName + command.ExecuteNonQuery() + Catch ex As Exception + Console.WriteLine(ex.Message) + End Try + + + command.Dispose() + objConn.Close() + objConn.Dispose() + + + End If + + LastReferenceUpdate = Now + + End Sub + + Public Sub GetInfobaseIDFromDatabase() + + 'У нас есть ГУИД базы, но нет сквозного кода для информации. + 'Сделано для оптимизации, чтобы в каждой строке события не записывать ГУИД, а хранить целое число. + + If ItIsMSSQL Then + + Dim objConn As New SqlConnection(ConnectionString) + objConn.Open() + + Dim command As New SqlCommand("SELECT [Code] FROM [dbo].[Infobases] WHERE [Guid] = @v1", objConn) + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Char)).Value = InfobaseGuid + + Dim rs = command.ExecuteReader + + If rs.Read Then + InfobaseID = Convert.ToInt32(rs(0)) + End If + rs.Close() + + If InfobaseID = 0 Then + + command.CommandText = "INSERT INTO Infobases ([Code],[Name],[guid])" + + " SELECT MAX(f) AS [Code], @v0 as [Name], @v1 as [guid] FROM " + + " (SELECT MAX(Code) + 1 AS f FROM Infobases UNION ALL" + + " SELECT 1 AS Expr1) AS T" + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v0", SqlDbType.Char)).Value = InfobaseName + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Char)).Value = InfobaseGuid + command.ExecuteNonQuery() + + command.CommandText = "SELECT [Code] FROM [dbo].[Infobases] WHERE [Guid] = @v1" + rs = command.ExecuteReader() + + If rs.Read Then + InfobaseID = Convert.ToInt32(rs(0)) + End If + + rs.Close() + + End If + + command.Dispose() + objConn.Close() + objConn.Dispose() + + ElseIf ItIsMySQL Then + + Dim objConn As New MySqlConnection(ConnectionString) + objConn.Open() + + Dim command As New MySqlCommand("SELECT `Code` FROM `Infobases` WHERE `Guid` = @v1", objConn) + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.VarChar)).Value = InfobaseGuid + + Dim rs = command.ExecuteReader + + If rs.Read Then + InfobaseID = Convert.ToInt32(rs(0)) + End If + rs.Close() + + If InfobaseID = 0 Then + + command.CommandText = "INSERT INTO Infobases (`Code`,`Name`,`guid`)" + + " SELECT MAX(f) AS `Code`, @v0 as `Name`, @v1 as `guid` FROM " + + " (SELECT MAX(Code) + 1 AS f FROM `Infobases` UNION ALL" + + " SELECT 1 AS `Expr1`) AS T" + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v0", MySqlDbType.VarChar)).Value = InfobaseName + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.VarChar)).Value = InfobaseGuid + command.ExecuteNonQuery() + + command.CommandText = "SELECT `Code` FROM `Infobases` WHERE `Guid` = @v1" + rs = command.ExecuteReader() + + If rs.Read Then + InfobaseID = Convert.ToInt32(rs(0)) + End If + + rs.Close() + + End If + + command.Dispose() + objConn.Close() + objConn.Dispose() + + End If + + '-------------------------------------------------------------- + End Sub + + Sub SaveReadParametersToFile() + + Dim ReadParametersFile = Path.Combine(My.Application.Info.DirectoryPath, "read-setting-" + InfobaseGuid + ".json") + + Dim ConfigSettingObj = New ReadParameters + ConfigSettingObj.CurrentPosition = CurrentPosition + ConfigSettingObj.CurrentFilename = CurrentFilename + ConfigSettingObj.LastEventNumber83 = LastEventNumber83 + + Dim JsonText As String = JsonConvert.SerializeObject(ConfigSettingObj, Formatting.Indented) + + My.Computer.FileSystem.WriteAllText(ReadParametersFile, JsonText, False) + + End Sub + + Sub GetReadParametersFromFile() + + Dim ReadParametersFile = Path.Combine(My.Application.Info.DirectoryPath, "read-setting-" + InfobaseGuid + ".json") + + If My.Computer.FileSystem.FileExists(ReadParametersFile) Then + + Dim JsonText = My.Computer.FileSystem.ReadAllText(ReadParametersFile) + + Dim ConfigSettingObj = JsonConvert.DeserializeObject(Of ReadParameters)(JsonText) + + CurrentPosition = Convert.ToInt64(ConfigSettingObj.CurrentPosition) + CurrentFilename = ConfigSettingObj.CurrentFilename + LastEventNumber83 = ConfigSettingObj.LastEventNumber83 + + End If + + End Sub + + Sub SaveEventsToSQL() + + If EventsList.Count = 0 Then + Return + End If + + If ItIsMSSQL Then + Dim objConn As New SqlConnection(ConnectionString) + objConn.Open() + + Dim command As New SqlCommand("BEGIN TRANSACTION", objConn) + command.ExecuteNonQuery() + + command.CommandText = "INSERT INTO [dbo].[Events] ([InfobaseCode],[DateTime],[TransactionStatus],[Transaction],[UserName],[ComputerName]" + + ",[AppName],[Field2],[EventID],[EventType],[Comment],[MetadataID],[DataStructure],[DataString]" + + ",[ServerID],[MainPortID],[SecondPortID],[Seance],[Field7],[Field8],[TransactionStartTime],[TransactionMark])" + + " VALUES(@v0,@v1,@v2,@v3,@v4,@v5,@v6,@v7,@v8,@v9,@v10,@v11,@v12,@v13,@v14,@v15,@v16,@v17,@v18,@v19,@v20,@v21)" + + Dim i = 0 + For Each Ev In EventsList + + If Ev.AppName = Nothing Then Continue For + + Try + command.Parameters.Clear() + command.Parameters.Add(New SqlParameter("@v0", SqlDbType.Int)).Value = InfobaseID + command.Parameters.Add(New SqlParameter("@v1", SqlDbType.DateTime)).Value = Ev.DateTime + command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Ev.TransactionStatus + command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Char)).Value = Ev.Transaction + command.Parameters.Add(New SqlParameter("@v4", SqlDbType.Int)).Value = Ev.UserName + command.Parameters.Add(New SqlParameter("@v5", SqlDbType.Int)).Value = Ev.ComputerName + command.Parameters.Add(New SqlParameter("@v6", SqlDbType.Int)).Value = Ev.AppName + command.Parameters.Add(New SqlParameter("@v7", SqlDbType.Char)).Value = Ev.Field2 + command.Parameters.Add(New SqlParameter("@v8", SqlDbType.Int)).Value = Ev.EventID + command.Parameters.Add(New SqlParameter("@v9", SqlDbType.Char)).Value = Ev.EventType + command.Parameters.Add(New SqlParameter("@v10", SqlDbType.VarChar)).Value = Ev.Comment + command.Parameters.Add(New SqlParameter("@v11", SqlDbType.Int)).Value = Ev.MetadataID + + If Ev.DataStructure.Length > 100 Then + Ev.DataStructure = Ev.DataStructure.Substring(0, 99) + End If + command.Parameters.Add(New SqlParameter("@v12", SqlDbType.Char)).Value = Ev.DataStructure + + command.Parameters.Add(New SqlParameter("@v13", SqlDbType.VarChar)).Value = Ev.DataString + command.Parameters.Add(New SqlParameter("@v14", SqlDbType.Int)).Value = Ev.ServerID + command.Parameters.Add(New SqlParameter("@v15", SqlDbType.Int)).Value = Ev.MainPortID + command.Parameters.Add(New SqlParameter("@v16", SqlDbType.Int)).Value = Ev.SecondPortID + command.Parameters.Add(New SqlParameter("@v17", SqlDbType.Int)).Value = Ev.Seance + command.Parameters.Add(New SqlParameter("@v18", SqlDbType.Char)).Value = Ev.Field7 + command.Parameters.Add(New SqlParameter("@v19", SqlDbType.Char)).Value = Ev.Field8 + command.Parameters.Add(New SqlParameter("@v20", SqlDbType.DateTime)).Value = Ev.TransactionStartTime + command.Parameters.Add(New SqlParameter("@v21", SqlDbType.BigInt)).Value = Ev.TransactionMark + + command.ExecuteNonQuery() + i += 1 + Catch ex As Exception + Log.Error("Ошибка сохранения в БД записи от " + Ev.DateTime.ToString + + " по ИБ " + InfobaseName + " : " + ex.Message) + End Try + + + Next + + SaveReadParametersToFile() + + Console.WriteLine(Now.ToShortTimeString + " Записано новых событий в базу " + i.ToString) + + command.CommandText = "COMMIT TRANSACTION" + command.Parameters.Clear() + command.ExecuteNonQuery() + + command.Dispose() + objConn.Close() + objConn.Dispose() + + ElseIf ItIsMySQL Then + + Dim objConn As New MySqlConnection(ConnectionString) + objConn.Open() + + Dim command As New MySqlCommand("START TRANSACTION", objConn) + command.ExecuteNonQuery() + + command.CommandText = "INSERT INTO `Events` (`InfobaseCode`,`DateTime`,`TransactionStatus`,`Transaction`,`UserName`,`ComputerName`" + + ",`AppName`,`Field2`,`EventID`,`EventType`,`Comment`,`MetadataID`,`DataStructure`,`DataString`" + + ",`ServerID`,`MainPortID`,`SecondPortID`,`Seance`,`Field7`,`Field8`,`TransactionStartTime`,`TransactionMark`)" + + " VALUES(@v0,@v1,@v2,@v3,@v4,@v5,@v6,@v7,@v8,@v9,@v10,@v11,@v12,@v13,@v14,@v15,@v16,@v17,@v18,@v19,@v20,@v21)" + + Dim i = 0 + For Each Ev In EventsList + + If Ev.AppName = Nothing Then Continue For + + Try + command.Parameters.Clear() + command.Parameters.Add(New MySqlParameter("@v0", MySqlDbType.Int32)).Value = InfobaseID + command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.DateTime)).Value = Ev.DateTime + command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Ev.TransactionStatus + command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.VarChar)).Value = Ev.Transaction + command.Parameters.Add(New MySqlParameter("@v4", MySqlDbType.Int32)).Value = Ev.UserName + command.Parameters.Add(New MySqlParameter("@v5", MySqlDbType.Int32)).Value = Ev.ComputerName + command.Parameters.Add(New MySqlParameter("@v6", MySqlDbType.Int32)).Value = Ev.AppName + command.Parameters.Add(New MySqlParameter("@v7", MySqlDbType.VarChar)).Value = Ev.Field2 + command.Parameters.Add(New MySqlParameter("@v8", MySqlDbType.Int32)).Value = Ev.EventID + command.Parameters.Add(New MySqlParameter("@v9", MySqlDbType.VarChar)).Value = Ev.EventType + command.Parameters.Add(New MySqlParameter("@v10", MySqlDbType.VarChar)).Value = Ev.Comment + command.Parameters.Add(New MySqlParameter("@v11", MySqlDbType.Int32)).Value = Ev.MetadataID + command.Parameters.Add(New MySqlParameter("@v12", MySqlDbType.VarChar)).Value = Ev.DataStructure + command.Parameters.Add(New MySqlParameter("@v13", MySqlDbType.VarChar)).Value = Ev.DataString + command.Parameters.Add(New MySqlParameter("@v14", MySqlDbType.Int32)).Value = Ev.ServerID + command.Parameters.Add(New MySqlParameter("@v15", MySqlDbType.Int32)).Value = Ev.MainPortID + command.Parameters.Add(New MySqlParameter("@v16", MySqlDbType.Int32)).Value = Ev.SecondPortID + command.Parameters.Add(New MySqlParameter("@v17", MySqlDbType.Int32)).Value = Ev.Seance + command.Parameters.Add(New MySqlParameter("@v18", MySqlDbType.VarChar)).Value = Ev.Field7 + command.Parameters.Add(New MySqlParameter("@v19", MySqlDbType.VarChar)).Value = Ev.Field8 + command.Parameters.Add(New MySqlParameter("@v20", MySqlDbType.DateTime)).Value = Ev.TransactionStartTime + command.Parameters.Add(New MySqlParameter("@v21", MySqlDbType.Int64)).Value = Ev.TransactionMark + + command.ExecuteNonQuery() + i += 1 + Catch ex As Exception + Log.Error("Ошибка сохранения в БД записи от " + Ev.DateTime.ToString + + " по ИБ " + InfobaseName + " : " + ex.Message) + End Try + + + Next + + Console.WriteLine(Now.ToShortTimeString + " Записано новых событий в базу " + i.ToString) + + SaveReadParametersToFile() + + command.CommandText = "COMMIT" + command.Parameters.Clear() + command.ExecuteNonQuery() + + command.Dispose() + objConn.Close() + objConn.Dispose() + + ElseIf ItIsES Then + + Dim Index = "event-log-" + InfobaseGuid + Dim node = New Uri(ConnectionString) + + Dim _settings = New ConnectionSettings(node).DefaultIndex(Index).MaximumRetries(2).MaxRetryTimeout(TimeSpan.FromSeconds(150)) + Dim _current = New ElasticClient(_settings) + + 'Let's create proper array for ES + Dim NewRecords As List(Of ESRecord) = New List(Of ESRecord) + For Each EventRecord In EventsList + Dim ESRecord = New ESRecord + ESRecord.DateTime = EventRecord.DateTime + + Dim MetadataObj = New Metadata + If DictMetadata.TryGetValue(EventRecord.MetadataID, MetadataObj) Then + ESRecord.Metadata = MetadataObj + End If + + Dim ApplicationObj = New Application + If DictApplications.TryGetValue(EventRecord.AppName, ApplicationObj) Then + ESRecord.Application = ApplicationObj + End If + + Dim UserNameObj = New User + If DictUsers.TryGetValue(EventRecord.UserName, UserNameObj) Then + ESRecord.UserName = UserNameObj + End If + + NewRecords.Add(ESRecord) + Next + + 'Dim elasticsearchMappingResolver As IElasticsearchMappingResolver = New ElasticsearchMappingResolver() + 'elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(TypeOf (), New ElasticsearchMappingTestDto()); + 'Dim context = New ElasticsearchContext(ConnectionString, New ElasticsearchSerializerConfiguration(elasticsearchMappingResolver, True, True)) + + + 'Dim descriptor = New BulkDescriptor() + 'For Each item In Events + ' ' descriptor.Index(Of OneEvent)(Function(op) op.Document(item)) + 'Next + 'Dim result = _current.Bulk(descriptor) + + Dim Result = _current.IndexMany(NewRecords, Index, "event-record") + + SaveReadParametersToFile() + + End If + + EventsList.Clear() + + End Sub + + Sub LoadReference() + + 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() + + + 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.ErrorException("Ошибка при работе со справочником", ex) + End Try + + + Try + + Dim FileName = Path.Combine(Catalog, "1Cv8.lgd") + + If My.Computer.FileSystem.FileExists(FileName) Then + + Dim Conn = New System.Data.SQLite.SQLiteConnection("Data Source=" + FileName) + Conn.Open() + Dim Command = New System.Data.SQLite.SQLiteCommand + Command.Connection = Conn + + Command.CommandText = "SELECT [code], [name] FROM [AppCodes]" + Dim rs = Command.ExecuteReader + While rs.Read + AddApplication(rs(0), rs(1)) + End While + rs.Close() + + Command.CommandText = "SELECT [code], [name] FROM [ComputerCodes]" + rs = Command.ExecuteReader + While rs.Read + AddComputer(rs(0), rs(1)) + End While + rs.Close() + + Command.CommandText = "SELECT [code], [name] FROM [EventCodes]" + rs = Command.ExecuteReader + While rs.Read + AddEvent(rs(0), rs(1)) + End While + rs.Close() + + Command.CommandText = "SELECT [code], [uuid], [name] FROM [UserCodes]" + rs = Command.ExecuteReader + While rs.Read + AddUser(rs(0), rs(1), rs(2)) + End While + rs.Close() + + Command.CommandText = "SELECT [code], [name] FROM [WorkServerCodes]" + rs = Command.ExecuteReader + While rs.Read + AddServer(rs(0), rs(1)) + End While + rs.Close() + + Command.CommandText = "SELECT [code], [uuid], [name] FROM [MetadataCodes]" + rs = Command.ExecuteReader + While rs.Read + AddMetadata(rs(0), rs(1), rs(2)) + End While + rs.Close() + + Command.CommandText = "SELECT [code], [name] FROM [PrimaryPortCodes]" + rs = Command.ExecuteReader + While rs.Read + AddMainPort(rs(0), rs(1)) + End While + rs.Close() + + Command.CommandText = "SELECT [code], [name] FROM [SecondaryPortCodes]" + rs = Command.ExecuteReader + While rs.Read + AddSecondPort(rs(0), rs(1)) + End While + rs.Close() + + Command.Dispose() + Conn.Close() + Conn.Dispose() + + SaveReferenceValuesToDatabase() + + End If + + Catch ex As Exception + Log.ErrorException("Ошибка при работе со справочником", ex) + End Try + + End Sub + + Sub FindAndStartParseFiles() + + Dim v83File = Path.Combine(Catalog, "1Cv8.lgd") + If My.Computer.FileSystem.FileExists(v83File) Then + + LoadEvents83(v83File) + + SaveEventsToSQL() + + Else + + Dim ArrayFiles(0) As String + Dim i = 0 + + If My.Computer.FileSystem.DirectoryExists(Catalog) Then + + Dim Files = My.Computer.FileSystem.GetFiles(Catalog) + For Each File In Files + If File.EndsWith(".lgp") Then + ReDim Preserve ArrayFiles(i) + ArrayFiles(i) = File + i = i + 1 + End If + Next + + System.Array.Sort(ArrayFiles) + + For Each File In ArrayFiles + If Not File Is Nothing Then + Try + Dim FI = My.Computer.FileSystem.GetFileInfo(File) + If FI.Name >= CurrentFilename Then + If Not FI.Name = CurrentFilename Then + CurrentPosition = 61 ' start position for log-file 1C + End If + CurrentFilename = FI.Name + LoadEvents(File) + End If + Catch ex As Exception + Log.ErrorException("Error in FindAndStartParseFiles", ex) + End Try + End If + + Next + + SaveEventsToSQL() + + End If + End If + + + End Sub + + Sub LoadEvents83(FileName As String) + Try + + Dim Conn = New System.Data.SQLite.SQLiteConnection("Data Source=" + FileName) + Conn.Open() + Dim Command = New System.Data.SQLite.SQLiteCommand + Command.Connection = Conn + + Dim ANSI = Text.Encoding.GetEncoding(1251) + Dim UTF8 = Text.Encoding.UTF8 + + While True + + Command.CommandText = "SELECT [rowID],[severity],[date],[connectID],[session]" + + ",[transactionStatus],[transactionDate],[transactionID],[userCode],[computerCode],[appCode]" + + ",[eventCode],[comment],[metadataCodes],[sessionDataSplitCode],[dataType],[data]" + + ",[dataPresentation],[workServerCode],[primaryPortCode],[secondaryPortCode]" + + " FROM [EventLog] WHERE [rowID] > " + LastEventNumber83.ToString + " LIMIT 1000" + Dim rs = Command.ExecuteReader + + While rs.Read + + Dim OneEvent = New OneEventRecord + OneEvent.RowID = rs("rowID") + OneEvent.DateTime = New Date().AddSeconds(Convert.ToInt64(rs("date") / 10000)) + OneEvent.TransactionStatus = rs("transactionStatus") + OneEvent.TransactionMark = rs("transactionID") + + OneEvent.TransactionStartTime = New Date().AddYears(2000) + + Try + If Not rs("transactionDate") = 0 Then + OneEvent.TransactionStartTime = New Date().AddSeconds(Convert.ToInt64(rs("transactionDate") / 10000)) + End If + Catch ex As Exception + End Try + + OneEvent.UserName = rs("userCode") + OneEvent.ComputerName = rs("computerCode") + OneEvent.AppName = rs("appCode") + OneEvent.EventID = rs("eventCode") + OneEvent.Comment = rs("comment") + 'OneEvent.MetadataID = rs("metadataCodes") + Dim MDCodes As String = rs("metadataCodes") + If String.IsNullOrEmpty(MDCodes) Then + OneEvent.MetadataID = 0 + ElseIf MDCodes.Contains(",") Then + Dim MDCode As String = MDCodes.Split(New Char() {","c}).GetValue(0) + Integer.TryParse(MDCode, OneEvent.MetadataID) + Else + Integer.TryParse(MDCodes, OneEvent.MetadataID) + End If + + Dim s = "" + If Not String.IsNullOrEmpty(rs("data")) Then + s = UTF8.GetString(ANSI.GetBytes(rs("data"))) + End If + OneEvent.DataStructure = s + + OneEvent.DataString = rs("dataPresentation") + OneEvent.ServerID = rs("workServerCode") + OneEvent.MainPortID = rs("primaryPortCode") + OneEvent.SecondPortID = rs("secondaryPortCode") + OneEvent.Seance = rs("session") + + OneEvent.Transaction = "" + OneEvent.Field2 = "" + OneEvent.EventType = "" + OneEvent.Field7 = "" + OneEvent.Field8 = "" + + + + EventsList.Add(OneEvent) + + LastEventNumber83 = OneEvent.RowID + + End While + rs.Close() + + If EventsList.Count = 0 Then + Exit While + End If + + SaveReferenceValuesToDatabase() + + End While + + + + + Command.Dispose() + Conn.Close() + Conn.Dispose() + + Catch ex As Exception + Log.ErrorException("Error while working with EventLog table (SQLite)", ex) + End Try + + + End Sub + + Sub LoadEvents(FileName As String) + + Dim FS As FileStream = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) + FS.Position = CurrentPosition + + Dim SR As StreamReader = New StreamReader(FS) + + + + 'Dim TextFile = My.Computer.FileSystem.OpenTextFileReader(FileName) + + + 'TextFile.BaseStream.Position = Events.CurrentPosition ' учесть, что первые 2 символа служебные, т.е. первый - №3 + '' + 2 символа перевода каретки в конце каждой строки + + '' '' TEMP + ''Dim TextFile2 = My.Computer.FileSystem.OpenTextFileReader(FileName) + ''TextFile2.BaseStream.Position = Events.CurrentPosition + 1 + '' '' TEMP + + Dim TextLine = "" + + Dim CountLines = 0 + Dim NewLine = True + Dim StrEvent = "" + Dim CountBracket = 0 + Dim Position = CurrentPosition + 'Dim WasReadSomeString = False + + While Not TextLine Is Nothing + + 'CountLines = CountLines + 1 + TextLine = SR.ReadLine() + + If TextLine Is Nothing Then + 'если чтение прервано на середине, то ничего прибавлять не нужно, если же чтение + 'было завершено до конца, а потом читаются новые события, то появляется запятая, которую нужно учеть с ПЛЮС ОДИН позиции + 'If WasReadSomeString Then + + ' Position = Position + 1 + + ' Events.CurrentPosition = Position + + 'End If + + Exit While + + End If + + ' WasReadSomeString = True + + Position = Position + 2 + Text.Encoding.UTF8.GetBytes(TextLine).Length + + CurrentPosition = Position + + If NewLine Then + StrEvent = TextLine + Else + StrEvent = StrEvent + vbNewLine + TextLine + End If + + If ItsEndOfEvent(TextLine, CountBracket) Then + NewLine = True + If Not StrEvent Is Nothing Then + Try + AddEvent(StrEvent) + Catch ex As Exception + + End Try + + '*** + 'Exit While + '** + End If + Else + NewLine = False + End If + + End While + + SaveEventsToSQL() + + SR.Close() + FS.Close() + + End Sub + + Function ItsEndOfEvent(Str As String, ByRef Count As Integer) + + ItsEndOfEvent = False + + Dim TempStr = Str + Dim TextBlockOpen = False + + For i = 0 To TempStr.Length - 1 + Dim Simb = TempStr.Substring(i, 1) + If Simb = """" Then + TextBlockOpen = Not TextBlockOpen + ElseIf Simb = "}" And Not TextBlockOpen Then + Count = Count - 1 + ElseIf Simb = "{" And Not TextBlockOpen Then + Count = Count + 1 + End If + Next + + ItsEndOfEvent = (Count = 0) + + End Function + + Sub CreateStr(ByRef Str As String, LastLvl As Integer, Arr() As Object) + + Dim StrLvl = Arr(0).GetEnumerator + Dim Lvl = 0 + Dim StrTab = "" + + While StrLvl.MoveNext + If StrLvl.Current = "." Then + Lvl = Lvl + 1 + + End If + End While + + For j = 1 To Lvl - 1 + StrTab = StrTab + " " + Next + + + Dim StrVal = "" + + Dim Count = 0 + For Each Ar In Arr + Count = Count + 1 + If Count > 1 Then + StrVal = StrVal + IIf(StrVal = "", "", "; ") + Ar.ToString.Trim + End If + Next + + + If Not StrVal = "" Then + If Lvl <> LastLvl Then + Str = Str + IIf(Str = "", "", vbNewLine) + End If + Str = Str + StrTab + StrVal + End If + + LastLvl = Lvl + + End Sub + + Function DeleteQuote(Str As String) + + Dim SubStr = Str.Substring(1, Str.Length - 2) + + Return SubStr + + End Function + + Function From16To10(Str As String) + + From16To10 = 0 + + Dim Simb = "0123456789ABCDEF" + + Dim L = Str.Length + + For i = 0 To L - 1 + Dim S = Str.Substring(i, 1) + + Dim Ind = Simb.IndexOf(S.ToUpper) + + If Ind > -1 Then + From16To10 = From16To10 + Ind * Math.Pow(16, L - (i + 1)) + End If + Next + + End Function + + Public Sub AddEvent(Str As String) + + Dim provider As CultureInfo = CultureInfo.InvariantCulture + Dim OneEvent As OneEventRecord = New OneEventRecord + + Dim Array = ParserServices.ParseEventlogString(Str) + OneEvent.DateTime = Date.ParseExact(Array(0), "yyyyMMddHHmmss", provider) + OneEvent.TransactionStatus = Array(1) + + Dim TransStr = Array(2).ToString.Replace("}", "").Replace("{", "") + Dim TransDate = From16To10(TransStr.Substring(0, TransStr.IndexOf(","))) + + OneEvent.TransactionStartTime = New Date().AddYears(2000) + + Try + If Not TransDate = 0 Then + OneEvent.TransactionStartTime = New Date().AddSeconds(Convert.ToInt64(TransDate / 10000)) + End If + Catch ex As Exception + End Try + + OneEvent.TransactionMark = From16To10(TransStr.Substring(TransStr.IndexOf(",") + 1)) + + OneEvent.Transaction = Array(2) + OneEvent.UserName = Convert.ToInt32(Array(3)) + OneEvent.ComputerName = Convert.ToInt32(Array(4)) + OneEvent.AppName = Convert.ToInt32(Array(5)) + OneEvent.Field2 = Array(6) + OneEvent.EventID = Convert.ToInt32(Array(7)) + OneEvent.EventType = Array(8) + OneEvent.Comment = DeleteQuote(Array(9)) + OneEvent.MetadataID = Convert.ToInt32(Array(10)) + OneEvent.DataStructure = Array(11) + OneEvent.DataString = DeleteQuote(Array(12)) + OneEvent.ServerID = Convert.ToInt32(Array(13)) + OneEvent.MainPortID = Convert.ToInt32(Array(14)) + OneEvent.SecondPortID = Convert.ToInt32(Array(15)) + OneEvent.Seance = Convert.ToInt32(Array(16)) + OneEvent.Field7 = Array(17) + OneEvent.Field8 = Array(18) + + '************************************************************************* + + + EventsList.Add(OneEvent) + 'Events(Events.Length - 1) = OneEvent + + If EventsList.Count >= 1000 Then + 'Console.WriteLine("Выгрузка 1000 событий: " + Now.ToString) + SaveEventsToSQL() + End If + + End Sub + + Public Sub DoWork() + + While True + + Console.WriteLine(Now.ToShortTimeString + " Start new iteration...") + + Try + + LoadReference() + + GetReadParametersFromFile() + + FindAndStartParseFiles() + + Catch ex As Exception + Log.ErrorException("Error occurred during log file processing (" + InfobaseName + ")", ex) + End Try + + Threading.Thread.Sleep(SleepTime) + + End While + + + End Sub +End Class diff --git a/EventLogLoaderService/Service1.vb b/EventLogLoaderService/Service1.vb index d03f25a..0fcb0b8 100644 --- a/EventLogLoaderService/Service1.vb +++ b/EventLogLoaderService/Service1.vb @@ -4,1468 +4,14 @@ Imports System.Data.SqlClient Imports System.IO Imports MySql.Data.MySqlClient Imports Nest +Imports Newtonsoft.Json Public Class EventLogLoaderService - Class ReferenceClass - - Structure User - Dim Code As Int32 - Dim Name As String - Dim Guid As String - End Structure - - Structure Metadata - Dim Code As Int32 - Dim Name As String - Dim Guid As String - End Structure - - Structure Computer - Dim Code As Int32 - Dim Name As String - End Structure - - Structure Application - Dim Code As Int32 - Dim Name As String - End Structure - - Structure EventType - Dim Code As Int32 - Dim Name As String - End Structure - - Structure Server - Dim Code As Int32 - Dim Name As String - End Structure - - Structure MainPort - Dim Code As Int32 - Dim Name As String - End Structure - - Structure SecondPort - Dim Code As Int32 - Dim Name As String - End Structure - - Dim ArrayUsers As List(Of User) = New List(Of User) - Dim ArrayComputers As List(Of Computer) = New List(Of Computer) - Dim ArrayApplications As List(Of Application) = New List(Of Application) - Dim ArrayEvents As List(Of EventType) = New List(Of EventType) - Dim ArrayMetadata As List(Of Metadata) = New List(Of Metadata) - Dim ArrayServers As List(Of Server) = New List(Of Server) - Dim ArrayMainPorts As List(Of MainPort) = New List(Of MainPort) - Dim ArraySecondPorts As List(Of SecondPort) = New List(Of SecondPort) - - Public InfobaseName As String - Public InfobaseGuid As String - Public InfobaseID As Integer - Public ConnectionString As String - Public ItIsMSSQL As Boolean = False - Public ItIsMySQL As Boolean = False - Public ItIsES As Boolean = False - - Public LastUpdate As DateTime - - Public Sub AddUser(Code As Integer, Guid As String, Name As String) - - Dim Usr = New User - Usr.Code = Code - Usr.Name = Name - Usr.Guid = Guid - - ArrayUsers.Add(Usr) - - End Sub - - Public Sub AddComputer(Code As Integer, Name As String) - - Dim Item = New Computer - Item.Code = Code - Item.Name = Name - - ArrayComputers.Add(Item) - - End Sub - - Public Sub AddApplication(Code As Integer, Name As String) - - Dim Item = New Application - Item.Code = Code - Item.Name = Name - - ArrayApplications.Add(Item) - - End Sub - - Public Sub AddEvent(Code As Integer, Name As String) - - Dim Item = New EventType - Item.Code = Code - Item.Name = Name - - ArrayEvents.Add(Item) - - End Sub - - Public Sub AddMetadata(Code As Integer, Guid As String, Name As String) - - Dim MD = New Metadata - MD.Code = Code - MD.Name = Name - MD.Guid = Guid - - ArrayMetadata.Add(MD) - - End Sub - - Public Sub AddServer(Code As Integer, Name As String) - - Dim Item = New Server - Item.Code = Code - Item.Name = Name - - ArrayServers.Add(Item) - - End Sub - - Public Sub AddMainPort(Code As Integer, Name As String) - - Dim Item = New MainPort - Item.Code = Code - If String.IsNullOrEmpty(Name) Then - Item.Name = "" - Else - Item.Name = Name - End If - - - ArrayMainPorts.Add(Item) - - End Sub - - Public Sub AddSecondPort(Code As Integer, Name As String) - - Dim Item = New SecondPort - Item.Code = Code - If String.IsNullOrEmpty(Name) Then - Item.Name = "" - Else - Item.Name = Name - End If - - ArraySecondPorts.Add(Item) - - End Sub - - Public Sub SaveReferenceToSQL() - - If ItIsMSSQL Then - Dim objConn As New SqlConnection(ConnectionString) - objConn.Open() - - '--------------------------------------------------------------------------------------------------------- - Dim command As New SqlCommand("IF NOT EXISTS (select * from [dbo].[Applications] where [Code] = @v1 AND [InfobaseCode] = @v3) " + _ - "INSERT INTO [dbo].[Applications] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1, @v2)", objConn) - - For Each Item In ArrayApplications - Try - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Code - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Name - command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "IF NOT EXISTS (select * from [dbo].[Computers] where [Code] = @v1 AND [InfobaseCode] = @v3) " + _ - "INSERT INTO [dbo].[Computers] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1,@v2)" - - For Each Item In ArrayComputers - Try - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Code - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Name - command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "IF NOT EXISTS (select * from [dbo].[EventsType] where [Code] = @v1 AND [InfobaseCode] = @v3) " + _ - "INSERT INTO [dbo].[EventsType] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1,@v2)" - - For Each Item In ArrayEvents - Try - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Code - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Name - command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "IF NOT EXISTS (select * from [dbo].[MainPorts] where [Code] = @v1 AND [InfobaseCode] = @v3) " + _ - "INSERT INTO [dbo].[MainPorts] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1,@v2)" - - For Each Item In ArrayMainPorts - Try - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Code - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Name - command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "IF NOT EXISTS (select * from [dbo].[Metadata] where [Code] = @v1 AND [InfobaseCode] = @v4) " + _ - "INSERT INTO [dbo].[Metadata] ([InfobaseCode],[Code],[Name],[Guid]) VALUES(@v4, @v1,@v2,@v3)" - - For Each Item In ArrayMetadata - Try - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Code - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Name - command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Char)).Value = Item.Guid - command.Parameters.Add(New SqlParameter("@v4", SqlDbType.Int)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "IF NOT EXISTS (select * from [dbo].[Users] where [Code] = @v1 AND [InfobaseCode] = @v4) " + _ - "INSERT INTO [dbo].[Users] ([InfobaseCode],[Code],[Name],[Guid]) VALUES(@v4, @v1,@v2,@v3)" - - For Each Item In ArrayUsers - Try - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Code - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Name - command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Char)).Value = Item.Guid - command.Parameters.Add(New SqlParameter("@v4", SqlDbType.Int)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "IF NOT EXISTS (select * from [dbo].[SecondPorts] where [Code] = @v1 AND [InfobaseCode] = @v3) " + _ - "INSERT INTO [dbo].[SecondPorts] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1,@v2)" - - For Each Item In ArraySecondPorts - Try - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Code - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Name - command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "IF NOT EXISTS (select * from [dbo].[Servers] where [Code] = @v1 AND [InfobaseCode] = @v3) " + _ - "INSERT INTO [dbo].[Servers] ([InfobaseCode],[Code],[Name]) VALUES(@v3, @v1,@v2)" - - For Each Item In ArrayServers - Try - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = Item.Code - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Item.Name - command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "IF NOT EXISTS (select * from [dbo].[Infobases] where [Guid] = @v0) " + _ - "INSERT INTO [dbo].[Infobases] ([Guid],[Code],[Name]) VALUES(@v0,@v1,@v2)" - - For Each Item In ArrayServers - Try - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v0", SqlDbType.Char)).Value = InfobaseGuid - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = InfobaseID - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = InfobaseName - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - command.Dispose() - objConn.Close() - objConn.Dispose() - - ElseIf ItIsMySQL Then - - Dim objConn = New MySql.Data.MySqlClient.MySqlConnection(ConnectionString) - objConn.Open() - - Dim command As New MySqlCommand("REPLACE INTO `Applications`(`InfobaseCode`, `Code`, `Name`) VALUES(@v3, @v1, @v2)", objConn) - - For Each Item In ArrayApplications - Try - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Code - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Name - command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "REPLACE INTO `Computers` (`InfobaseCode`,`Code`,`Name`) VALUES(@v3, @v1, @v2)" - - For Each Item In ArrayComputers - Try - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Code - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Name - command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "REPLACE INTO `EventsType` (`InfobaseCode`,`Code`,`Name`) VALUES(@v3, @v1,@v2)" - - For Each Item In ArrayEvents - Try - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Code - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Name - command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "REPLACE INTO `MainPorts` (`InfobaseCode`,`Code`,`Name`) VALUES(@v3, @v1,@v2)" - - For Each Item In ArrayMainPorts - Try - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Code - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Name - command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "REPLACE INTO `Metadata` (`InfobaseCode`,`Code`,`Name`,`Guid`) VALUES(@v4, @v1,@v2,@v3)" - - For Each Item In ArrayMetadata - Try - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Code - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Name - command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.VarChar)).Value = Item.Guid - command.Parameters.Add(New MySqlParameter("@v4", MySqlDbType.Int32)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "REPLACE INTO `Users` (`InfobaseCode`,`Code`,`Name`,`Guid`) VALUES(@v4, @v1,@v2,@v3)" - - For Each Item In ArrayUsers - Try - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Code - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Name - command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.VarChar)).Value = Item.Guid - command.Parameters.Add(New MySqlParameter("@v4", MySqlDbType.Int32)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "REPLACE INTO `SecondPorts` (`InfobaseCode`,`Code`,`Name`) VALUES(@v3, @v1,@v2)" - - For Each Item In ArraySecondPorts - Try - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Code - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Name - command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "REPLACE INTO `Servers` (`InfobaseCode`,`Code`,`Name`) VALUES(@v3, @v1,@v2)" - - For Each Item In ArrayServers - Try - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = Item.Code - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Item.Name - command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - '--------------------------------------------------------------------------------------------------------- - command.CommandText = "REPLACE INTO `Infobases` (`Guid`,`Code`,`Name`) VALUES(@v0,@v1,@v2)" - - For Each Item In ArrayServers - Try - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v0", MySqlDbType.VarChar)).Value = InfobaseGuid - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = InfobaseID - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = InfobaseName - command.ExecuteNonQuery() - Catch ex As Exception - Console.WriteLine(ex.Message) - End Try - Next - - command.Dispose() - objConn.Close() - objConn.Dispose() - - - End If - - - - ArrayUsers.Clear() - ArrayComputers.Clear() - ArrayApplications.Clear() - ArrayEvents.Clear() - ArrayMetadata.Clear() - ArrayServers.Clear() - ArrayMainPorts.Clear() - ArraySecondPorts.Clear() - - LastUpdate = Now - - End Sub - - - End Class - - Class EventLogLoader - - Class OneEvent - Public RowID As Integer - Public DateTime As Date - Public TransactionStatus As String - Public Transaction As String - Public TransactionStartTime As Date - Public TransactionMark As Int64 - Public UserName As Integer - Public ComputerName As Integer - Public AppName As Integer - Public Field2 As String - Public EventID As Integer - Public EventType As String - Public Comment As String - Public MetadataID As Integer - Public DataStructure As String - Public DataString As String - Public ServerID As Integer - Public MainPortID As Integer - Public SecondPortID As Integer - Public Seance As Integer - Public Field7 As String - Public Field8 As String - End Class - - Public Events As List(Of OneEvent) = New List(Of OneEvent) - Public CurrentPosition As Int64 = 0 - Public CurrentFilename As String = "" - Public Log As NLog.Logger - - Public InfobaseName As String - Public InfobaseID As Integer - Public LastEventNumber83 As Integer = 0 - - Public ConnectionString As String - Public ItIsMSSQL As Boolean - Public ItIsMySQL As Boolean - Public ItIsES As Boolean - - Sub CreateStr(ByRef Str As String, LastLvl As Integer, Arr() As Object) - - Dim StrLvl = Arr(0).GetEnumerator - Dim Lvl = 0 - Dim StrTab = "" - - While StrLvl.MoveNext - If StrLvl.Current = "." Then - Lvl = Lvl + 1 - - End If - End While - - For j = 1 To Lvl - 1 - StrTab = StrTab + " " - Next - - - Dim StrVal = "" - - Dim Count = 0 - For Each Ar In Arr - Count = Count + 1 - If Count > 1 Then - StrVal = StrVal + IIf(StrVal = "", "", "; ") + Ar.ToString.Trim - End If - Next - - - If Not StrVal = "" Then - If Lvl <> LastLvl Then - Str = Str + IIf(Str = "", "", vbNewLine) - End If - Str = Str + StrTab + StrVal - End If - - LastLvl = Lvl - - End Sub - - Function DeleteQuote(Str As String) - - Dim SubStr = Str.Substring(1, Str.Length - 2) - - Return SubStr - - End Function - - Function From16To10(Str As String) - - From16To10 = 0 - - Dim Simb = "0123456789ABCDEF" - - Dim L = Str.Length - - For i = 0 To L - 1 - Dim S = Str.Substring(i, 1) - - Dim Ind = Simb.IndexOf(S.ToUpper) - - If Ind > -1 Then - From16To10 = From16To10 + Ind * Math.Pow(16, L - (i + 1)) - End If - Next - - End Function - - Public Sub AddEvent(Str As String) - - Dim provider As CultureInfo = CultureInfo.InvariantCulture - Dim OneEvent As OneEvent = New OneEvent - - Dim Array = ParserServices.ParseEventlogString(Str) - OneEvent.DateTime = Date.ParseExact(Array(0), "yyyyMMddHHmmss", provider) - OneEvent.TransactionStatus = Array(1) - - Dim TransStr = Array(2).ToString.Replace("}", "").Replace("{", "") - Dim TransDate = From16To10(TransStr.Substring(0, TransStr.IndexOf(","))) - - OneEvent.TransactionStartTime = New Date().AddYears(2000) - - Try - If Not TransDate = 0 Then - OneEvent.TransactionStartTime = New Date().AddSeconds(Convert.ToInt64(TransDate / 10000)) - End If - Catch ex As Exception - End Try - - OneEvent.TransactionMark = From16To10(TransStr.Substring(TransStr.IndexOf(",") + 1)) - - OneEvent.Transaction = Array(2) - OneEvent.UserName = Convert.ToInt32(Array(3)) - OneEvent.ComputerName = Convert.ToInt32(Array(4)) - OneEvent.AppName = Convert.ToInt32(Array(5)) - OneEvent.Field2 = Array(6) - OneEvent.EventID = Convert.ToInt32(Array(7)) - OneEvent.EventType = Array(8) - OneEvent.Comment = DeleteQuote(Array(9)) - OneEvent.MetadataID = Convert.ToInt32(Array(10)) - OneEvent.DataStructure = Array(11) - OneEvent.DataString = DeleteQuote(Array(12)) - OneEvent.ServerID = Convert.ToInt32(Array(13)) - OneEvent.MainPortID = Convert.ToInt32(Array(14)) - OneEvent.SecondPortID = Convert.ToInt32(Array(15)) - OneEvent.Seance = Convert.ToInt32(Array(16)) - OneEvent.Field7 = Array(17) - OneEvent.Field8 = Array(18) - - '************************************************************************* - - - Events.Add(OneEvent) - 'Events(Events.Length - 1) = OneEvent - - If Events.Count >= 1000 Then - 'Console.WriteLine("Выгрузка 1000 событий: " + Now.ToString) - SaveEventsToSQL() - End If - - End Sub - - Public Sub SaveEventsToSQL() - - If Events.Count = 0 Then - Return - End If - - If ItIsMSSQL Then - Dim objConn As New SqlConnection(ConnectionString) - objConn.Open() - - Dim command As New SqlCommand("BEGIN TRANSACTION", objConn) - command.ExecuteNonQuery() - - command.CommandText = "INSERT INTO [dbo].[Events] ([InfobaseCode],[DateTime],[TransactionStatus],[Transaction],[UserName],[ComputerName]" + - ",[AppName],[Field2],[EventID],[EventType],[Comment],[MetadataID],[DataStructure],[DataString]" + - ",[ServerID],[MainPortID],[SecondPortID],[Seance],[Field7],[Field8],[TransactionStartTime],[TransactionMark])" + - " VALUES(@v0,@v1,@v2,@v3,@v4,@v5,@v6,@v7,@v8,@v9,@v10,@v11,@v12,@v13,@v14,@v15,@v16,@v17,@v18,@v19,@v20,@v21)" - - Dim i = 0 - For Each Ev In Events - - If Ev.AppName = Nothing Then Continue For - - Try - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v0", SqlDbType.Int)).Value = InfobaseID - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.DateTime)).Value = Ev.DateTime - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = Ev.TransactionStatus - command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Char)).Value = Ev.Transaction - command.Parameters.Add(New SqlParameter("@v4", SqlDbType.Int)).Value = Ev.UserName - command.Parameters.Add(New SqlParameter("@v5", SqlDbType.Int)).Value = Ev.ComputerName - command.Parameters.Add(New SqlParameter("@v6", SqlDbType.Int)).Value = Ev.AppName - command.Parameters.Add(New SqlParameter("@v7", SqlDbType.Char)).Value = Ev.Field2 - command.Parameters.Add(New SqlParameter("@v8", SqlDbType.Int)).Value = Ev.EventID - command.Parameters.Add(New SqlParameter("@v9", SqlDbType.Char)).Value = Ev.EventType - command.Parameters.Add(New SqlParameter("@v10", SqlDbType.VarChar)).Value = Ev.Comment - command.Parameters.Add(New SqlParameter("@v11", SqlDbType.Int)).Value = Ev.MetadataID - - If Ev.DataStructure.Length > 100 Then - Ev.DataStructure = Ev.DataStructure.Substring(0, 99) - End If - command.Parameters.Add(New SqlParameter("@v12", SqlDbType.Char)).Value = Ev.DataStructure - - command.Parameters.Add(New SqlParameter("@v13", SqlDbType.VarChar)).Value = Ev.DataString - command.Parameters.Add(New SqlParameter("@v14", SqlDbType.Int)).Value = Ev.ServerID - command.Parameters.Add(New SqlParameter("@v15", SqlDbType.Int)).Value = Ev.MainPortID - command.Parameters.Add(New SqlParameter("@v16", SqlDbType.Int)).Value = Ev.SecondPortID - command.Parameters.Add(New SqlParameter("@v17", SqlDbType.Int)).Value = Ev.Seance - command.Parameters.Add(New SqlParameter("@v18", SqlDbType.Char)).Value = Ev.Field7 - command.Parameters.Add(New SqlParameter("@v19", SqlDbType.Char)).Value = Ev.Field8 - command.Parameters.Add(New SqlParameter("@v20", SqlDbType.DateTime)).Value = Ev.TransactionStartTime - command.Parameters.Add(New SqlParameter("@v21", SqlDbType.BigInt)).Value = Ev.TransactionMark - - command.ExecuteNonQuery() - i += 1 - Catch ex As Exception - Log.Error("Ошибка сохранения в БД записи от " + Ev.DateTime.ToString + - " по ИБ " + InfobaseName + " : " + ex.Message) - End Try - - - Next - - Console.WriteLine(Now.ToShortTimeString + " Записано новых событий в базу " + i.ToString) - - command.CommandText = "IF NOT EXISTS (select * from [dbo].[Params] where [InfobaseCode] = @v3) " + - "INSERT INTO [dbo].[Params] ([InfobaseCode], [Position], [Filename], [LastEventID]) VALUES(@v3,@v1,@v2,@v4) " + - "ELSE UPDATE [dbo].[Params] SET [Position] = @v1, [Filename] = @v2, [LastEventID] = @v4 WHERE [InfobaseCode] = @v3" - - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.BigInt)).Value = CurrentPosition - command.Parameters.Add(New SqlParameter("@v2", SqlDbType.Char)).Value = IIf(CurrentFilename = "", " ", CurrentFilename) - command.Parameters.Add(New SqlParameter("@v3", SqlDbType.Int)).Value = InfobaseID - command.Parameters.Add(New SqlParameter("@v4", SqlDbType.Int)).Value = IIf(LastEventNumber83 = 0, -1, LastEventNumber83) - command.ExecuteNonQuery() - - command.CommandText = "COMMIT TRANSACTION" - command.Parameters.Clear() - command.ExecuteNonQuery() - - command.Dispose() - objConn.Close() - objConn.Dispose() - - ElseIf ItIsMySQL Then - - Dim objConn As New MySqlConnection(ConnectionString) - objConn.Open() - - Dim command As New MySqlCommand("START TRANSACTION", objConn) - command.ExecuteNonQuery() - - command.CommandText = "INSERT INTO `Events` (`InfobaseCode`,`DateTime`,`TransactionStatus`,`Transaction`,`UserName`,`ComputerName`" + - ",`AppName`,`Field2`,`EventID`,`EventType`,`Comment`,`MetadataID`,`DataStructure`,`DataString`" + - ",`ServerID`,`MainPortID`,`SecondPortID`,`Seance`,`Field7`,`Field8`,`TransactionStartTime`,`TransactionMark`)" + - " VALUES(@v0,@v1,@v2,@v3,@v4,@v5,@v6,@v7,@v8,@v9,@v10,@v11,@v12,@v13,@v14,@v15,@v16,@v17,@v18,@v19,@v20,@v21)" - - Dim i = 0 - For Each Ev In Events - - If Ev.AppName = Nothing Then Continue For - - Try - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v0", MySqlDbType.Int32)).Value = InfobaseID - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.DateTime)).Value = Ev.DateTime - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = Ev.TransactionStatus - command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.VarChar)).Value = Ev.Transaction - command.Parameters.Add(New MySqlParameter("@v4", MySqlDbType.Int32)).Value = Ev.UserName - command.Parameters.Add(New MySqlParameter("@v5", MySqlDbType.Int32)).Value = Ev.ComputerName - command.Parameters.Add(New MySqlParameter("@v6", MySqlDbType.Int32)).Value = Ev.AppName - command.Parameters.Add(New MySqlParameter("@v7", MySqlDbType.VarChar)).Value = Ev.Field2 - command.Parameters.Add(New MySqlParameter("@v8", MySqlDbType.Int32)).Value = Ev.EventID - command.Parameters.Add(New MySqlParameter("@v9", MySqlDbType.VarChar)).Value = Ev.EventType - command.Parameters.Add(New MySqlParameter("@v10", MySqlDbType.VarChar)).Value = Ev.Comment - command.Parameters.Add(New MySqlParameter("@v11", MySqlDbType.Int32)).Value = Ev.MetadataID - command.Parameters.Add(New MySqlParameter("@v12", MySqlDbType.VarChar)).Value = Ev.DataStructure - command.Parameters.Add(New MySqlParameter("@v13", MySqlDbType.VarChar)).Value = Ev.DataString - command.Parameters.Add(New MySqlParameter("@v14", MySqlDbType.Int32)).Value = Ev.ServerID - command.Parameters.Add(New MySqlParameter("@v15", MySqlDbType.Int32)).Value = Ev.MainPortID - command.Parameters.Add(New MySqlParameter("@v16", MySqlDbType.Int32)).Value = Ev.SecondPortID - command.Parameters.Add(New MySqlParameter("@v17", MySqlDbType.Int32)).Value = Ev.Seance - command.Parameters.Add(New MySqlParameter("@v18", MySqlDbType.VarChar)).Value = Ev.Field7 - command.Parameters.Add(New MySqlParameter("@v19", MySqlDbType.VarChar)).Value = Ev.Field8 - command.Parameters.Add(New MySqlParameter("@v20", MySqlDbType.DateTime)).Value = Ev.TransactionStartTime - command.Parameters.Add(New MySqlParameter("@v21", MySqlDbType.Int64)).Value = Ev.TransactionMark - - command.ExecuteNonQuery() - i += 1 - Catch ex As Exception - Log.Error("Ошибка сохранения в БД записи от " + Ev.DateTime.ToString + - " по ИБ " + InfobaseName + " : " + ex.Message) - End Try - - - Next - - Console.WriteLine(Now.ToShortTimeString + " Записано новых событий в базу " + i.ToString) - - command.CommandText = "REPLACE INTO `Params` (`InfobaseCode`, `Position`, `Filename`, `LastEventID`) VALUES(@v3,@v1,@v2,@v4)" - - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int64)).Value = CurrentPosition - command.Parameters.Add(New MySqlParameter("@v2", MySqlDbType.VarChar)).Value = IIf(CurrentFilename = "", " ", CurrentFilename) - command.Parameters.Add(New MySqlParameter("@v3", MySqlDbType.Int32)).Value = InfobaseID - command.Parameters.Add(New MySqlParameter("@v4", MySqlDbType.Int32)).Value = IIf(LastEventNumber83 = 0, -1, LastEventNumber83) - command.ExecuteNonQuery() - - command.CommandText = "COMMIT" - command.Parameters.Clear() - command.ExecuteNonQuery() - - command.Dispose() - objConn.Close() - objConn.Dispose() - - ElseIf ItIsES Then - - Dim Index = "event-log-ibguid" - Dim node = New Uri(ConnectionString) - - Dim _settings = New ConnectionSettings(node).DefaultIndex(Index).MaximumRetries(2).MaxRetryTimeout(TimeSpan.FromSeconds(150)) - Dim _current = New ElasticClient(_settings) - - 'Dim elasticsearchMappingResolver As IElasticsearchMappingResolver = New ElasticsearchMappingResolver() - 'elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(TypeOf (), New ElasticsearchMappingTestDto()); - 'Dim context = New ElasticsearchContext(ConnectionString, New ElasticsearchSerializerConfiguration(elasticsearchMappingResolver, True, True)) - - - 'Dim descriptor = New BulkDescriptor() - 'For Each item In Events - ' ' descriptor.Index(Of OneEvent)(Function(op) op.Document(item)) - 'Next - 'Dim result = _current.Bulk(descriptor) - - Dim Result = _current.IndexMany(Events, Index, "event-record") - - Dim a = 0 - - End If - - - - Events.Clear() - - End Sub - - Public Sub GetParamFromSQL() - - If ItIsMSSQL Then - - Dim objConn As New SqlConnection(ConnectionString) - objConn.Open() - - Dim command As New SqlCommand("SELECT [Position],[Filename],[LastEventID] FROM [dbo].[Params] WHERE [InfobaseCode] = @v1", objConn) - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Int)).Value = InfobaseID - - Dim rs = command.ExecuteReader - - While rs.Read - CurrentPosition = Convert.ToInt64(rs(0)) - CurrentFilename = rs(1).ToString.Trim - LastEventNumber83 = rs(2) - End While - - rs.Close() - command.Dispose() - objConn.Close() - objConn.Dispose() - - ElseIf ItIsMySQL Then - - Dim objConn = New MySql.Data.MySqlClient.MySqlConnection(ConnectionString) - objConn.Open() - - - Dim command As New MySqlCommand("SELECT `Position`,`Filename`,`LastEventID` FROM `Params` WHERE `InfobaseCode` = @v1", objConn) - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.Int32)).Value = InfobaseID - - Dim rs = command.ExecuteReader - - While rs.Read - CurrentPosition = Convert.ToInt64(rs(0)) - CurrentFilename = rs(1).ToString.Trim - LastEventNumber83 = rs(2) - End While - - rs.Close() - command.Dispose() - objConn.Close() - objConn.Dispose() - - End If - - - - End Sub - - End Class - - Class InfoBaseEventlog - - Public Catalog As String - Public Log As NLog.Logger - Public Name As String - Public ConnectionString As String - Public ItIsMSSQL As Boolean = False - Public ItIsMySQL As Boolean = False - Public ItIsES As Boolean = False - Public Guid As String - Public ID As Integer = 0 - Public Reference As ReferenceClass - Public Events As EventLogLoader - 'Dim Parser As New Parser - Public SleepTime As Integer = 60 * 1000 '1 минут - - Public Sub PrepareInfobaseID() - - 'У нас есть ГУИД базы, но нет сквозного кода для информации. - 'Сделано для оптимизации, чтобы в каждой строке события не записывать ГУИД, а хранить целое число. - - If ItIsMSSQL Then - - Dim objConn As New SqlConnection(ConnectionString) - objConn.Open() - - Dim command As New SqlCommand("SELECT [Code] FROM [dbo].[Infobases] WHERE [Guid] = @v1", objConn) - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Char)).Value = Guid - - Dim rs = command.ExecuteReader - - If rs.Read Then - ID = Convert.ToInt32(rs(0)) - End If - rs.Close() - - If ID = 0 Then - - command.CommandText = "INSERT INTO Infobases ([Code],[Name],[guid])" + _ - " SELECT MAX(f) AS [Code], @v0 as [Name], @v1 as [guid] FROM " + _ - " (SELECT MAX(Code) + 1 AS f FROM Infobases UNION ALL" + _ - " SELECT 1 AS Expr1) AS T" - command.Parameters.Clear() - command.Parameters.Add(New SqlParameter("@v0", SqlDbType.Char)).Value = Name - command.Parameters.Add(New SqlParameter("@v1", SqlDbType.Char)).Value = Guid - command.ExecuteNonQuery() - - command.CommandText = "SELECT [Code] FROM [dbo].[Infobases] WHERE [Guid] = @v1" - rs = command.ExecuteReader() - - If rs.Read Then - ID = Convert.ToInt32(rs(0)) - End If - - rs.Close() - - End If - - command.Dispose() - objConn.Close() - objConn.Dispose() - - ElseIf ItIsMySQL Then - - Dim objConn As New MySqlConnection(ConnectionString) - objConn.Open() - - Dim command As New MySqlCommand("SELECT `Code` FROM `Infobases` WHERE `Guid` = @v1", objConn) - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.VarChar)).Value = Guid - - Dim rs = command.ExecuteReader - - If rs.Read Then - ID = Convert.ToInt32(rs(0)) - End If - rs.Close() - - If ID = 0 Then - - command.CommandText = "INSERT INTO Infobases (`Code`,`Name`,`guid`)" + _ - " SELECT MAX(f) AS `Code`, @v0 as `Name`, @v1 as `guid` FROM " + _ - " (SELECT MAX(Code) + 1 AS f FROM `Infobases` UNION ALL" + _ - " SELECT 1 AS `Expr1`) AS T" - command.Parameters.Clear() - command.Parameters.Add(New MySqlParameter("@v0", MySqlDbType.VarChar)).Value = Name - command.Parameters.Add(New MySqlParameter("@v1", MySqlDbType.VarChar)).Value = Guid - command.ExecuteNonQuery() - - command.CommandText = "SELECT `Code` FROM `Infobases` WHERE `Guid` = @v1" - rs = command.ExecuteReader() - - If rs.Read Then - ID = Convert.ToInt32(rs(0)) - End If - - rs.Close() - - End If - - command.Dispose() - objConn.Close() - objConn.Dispose() - - End If - - '-------------------------------------------------------------- - End Sub - - Public Sub Initialize() - - Events = New EventLogLoader - Events.InfobaseID = ID - Events.InfobaseName = Name - Events.ConnectionString = ConnectionString - Events.Log = Log - Events.ItIsMSSQL = ItIsMSSQL - Events.ItIsMySQL = ItIsMySQL - Events.ItIsES = ItIsES - Events.GetParamFromSQL() - - End Sub - - Public Sub LoadReference() - - 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 >= Reference.LastUpdate 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() - - - 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" - Reference.AddUser(Convert.ToInt32(a(4)), a(2), a(3)) - Case "2" - Reference.AddComputer(Convert.ToInt32(a(3)), a(2)) - Case "3" - Reference.AddApplication(Convert.ToInt32(a(3)), a(2)) - Case "4" - Reference.AddEvent(Convert.ToInt32(a(3)), a(2)) - Case "5" - Reference.AddMetadata(Convert.ToInt32(a(4)), a(2), a(3)) - Case "6" - Reference.AddServer(Convert.ToInt32(a(3)), a(2)) - Case "7" - Reference.AddMainPort(Convert.ToInt32(a(3)), a(2)) - Case "8" - Reference.AddSecondPort(Convert.ToInt32(a(3)), a(2)) - 'Case "9" - не видел этих в файле - 'Case "10" - Case "11" - Case "12" - Case "13" - 'в числе последних трех должны быть статус транзакци и важность - Case Else - - End Select - - End If - Next - - Reference.SaveReferenceToSQL() - - End If - - End If - Catch ex As Exception - Log.ErrorException("Ошибка при работе со справочником", ex) - End Try - - - Try - - Dim FileName = Path.Combine(Catalog, "1Cv8.lgd") - - If My.Computer.FileSystem.FileExists(FileName) Then - - Dim Conn = New System.Data.SQLite.SQLiteConnection("Data Source=" + FileName) - Conn.Open() - Dim Command = New System.Data.SQLite.SQLiteCommand - Command.Connection = Conn - - Command.CommandText = "SELECT [code], [name] FROM [AppCodes]" - Dim rs = Command.ExecuteReader - While rs.Read - Reference.AddApplication(rs(0), rs(1)) - End While - rs.Close() - - Command.CommandText = "SELECT [code], [name] FROM [ComputerCodes]" - rs = Command.ExecuteReader - While rs.Read - Reference.AddComputer(rs(0), rs(1)) - End While - rs.Close() - - Command.CommandText = "SELECT [code], [name] FROM [EventCodes]" - rs = Command.ExecuteReader - While rs.Read - Reference.AddEvent(rs(0), rs(1)) - End While - rs.Close() - - Command.CommandText = "SELECT [code], [uuid], [name] FROM [UserCodes]" - rs = Command.ExecuteReader - While rs.Read - Reference.AddUser(rs(0), rs(1), rs(2)) - End While - rs.Close() - - Command.CommandText = "SELECT [code], [name] FROM [WorkServerCodes]" - rs = Command.ExecuteReader - While rs.Read - Reference.AddServer(rs(0), rs(1)) - End While - rs.Close() - - Command.CommandText = "SELECT [code], [uuid], [name] FROM [MetadataCodes]" - rs = Command.ExecuteReader - While rs.Read - Reference.AddMetadata(rs(0), rs(1), rs(2)) - End While - rs.Close() - - Command.CommandText = "SELECT [code], [name] FROM [PrimaryPortCodes]" - rs = Command.ExecuteReader - While rs.Read - Reference.AddMainPort(rs(0), rs(1)) - End While - rs.Close() - - Command.CommandText = "SELECT [code], [name] FROM [SecondaryPortCodes]" - rs = Command.ExecuteReader - While rs.Read - Reference.AddSecondPort(rs(0), rs(1)) - End While - rs.Close() - - Command.Dispose() - Conn.Close() - Conn.Dispose() - - Reference.SaveReferenceToSQL() - - End If - - Catch ex As Exception - Log.ErrorException("Ошибка при работе со справочником", ex) - End Try - - End Sub - - Sub FindAndStartParseFiles() - - Dim v83File = Path.Combine(Catalog, "1Cv8.lgd") - If My.Computer.FileSystem.FileExists(v83File) Then - - LoadEvents83(v83File) - - Events.SaveEventsToSQL() - - Else - - Dim ArrayFiles(0) As String - Dim i = 0 - - If My.Computer.FileSystem.DirectoryExists(Catalog) Then - - Dim Files = My.Computer.FileSystem.GetFiles(Catalog) - For Each File In Files - If File.EndsWith(".lgp") Then - ReDim Preserve ArrayFiles(i) - ArrayFiles(i) = File - i = i + 1 - End If - Next - - System.Array.Sort(ArrayFiles) - - For Each File In ArrayFiles - If Not File Is Nothing Then - Try - Dim FI = My.Computer.FileSystem.GetFileInfo(File) - If FI.Name >= Events.CurrentFilename Then - If Not FI.Name = Events.CurrentFilename Then - Events.CurrentPosition = 61 ' start position for log-file 1C - End If - Events.CurrentFilename = FI.Name - LoadEvents(File) - End If - Catch ex As Exception - Log.ErrorException("Ошибка в FindAndStartParseFiles", ex) - End Try - End If - - Next - - Events.SaveEventsToSQL() - - End If - End If - - - - - End Sub - - Sub LoadEvents83(FileName As String) - Try - - Dim Conn = New System.Data.SQLite.SQLiteConnection("Data Source=" + FileName) - Conn.Open() - Dim Command = New System.Data.SQLite.SQLiteCommand - Command.Connection = Conn - - Dim ANSI = Text.Encoding.GetEncoding(1251) - Dim UTF8 = Text.Encoding.UTF8 - - While True - - Command.CommandText = "SELECT [rowID],[severity],[date],[connectID],[session]" + _ - ",[transactionStatus],[transactionDate],[transactionID],[userCode],[computerCode],[appCode]" + _ - ",[eventCode],[comment],[metadataCodes],[sessionDataSplitCode],[dataType],[data]" + _ - ",[dataPresentation],[workServerCode],[primaryPortCode],[secondaryPortCode]" + _ - " FROM [EventLog] WHERE [rowID] > " + Events.LastEventNumber83.ToString + " LIMIT 1000" - Dim rs = Command.ExecuteReader - - While rs.Read - - Dim OneEvent = New EventLogLoader.OneEvent - OneEvent.RowID = rs("rowID") - OneEvent.DateTime = New Date().AddSeconds(Convert.ToInt64(rs("date") / 10000)) - OneEvent.TransactionStatus = rs("transactionStatus") - OneEvent.TransactionMark = rs("transactionID") - - OneEvent.TransactionStartTime = New Date().AddYears(2000) - - Try - If Not rs("transactionDate") = 0 Then - OneEvent.TransactionStartTime = New Date().AddSeconds(Convert.ToInt64(rs("transactionDate") / 10000)) - End If - Catch ex As Exception - End Try - - OneEvent.UserName = rs("userCode") - OneEvent.ComputerName = rs("computerCode") - OneEvent.AppName = rs("appCode") - OneEvent.EventID = rs("eventCode") - OneEvent.Comment = rs("comment") - 'OneEvent.MetadataID = rs("metadataCodes") - Dim MDCodes As String = rs("metadataCodes") - If String.IsNullOrEmpty(MDCodes) Then - OneEvent.MetadataID = 0 - ElseIf MDCodes.Contains(",") Then - Dim MDCode As String = MDCodes.Split(New Char() {","c}).GetValue(0) - Integer.TryParse(MDCode, OneEvent.MetadataID) - Else - Integer.TryParse(MDCodes, OneEvent.MetadataID) - End If - - Dim s = "" - If Not String.IsNullOrEmpty(rs("data")) Then - s = UTF8.GetString(ANSI.GetBytes(rs("data"))) - End If - OneEvent.DataStructure = s - - OneEvent.DataString = rs("dataPresentation") - OneEvent.ServerID = rs("workServerCode") - OneEvent.MainPortID = rs("primaryPortCode") - OneEvent.SecondPortID = rs("secondaryPortCode") - OneEvent.Seance = rs("session") - - OneEvent.Transaction = "" - OneEvent.Field2 = "" - OneEvent.EventType = "" - OneEvent.Field7 = "" - OneEvent.Field8 = "" - - - - Events.Events.Add(OneEvent) - - Events.LastEventNumber83 = OneEvent.RowID - - End While - rs.Close() - - If Events.Events.Count = 0 Then - Exit While - End If - - Events.SaveEventsToSQL() - - End While - - - - - Command.Dispose() - Conn.Close() - Conn.Dispose() - - Catch ex As Exception - Log.ErrorException("Ошибка при работе с таблицей событий", ex) - End Try - - - End Sub - - Sub LoadEvents(FileName As String) - - Dim FS As FileStream = New FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) - FS.Position = Events.CurrentPosition - - Dim SR As StreamReader = New StreamReader(FS) - - - - 'Dim TextFile = My.Computer.FileSystem.OpenTextFileReader(FileName) - - - 'TextFile.BaseStream.Position = Events.CurrentPosition ' учесть, что первые 2 символа служебные, т.е. первый - №3 - '' + 2 символа перевода каретки в конце каждой строки - - '' '' TEMP - ''Dim TextFile2 = My.Computer.FileSystem.OpenTextFileReader(FileName) - ''TextFile2.BaseStream.Position = Events.CurrentPosition + 1 - '' '' TEMP - - Dim TextLine = "" - - Dim CountLines = 0 - Dim NewLine = True - Dim StrEvent = "" - Dim CountBracket = 0 - Dim Position = Events.CurrentPosition - 'Dim WasReadSomeString = False - - While Not TextLine Is Nothing - - 'CountLines = CountLines + 1 - TextLine = SR.ReadLine() - - If TextLine Is Nothing Then - 'если чтение прервано на середине, то ничего прибавлять не нужно, если же чтение - 'было завершено до конца, а потом читаются новые события, то появляется запятая, которую нужно учеть с ПЛЮС ОДИН позиции - 'If WasReadSomeString Then - - ' Position = Position + 1 - - ' Events.CurrentPosition = Position - - 'End If - - Exit While - - End If - - ' WasReadSomeString = True - - Position = Position + 2 + Text.Encoding.UTF8.GetBytes(TextLine).Length - - Events.CurrentPosition = Position - - If NewLine Then - StrEvent = TextLine - Else - StrEvent = StrEvent + vbNewLine + TextLine - End If - - If ItsEndOfEvent(TextLine, CountBracket) Then - NewLine = True - If Not StrEvent Is Nothing Then - Try - Events.AddEvent(StrEvent) - Catch ex As Exception - - End Try - - '*** - 'Exit While - '** - End If - Else - NewLine = False - End If - - End While - - Events.SaveEventsToSQL() - - SR.Close() - fs.Close() - - End Sub - - Function ItsEndOfEvent(Str As String, ByRef Count As Integer) - - ItsEndOfEvent = False - - Dim TempStr = Str - Dim TextBlockOpen = False - - For i = 0 To TempStr.Length - 1 - Dim Simb = TempStr.Substring(i, 1) - If Simb = """" Then - TextBlockOpen = Not TextBlockOpen - ElseIf Simb = "}" And Not TextBlockOpen Then - Count = Count - 1 - ElseIf Simb = "{" And Not TextBlockOpen Then - Count = Count + 1 - End If - Next - - ItsEndOfEvent = (Count = 0) - - End Function - - Public Sub DoWork() - - Try - Reference = New ReferenceClass - Reference.InfobaseGuid = Guid - Reference.InfobaseID = ID - Reference.InfobaseName = Name - Reference.ConnectionString = ConnectionString - Reference.ItIsMSSQL = ItIsMSSQL - Reference.ItIsMySQL = ItIsMySQL - Reference.ItIsES = ItIsES - - Catch ex As Exception - Log.ErrorException("Ошибка создания объекта справочника для ИБ (" + Name + ")", ex) - End Try - - - While True - - Console.WriteLine(Now.ToShortTimeString + " Запуск итерации проверки новых событий") - Try - - LoadReference() - - Initialize() - - FindAndStartParseFiles() - - Catch ex As Exception - Log.ErrorException("Ошибка обработки файлов событий ИБ (" + Name + ")", ex) - End Try - - Threading.Thread.Sleep(SleepTime) - - End While - - - End Sub - - End Class - - Dim ArrayIB() As InfoBaseEventlog + Dim ListOfProcessors As List(Of EventLogProcessor) = New List(Of EventLogProcessor) Dim ArrayThread() As Threading.Thread Dim ConfigSettingObj As ConfigSetting = New ConfigSetting + Dim ConnectionString As String Dim DBType As String Dim ItIsMSSQL As Boolean = False @@ -1499,37 +45,33 @@ Public Class EventLogLoaderService Dim s = ConfigSettingObj.RepeatTime SleepTime = s * 1000 - Dim i = 0 For Each IBConfig In ConfigSettingObj.Infobases Dim IB_ID = IBConfig.DatabaseID Dim IB_Name = IBConfig.DatabaseName Dim IB_Catalog = IBConfig.DatabaseCatalog - Dim IB = New InfoBaseEventlog - IB.Log = NLog.LogManager.GetLogger("CurrentThread") - IB.Guid = IB_ID - IB.Name = IB_Name - IB.Catalog = IB_Catalog - IB.ConnectionString = ConnectionString - IB.SleepTime = SleepTime - IB.ItIsMSSQL = ItIsMSSQL - IB.ItIsMySQL = ItIsMySQL - IB.ItIsES = ItIsES + Dim EventLogProcessorObj = New EventLogProcessor + EventLogProcessorObj.Log = NLog.LogManager.GetLogger("CurrentThread") + EventLogProcessorObj.InfobaseGuid = IB_ID + EventLogProcessorObj.InfobaseName = IB_Name + EventLogProcessorObj.Catalog = IB_Catalog + EventLogProcessorObj.ConnectionString = ConnectionString + EventLogProcessorObj.SleepTime = SleepTime + EventLogProcessorObj.ItIsMSSQL = ItIsMSSQL + EventLogProcessorObj.ItIsMySQL = ItIsMySQL + EventLogProcessorObj.ItIsES = ItIsES - ReDim Preserve ArrayIB(i) - ArrayIB(i) = IB + ListOfProcessors.Add(EventLogProcessorObj) - i = i + 1 Next - LoadConfigSetting = True Else - Log.Error("Файл config.json не найден") + Log.Error("File config.json was not found!") End If Catch ex As Exception - Log.ErrorException("Ошибка загрузки параметров из config.json", ex) + Log.ErrorException("Parameters cannot be load from config.json file (it may be corrupted)", ex) End Try @@ -1549,7 +91,6 @@ Public Class EventLogLoaderService SubStop() End Sub - Public Sub SubStart() WorkerThread.Start() End Sub @@ -1583,7 +124,7 @@ Public Class EventLogLoaderService 'Log.Info("Запуск основного функционала") If Not LoadConfigSetting() Then - Log.Error("Ошибка работы с файлом параметров config.json в каталоге приложения") + Log.Error("Error while working with config.json file in application folder") Environment.Exit(-1) End If @@ -1591,12 +132,12 @@ Public Class EventLogLoaderService Dim i = 0 - For Each IB In ArrayIB + For Each IB In ListOfProcessors Try - IB.PrepareInfobaseID() + IB.GetInfobaseIDFromDatabase() Catch ex As Exception - Log.ErrorException("Ошибка получения ID ИБ из БД (" + IB.Name + ")", ex) + Log.ErrorException("Error occurred while getting infobase ID from target database (" + IB.InfobaseName + ")", ex) Continue For End Try @@ -1611,7 +152,7 @@ Public Class EventLogLoaderService i = i + 1 Catch ex As Exception - Log.ErrorException("Ошибка запуска потока для обслуживания ИБ (" + IB.Name + ")", ex) + Log.ErrorException("Error occurred while starting new thread (" + IB.InfobaseName + ")", ex) End Try Next @@ -1655,57 +196,57 @@ Public Class EventLogLoaderService command.ExecuteNonQuery() '********************************************************************************** - command.CommandText = "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Params'))" + vbNewLine + _ - " CREATE TABLE [dbo].[Params] ([InfobaseCode] int NOT NULL, [Position] bigint, [Filename] [char](100), [LastEventID] int);" + vbNewLine + _ - " IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Params') AND Name = 'ClusteredIndex')" + vbNewLine + _ - " CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Params] ([InfobaseCode] ASC);" - command.ExecuteNonQuery() + 'command.CommandText = "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Params'))" + vbNewLine + _ + ' " CREATE TABLE [dbo].[Params] ([InfobaseCode] int NOT NULL, [Position] bigint, [Filename] [char](100), [LastEventID] int);" + vbNewLine + _ + ' " IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Params') AND Name = 'ClusteredIndex')" + vbNewLine + _ + ' " CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Params] ([InfobaseCode] ASC);" + 'command.ExecuteNonQuery() '********************************************************************************** - command.CommandText = "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Infobases'))" + vbNewLine + _ - " CREATE TABLE [dbo].[Infobases] ([Guid] [char](40) NOT NULL, [Code] int NOT NULL, [Name] [char](100))" + vbNewLine + _ - " IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Infobases') AND Name = 'ClusteredIndex')" + vbNewLine + _ + command.CommandText = "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Infobases'))" + vbNewLine + + " CREATE TABLE [dbo].[Infobases] ([Guid] [char](40) NOT NULL, [Code] int NOT NULL, [Name] [char](100))" + vbNewLine + + " IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Infobases') AND Name = 'ClusteredIndex')" + vbNewLine + " CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Infobases] ([Guid] ASC);" command.ExecuteNonQuery() '********************************************************************************** command.CommandText = - "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Users'))" + vbNewLine + _ - "CREATE TABLE [dbo].[Users]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100), [Guid] [char](40));" + vbNewLine + _ - "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Users') AND Name = 'ClusteredIndex')" + vbNewLine + _ - "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Users] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + _ - "" + _ - "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Metadata'))" + vbNewLine + _ - "CREATE TABLE [dbo].[Metadata]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100), [Guid] [char](40));" + vbNewLine + _ - "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Metadata') AND Name = 'ClusteredIndex')" + vbNewLine + _ - "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Metadata] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + _ - "" + _ - "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Computers'))" + vbNewLine + _ - "CREATE TABLE [dbo].[Computers]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100));" + vbNewLine + _ - "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Computers') AND Name = 'ClusteredIndex')" + vbNewLine + _ - "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Computers] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + _ - "" + _ - "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Applications'))" + vbNewLine + _ - "CREATE TABLE [dbo].[Applications]([InfobaseCode] int NOT NULL, [Code] int NOT NULL,[Name] [char](100));" + vbNewLine + _ - "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Applications') AND Name = 'ClusteredIndex')" + vbNewLine + _ - "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Applications] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + _ - "" + _ - "IF NOT EXISTS (select * from sysobjects where id = object_id(N'EventsType'))" + vbNewLine + _ - "CREATE TABLE [dbo].[EventsType]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100));" + vbNewLine + _ - "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'EventsType') AND Name = 'ClusteredIndex')" + vbNewLine + _ - "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[EventsType] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + _ - "" + _ - "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Servers'))" + vbNewLine + _ - "CREATE TABLE [dbo].[Servers]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100));" + vbNewLine + _ - "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Servers') AND Name = 'ClusteredIndex')" + vbNewLine + _ - "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Servers] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + _ - "" + _ - "IF NOT EXISTS (select * from sysobjects where id = object_id(N'MainPorts'))" + vbNewLine + _ - "CREATE TABLE [dbo].[MainPorts]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100));" + vbNewLine + _ - "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'MainPorts') AND Name = 'ClusteredIndex')" + vbNewLine + _ - "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[MainPorts] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + _ - "" + _ - "IF NOT EXISTS (select * from sysobjects where id = object_id(N'SecondPorts'))" + vbNewLine + _ - "CREATE TABLE [dbo].[SecondPorts]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100));" + vbNewLine + _ - "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'SecondPorts') AND Name = 'ClusteredIndex')" + vbNewLine + _ + "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Users'))" + vbNewLine + + "CREATE TABLE [dbo].[Users]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100), [Guid] [char](40));" + vbNewLine + + "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Users') AND Name = 'ClusteredIndex')" + vbNewLine + + "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Users] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + + "" + + "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Metadata'))" + vbNewLine + + "CREATE TABLE [dbo].[Metadata]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100), [Guid] [char](40));" + vbNewLine + + "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Metadata') AND Name = 'ClusteredIndex')" + vbNewLine + + "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Metadata] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + + "" + + "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Computers'))" + vbNewLine + + "CREATE TABLE [dbo].[Computers]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100));" + vbNewLine + + "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Computers') AND Name = 'ClusteredIndex')" + vbNewLine + + "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Computers] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + + "" + + "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Applications'))" + vbNewLine + + "CREATE TABLE [dbo].[Applications]([InfobaseCode] int NOT NULL, [Code] int NOT NULL,[Name] [char](100));" + vbNewLine + + "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Applications') AND Name = 'ClusteredIndex')" + vbNewLine + + "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Applications] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + + "" + + "IF NOT EXISTS (select * from sysobjects where id = object_id(N'EventsType'))" + vbNewLine + + "CREATE TABLE [dbo].[EventsType]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100));" + vbNewLine + + "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'EventsType') AND Name = 'ClusteredIndex')" + vbNewLine + + "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[EventsType] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + + "" + + "IF NOT EXISTS (select * from sysobjects where id = object_id(N'Servers'))" + vbNewLine + + "CREATE TABLE [dbo].[Servers]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100));" + vbNewLine + + "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'Servers') AND Name = 'ClusteredIndex')" + vbNewLine + + "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[Servers] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + + "" + + "IF NOT EXISTS (select * from sysobjects where id = object_id(N'MainPorts'))" + vbNewLine + + "CREATE TABLE [dbo].[MainPorts]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100));" + vbNewLine + + "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'MainPorts') AND Name = 'ClusteredIndex')" + vbNewLine + + "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[MainPorts] ([InfobaseCode] ASC, [Code] ASC);" + vbNewLine + + "" + + "IF NOT EXISTS (select * from sysobjects where id = object_id(N'SecondPorts'))" + vbNewLine + + "CREATE TABLE [dbo].[SecondPorts]([InfobaseCode] int NOT NULL, [Code] int NOT NULL, [Name] [char](100));" + vbNewLine + + "IF NOT EXISTS (select * from sys.indexes where object_id = object_id(N'SecondPorts') AND Name = 'ClusteredIndex')" + vbNewLine + "CREATE UNIQUE CLUSTERED INDEX [ClusteredIndex] ON [dbo].[SecondPorts] ([InfobaseCode] ASC, [Code] ASC);" command.ExecuteNonQuery() @@ -1727,39 +268,39 @@ Public Class EventLogLoaderService Dim command = New MySql.Data.MySqlClient.MySqlCommand command.Connection = objConn - command.CommandText = "CREATE TABLE IF NOT EXISTS `Events` (`InfobaseCode` int(11) NOT NULL, `DateTime` int(11) NOT NULL," + _ - "`TransactionStatus` varchar(1) NULL, `TransactionStartTime` datetime NULL, " + _ - "`TransactionMark` bigint NULL, `Transaction` varchar(100) NULL, `UserName` int(11) NULL, `ComputerName` int(11) NULL, " + _ - "`AppName` int(11) NULL, `Field2` varchar(100) NULL, `EventID` int(11) NULL, `EventType` varchar(1) NULL, " + _ - "`Comment` text NULL, `MetadataID` int(11) NULL, `DataStructure` varchar(100) NULL, `DataString` text NULL, " + _ - "`ServerID` int(11) NULL, `MainPortID` int(11) NULL, `SecondPortID` int(11) NULL, `Seance` int(11) NULL, " + _ - "`Field7` varchar(100) NULL, `Field8` varchar(100) NULL" + _ + command.CommandText = "CREATE TABLE IF NOT EXISTS `Events` (`InfobaseCode` int(11) NOT NULL, `DateTime` int(11) NOT NULL," + + "`TransactionStatus` varchar(1) NULL, `TransactionStartTime` datetime NULL, " + + "`TransactionMark` bigint NULL, `Transaction` varchar(100) NULL, `UserName` int(11) NULL, `ComputerName` int(11) NULL, " + + "`AppName` int(11) NULL, `Field2` varchar(100) NULL, `EventID` int(11) NULL, `EventType` varchar(1) NULL, " + + "`Comment` text NULL, `MetadataID` int(11) NULL, `DataStructure` varchar(100) NULL, `DataString` text NULL, " + + "`ServerID` int(11) NULL, `MainPortID` int(11) NULL, `SecondPortID` int(11) NULL, `Seance` int(11) NULL, " + + "`Field7` varchar(100) NULL, `Field8` varchar(100) NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" command.ExecuteNonQuery() '********************************************************************************** - command.CommandText = "CREATE TABLE IF NOT EXISTS `Params` (`InfobaseCode` int(11) NOT NULL, `Position` bigint, `Filename` varchar(100)," + _ - "`LastEventID` int(11), PRIMARY KEY `InfobaseCode` (`InfobaseCode`));" - command.ExecuteNonQuery() + 'command.CommandText = "CREATE TABLE IF NOT EXISTS `Params` (`InfobaseCode` int(11) NOT NULL, `Position` bigint, `Filename` varchar(100)," + _ + ' "`LastEventID` int(11), PRIMARY KEY `InfobaseCode` (`InfobaseCode`));" + 'command.ExecuteNonQuery() '********************************************************************************** - command.CommandText = "CREATE TABLE IF NOT EXISTS `Infobases` (`Guid` varchar(40) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100)," + _ + command.CommandText = "CREATE TABLE IF NOT EXISTS `Infobases` (`Guid` varchar(40) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100)," + "PRIMARY KEY `Guid` (`Guid`));" command.ExecuteNonQuery() '********************************************************************************** command.CommandText = - "CREATE TABLE IF NOT EXISTS `Users`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), `Guid` varchar(40), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + _ - "" + _ - "CREATE TABLE IF NOT EXISTS `Metadata`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), `Guid` varchar(40), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + _ - "" + _ - "CREATE TABLE IF NOT EXISTS `Computers`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + _ - "" + _ - "CREATE TABLE IF NOT EXISTS `Applications`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + _ - "" + _ - "CREATE TABLE IF NOT EXISTS `EventsType`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + _ - "" + _ - "CREATE TABLE IF NOT EXISTS `Servers`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + _ - "" + _ - "CREATE TABLE IF NOT EXISTS `MainPorts`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + _ - "" + _ + "CREATE TABLE IF NOT EXISTS `Users`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), `Guid` varchar(40), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + + "" + + "CREATE TABLE IF NOT EXISTS `Metadata`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), `Guid` varchar(40), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + + "" + + "CREATE TABLE IF NOT EXISTS `Computers`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + + "" + + "CREATE TABLE IF NOT EXISTS `Applications`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + + "" + + "CREATE TABLE IF NOT EXISTS `EventsType`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + + "" + + "CREATE TABLE IF NOT EXISTS `Servers`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + + "" + + "CREATE TABLE IF NOT EXISTS `MainPorts`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" + vbNewLine + + "" + "CREATE TABLE IF NOT EXISTS `SecondPorts`(`InfobaseCode` int(11) NOT NULL, `Code` int(11) NOT NULL, `Name` varchar(100), PRIMARY KEY (`InfobaseCode`, `Code`));" command.ExecuteNonQuery() @@ -1773,11 +314,11 @@ Public Class EventLogLoaderService End If - Log.Info("Проверка таблиц в БД выполнена успешно!") + Log.Info("Target database tables have been verified!") Catch ex As Exception - Log.ErrorException("Ошибка при проверке таблиц в БД", ex) + Log.ErrorException("Error occurred while during target database tables verification", ex) End Try From f28d00beaf80e504a6c0e3b61e301c7dd0c13c43 Mon Sep 17 00:00:00 2001 From: Alex Bochkov Date: Sun, 25 Dec 2016 17:15:40 -0800 Subject: [PATCH 7/7] WIP --- EventLogLoader/EventLogLoaderDebug.vbproj | 16 +++- EventLogLoader/app.config | 8 +- EventLogLoader/packages.config | 4 + EventLogLoaderManager/App.config | 8 +- .../EventLogLoaderManager.vbproj | 4 +- .../EventLogLoaderService.vbproj | 22 ++--- EventLogLoaderService/EventLogProcessor.vb | 85 ++++++++++++++----- EventLogLoaderService/Service1.vb | 4 +- EventLogLoaderService/app.config | 24 ++---- EventLogLoaderService/packages.config | 11 +-- 10 files changed, 114 insertions(+), 72 deletions(-) create mode 100644 EventLogLoader/packages.config diff --git a/EventLogLoader/EventLogLoaderDebug.vbproj b/EventLogLoader/EventLogLoaderDebug.vbproj index 7561397..83b2d31 100644 --- a/EventLogLoader/EventLogLoaderDebug.vbproj +++ b/EventLogLoader/EventLogLoaderDebug.vbproj @@ -1,5 +1,5 @@  - + Debug x86 @@ -14,7 +14,7 @@ EventLogLoader 512 Console - v4.5 + v4.6 false @@ -85,6 +85,10 @@ + + ..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net46\System.Data.SQLite.dll + True + @@ -139,6 +143,7 @@ My Settings.Designer.vb + @@ -168,6 +173,13 @@ + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + -
- + - + - - + + + + - - - + - \ No newline at end of file + diff --git a/EventLogLoaderService/packages.config b/EventLogLoaderService/packages.config index 8c214b8..ecd3ec5 100644 --- a/EventLogLoaderService/packages.config +++ b/EventLogLoaderService/packages.config @@ -1,12 +1,9 @@  - - + + - + - - - - + \ No newline at end of file