This commit is contained in:
2023-01-23 16:21:42 +01:00
parent 01b066e4e3
commit 60c739833f
57 changed files with 77259 additions and 198787 deletions

View File

@@ -1,36 +1,85 @@
Imports System.ComponentModel
Imports System.IO
Imports DD_LIB_Standards
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Logging
Public Class ClassInit
Public Sub New()
End Sub
Public Sub InitLogger()
LOGCONFIG = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing,
Public Sub InitLoggerANDConfig()
Try
LOGCONFIG = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing,
My.Application.Info.CompanyName,
"ADDI")
LOGGER = LOGCONFIG.GetLogger()
LOGGER = LOGCONFIG.GetLogger()
LOGGER.Info("## ADDI started - {0}", Now)
Try
Dim directory As New IO.DirectoryInfo(Application.LocalUserAppDataPath & "\Log")
LOGGER.Info("## ADDI started - {0}", Now)
Try
Dim directory As New IO.DirectoryInfo(Application.LocalUserAppDataPath & "\Log")
For Each file As IO.FileInfo In directory.GetFiles
If (Now - file.CreationTime).Days > 29 Then
file.Delete()
Else
Exit For
For Each file As IO.FileInfo In directory.GetFiles
If (Now - file.CreationTime).Days > 29 Then
file.Delete()
Else
Exit For
End If
Next
Catch ex As Exception
End Try
Dim oUserAppDataPath As String = Application.UserAppDataPath
Dim oLegacyAppDataPath As String = Application.UserAppDataPath
Dim oCommonAppDataPath = Application.CommonAppDataPath
Dim oStartupPath = Application.StartupPath
' If AppConfig from Startup Path should be forced, rewrite the common app data path
If My.Settings.UseAppConfigConString = True Then
' UserAppDataPath = StartupPath
oCommonAppDataPath = oStartupPath
End If
CONFIG = New ConfigManager(Of ClassConfig)(LOGCONFIG, oUserAppDataPath, oCommonAppDataPath, oStartupPath)
LOGGER.Info("Config loaded")
Try
If CONFIG.Config.ConnectionString <> String.Empty Then
LOGGER.Debug("Connection String loaded")
MyConnectionString = DecryptConnectionString(CONFIG.Config.ConnectionString)
End If
Next
Catch ex As Exception
LOGGER.Error(ex, "Unexpected Error Getting CONFIG.TestMode or CONFIG.ConnectionStringTest")
End Try
Catch ex As Exception
End Try
End Sub
End Sub
Private Shared 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
Public Shared Function InitDatabase()
Try
Dim dbResult As Boolean
@@ -41,6 +90,10 @@ Public Class ClassInit
MsgBox("The Exclude File Structure for files in Folderwatch could not be initialized!", MsgBoxStyle.Information)
End If
clsDatabase.GUI = True
If CONFIG.Config.ConnectionString <> String.Empty Then
LOGGER.Debug("Connection String from CONFIG")
MyConnectionString = DecryptConnectionString(CONFIG.Config.ConnectionString)
End If
If MyConnectionString <> String.Empty Then
dbResult = clsDatabase.Init(MyConnectionString)
Else
@@ -140,7 +193,7 @@ Public Class ClassInit
End If
End If
sql = "SELECT * FROM TBDD_SQL_COMMANDS"
sql = "SELECT * FROM TBDD_SQL_COMMANDS"
Dim oDTSQL_COMMANDS As DataTable = ClassDatabase.Return_Datatable(sql, True)
For Each oRow As DataRow In oDTSQL_COMMANDS.Rows
If oRow.Item("TITLE") = "ADDI_DOC_SEARCH_RECORD" Then
@@ -214,6 +267,15 @@ WHERE (USERNAME = '{0}') AND T2.SHORT_NAME = 'ADDI'", USER_USERNAME)
USER_GENERAL_VIEWER = USER_DT.Rows(0).Item("GENERAL_VIEWER")
Right_RO = True
Try
If CBool(USER_DT.Rows(0).Item("PMO_READ_ONLY")) = True Then
WM_READ_ONLY = True
LOGGER.Info("WINDREAM IS CONFIGURED READ ONLY!!")
End If
Catch ex As Exception
End Try
If Right_RO = False Then
LOGGER.Warn("User '" & USER_USERNAME & "' not authorized for using Record-Organizer!")
@@ -280,23 +342,28 @@ WHERE (USERNAME = '{0}') AND T2.SHORT_NAME = 'ADDI'", USER_USERNAME)
End If
Try
If SHARE_DRIVE_ACTIVE = True Then
End If
LOGGER.Info($"SHAREDRIVE IS ACTIVE = {SHARE_DRIVE_ACTIVE.ToString}")
Try
WMMOD = New DigitalData.Modules.Windream.Windream(LOGCONFIG, False, WMDriveLetter, WMPATH_PREFIX, True, "", "", "", "")
If IsNothing(WMMOD) Then
MsgBox("No windream connectable", MsgBoxStyle.Exclamation)
If WM_READ_ONLY = True Then
If SHARE_DRIVE_ACTIVE = True Then
LOGGER.Info($"SHAREDRIVE IS ACTIVE = {SHARE_DRIVE_ACTIVE.ToString}")
End If
Catch ex As Exception
LOGGER.Warn("Could not create the login for DigitalData.Modules.Windream.Windream!")
End Try
If clsWindream.Create_Session = False Then
LOGGER.Warn("Could not create the login for windream - No session created!")
ClassHelper.MSGBOX_Handler("ERROR", "windream-login Error:", "Could not create the login/session!", "ADDI will start anyway but be aware that searching and importing won't be possible!")
Else
Try
WMMOD = New DigitalData.Modules.Windream.Windream(LOGCONFIG, False, WMDriveLetter, WMPATH_PREFIX, True, "", "", "", "")
If IsNothing(WMMOD) Then
MsgBox("No windream connectable", MsgBoxStyle.Exclamation)
End If
Catch ex As Exception
LOGGER.Warn("Could not create the login for DigitalData.Modules.Windream.Windream!")
End Try
If clsWindream.Create_Session = False Then
LOGGER.Warn("Could not create the login for windream - No session created!")
ClassHelper.MSGBOX_Handler("ERROR", "windream-login Error:", "Could not create the login/session!", "ADDI will start anyway but be aware that searching and importing won't be possible!")
End If
End If
Catch ex As Exception
LOGGER.Warn("Unexpected Error in clswindream.Init: " & ex.Message)
MsgBox("Unexpected Error in Creating windream-Session: " & ex.Message & vbNewLine & "Please inform Your sysadmin!", MsgBoxStyle.Critical)