WIP: Use ConfigManager

This commit is contained in:
Jonathan Jenne 2019-05-28 14:07:35 +02:00
parent e9135d3543
commit 2bd7ff9d2c
17 changed files with 418 additions and 248 deletions

2
.gitignore vendored
View File

@ -97,7 +97,7 @@ publish/
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
packages/
# Windows Azure Build Output
csx

View File

@ -1,20 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Global_Indexer.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Global_Indexer.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Global_Indexer.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Global_Indexer.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<connectionStrings>
<add name="Global_Indexer.My.MySettings.DD_ECMConnectionString"
connectionString="Data Source=172.24.12.41\TESTS;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd"
providerName="System.Data.SqlClient" />
<add name="Global_Indexer.My.MySettings.DD_ECMConnectionString" connectionString="Data Source=172.24.12.41\TESTS;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd" providerName="System.Data.SqlClient"/>
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<userSettings>
<Global_Indexer.My.MySettings>
@ -37,7 +35,7 @@
<value>False</value>
</setting>
<setting name="REGEX_Replace" serializeAs="String">
<value />
<value/>
</setting>
</Global_Indexer.My.MySettings>
</userSettings>
@ -48,4 +46,4 @@
</setting>
</Global_Indexer.My.MySettings>
</applicationSettings>
</configuration>
</configuration>

View File

@ -0,0 +1,18 @@
Imports DigitalData.Modules.Config.ConfigAttributes
Public Class ClassConfig
<ConnectionString>
Public Property ConnectionString As String = ""
' Folderwatch
Public Property FolderWatchStarted As Boolean = False
Public Property FolderWatchScanStarted As Boolean = False
' PDF Viewer Settings
Public Property UniversalViewerPath As String = ""
Public Property FilePreview As Boolean = False
' Misc Settings
Public Property DeleteOriginalFile As Boolean = False
Public Property LogErrorsOnly As Boolean = True
End Class

View File

@ -18,7 +18,9 @@ Public Class ClassFolderWatcher
FolderWatcher.EnableRaisingEvents = True
AddHandler FolderWatcher.Created, AddressOf OnCreated
FW_started = True
SaveConfigValue("FW_started", "True")
'SaveConfigValue("FW_started", "True")
CONFIG.Config.FolderWatchStarted = True
CONFIG.Save()
End If
Catch ex As Exception
ClassLogger.Add($"Error in Restart_FolderWatch: {ex.Message}", False)
@ -37,7 +39,9 @@ Public Class ClassFolderWatcher
FolderWatcher_SCAN.EnableRaisingEvents = True
AddHandler FolderWatcher_SCAN.Created, AddressOf OnCreated
FWSCAN_started = True
SaveConfigValue("FWSCAN_started", "True")
'SaveConfigValue("FWSCAN_started", "True")
CONFIG.Config.FolderWatchScanStarted = True
CONFIG.Save()
End If
Catch ex As Exception
ClassLogger.Add($"Error in Restart_FolderWatchSCAN: {ex.Message}", False)
@ -56,7 +60,9 @@ Public Class ClassFolderWatcher
FolderWatcher.EnableRaisingEvents = True
AddHandler FolderWatcher.Created, AddressOf OnCreated
FW_started = True
SaveConfigValue("FW_started", "True")
'SaveConfigValue("FW_started", "True")
CONFIG.Config.FolderWatchStarted = True
CONFIG.Save()
Return 1
End If
If FolderWatcher.EnableRaisingEvents = False Then
@ -68,14 +74,18 @@ Public Class ClassFolderWatcher
FolderWatcher.EnableRaisingEvents = True
AddHandler FolderWatcher.Created, AddressOf OnCreated
FW_started = True
SaveConfigValue("FW_started", "True")
'SaveConfigValue("FW_started", "True")
CONFIG.Config.FolderWatchStarted = True
CONFIG.Save()
Return 1
Else
'Gestartet also Stoppen
FolderWatcher.EnableRaisingEvents = False
FW_started = False
ClassLogger.Add(" >> FolderWatch gestoppt", False)
SaveConfigValue("FW_started", "False")
'SaveConfigValue("FW_started", "False")
CONFIG.Config.FolderWatchStarted = False
CONFIG.Save()
Return 0
End If
'If watcher.EnableRaisingEvents = False Then
@ -118,7 +128,9 @@ Public Class ClassFolderWatcher
FolderWatcher_SCAN.EnableRaisingEvents = True
AddHandler FolderWatcher_SCAN.Created, AddressOf OnCreated
FWSCAN_started = True
SaveConfigValue("FWSCAN_started", "True")
'SaveConfigValue("FWSCAN_started", "True")
CONFIG.Config.FolderWatchScanStarted = True
CONFIG.Save()
Return 1
End If
If FolderWatcher_SCAN.EnableRaisingEvents = False Then
@ -130,14 +142,18 @@ Public Class ClassFolderWatcher
FolderWatcher_SCAN.EnableRaisingEvents = True
AddHandler FolderWatcher_SCAN.Created, AddressOf OnCreated
FWSCAN_started = True
SaveConfigValue("FWSCAN_started", "True")
'SaveConfigValue("FWSCAN_started", "True")
CONFIG.Config.FolderWatchScanStarted = True
CONFIG.Save()
Return 1
Else
'Gestartet also Stoppen
FolderWatcher_SCAN.EnableRaisingEvents = False
FWSCAN_started = False
ClassLogger.Add(" >> FolderWatch Scan gestoppt", False)
SaveConfigValue("FWSCAN_started", "False")
'SaveConfigValue("FWSCAN_started", "False")
CONFIG.Config.FolderWatchScanStarted = False
CONFIG.Save()
Return 0
End If
@ -152,7 +168,9 @@ Public Class ClassFolderWatcher
FolderWatcher.EnableRaisingEvents = False
FW_started = False
ClassLogger.Add(" >> FolderWatch gestoppt", False)
SaveConfigValue("FW_started", "False")
'SaveConfigValue("FW_started", "False")
CONFIG.Config.FolderWatchStarted = True
CONFIG.Save()
Return True
Else
Return False

View File

@ -1,5 +1,7 @@
Imports System.ComponentModel
Imports DLLLicenseManager
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Config
Public Class ClassInit
Public _lizenzManager As ClassLicenseManager
@ -10,12 +12,27 @@ Public Class ClassInit
ClassLogger.Init("", Environment.UserName)
ClassLogger.Add(">> Programmstart: " & Now, False)
ClassLogger.Add(">> Username: " & Environment.UserName, False)
'Throw New Exception("Dummy Fehler!")
LOGCONFIG = New LogConfig(LogConfig.PathType.AppData)
LOGGER = LOGCONFIG.GetLogger("Globix")
LOGGER.Info("Programmstart")
LOGGER.Info("Username: {0}", Environment.UserName)
End Sub
Public Sub InitConfig()
CONFIG = New ConfigManager(Of ClassConfig)(LOGCONFIG, Application.UserAppDataPath, Application.CommonAppDataPath)
MyConnectionString = DecryptConnectionString(CONFIG.Config.ConnectionString)
LogErrorsOnly = CONFIG.Config.LogErrorsOnly
Preview = CONFIG.Config.FilePreview
UniversalViewer_Path = CONFIG.Config.UniversalViewerPath
FW_started = CONFIG.Config.FolderWatchStarted
FWSCAN_started = CONFIG.Config.FolderWatchScanStarted
CURR_DELETE_ORIGIN = CONFIG.Config.DeleteOriginalFile
End Sub
Public Function InitDatabase()
Dim dbResult As Boolean
LoadMyConfig()
'LoadMyConfig()
If LoadFileExclusion() = False Then
If USER_LANGUAGE = "de-DE" Then
MsgBox("Die Ausschlusskriterien für Dateien in Folderwatch konnten nicht angelegt werden!", MsgBoxStyle.Information)
@ -43,7 +60,7 @@ Public Class ClassInit
Return True
End If
End Function
<STAThread()> _
<STAThread()>
Public Sub InitBasics()
Dim configResult As Boolean
configResult = Load_BasicConfig()
@ -56,6 +73,25 @@ Public Class ClassInit
End If
End If
End Sub
Public Function Load_BasicConfig()
Try
ClassDatabase.Init()
Dim sql As String = "select * from tbdd_Modules where NAME = 'Global-Indexer'"
Dim DT As DataTable = ClassDatabase.Return_Datatable(sql)
If DT.Rows.Count = 1 Then
GI_withWindream = DT.Rows(0).Item("BIT1")
vWLaufwerk = DT.Rows(0).Item("STRING1")
Else
Return False
End If
Catch ex As Exception
MsgBox("Error in Load_BasicConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
Return True
End Function
Public Sub Init_Folderwatch()
Try
Dim sql As String = "SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'DEFAULT' AND USER_ID = " & USER_ID
@ -66,14 +102,18 @@ Public Class ClassInit
If folderwatchPath = String.Empty Then
ClassLogger.Add("Init_Folderwatch: folderwatchPath is empty", True)
FW_started = False
SaveConfigValue("FW_started", "False")
'SaveConfigValue("FW_started", "False")
CONFIG.Config.FolderWatchStarted = False
CONFIG.Save()
Exit Sub
End If
If Not IO.Directory.Exists(folderwatchPath) Then
ClassLogger.Add("Init_Folderwatch: folderwatchPath does not exists or is invalid path", True)
FW_started = False
SaveConfigValue("FW_started", "False")
'SaveConfigValue("FW_started", "False")
CONFIG.Config.FolderWatchStarted = False
CONFIG.Save()
Exit Sub
End If
@ -97,14 +137,18 @@ Public Class ClassInit
If folderwatchScanPath = String.Empty Then
ClassLogger.Add("Init_Folderwatch: folderwatchScanPath is empty", True)
FWSCAN_started = False
SaveConfigValue("FW_started", "False")
'SaveConfigValue("FW_started", "False")
CONFIG.Config.FolderWatchStarted = False
CONFIG.Save()
Exit Sub
End If
If Not IO.Directory.Exists(folderwatchScanPath) Then
ClassLogger.Add("Init_Folderwatch: folderwatchScanPath does not exists or is invalid path", True)
FWSCAN_started = False
SaveConfigValue("FW_started", "False")
'SaveConfigValue("FW_started", "False")
CONFIG.Config.FolderWatchStarted = False
CONFIG.Save()
Exit Sub
End If
@ -245,7 +289,29 @@ Public Class ClassInit
MsgBox(ex.Message, MsgBoxStyle.Critical)
START_INCOMPLETE = True
End Try
End Sub
Private Function DecryptConnectionString(EncryptedConnectionString As String) As String
Dim oBuilder As New SqlClient.SqlConnectionStringBuilder With {
.ConnectionString = EncryptedConnectionString
}
If oBuilder.ConnectionString.Contains("Password=") Then
Dim oPlaintextPassword As String
Dim oDecryptor As New ClassEncryption("!35452didalog=")
Try
oPlaintextPassword = oDecryptor.DecryptData(oBuilder.Password)
Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Debug("Password {0} could not be decrypted. Assuming plaintext password.")
oPlaintextPassword = oBuilder.Password
End Try
Return EncryptedConnectionString.Replace(oBuilder.Password, oPlaintextPassword)
Else
Return EncryptedConnectionString
End If
End Function
End Class

View File

@ -11,7 +11,7 @@
<AssemblyName>Global_Indexer</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>WindowsForms</MyType>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
@ -28,6 +28,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -143,6 +144,15 @@
<Reference Include="DevExpress.XtraTreeList.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="DigitalData.Modules.Config">
<HintPath>..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Modules.Filesystem">
<HintPath>..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Filesystem.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Modules.Logging">
<HintPath>..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
</Reference>
<Reference Include="DLLLicenseManager, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>P:\Visual Studio Projekte\Bibliotheken\DLLLicenseManager.dll</HintPath>
@ -159,6 +169,10 @@
<HintPath>P:\Visual Studio Projekte\Bibliotheken\windream\Interop.WMOTOOLLib.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="Oracle.ManagedDataAccess">
<HintPath>P:\Visual Studio Projekte\Bibliotheken\Oracle.ManagedDataAccess.dll</HintPath>
</Reference>
@ -200,6 +214,7 @@
<Compile Include="AboutBox1.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="ClassConfig.vb" />
<Compile Include="ClassConstants.vb" />
<Compile Include="ClassControls.vb" />
<Compile Include="ClassDatabase.vb" />
@ -594,6 +609,7 @@
</COMReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Resources\database_refresh.png" />
</ItemGroup>
<ItemGroup>

View File

@ -1,4 +1,7 @@
Module ModuleCURRENT
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Logging
Module ModuleCURRENT
Public ERROR_STATE As String
Public START_INCOMPLETE As Boolean = False
Public CURRENT_FILENAME As String
@ -7,6 +10,10 @@
Public CURRENT_WORKFILE As String
Public CURR_WORKFILE_EXTENSION As String
Public CONFIG As ConfigManager(Of ClassConfig)
Public LOGCONFIG As LogConfig
Public LOGGER As Logger
Public CURRENT_DOKART_ID As Integer
Public CURRENT_DOKART_DUPLICATE_HANDLING As String = "Default"
Public CURRENT_LASTDOKART As String = ""

View File

@ -15,217 +15,239 @@ Module ModuleMySettings
Public FW_started As Boolean = False
Public FWSCAN_started As Boolean = False
Public Function GetUserConfigPath() As String
Return Path.Combine(Application.UserAppDataPath(), USER_CONFIG_FILE)
End Function
'Public Function GetUserConfigPath() As String
' Return Path.Combine(Application.UserAppDataPath(), USER_CONFIG_FILE)
'End Function
Public Function GetAllUsersConfigPath() As String
Return Path.Combine(Application.CommonAppDataPath(), COMPUTER_CONFIG_FILE)
End Function
'Public Function GetAllUsersConfigPath() As String
' Return Path.Combine(Application.CommonAppDataPath(), COMPUTER_CONFIG_FILE)
'End Function
Public Function GetCurrentConfigPath() As String
If File.Exists(GetUserConfigPath()) Then
Return GetUserConfigPath()
Else
Return GetAllUsersConfigPath()
End If
End Function
'Public Function GetCurrentConfigPath() As String
' If File.Exists(GetUserConfigPath()) Then
' Return GetUserConfigPath()
' Else
' Return GetAllUsersConfigPath()
' End If
'End Function
Public Function LoadMyConfig()
Dim rowresult As String = ""
Try
Dim oDatatable As DataTable
''if file doesn't exist, create the file with its default xml table
'If Not File.Exists(ConfigPath) Then
' DT = CreateConfigTable()
' DT.WriteXml(ConfigPath)
'End If
'DT = GetTablefromXML()
'Public Function LoadMyConfig()
' Dim rowresult As String = ""
' Try
' Dim oDatatable As DataTable
' ''if file doesn't exist, create the file with its default xml table
' 'If Not File.Exists(ConfigPath) Then
' ' DT = CreateConfigTable()
' ' DT.WriteXml(ConfigPath)
' 'End If
' 'DT = GetTablefromXML()
' if file in %APPDATA% doesn't exist,
' check for file in %ALLUSERSPROFILE%,
' otherwise create the file with its default xml table
If File.Exists(GetUserConfigPath()) Then
oDatatable = GetTablefromXML(GetUserConfigPath())
ElseIf File.Exists(GetAllUsersConfigPath()) Then
oDatatable = GetTablefromXML(GetAllUsersConfigPath())
Else
oDatatable = CreateConfigTable()
oDatatable.WriteXml(GetUserConfigPath())
End If
' ' if file in %APPDATA% doesn't exist,
' ' check for file in %ALLUSERSPROFILE%,
' ' otherwise create the file with its default xml table
' If File.Exists(GetUserConfigPath()) Then
' oDatatable = GetTablefromXML(GetUserConfigPath())
' ElseIf File.Exists(GetAllUsersConfigPath()) Then
' oDatatable = GetTablefromXML(GetAllUsersConfigPath())
' Else
' oDatatable = CreateConfigTable()
' oDatatable.WriteXml(GetUserConfigPath())
' End If
For Each Row As DataRow In oDatatable.Rows
rowresult &= Row.Item("ConfigName")
Select Case Row.Item("ConfigName")
Case "MyConnectionString"
Dim connstring As String
'Den ConnectonString mit verschlüsseltem PW laden
Dim csb As New SqlClient.SqlConnectionStringBuilder
csb.ConnectionString = Row.Item("Value")
If csb.ConnectionString.Contains("Password=") Then
'SA-Auth
'Jetzt das Passwort entschlüsseln
Dim PWplainText As String
Dim wrapper As New ClassEncryption("!35452didalog=")
' DecryptData throws if the wrong password is used.
Try
PWplainText = wrapper.DecryptData(csb.Password)
Catch ex As Exception
ClassLogger.Add("- the Password '" & csb.Password & "' could not be decrypted", False)
PWplainText = csb.Password
End Try
connstring = Row.Item("Value").ToString.Replace(csb.Password, PWplainText)
Else
'Win-Auth
connstring = Row.Item("Value").ToString
End If
' For Each Row As DataRow In oDatatable.Rows
' rowresult &= Row.Item("ConfigName")
' Select Case Row.Item("ConfigName")
' Case "MyConnectionString"
' Dim connstring As String
' 'Den ConnectonString mit verschlüsseltem PW laden
' Dim csb As New SqlClient.SqlConnectionStringBuilder
' csb.ConnectionString = Row.Item("Value")
' If csb.ConnectionString.Contains("Password=") Then
' 'SA-Auth
' 'Jetzt das Passwort entschlüsseln
' Dim PWplainText As String
' Dim wrapper As New ClassEncryption("!35452didalog=")
' ' DecryptData throws if the wrong password is used.
' Try
' PWplainText = wrapper.DecryptData(csb.Password)
' Catch ex As Exception
' ClassLogger.Add("- the Password '" & csb.Password & "' could not be decrypted", False)
' PWplainText = csb.Password
' End Try
' connstring = Row.Item("Value").ToString.Replace(csb.Password, PWplainText)
' Else
' 'Win-Auth
' connstring = Row.Item("Value").ToString
' End If
MyConnectionString = connstring
Case "LogErrorsOnly"
LogErrorsOnly = CBool(Row.Item("Value"))
Case "Preview"
Preview = CBool(Row.Item("Value"))
Case "UniversalViewer"
UniversalViewer_Path = Row.Item("Value")
Case "FW_started"
FW_started = CBool(Row.Item("Value"))
Case "FWSCAN_started"
FWSCAN_started = CBool(Row.Item("Value"))
Case "Delete_OriginFile"
CURR_DELETE_ORIGIN = CBool(Row.Item("Value"))
End Select
' MyConnectionString = connstring
' Case "LogErrorsOnly"
' LogErrorsOnly = CBool(Row.Item("Value"))
' Case "Preview"
' Preview = CBool(Row.Item("Value"))
' Case "UniversalViewer"
' UniversalViewer_Path = Row.Item("Value")
' Case "FW_started"
' FW_started = CBool(Row.Item("Value"))
' Case "FWSCAN_started"
' FWSCAN_started = CBool(Row.Item("Value"))
' Case "Delete_OriginFile"
' CURR_DELETE_ORIGIN = CBool(Row.Item("Value"))
' End Select
Next
'update 1.1
If rowresult.Contains("FW_started") = False Then
Dim newRow As DataRow = oDatatable.NewRow()
newRow("ConfigName") = "FW_started"
newRow("Value") = "False"
oDatatable.Rows.Add(newRow)
oDatatable.WriteXml(GetUserConfigPath())
End If
'update 1.6
If rowresult.Contains("Delete_OriginFile") = False Then
Dim newRow As DataRow = oDatatable.NewRow()
newRow("ConfigName") = "Delete_OriginFile"
newRow("Value") = "False"
oDatatable.Rows.Add(newRow)
oDatatable.WriteXml(GetUserConfigPath())
End If
If rowresult.Contains("FWSCAN_started") = False Then
Dim newRow As DataRow = oDatatable.NewRow()
newRow("ConfigName") = "FWSCAN_started"
newRow("Value") = "False"
oDatatable.Rows.Add(newRow)
oDatatable.WriteXml(GetUserConfigPath())
End If
Catch ex As Exception
MsgBox("Error in MySettings-LoadMyConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
Return True
' Next
' 'update 1.1
' If rowresult.Contains("FW_started") = False Then
' Dim newRow As DataRow = oDatatable.NewRow()
' newRow("ConfigName") = "FW_started"
' newRow("Value") = "False"
' oDatatable.Rows.Add(newRow)
' oDatatable.WriteXml(GetUserConfigPath())
' End If
' 'update 1.6
' If rowresult.Contains("Delete_OriginFile") = False Then
' Dim newRow As DataRow = oDatatable.NewRow()
' newRow("ConfigName") = "Delete_OriginFile"
' newRow("Value") = "False"
' oDatatable.Rows.Add(newRow)
' oDatatable.WriteXml(GetUserConfigPath())
' End If
' If rowresult.Contains("FWSCAN_started") = False Then
' Dim newRow As DataRow = oDatatable.NewRow()
' newRow("ConfigName") = "FWSCAN_started"
' newRow("Value") = "False"
' oDatatable.Rows.Add(newRow)
' oDatatable.WriteXml(GetUserConfigPath())
' End If
' Catch ex As Exception
' MsgBox("Error in MySettings-LoadMyConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
' Return False
' End Try
' Return True
End Function
Private Function GetTablefromXML(ConfigPath As String)
Try
Dim DS As New DataSet
DS.ReadXml(ConfigPath)
Return DS.Tables(0)
Catch ex As Exception
MsgBox("Error in GetTablefromXML" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
'End Function
'Private Function GetTablefromXML(ConfigPath As String)
' Try
' Dim DS As New DataSet
' DS.ReadXml(ConfigPath)
' Return DS.Tables(0)
' Catch ex As Exception
' MsgBox("Error in GetTablefromXML" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
' Return Nothing
' End Try
End Function
Private Function CreateConfigTable() As DataTable
Try
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim oTable As New DataTable
oTable.TableName = "MyConfig"
'End Function
'Private Function CreateConfigTable() As DataTable
' Try
' ' Create sample Customers table, in order
' ' to demonstrate the behavior of the DataTableReader.
' Dim oTable As New DataTable
' oTable.TableName = "MyConfig"
' Create two columns, ID and Name.
Dim oIdColumn As DataColumn = oTable.Columns.Add("ID",
GetType(System.Int32))
' ' Create two columns, ID and Name.
' Dim oIdColumn As DataColumn = oTable.Columns.Add("ID",
' GetType(System.Int32))
oIdColumn.AutoIncrement = True
oIdColumn.AutoIncrementSeed = 0
oIdColumn.AutoIncrementStep = 1
oTable.Columns.Add("ConfigName", GetType(System.String))
oTable.Columns.Add("Value", GetType(System.String))
'Set the ID column as the primary key column.
oTable.PrimaryKey = New DataColumn() {oIdColumn}
Dim newRow As DataRow = oTable.NewRow()
newRow("ConfigName") = "MyConnectionString"
newRow("Value") = ""
oTable.Rows.Add(newRow)
Dim newRow1 As DataRow = oTable.NewRow()
newRow1("ConfigName") = "LogErrorsOnly"
newRow1("Value") = "True"
oTable.Rows.Add(newRow1)
Dim newRow2 As DataRow = oTable.NewRow()
newRow2("ConfigName") = "Preview"
newRow2("Value") = "True"
oTable.Rows.Add(newRow2)
Dim newRow3 As DataRow = oTable.NewRow()
newRow3("ConfigName") = "UniversalViewer"
newRow3("Value") = ""
oTable.Rows.Add(newRow3)
Dim newRow4 As DataRow = oTable.NewRow()
newRow4("ConfigName") = "FW_started"
newRow4("Value") = "False"
oTable.Rows.Add(newRow4)
Dim newRow5 As DataRow = oTable.NewRow()
newRow5("ConfigName") = "FWSCAN_started"
newRow5("Value") = "False"
oTable.Rows.Add(newRow5)
oTable.AcceptChanges()
Return oTable
Catch ex As Exception
MsgBox("Error in CreateConfigTable" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
' oIdColumn.AutoIncrement = True
' oIdColumn.AutoIncrementSeed = 0
' oIdColumn.AutoIncrementStep = 1
' oTable.Columns.Add("ConfigName", GetType(System.String))
' oTable.Columns.Add("Value", GetType(System.String))
' 'Set the ID column as the primary key column.
' oTable.PrimaryKey = New DataColumn() {oIdColumn}
' Dim newRow As DataRow = oTable.NewRow()
' newRow("ConfigName") = "MyConnectionString"
' newRow("Value") = ""
' oTable.Rows.Add(newRow)
' Dim newRow1 As DataRow = oTable.NewRow()
' newRow1("ConfigName") = "LogErrorsOnly"
' newRow1("Value") = "True"
' oTable.Rows.Add(newRow1)
' Dim newRow2 As DataRow = oTable.NewRow()
' newRow2("ConfigName") = "Preview"
' newRow2("Value") = "True"
' oTable.Rows.Add(newRow2)
' Dim newRow3 As DataRow = oTable.NewRow()
' newRow3("ConfigName") = "UniversalViewer"
' newRow3("Value") = ""
' oTable.Rows.Add(newRow3)
' Dim newRow4 As DataRow = oTable.NewRow()
' newRow4("ConfigName") = "FW_started"
' newRow4("Value") = "False"
' oTable.Rows.Add(newRow4)
' Dim newRow5 As DataRow = oTable.NewRow()
' newRow5("ConfigName") = "FWSCAN_started"
' newRow5("Value") = "False"
' oTable.Rows.Add(newRow5)
' oTable.AcceptChanges()
' Return oTable
' Catch ex As Exception
' MsgBox("Error in CreateConfigTable" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
' Return Nothing
' End Try
'End Function
''' <summary>
''' Save settings to user config, NOT to common config
''' </summary>
Public Function SaveConfigValue(name As String, value As String)
Try
Dim oUserConfigPath = GetUserConfigPath()
Dim oCurrentConfigPath = GetCurrentConfigPath()
'''' <summary>
'''' Save settings to user config, NOT to common config
'''' </summary>
'Public Function SaveConfigValue(name As String, value As String)
' Try
' Dim oUserConfigPath = GetUserConfigPath()
' Dim oCurrentConfigPath = GetCurrentConfigPath()
Dim oDatatable As DataTable = GetTablefromXML(oCurrentConfigPath)
' Dim oDatatable As DataTable = GetTablefromXML(oCurrentConfigPath)
For Each Row As DataRow In oDatatable.Rows
If Row.Item("ConfigName") = name Then
Row.Item("Value") = value
End If
Next
oDatatable.AcceptChanges()
oDatatable.WriteXml(oUserConfigPath)
' For Each Row As DataRow In oDatatable.Rows
' If Row.Item("ConfigName") = name Then
' Row.Item("Value") = value
' End If
' Next
' oDatatable.AcceptChanges()
' oDatatable.WriteXml(oUserConfigPath)
Return True
Catch ex As Exception
MsgBox("Error in SaveConfigValue" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
End Function
Public Function Load_BasicConfig()
Try
ClassDatabase.Init()
Dim sql As String = "select * from tbdd_Modules where NAME = 'Global-Indexer'"
Dim DT As DataTable = ClassDatabase.Return_Datatable(sql)
If DT.Rows.Count = 1 Then
GI_withWindream = DT.Rows(0).Item("BIT1")
vWLaufwerk = DT.Rows(0).Item("STRING1")
Else
Return False
End If
Catch ex As Exception
MsgBox("Error in Load_BasicConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
Return True
End Function
' Return True
' Catch ex As Exception
' MsgBox("Error in SaveConfigValue" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
' Return False
' End Try
'End Function
'Public Function Load_BasicConfig()
' Try
' ClassDatabase.Init()
' Dim sql As String = "select * from tbdd_Modules where NAME = 'Global-Indexer'"
' Dim DT As DataTable = ClassDatabase.Return_Datatable(sql)
' If DT.Rows.Count = 1 Then
' GI_withWindream = DT.Rows(0).Item("BIT1")
' vWLaufwerk = DT.Rows(0).Item("STRING1")
' Else
' Return False
' End If
' Catch ex As Exception
' MsgBox("Error in Load_BasicConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
' Return False
' End Try
' Return True
'End Function
'Private Function DecryptConnectionString(EncryptedConnectionString As String) As String
' Dim oBuilder As New SqlClient.SqlConnectionStringBuilder With {
' .ConnectionString = EncryptedConnectionString
' }
' If oBuilder.ConnectionString.Contains("Password=") Then
' Dim oPlaintextPassword As String
' Dim oDecryptor As New ClassEncryption("!35452didalog=")
' Try
' oPlaintextPassword = oDecryptor.DecryptData(oBuilder.Password)
' Catch ex As Exception
' LOGGER.Error(ex)
' LOGGER.Debug("Password {0} could not be decrypted. Assuming plaintext password.")
' oPlaintextPassword = oBuilder.Password
' End Try
' Return EncryptedConnectionString.Replace(oBuilder.Password, oPlaintextPassword)
' Else
' Return EncryptedConnectionString
' End If
'End Function
End Module

View File

@ -1,7 +1,7 @@
'------------------------------------------------------------------------------
' <auto-generated>
' Dieser Code wurde von einem Tool generiert.
' Laufzeitversion:4.0.30319.34209
' Laufzeitversion:4.0.30319.42000
'
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
' der Code erneut generiert wird.
@ -14,8 +14,8 @@ Option Explicit On
Namespace My
'HINWEIS: Diese Datei wird automatisch generiert. Ändern Sie sie nicht direkt. Zum Ändern
' oder bei in dieser Datei auftretenden Buildfehlern wechseln Sie zum Projekt-Designer.
'HINWEIS: Diese Datei wird automatisch generiert und darf nicht direkt bearbeitet werden. Wenn Sie Änderungen vornehmen möchten
' oder in dieser Datei Buildfehler auftreten, wechseln Sie zum Projekt-Designer.
' (Wechseln Sie dazu zu den Projekteigenschaften, oder doppelklicken Sie auf den Knoten "Mein Projekt" im
' Projektmappen-Explorer). Nehmen Sie auf der Registerkarte "Anwendung" entsprechende Änderungen vor.
'

View File

@ -1,7 +1,7 @@
'------------------------------------------------------------------------------
' <auto-generated>
' Dieser Code wurde von einem Tool generiert.
' Laufzeitversion:4.0.30319.34209
' Laufzeitversion:4.0.30319.42000
'
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
' der Code erneut generiert wird.
@ -22,7 +22,7 @@ Namespace My.Resources
'''<summary>
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _

View File

@ -15,7 +15,7 @@ Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0"), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase

View File

@ -22,7 +22,7 @@ Namespace My.Resources
'''<summary>
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Class _frmLicense

View File

@ -58,7 +58,9 @@ Public Class frmConfig_Basic
Dim pw As String = cipherText
constring = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & pw & ";"
End If
SaveConfigValue("MyConnectionString", constring)
'SaveConfigValue("MyConnectionString", constring)
CONFIG.Config.ConnectionString = constring
CONFIG.Save()
Me.txtActualConnection.Text = constring
@ -122,7 +124,9 @@ Public Class frmConfig_Basic
End Sub
Private Sub frmConfig_Basic_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
SaveConfigValue("UniversalViewer", txtuniversalViewer.Text)
'SaveConfigValue("UniversalViewer", txtuniversalViewer.Text)
CONFIG.Config.UniversalViewerPath = txtuniversalViewer.Text
CONFIG.Save()
End Sub
<STAThread()> _
Private Sub frmConfig_Basic_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@ -153,8 +157,10 @@ Public Class frmConfig_Basic
If .ShowDialog() = DialogResult.OK Then
Me.txtuniversalViewer.Text = .FileName
SaveConfigValue("UniversalViewer", txtuniversalViewer.Text)
'SaveConfigValue("UniversalViewer", txtuniversalViewer.Text)
UniversalViewer_Path = txtuniversalViewer.Text
CONFIG.Config.UniversalViewerPath = txtuniversalViewer.Text
CONFIG.Save()
End If
End With
Catch ex As Exception
@ -271,11 +277,15 @@ Public Class frmConfig_Basic
ClassDatabase.Execute_non_Query("DELETE FROM TBGI_FOLDERWATCH_USER WHERE USER_ID = " & USER_ID & " AND FOLDER_TYPE = '" & FOLDER_TYPE & "'", True)
If FOLDER_TYPE = "SCAN" Then
CURRENT_SCAN_FOLDERWATCH = ""
SaveConfigValue("FWSCAN_started", "False")
'SaveConfigValue("FWSCAN_started", "False")
CONFIG.Config.FolderWatchScanStarted = False
CONFIG.Save()
FWSCAN_started = False
Else
FW_started = False
SaveConfigValue("FW_started", "False")
'SaveConfigValue("FW_started", "False")
CONFIG.Config.FolderWatchStarted = False
CONFIG.Save()
CURRENT_FOLDERWATCH = ""
End If
@ -389,7 +399,9 @@ Public Class frmConfig_Basic
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles chkLogErrorsOnly.CheckedChanged
If formloaded = True Then
SaveConfigValue("LogErrorsOnly", chkLogErrorsOnly.Checked)
CONFIG.Config.LogErrorsOnly = chkLogErrorsOnly.Checked
CONFIG.Save()
'SaveConfigValue("LogErrorsOnly", chkLogErrorsOnly.Checked)
ClassLogger.Add(" >> LogErrorsOnly changed to '" & chkLogErrorsOnly.Checked, False)
LogErrorsOnly = chkLogErrorsOnly.Checked
End If

View File

@ -2702,7 +2702,9 @@ Public Class frmIndex
Return utf8Encoding.GetString(encodedString)
End Function
Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs)
SaveConfigValue("Preview", True)
CONFIG.Config.FilePreview = CheckBox1.Checked
CONFIG.Save()
'SaveConfigValue("Preview", True)
End Sub
Private Function WORK_FILE()
Try
@ -3136,7 +3138,9 @@ Public Class frmIndex
Private Sub chkdelete_origin_CheckedChanged(sender As Object, e As EventArgs) Handles chkdelete_origin.CheckedChanged
CURR_DELETE_ORIGIN = chkdelete_origin.Checked
SaveConfigValue("Delete_OriginFile", CURR_DELETE_ORIGIN)
CONFIG.Config.DeleteOriginalFile = chkdelete_origin.Checked
CONFIG.Save()
'SaveConfigValue("Delete_OriginFile", CURR_DELETE_ORIGIN)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

View File

@ -7,7 +7,7 @@ Public NotInheritable Class frmSplash
'TODO: Dieses Formular kann einfach als Begrüßungsbildschirm für die Anwendung festgelegt werden, indem Sie zur Registerkarte "Anwendung"
' des Projekt-Designers wechseln (Menü "Projekt", Option "Eigenschaften").
Private InitSteps As Integer = 4
Private InitSteps As Integer = 5
Private bw As New BackgroundWorker()
Private Sub frmSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
@ -57,15 +57,20 @@ Public NotInheritable Class frmSplash
Thread.Sleep(600)
bw.ReportProgress(CalcProgress(2), "Initialize Database")
bw.ReportProgress(CalcProgress(2), "Initialize Config")
Init.InitConfig()
Thread.Sleep(600)
bw.ReportProgress(CalcProgress(3), "Initialize Database")
If Init.InitDatabase() = True Then
Thread.Sleep(600)
bw.ReportProgress(CalcProgress(3), "Initialize UserConfiguration")
bw.ReportProgress(CalcProgress(4), "Initialize UserConfiguration")
Init.InitUserLogin()
Thread.Sleep(600)
bw.ReportProgress(CalcProgress(4), "Initialize windream-Settings")
bw.ReportProgress(CalcProgress(5), "Initialize windream-Settings")
Init.InitBasics()
Thread.Sleep(500)

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.5.11" targetFramework="net461" />
</packages>