From aef4a040ed97c4e57066f7d11ea455d33cd2b7f8 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 5 Nov 2019 16:31:06 +0100 Subject: [PATCH] fix CURR_Logger being nothing, create NI config if it does not exist, rename CURR_MyLogger to CURR_LogConfig --- ToolCollection/ClassDIProfile.vb | 12 +++++++++--- ToolCollection/ClassMI_Profile.vb | 2 +- ToolCollection/ClassMoReDokumentart.vb | 2 +- ToolCollection/ClassMoReDokumentarten.vb | 2 +- ToolCollection/ClassNIProfil.vb | 2 +- ToolCollection/ClassNIProfile.vb | 18 ++++++++++++------ ToolCollection/ModuleCURRENT.vb | 4 ++-- ToolCollection/ToolCollection.vbproj | 7 +++++++ ToolCollection/frmDIProfilEigenschaften.vb | 2 +- ToolCollection/frmDIProfilHinzufuegen.vb | 2 +- ToolCollection/frmDIRegelAssistent.vb | 2 +- ToolCollection/frmDIRegelverwaltung.vb | 2 +- ToolCollection/frmMIParameterHinzufügen.vb | 2 +- ToolCollection/frmMIProfileigenschaften.vb | 2 +- ToolCollection/frmMI_Profilhinzufuegen.vb | 2 +- ToolCollection/frmNB_AD_add.vb | 2 +- ToolCollection/frmNIProfilhinzufuegen.vb | 2 +- ToolCollection/frmNIVerknuepfungen.vb | 6 +++--- ToolCollection/frmStart.vb | 3 ++- 19 files changed, 48 insertions(+), 28 deletions(-) diff --git a/ToolCollection/ClassDIProfile.vb b/ToolCollection/ClassDIProfile.vb index 74b5b0c..4bd9656 100644 --- a/ToolCollection/ClassDIProfile.vb +++ b/ToolCollection/ClassDIProfile.vb @@ -5,10 +5,13 @@ Public Class ClassDIProfile Public Shared xmlConfigFile As String Public Shared aktivesProfil As ClassDIProfil Public Shared aktivesProfilAusProfileigenschaften As Boolean = False - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) Public Shared Sub Init() - xmlConfigFile = My.Application.Info.DirectoryPath & "\" & My.Settings.vDIConfigDatei + Dim oConfigPath As String = My.Application.Info.DirectoryPath & "\" & My.Settings.vDIConfigDatei + CURR_Logger.Info("[ClassDIProfile] Loading config for DI from {0}", oConfigPath) + + xmlConfigFile = oConfigPath ClassDIProfile.LoadFromXmlFile() ' 3b. Windream initialisieren (Connection, Session, ... aufbauen) _windream.Init() @@ -98,7 +101,7 @@ Public Class ClassDIProfile End Function - Public Shared Function IsXmlAccessable() + Public Shared Function IsXmlAccessable() As Boolean Dim xml As New Xml.XmlDocument Try @@ -110,6 +113,9 @@ Public Class ClassDIProfile Catch ex As Exception Try + CURR_Logger.Warn("[ClassDIProfile] Could not load config file, creating default.") + CURR_Logger.Error(ex) + If My.Settings.vLogErrorsonly = False Then MsgBox("System kann nicht auf Konfig-Datei " & vbNewLine & xmlConfigFile & vbNewLine & " zugreifen! (Nicht vorhanden bzw Syntaxfehler)" & vbNewLine & "Datei wird neu erstellt!", MsgBoxStyle.Exclamation, "Achtung:") Dim fw As System.IO.StreamWriter = New System.IO.StreamWriter(xmlConfigFile) diff --git a/ToolCollection/ClassMI_Profile.vb b/ToolCollection/ClassMI_Profile.vb index fd81e2d..d371751 100644 --- a/ToolCollection/ClassMI_Profile.vb +++ b/ToolCollection/ClassMI_Profile.vb @@ -3,7 +3,7 @@ Public Shared xmlConfigFile As String Public Shared aktivesProfil As ClassMI_Profil Public Shared aktivesProfilAusProfileigenschaften As Boolean = False - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) 'Public Shared xmlConfigFile As String = My.Settings.vConfigDatei 'Private Shared config As ClassMerkatorIntegrationKonfiguration = New ClassMerkatorIntegrationKonfiguration() diff --git a/ToolCollection/ClassMoReDokumentart.vb b/ToolCollection/ClassMoReDokumentart.vb index efee4c4..cfdd2c0 100644 --- a/ToolCollection/ClassMoReDokumentart.vb +++ b/ToolCollection/ClassMoReDokumentart.vb @@ -18,7 +18,7 @@ Private _namenskonvention As String Private _zielort As String - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) Private _saved As Boolean 'Private _config As ClassNachindexierungKonfiguration = New ClassNachindexierungKonfiguration diff --git a/ToolCollection/ClassMoReDokumentarten.vb b/ToolCollection/ClassMoReDokumentarten.vb index 95c0213..22f2c4a 100644 --- a/ToolCollection/ClassMoReDokumentarten.vb +++ b/ToolCollection/ClassMoReDokumentarten.vb @@ -1,7 +1,7 @@ Public Class ClassMoReDokumentarten Private Shared _profiles() As ClassMoReDokumentart - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) Public Shared xmlConfigFile As String Public Shared Sub Init() diff --git a/ToolCollection/ClassNIProfil.vb b/ToolCollection/ClassNIProfil.vb index 1b581e8..8e5dc33 100644 --- a/ToolCollection/ClassNIProfil.vb +++ b/ToolCollection/ClassNIProfil.vb @@ -65,7 +65,7 @@ Private _CrFolder_Created_Folder As String Private _CrFolder_move As Boolean - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) Private _saved As Boolean 'Private _config As ClassNachindexierungKonfiguration = New ClassNachindexierungKonfiguration diff --git a/ToolCollection/ClassNIProfile.vb b/ToolCollection/ClassNIProfile.vb index bd708a1..90d1ae0 100644 --- a/ToolCollection/ClassNIProfile.vb +++ b/ToolCollection/ClassNIProfile.vb @@ -2,15 +2,19 @@ Public Class ClassNIProfile Private Shared _Logger As DigitalData.Modules.Logging.Logger Private Shared _profiles() As ClassNIProfil - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) Public Shared xmlConfigFile As String + Public Shared Sub Init() - xmlConfigFile = My.Application.Info.DirectoryPath & "\" & My.Settings.vNIConfigDatei + Dim oConfigPath As String = My.Application.Info.DirectoryPath & "\" & My.Settings.vNIConfigDatei + CURR_Logger.Info("[ClassNIProfile] Loading config for NI from {0}", oConfigPath) + + xmlConfigFile = oConfigPath ClassNIProfile.LoadFromXmlFile() ' 3b. Windream initialisieren (Connection, Session, ... aufbauen) _windream.Init() End Sub - Public Shared Function IsXmlAccessable() + Public Shared Function IsXmlAccessable() As Boolean Dim xml As New Xml.XmlDocument Try ' XML-Datei laden und speichern um Zugriff zu testen @@ -20,7 +24,8 @@ Public Class ClassNIProfile Return True Catch ex As Exception Try - _Logger.Error(ex) + CURR_Logger.Warn("[ClassNIProfile] Could not load config file, creating default.") + CURR_Logger.Error(ex) Dim fw As System.IO.StreamWriter = New System.IO.StreamWriter(xmlConfigFile) fw.WriteLine("") @@ -34,7 +39,6 @@ Public Class ClassNIProfile Catch e2 As Exception Return False End Try - End Try End Function Public Shared Sub LoadFromXmlFile() @@ -47,7 +51,9 @@ Public Class ClassNIProfile If xmlConfigFile Is Nothing Then Exit Sub If Not xmlConfigFile = "" Then - If System.IO.File.Exists(xmlConfigFile) Then + 'If System.IO.File.Exists(xmlConfigFile) Then + If ClassNIProfile.IsXmlAccessable() Then + xml = New Xml.XmlDocument() xml.Load(xmlConfigFile) 'MsgBox(xmlConfigFile) diff --git a/ToolCollection/ModuleCURRENT.vb b/ToolCollection/ModuleCURRENT.vb index db7d426..5073926 100644 --- a/ToolCollection/ModuleCURRENT.vb +++ b/ToolCollection/ModuleCURRENT.vb @@ -24,6 +24,6 @@ Module ModuleCURRENT Public CURRENT_DYNAMICFOLDER As String Public CURRENT_IndexList As List(Of String) - Public CURR_MyLogger As LogConfig - Public CURR_Logger As DigitalData.Modules.Logging.Logger + Public Property CURR_LogConfig As LogConfig + Public Property CURR_Logger As DigitalData.Modules.Logging.Logger End Module diff --git a/ToolCollection/ToolCollection.vbproj b/ToolCollection/ToolCollection.vbproj index 94fbede..c5a9ad5 100644 --- a/ToolCollection/ToolCollection.vbproj +++ b/ToolCollection/ToolCollection.vbproj @@ -86,9 +86,15 @@ bin\x64\Release\ + + ..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll + ..\..\DDMonorepo\Modules.Database\bin\Debug\DigitalData.Modules.Database.dll + + ..\..\DDMonorepo\Modules.Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll + ..\..\DDMonorepo\Modules.Logging\bin\Debug\DigitalData.Modules.Logging.dll @@ -550,6 +556,7 @@ Designer + PreserveNewest DSNachbearbeitung.xsd diff --git a/ToolCollection/frmDIProfilEigenschaften.vb b/ToolCollection/frmDIProfilEigenschaften.vb index 88c2db4..4480973 100644 --- a/ToolCollection/frmDIProfilEigenschaften.vb +++ b/ToolCollection/frmDIProfilEigenschaften.vb @@ -11,7 +11,7 @@ Public Class frmDIProfilEigenschaften Dim arrProfile(1, 1) As Object Dim Prof_Anzahl As Integer - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) Private Shared _Instance As frmDIProfilEigenschaften = Nothing Public Shared Function Instance() As frmDIProfilEigenschaften diff --git a/ToolCollection/frmDIProfilHinzufuegen.vb b/ToolCollection/frmDIProfilHinzufuegen.vb index 78be87a..bae0bba 100644 --- a/ToolCollection/frmDIProfilHinzufuegen.vb +++ b/ToolCollection/frmDIProfilHinzufuegen.vb @@ -1,7 +1,7 @@ Public Class frmDIProfilHinzufuegen Public oSession - Protected _windream As New ClassWindream_allgemein(CURR_MyLogger) + Protected _windream As New ClassWindream_allgemein(CURR_LogConfig) ' Private _parentClass As ClassDateiimport = ClassDateiimport.GetInstance Private Sub frmProfilHinzufügen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load diff --git a/ToolCollection/frmDIRegelAssistent.vb b/ToolCollection/frmDIRegelAssistent.vb index 8a67b88..ac70cd3 100644 --- a/ToolCollection/frmDIRegelAssistent.vb +++ b/ToolCollection/frmDIRegelAssistent.vb @@ -28,7 +28,7 @@ Public Class frmDIRegelAssistent Private _trennzeichen_temp As String = " " Private _value As String = "" Private _indexe As String() - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) Private _datumFormat As String = "" Private _removeZeros As Boolean = False #End Region diff --git a/ToolCollection/frmDIRegelverwaltung.vb b/ToolCollection/frmDIRegelverwaltung.vb index a742713..6f0bdaf 100644 --- a/ToolCollection/frmDIRegelverwaltung.vb +++ b/ToolCollection/frmDIRegelverwaltung.vb @@ -2,7 +2,7 @@ Private profilname As String Private selectedProfil As ClassDIProfil - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) Public _regeln As ClassDIRegeln diff --git a/ToolCollection/frmMIParameterHinzufügen.vb b/ToolCollection/frmMIParameterHinzufügen.vb index f2565f7..afc860a 100644 --- a/ToolCollection/frmMIParameterHinzufügen.vb +++ b/ToolCollection/frmMIParameterHinzufügen.vb @@ -1,6 +1,6 @@ Public Class frmMIParameterHinzufügen Public selectedProfil As ClassMI_Profil - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) Private Sub frmParameterHinzufügen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Me.selectedProfil.DokumenttypString = "" Then diff --git a/ToolCollection/frmMIProfileigenschaften.vb b/ToolCollection/frmMIProfileigenschaften.vb index 5a457ef..3cb1d86 100644 --- a/ToolCollection/frmMIProfileigenschaften.vb +++ b/ToolCollection/frmMIProfileigenschaften.vb @@ -2,7 +2,7 @@ ' entspricht dem, über die Toolbar-Combobox ausgewählten, Profil und enthält alle relevanten Informationen darüber Private _selectedProfile As ClassMI_Profil Dim Formloaded As Boolean = False - Public Shared _windream As New ClassWindream_allgemein(CURR_MyLogger) + Public Shared _windream As New ClassWindream_allgemein(CURR_LogConfig) Private Shared _Instance As frmMIProfileigenschaften = Nothing Public Shared Function Instance() As frmMIProfileigenschaften If _Instance Is Nothing OrElse _Instance.IsDisposed = True Then diff --git a/ToolCollection/frmMI_Profilhinzufuegen.vb b/ToolCollection/frmMI_Profilhinzufuegen.vb index ad1c959..3f851fb 100644 --- a/ToolCollection/frmMI_Profilhinzufuegen.vb +++ b/ToolCollection/frmMI_Profilhinzufuegen.vb @@ -2,7 +2,7 @@ Imports Scripting Public Class frmMI_Profilhinzufuegen Public oSession - Protected _windream As New ClassWindream_allgemein(CURR_MyLogger) + Protected _windream As New ClassWindream_allgemein(CURR_LogConfig) 'Public oSession 'Public oConnect 'Public oBrowser As New WMOBRWSLib.ServerBrowser diff --git a/ToolCollection/frmNB_AD_add.vb b/ToolCollection/frmNB_AD_add.vb index 6bc84e2..fc0f3fc 100644 --- a/ToolCollection/frmNB_AD_add.vb +++ b/ToolCollection/frmNB_AD_add.vb @@ -6,7 +6,7 @@ Public Class frmNB_AD_add Dim Rechtename As String = "" Dim deleteall As Boolean = False Dim AccessRight As Integer - Private _windream As New ClassWindream_allgemein(CURR_MyLogger) + Private _windream As New ClassWindream_allgemein(CURR_LogConfig) Dim _windreamRechte As ClassWD_Rechte Dim countRegel As Integer Dim _deleteRoles As Boolean = False diff --git a/ToolCollection/frmNIProfilhinzufuegen.vb b/ToolCollection/frmNIProfilhinzufuegen.vb index 045fafb..92a5121 100644 --- a/ToolCollection/frmNIProfilhinzufuegen.vb +++ b/ToolCollection/frmNIProfilhinzufuegen.vb @@ -17,7 +17,7 @@ Public Class frmNIProfilhinzufuegen Private Sub frmNIProfilhinzufuegen_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load - _windream = New ClassWindream_allgemein(CURR_MyLogger) + _windream = New ClassWindream_allgemein(CURR_LogConfig) ' Verbindung mit windream herstellen _windream.Init() diff --git a/ToolCollection/frmNIVerknuepfungen.vb b/ToolCollection/frmNIVerknuepfungen.vb index 5c5a9eb..0ab74aa 100644 --- a/ToolCollection/frmNIVerknuepfungen.vb +++ b/ToolCollection/frmNIVerknuepfungen.vb @@ -52,10 +52,10 @@ Public Class frmNIVerknuepfungen ' Dieser Aufruf ist für den Windows Form-Designer erforderlich. InitializeComponent() - _Logger = CURR_MyLogger.GetLogger() + _Logger = CURR_LogConfig.GetLogger() _flagIgnoreCheckedChanged = False - _windream = New ClassWindream_allgemein(CURR_MyLogger) - database = New ClassNIDatenbankzugriff(CURR_MyLogger) + _windream = New ClassWindream_allgemein(CURR_LogConfig) + database = New ClassNIDatenbankzugriff(CURR_LogConfig) ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. Me.LoadProfilesInCombobox() End Sub diff --git a/ToolCollection/frmStart.vb b/ToolCollection/frmStart.vb index 2822b84..fa50124 100644 --- a/ToolCollection/frmStart.vb +++ b/ToolCollection/frmStart.vb @@ -47,7 +47,8 @@ Public Class frmStart Private Sub FMStart_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load _MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log")) _Logger = _MyLogger.GetLogger() - CURR_MyLogger = _MyLogger + CURR_Logger = _Logger + CURR_LogConfig = _MyLogger 'Aktueller Benutzer Me.tslblVersion.Text = Environment.UserName.ToString Me.Text = Application.CompanyName & "-" & Application.ProductName