diff --git a/EventLogLoader.sln b/EventLogLoader.sln
index 4d3ca89..3ec81eb 100644
--- a/EventLogLoader.sln
+++ b/EventLogLoader.sln
@@ -1,20 +1,14 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EventLogLoaderDebug", "EventLogLoader\EventLogLoaderDebug.vbproj", "{2CE569B2-834D-4FE6-A23F-ACC68E8BDA9E}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EventLogLoaderManager", "EventLogLoaderManager\EventLogLoaderManager.vbproj", "{AF261326-5435-43E2-8407-4F0DFAED7B29}"
EndProject
-Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "IniFile", "IniFile\IniFile.vbproj", "{8119A1A1-E5D6-4269-9A5C-0F49E039E72D}"
-EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EventLogLoaderService", "EventLogLoaderService\EventLogLoaderService.vbproj", "{F7EF5930-B310-4697-B522-2325EAF247F2}"
EndProject
-Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Installer", "Installer\Installer.vbproj", "{593952E2-6C95-4496-BFD5-C8C64DF78DE5}"
-EndProject
-Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Service1C", "Service1C\Service1C.vbproj", "{7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}"
-EndProject
-Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Parser", "Parser\Parser.vbproj", "{3164BFA8-8AC5-4BC2-965A-15D40B6316AA}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -45,16 +39,6 @@ Global
{AF261326-5435-43E2-8407-4F0DFAED7B29}.Release|Mixed Platforms.Build.0 = Release|x86
{AF261326-5435-43E2-8407-4F0DFAED7B29}.Release|x86.ActiveCfg = Release|x86
{AF261326-5435-43E2-8407-4F0DFAED7B29}.Release|x86.Build.0 = Release|x86
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}.Debug|x86.ActiveCfg = Debug|Any CPU
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}.Release|Any CPU.Build.0 = Release|Any CPU
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}.Release|x86.ActiveCfg = Release|Any CPU
{F7EF5930-B310-4697-B522-2325EAF247F2}.Debug|Any CPU.ActiveCfg = Debug|x86
{F7EF5930-B310-4697-B522-2325EAF247F2}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{F7EF5930-B310-4697-B522-2325EAF247F2}.Debug|Mixed Platforms.Build.0 = Debug|x86
@@ -65,36 +49,6 @@ Global
{F7EF5930-B310-4697-B522-2325EAF247F2}.Release|Mixed Platforms.Build.0 = Release|x86
{F7EF5930-B310-4697-B522-2325EAF247F2}.Release|x86.ActiveCfg = Release|x86
{F7EF5930-B310-4697-B522-2325EAF247F2}.Release|x86.Build.0 = Release|x86
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}.Debug|x86.ActiveCfg = Debug|Any CPU
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}.Release|Any CPU.Build.0 = Release|Any CPU
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}.Release|x86.ActiveCfg = Release|Any CPU
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}.Debug|x86.ActiveCfg = Debug|Any CPU
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}.Release|Any CPU.Build.0 = Release|Any CPU
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}.Release|x86.ActiveCfg = Release|Any CPU
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}.Debug|x86.ActiveCfg = Debug|Any CPU
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}.Release|Any CPU.Build.0 = Release|Any CPU
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/EventLogLoader/EventLogLoaderDebug.vbproj b/EventLogLoader/EventLogLoaderDebug.vbproj
index 59135fc..7275f4f 100644
--- a/EventLogLoader/EventLogLoaderDebug.vbproj
+++ b/EventLogLoader/EventLogLoaderDebug.vbproj
@@ -158,10 +158,6 @@
{F7EF5930-B310-4697-B522-2325EAF247F2}
EventLogLoaderService
-
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}
- IniFile
-
diff --git a/EventLogLoaderManager/EventLogLoaderManager.vbproj b/EventLogLoaderManager/EventLogLoaderManager.vbproj
index f61a4c5..7bac15f 100644
--- a/EventLogLoaderManager/EventLogLoaderManager.vbproj
+++ b/EventLogLoaderManager/EventLogLoaderManager.vbproj
@@ -69,6 +69,10 @@
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
@@ -113,6 +117,8 @@
Form
+
+
Form
@@ -170,18 +176,6 @@
{F7EF5930-B310-4697-B522-2325EAF247F2}
EventLogLoaderService
-
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}
- IniFile
-
-
- {593952E2-6C95-4496-BFD5-C8C64DF78DE5}
- Installer
-
-
- {7261F9CC-9B2F-4FA5-ADD3-9FCF4948623F}
- Service1C
-
diff --git a/EventLogLoaderManager/Form1.vb b/EventLogLoaderManager/Form1.vb
index e72660e..6d853b3 100644
--- a/EventLogLoaderManager/Form1.vb
+++ b/EventLogLoaderManager/Form1.vb
@@ -4,73 +4,30 @@ Imports System.Management
Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Imports System.Net
+Imports EventLogLoaderService
Public Class Form1
- Dim ArrayServices() As Service1C.ServiceDescriptionClass
- Dim PathIniFile = Path.Combine(My.Application.Info.DirectoryPath, "setting.ini")
- Dim IniFile As IniFile.IniFileClass = New IniFile.IniFileClass
+ Dim ArrayServices() As ServiceDescriptionClass
+ Dim PathConfigFile = Path.Combine(My.Application.Info.DirectoryPath, "config.json")
Dim GroupExtraPath As ListViewGroup
- Structure InfobaseParams
- Dim Guid As String
- Dim Name As String
- Dim CatalogEventlog As String
- Dim Found As Boolean
- End Structure
-
- Dim ArrayInfoBaseParamSaved As List(Of InfobaseParams) = New List(Of InfobaseParams)
+ Dim ConfigSetting As ConfigSetting = New ConfigSetting
Sub LoadFromIniFile()
- If My.Computer.FileSystem.FileExists(PathIniFile) Then
- IniFile.Load(PathIniFile)
+ ConfigSetting = ConfigSettingsModule.LoadConfigSettingFromFile(PathConfigFile)
-
- Dim s = IniFile.RestoreIniValue(IniFile, "GlobalValues", "ConnectionString")
- If Not s = "" Then
- ConnectionStringBox.Text = s
- End If
-
- s = IniFile.RestoreIniValue(IniFile, "GlobalValues", "DBType")
- If Not s = "" Then
- DBType.Text = s
- End If
-
- Try
- s = IniFile.RestoreIniValue(IniFile, "GlobalValues", "RepeatTime")
- If Not s = "" Then
- RepeatTime.Text = Convert.ToInt32(s).ToString
- End If
- Catch ex As Exception
- RepeatTime.Text = 60
- End Try
-
- Dim i = 0
- s = IniFile.RestoreIniValue(IniFile, "GlobalValues", "DatabaseCount")
- If Not s = "" Then
- i = Convert.ToInt32(s)
- End If
-
- For j = 1 To i
-
- Dim IB = New InfobaseParams
- IB.Guid = IniFile.RestoreIniValue(IniFile, "Databases", "DatabaseID" + j.ToString)
- IB.Name = IniFile.RestoreIniValue(IniFile, "Databases", "DatabaseName" + j.ToString)
- IB.CatalogEventlog = IniFile.RestoreIniValue(IniFile, "Databases", "DatabaseCatalog" + j.ToString)
-
- ArrayInfoBaseParamSaved.Add(IB)
-
- Next
-
- End If
+ ConnectionStringBox.Text = ConfigSetting.ConnectionString
+ DBType.Text = ConfigSetting.DBType
+ RepeatTime.Text = ConfigSetting.RepeatTime.ToString
End Sub
- Function FindInfobase(Guid As String) As Service1C.ServiceDescriptionClass.Infobases
+ Function FindInfobase(Guid As String) As ServiceDescriptionClass.Infobases
- FindInfobase = New Service1C.ServiceDescriptionClass.Infobases
+ FindInfobase = New ServiceDescriptionClass.Infobases
For Each Srv In ArrayServices
If Not Srv.ArrayInfobases Is Nothing Then
@@ -90,53 +47,40 @@ Public Class Form1
FindInfobaseInSavedParams = False
- For i = 0 To ArrayInfoBaseParamSaved.Count - 1
- Dim IB = ArrayInfoBaseParamSaved(i)
- If IB.Guid = Guid Then
+ For Each IB In ConfigSetting.Infobases
+ If IB.DatabaseID = Guid Then
IB.Found = True
- ArrayInfoBaseParamSaved(i) = IB
Return True
End If
Next
- 'For Each Ib In ArrayInfoBaseParamSaved
- ' If Ib.Guid = Guid Then
- ' Ib.Found = True
- ' Return True
- ' End If
- 'Next
End Function
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- If My.Computer.FileSystem.FileExists(PathIniFile) Then
- IniFile.Load(PathIniFile)
- IniFile.RemoveAllSections()
- End If
+ Dim ConfigSetting = New ConfigSetting
+ ConfigSetting.ConnectionString = ConnectionStringBox.Text.Trim
+ ConfigSetting.DBType = DBType.Text.Trim
- IniFile.AddSection("GlobalValues").AddKey("ConnectionString").Value = ConnectionStringBox.Text.Trim
- IniFile.AddSection("GlobalValues").AddKey("DBType").Value = DBType.Text.Trim
-
- Dim i = 0
For Each Item As ListViewItem In ListView.Items
If Item.Checked Then
- i = i + 1
+ Dim IBSetting = New ConfigSettingsModule.InfobaseSetting
+ IBSetting.DatabaseID = Item.SubItems(1).Text
+ IBSetting.DatabaseName = Item.SubItems(0).Text
+ IBSetting.DatabaseCatalog = Item.SubItems(4).Text
- IniFile.AddSection("Databases").AddKey("DatabaseID" + i.ToString).Value = Item.SubItems(1).Text
- IniFile.AddSection("Databases").AddKey("DatabaseName" + i.ToString).Value = Item.SubItems(0).Text
- IniFile.AddSection("Databases").AddKey("DatabaseCatalog" + i.ToString).Value = Item.SubItems(4).Text
+ ConfigSetting.Infobases.Add(IBSetting)
End If
Next
- IniFile.AddSection("GlobalValues").AddKey("DatabaseCount").Value = i
Dim Rep = Convert.ToInt32(RepeatTime.Text)
- IniFile.AddSection("GlobalValues").AddKey("RepeatTime").Value = IIf(Rep = 0, 60, Rep)
+ ConfigSetting.RepeatTime = IIf(Rep = 0, 60, Rep)
+ ConfigSettingsModule.SaveConfigSettingToFile(ConfigSetting, PathConfigFile)
- IniFile.Save(PathIniFile)
Dim sc = New System.ServiceProcess.ServiceController("EventLog loader service")
Try
@@ -166,10 +110,10 @@ Public Class Form1
Dim User = "LocalSystem"
Dim Pwd = ""
- If Not Installer.ObjTec.Services.ServiceInstaller.InstallService(PathName, ServName, DisplayName, lpDependencies, User, Pwd) Then
+ If Not ObjTec.Services.ServiceInstaller.InstallService(PathName, ServName, DisplayName, lpDependencies, User, Pwd) Then
Dim ErrorCode = Marshal.GetLastWin32Error()
- MsgBox("Ошибка установки службы Windows: " + Installer.ObjTec.Services.ServiceInstaller.GetErrorDescription(ErrorCode), , Text)
+ MsgBox("Ошибка установки службы Windows: " + ObjTec.Services.ServiceInstaller.GetErrorDescription(ErrorCode), , Text)
Else
@@ -184,10 +128,10 @@ Public Class Form1
Dim ServName = "EventLog loader service"
- If Not Installer.ObjTec.Services.ServiceInstaller.UninstallService(ServName) Then
+ If Not ObjTec.Services.ServiceInstaller.UninstallService(ServName) Then
Dim ErrorCode = Marshal.GetLastWin32Error()
- MsgBox("Ошибка удаления службы Windows: " + Installer.ObjTec.Services.ServiceInstaller.GetErrorDescription(ErrorCode), , Text)
+ MsgBox("Ошибка удаления службы Windows: " + ObjTec.Services.ServiceInstaller.GetErrorDescription(ErrorCode), , Text)
Else
@@ -226,7 +170,7 @@ Public Class Form1
Dim PathName As String = info("PathName")
Dim DisplayName As String = info("DisplayName")
- Dim Serv = New Service1C.ServiceDescriptionClass
+ Dim Serv = New ServiceDescriptionClass
Serv.Name = info("Name")
Serv.DisplayName = info("DisplayName")
Serv.Description = info("Description")
@@ -281,29 +225,24 @@ Public Class Form1
GroupExtraPath = New ListViewGroup("Дополнительные пути для загрузки событий из ЖР")
ListView.Groups.Add(GroupExtraPath)
-
- For Each Ib In ArrayInfoBaseParamSaved
- If Not Ib.Found Then
-
- Dim item1 = New ListViewItem(Ib.Name, GroupExtraPath)
+ For Each IB In ConfigSetting.Infobases
+ If Not IB.Found Then
+ Dim item1 = New ListViewItem(IB.DatabaseName, GroupExtraPath)
item1.Checked = True
- item1.SubItems.Add(Ib.Guid)
+ item1.SubItems.Add(IB.DatabaseID)
item1.SubItems.Add("")
- item1.SubItems.Add(CalcullateFolderSize(Ib.CatalogEventlog))
- item1.SubItems.Add(Ib.CatalogEventlog)
+ item1.SubItems.Add(CalcullateFolderSize(IB.DatabaseCatalog))
+ item1.SubItems.Add(IB.DatabaseCatalog)
ListView.Items.Add(item1)
-
End If
Next
-
-
End Sub
- Private Function LoadFileInfobasesList() As List(Of Service1C.ServiceDescriptionClass.Infobases)
+ Private Function LoadFileInfobasesList() As List(Of ServiceDescriptionClass.Infobases)
- Dim Result As List(Of Service1C.ServiceDescriptionClass.Infobases) = New List(Of Service1C.ServiceDescriptionClass.Infobases)
+ Dim Result As List(Of ServiceDescriptionClass.Infobases) = New List(Of ServiceDescriptionClass.Infobases)
'Try
@@ -313,7 +252,7 @@ Public Class Form1
Dim reader As StreamReader = My.Computer.FileSystem.OpenTextFileReader(IbasesListPath)
Dim aa As String = ""
- Dim Infobase As Service1C.ServiceDescriptionClass.Infobases = Nothing
+ Dim Infobase As ServiceDescriptionClass.Infobases = Nothing
Try
Do
@@ -328,7 +267,7 @@ Public Class Form1
Result.Add(Infobase)
End If
- Infobase = New Service1C.ServiceDescriptionClass.Infobases
+ Infobase = New ServiceDescriptionClass.Infobases
Infobase.Name = a.Substring(1, a.Length - 2)
ElseIf a.StartsWith("Connect=File=") Then
'Connect=File="C:\Users\Alex\Documents\AS";
@@ -355,7 +294,7 @@ Public Class Form1
Infobase.GUID = a.Substring(3)
End If
Catch ex As Exception
- Infobase = New Service1C.ServiceDescriptionClass.Infobases
+ Infobase = New ServiceDescriptionClass.Infobases
End Try
aa = reader.ReadLine
diff --git a/EventLogLoaderManager/Installer.vb b/EventLogLoaderManager/Installer.vb
new file mode 100644
index 0000000..e57c998
--- /dev/null
+++ b/EventLogLoaderManager/Installer.vb
@@ -0,0 +1,220 @@
+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/EventLogLoaderManager/ServiceDescriptionClass.vb b/EventLogLoaderManager/ServiceDescriptionClass.vb
new file mode 100644
index 0000000..aab98b0
--- /dev/null
+++ b/EventLogLoaderManager/ServiceDescriptionClass.vb
@@ -0,0 +1,248 @@
+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/EventLogLoaderService/ConfigSettings.vb b/EventLogLoaderService/ConfigSettings.vb
new file mode 100644
index 0000000..d3f1dd5
--- /dev/null
+++ b/EventLogLoaderService/ConfigSettings.vb
@@ -0,0 +1,48 @@
+Imports Newtonsoft.Json
+
+Public Module ConfigSettingsModule
+
+ Class InfobaseSetting
+ Public DatabaseID As String
+ Public DatabaseName As String
+ Public DatabaseCatalog As String
+ Public Found As Boolean
+ End Class
+
+ Class ConfigSetting
+ Public ConnectionString As String
+ Public DBType As String
+ Public RepeatTime As Integer
+ Public Infobases As List(Of InfobaseSetting)
+ Sub New()
+ Infobases = New List(Of InfobaseSetting)
+ End Sub
+ End Class
+
+ Public Function LoadConfigSettingFromFile(ConfigFilePath As String) As ConfigSetting
+
+ If My.Computer.FileSystem.FileExists(ConfigFilePath) Then
+
+ Dim JsonText = My.Computer.FileSystem.ReadAllText(ConfigFilePath)
+
+ Dim ConfigSettingObj = JsonConvert.DeserializeObject(Of ConfigSetting)(JsonText)
+
+ Return ConfigSettingObj
+
+ End If
+
+ Return Nothing
+
+ End Function
+
+ Public Sub SaveConfigSettingToFile(ConfigSettingObj As ConfigSetting, ConfigFilePath As String)
+
+ Dim JsonText As String = JsonConvert.SerializeObject(ConfigSettingObj, Formatting.Indented)
+
+ My.Computer.FileSystem.WriteAllText(ConfigFilePath, JsonText, False)
+
+
+ End Sub
+
+
+End Module
diff --git a/EventLogLoaderService/EventLogLoaderService.vbproj b/EventLogLoaderService/EventLogLoaderService.vbproj
index 513d7b4..002335c 100644
--- a/EventLogLoaderService/EventLogLoaderService.vbproj
+++ b/EventLogLoaderService/EventLogLoaderService.vbproj
@@ -102,10 +102,12 @@
+
True
Application.myapp
+
ProjectInstaller.vb
@@ -159,16 +161,6 @@
-
-
- {8119A1A1-E5D6-4269-9A5C-0F49E039E72D}
- IniFile
-
-
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}
- Parser
-
-
False
diff --git a/EventLogLoaderService/Parser.vb b/EventLogLoaderService/Parser.vb
new file mode 100644
index 0000000..67901c1
--- /dev/null
+++ b/EventLogLoaderService/Parser.vb
@@ -0,0 +1,188 @@
+Public Module ParserServices
+
+ 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
+
+ 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
+
+ Function CountSubstringInString(Str As String, SubStr As String)
+
+ CountSubstringInString = (Str.Length - Str.Replace(SubStr, "").Length) / SubStr.Length
+
+ End Function
+
+
+End Module
\ No newline at end of file
diff --git a/EventLogLoaderService/Service1.vb b/EventLogLoaderService/Service1.vb
index d16d5f6..9f7b336 100644
--- a/EventLogLoaderService/Service1.vb
+++ b/EventLogLoaderService/Service1.vb
@@ -600,7 +600,7 @@ Public Class EventLogLoaderService
' ReDim Preserve Events(Events.Length)
'End If
- Dim Array = Parser.ParserServices.ParsesClass.ParseEventlogString(Str)
+ Dim Array = ParserServices.ParseEventlogString(Str)
OneEvent.DateTime = Date.ParseExact(Array(0), "yyyyMMddHHmmss", provider)
OneEvent.TransactionStatus = Array(1)
@@ -1008,7 +1008,7 @@ Public Class EventLogLoaderService
FS.Close()
- Dim ArrayLines = Parser.ParserServices.ParsesClass.ParseString(Text)
+ Dim ArrayLines = ParserServices.ParseString(Text)
Dim i = 0
For Each a In ArrayLines
@@ -1442,59 +1442,42 @@ Public Class EventLogLoaderService
Dim ArrayIB() As InfoBaseEventlog
Dim ArrayThread() As Threading.Thread
- Dim Param As IniFile.IniFileClass
+ Dim ConfigSettingObj As ConfigSetting = New ConfigSetting
Dim ConnectionString As String
Dim DBType As String
Dim ItIsMSSQL As Boolean = False
Dim ItIsMySQL As Boolean = False
Public SleepTime As Integer = 60 * 1000 '1 минута
- Function LoadIniFileParams()
+ Function LoadConfigSetting()
- LoadIniFileParams = False
+ LoadConfigSetting = False
Try
- Param = New IniFile.IniFileClass
- Dim PathIniFile = Path.Combine(My.Application.Info.DirectoryPath, "setting.ini")
- If My.Computer.FileSystem.FileExists(PathIniFile) Then
+ Dim PathConfigFile = Path.Combine(My.Application.Info.DirectoryPath, "config.json")
+ If My.Computer.FileSystem.FileExists(PathConfigFile) Then
- Param.Load(PathIniFile)
+ ConfigSettingObj = ConfigSettingsModule.LoadConfigSettingFromFile(PathConfigFile)
- Dim s As String
+ ConnectionString = ConfigSettingObj.ConnectionString
- s = Param.RestoreIniValue(Param, "GlobalValues", "ConnectionString")
- If Not s = "" Then
- ConnectionString = s
+ DBType = ConfigSettingObj.DBType
+ If DBType = "MySQL" Then
+ ItIsMySQL = True
+ ElseIf DBType = "MS SQL Server" Then
+ ItIsMSSQL = True
End If
- s = Param.RestoreIniValue(Param, "GlobalValues", "DBType")
- If Not s = "" Then
- DBType = s
+ Dim s = ConfigSettingObj.RepeatTime
+ SleepTime = s * 1000
- If DBType = "MySQL" Then
- ItIsMySQL = True
- ElseIf DBType = "MS SQL Server" Then
- ItIsMSSQL = True
- End If
- End If
+ Dim i = 0
+ For Each IBConfig In ConfigSettingObj.Infobases
- Try
- s = Param.RestoreIniValue(Param, "GlobalValues", "RepeatTime")
- If Not s = "" Then
- SleepTime = Convert.ToInt32(s) * 1000
- End If
- Catch ex As Exception
- End Try
-
- Dim CountStr = Param.RestoreIniValue(Param, "GlobalValues", "DatabaseCount")
- Dim Count As Integer = Convert.ToInt32(IIf(CountStr = "", "0", CountStr))
-
- For i = 1 To Count
-
- Dim IB_ID = Param.RestoreIniValue(Param, "Databases", "DatabaseID" + i.ToString)
- Dim IB_Name = Param.RestoreIniValue(Param, "Databases", "DatabaseName" + i.ToString)
- Dim IB_Catalog = Param.RestoreIniValue(Param, "Databases", "DatabaseCatalog" + i.ToString)
+ 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")
@@ -1506,22 +1489,22 @@ Public Class EventLogLoaderService
IB.ItIsMSSQL = ItIsMSSQL
IB.ItIsMySQL = ItIsMySQL
- ReDim Preserve ArrayIB(i - 1)
- ArrayIB(i - 1) = IB
+ ReDim Preserve ArrayIB(i)
+ ArrayIB(i) = IB
+ i = i + 1
Next
- LoadIniFileParams = True
+ LoadConfigSetting = True
Else
- Log.Error("Файл setting.ini не найден")
+ Log.Error("Файл config.json не найден")
End If
Catch ex As Exception
- Log.ErrorException("Ошибка загрузки параметров из ini-файла", ex)
+ Log.ErrorException("Ошибка загрузки параметров из config.json", ex)
End Try
-
End Function
Private WorkerThread As Thread
@@ -1571,7 +1554,7 @@ Public Class EventLogLoaderService
'Log.Info("Запуск основного функционала")
- If Not LoadIniFileParams() Then
+ If Not LoadConfigSetting() Then
Log.Error("Ошибка работы с файлом параметров setting.ini в каталоге приложения")
Environment.Exit(-1)
End If
diff --git a/Service1C/Class1.vb b/Service1C/Class1.vb
index 972156d..aab98b0 100644
--- a/Service1C/Class1.vb
+++ b/Service1C/Class1.vb
@@ -1,4 +1,5 @@
Imports System.IO
+Imports EventLogLoaderService
Public Class ServiceDescriptionClass
Public Name As String
@@ -181,7 +182,7 @@ Public Class ServiceDescriptionClass
Dim Text = My.Computer.FileSystem.ReadAllText(TMP)
My.Computer.FileSystem.DeleteFile(TMP)
- Dim Array = Parser.ParserServices.ParsesClass.ParseString(Text)
+ Dim Array = ParserServices.ParseString(Text)
Dim i = 0
diff --git a/Service1C/Service1C.vbproj b/Service1C/Service1C.vbproj
index 43b27b2..61f93bb 100644
--- a/Service1C/Service1C.vbproj
+++ b/Service1C/Service1C.vbproj
@@ -97,9 +97,9 @@
-
- {3164BFA8-8AC5-4BC2-965A-15D40B6316AA}
- Parser
+
+ {F7EF5930-B310-4697-B522-2325EAF247F2}
+ EventLogLoaderService