add logging

This commit is contained in:
Jonathan Jenne
2023-08-03 09:03:32 +02:00
parent 7f997f6802
commit c347ee7d55
2 changed files with 12 additions and 20 deletions

View File

@@ -16,23 +16,7 @@ Public Class ClassInit
My.Application.Info.CompanyName, My.Application.Info.CompanyName,
"OrgFlow") "OrgFlow")
LOGGER = LOGCONFIG.GetLogger() LOGGER = LOGCONFIG.GetLogger()
LOGGER.Info("OrgFlow started")
LOGGER.Info("## OrgFlow 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
End If
Next
Catch ex As Exception
End Try
Dim oUserAppDataPath As String = Application.UserAppDataPath Dim oUserAppDataPath As String = Application.UserAppDataPath
Dim oLegacyAppDataPath As String = Application.UserAppDataPath Dim oLegacyAppDataPath As String = Application.UserAppDataPath
@@ -58,9 +42,8 @@ Public Class ClassInit
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex)
End Try End Try
End Sub End Sub
Private Shared Function DecryptConnectionString(EncryptedConnectionString As String) As String Private Shared Function DecryptConnectionString(EncryptedConnectionString As String) As String
Dim oBuilder As New SqlClient.SqlConnectionStringBuilder With { Dim oBuilder As New SqlClient.SqlConnectionStringBuilder With {
@@ -131,6 +114,7 @@ Public Class ClassInit
Return True Return True
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Unexpected Error in Init Database:" & vbNewLine & ex.Message, MsgBoxStyle.Critical) MsgBox("Unexpected Error in Init Database:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False Return False
End Try End Try
@@ -173,6 +157,7 @@ Public Class ClassInit
MY_ADDON_PATH = AddonPath MY_ADDON_PATH = AddonPath
SaveMySettingsValue("PATH_ADDON", MY_ADDON_PATH, "ConfigMain") SaveMySettingsValue("PATH_ADDON", MY_ADDON_PATH, "ConfigMain")
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Unexpected Error in InitAddons:" & vbNewLine & ex.Message, MsgBoxStyle.Critical) MsgBox("Unexpected Error in InitAddons:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try End Try
End Sub End Sub
@@ -232,6 +217,7 @@ Public Class ClassInit
Next Next
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Unexpected Error in InitBasics2:" & vbNewLine & ex.Message, MsgBoxStyle.Critical) MsgBox("Unexpected Error in InitBasics2:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try End Try
@@ -244,6 +230,7 @@ Public Class ClassInit
"And T.ACTIVE = 1 And T1.USER_ID = {0}", USER_GUID) "And T.ACTIVE = 1 And T1.USER_ID = {0}", USER_GUID)
CURRENT_TBPMO_CONN_SWITCH = MYDB_ECM.GetDatatable(sql) CURRENT_TBPMO_CONN_SWITCH = MYDB_ECM.GetDatatable(sql)
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Warn("Unexpected Error in Init_CONN_SWITCH: " & ex.Message) LOGGER.Warn("Unexpected Error in Init_CONN_SWITCH: " & ex.Message)
End Try End Try
End Sub End Sub
@@ -432,6 +419,7 @@ WHERE (USERNAME = '{0}') AND T2.SHORT_NAME = 'ADDI'", USER_USERNAME)
End If End If
End If End If
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Warn("Unexpected Error in InitUserLogin: " & ex.Message) LOGGER.Warn("Unexpected Error in InitUserLogin: " & ex.Message)
MsgBox("Unexpected Error in InitUserLogin: " & ex.Message, MsgBoxStyle.Critical) MsgBox("Unexpected Error in InitUserLogin: " & ex.Message, MsgBoxStyle.Critical)
Return False Return False

View File

@@ -297,6 +297,7 @@ Module ModuleMySettings
Catch ex As Exception Catch ex As Exception
MsgBox("Error in LoadMyConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical) MsgBox("Error in LoadMyConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
LOGGER.Error(ex)
LOGGER.Warn("Error in LoadMyConfig: " & ex.Message, True) LOGGER.Warn("Error in LoadMyConfig: " & ex.Message, True)
Return False Return False
End Try End Try
@@ -326,7 +327,7 @@ Module ModuleMySettings
table.TableName = "MyConfig" table.TableName = "MyConfig"
' Create two columns, ID and Name. ' Create two columns, ID and Name.
Dim idColumn As DataColumn = table.Columns.Add("ID", _ Dim idColumn As DataColumn = table.Columns.Add("ID",
GetType(System.Int32)) GetType(System.Int32))
idColumn.AutoIncrement = True idColumn.AutoIncrement = True
@@ -399,6 +400,7 @@ Module ModuleMySettings
LOGGER.Info("CreateConfigTable su...") LOGGER.Info("CreateConfigTable su...")
Return table Return table
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Error in CreateConfigTable" & vbNewLine & ex.Message, MsgBoxStyle.Critical) MsgBox("Error in CreateConfigTable" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return Nothing Return Nothing
End Try End Try
@@ -426,6 +428,7 @@ Module ModuleMySettings
End If End If
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Error in SaveConfigValue" & vbNewLine & ex.Message, MsgBoxStyle.Critical) MsgBox("Error in SaveConfigValue" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False Return False
End Try End Try
@@ -450,6 +453,7 @@ Module ModuleMySettings
Return False Return False
End If End If
Catch ex As Exception Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Error in Settings_LoadBasicConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical) MsgBox("Error in Settings_LoadBasicConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False Return False
End Try End Try