update to devexpress 15.2.16, add logger, add config

This commit is contained in:
Jonathan Jenne
2019-07-04 10:40:48 +02:00
parent 18b8cd5c23
commit 40460d7af9
17 changed files with 455 additions and 102 deletions

View File

@@ -1,24 +1,13 @@
Imports System.ComponentModel
Imports DD_LIB_Standards
Imports System.IO
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Config
Public Class ClassInit
Public _lizenzManager As clsLicenseManager
Public Sub InitLogger()
Try
' legt den Speicherort fest
Dim f As New IO.DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Digital Data\Clipboard Watcher\Log"))
If IO.Directory.Exists(f.ToString) = False Then
IO.Directory.CreateDirectory(f.ToString)
End If
Dim logfilename As String = f.ToString & "\" & System.DateTime.Now.ToString("yyyy_MM_dd") & ".txt"
LOGGER_FILEPATH = logfilename
clsLogger.LOGFILE_PATH = LOGGER_FILEPATH
Catch ex As Exception
MsgBox("Unexpected Error while initializing Logger: " & ex.Message, MsgBoxStyle.Critical)
End Try
LogConfig = New LogConfig(LogConfig.PathType.AppData)
Logger = LogConfig.GetLogger()
End Sub
Public Function InitDatabase()
Dim dbResult As Boolean
@@ -41,14 +30,47 @@ Public Class ClassInit
End If
End Function
Public Function InitBasics()
Dim configResult As Boolean
configResult = LoadMyConfig()
If configResult = False Then
Throw New Exception("Unexpected error inm Initialisieren der Basis-Einstellungen. Weitere Informationen finden Sie in der Logdatei.")
ConfigManager = New ConfigManager(Of ClassConfig)(LogConfig, Application.UserAppDataPath, Application.CommonAppDataPath)
With ConfigManager.Config
MyConnectionString = DecryptConnectionString(.ConnectionString)
LogErrorsOnly = .LogErrorsOnly
HotkeyFunctionKey = .HotkeyFunctionKey
HotkeySearchKey = .HotkeySearchKey
LogConfig.Debug = Not .LogErrorsOnly
End With
'Dim configResult As Boolean
'configResult = LoadMyConfig()
'If configResult = False Then
' Throw New Exception("Unexpected error inm Initialisieren der Basis-Einstellungen. Weitere Informationen finden Sie in der Logdatei.")
'Else
' Return False
'End If
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 clsEncryption("!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 False
Return EncryptedConnectionString
End If
End Function
Public Shared Function InitUserLogin(Optional _User As String = "")
Try
If _User = "" Then
@@ -63,13 +85,13 @@ Public Class ClassInit
ElseIf DT_CLIENT_USER.Rows.Count = 1 Then
CLIENT_SELECTED = DT_CLIENT_USER.Rows(0).Item("CLIENT_ID")
Else
clsLogger.Add("User '" & USER_USERNAME & "' not related to a client", True)
Logger.Info("User '" & USER_USERNAME & "' not related to a client", True)
ERROR_INIT = "NO CLIENT"
'ERROR_STATE = "NO CLIENT"
Return False
End If
Catch ex As Exception
clsLogger.Add("Unexpected error in checking CLIENT: " & ex.Message)
Logger.Info("Unexpected error in checking CLIENT: " & ex.Message)
CLIENT_SELECTED = 1
End Try
@@ -77,14 +99,14 @@ Public Class ClassInit
Dim sql = String.Format("SELECT * FROM [dbo].[FNDD_CHECK_USER_MODULE] ('{0}','CW',{1})", USER_USERNAME, CLIENT_SELECTED)
Dim DT_CHECKUSER_MODULE As DataTable = clsDatabase.Return_Datatable(sql)
If DT_CHECKUSER_MODULE.Rows.Count = 0 Then
clsLogger.Add("DT_CHECKUSER_MODULE.Rows.Count = 0", True)
Logger.Info("DT_CHECKUSER_MODULE.Rows.Count = 0", True)
'ERROR_STATE = "NO USER"
MsgBox("Sorry - Something went wrong in getting Your rights." & vbNewLine & "Please contact the system administrator!", MsgBoxStyle.Exclamation)
Return False
End If
If DT_CHECKUSER_MODULE.Rows.Count = 1 Then
clsLogger.Add(">> Login Username: " & USER_USERNAME, False)
clsLogger.Add(">> Login time: " & Now.ToString, False)
Logger.Info(">> Login Username: " & USER_USERNAME, False)
Logger.Info(">> Login time: " & Now.ToString, False)
USER_ID = DT_CHECKUSER_MODULE.Rows(0).Item("USER_ID")
USER_SURNAME = IIf(IsDBNull(DT_CHECKUSER_MODULE.Rows(0).Item("USER_SURNAME")), "", DT_CHECKUSER_MODULE.Rows(0).Item("USER_SURNAME"))
USER_PRENAME = IIf(IsDBNull(DT_CHECKUSER_MODULE.Rows(0).Item("USER_PRENAME")), "", DT_CHECKUSER_MODULE.Rows(0).Item("USER_PRENAME"))
@@ -100,7 +122,7 @@ Public Class ClassInit
Else
clsLogger.Add(" - User '" & USER_USERNAME & "' not listed in Useradministration!", False)
Logger.Info(" - User '" & USER_USERNAME & "' not listed in Useradministration!", False)
'MsgBox("Achtung: Sie sind nicht in der Userverwaltung hinterlegt." & vbNewLine & "Bitte setzen Sie sich mit dem Systembetreuer in Verbindung!", MsgBoxStyle.Critical, "Achtung:")
'Me.Close()
Dim msg = String.Format("You are not listed in the Useradministration." & vbNewLine & "Please contact the admin.")
@@ -110,7 +132,7 @@ Public Class ClassInit
If USER_IN_MODULE = False Then
If USER_IS_ADMIN = False Then
clsLogger.Add(" - User: " & USER_USERNAME & " not related to module!", False)
Logger.Info(" - User: " & USER_USERNAME & " not related to module!", False)
Dim msg = String.Format("Sie sind nicht für die Nutzung dieses Moduls freigeschaltet." & vbNewLine & "Bitte setzen Sie sich mit dem Systemadministrator in Verbindung!")
If USER_LANGUAGE <> "de-DE" Then
@@ -146,7 +168,7 @@ Public Class ClassInit
WD_UNICODE = clsDatabase.Execute_Scalar("SELECT WD_UNICODE FROM TBCW_CONFIGURATION WHERE GUID = 1")
If LogErrorsOnly = False Then clsLogger.Add(" >> Count Users logged in: " & USERCOUNT_LOGGED_IN.ToString, False)
Logger.Debug(" >> Count Users logged in: " & USERCOUNT_LOGGED_IN.ToString, False)
If LICENSE_COUNT < USERCOUNT_LOGGED_IN And LICENSE_EXPIRED = False Then
Dim msg = String.Format("Die Anzahl der aktuell angemeldeten User (" & USERCOUNT_LOGGED_IN.ToString & ") überschreitet die Anzahl der aktuellen Lizenzen!" & vbNewLine & "Anzahl der Lizenzen: " & LICENSE_COUNT.ToString & vbNewLine & "Bitte setzen Sie sich mit dem Systembetreuer in Verbindung!")
@@ -155,12 +177,12 @@ Public Class ClassInit
"Number of licenses: " & LICENSE_COUNT.ToString & vbNewLine & "Please contact Your admin!")
End If
MsgBox(msg, MsgBoxStyle.Exclamation)
clsLogger.Add(" >> The number of logged Users (" & USERCOUNT_LOGGED_IN.ToString & ") exceeds the number of licenses (" & LICENSE_COUNT & ") ", False)
Logger.Info(" >> The number of logged Users (" & USERCOUNT_LOGGED_IN.ToString & ") exceeds the number of licenses (" & LICENSE_COUNT & ") ", False)
If USER_IS_ADMIN = False Then
'Anmeldung wieder herausnehmen
sql = "DELETE FROM TBDD_USER_MODULE_LOG_IN WHERE USER_ID = " & USER_ID & " AND MODULE= 'Clipboard-Watcher'"
clsDatabase.Execute_non_Query(sql, True)
clsLogger.Add(" - logged out the user", False)
Logger.Info(" - logged out the user", False)
Return False
End If
End If
@@ -168,7 +190,7 @@ Public Class ClassInit
Catch ex As Exception
clsLogger.Add("Unexpected Error in InitUserLogin: " & ex.Message, True)
Logger.Info("Unexpected Error in InitUserLogin: " & ex.Message, True)
MsgBox("Unexpected Error in InitUserLogin: " & ex.Message, MsgBoxStyle.Critical)
Return False
End Try