Improve error handling and logging for rights and indexing
Enhanced error handling in ClassWD_Rechte to unlock objects after exceptions and prevent resource locks. Refactored frmNIHauptseite to add detailed debug logging and robust error handling in File_SetBooleanIndex, including better handling of missing or invalid index values. Replaced SetErrorMeldung with File_SetBooleanIndex for AD post-processing errors. These changes improve traceability and reliability.
This commit is contained in:
@@ -393,13 +393,13 @@ Public Class ClassWD_Rechte
|
|||||||
End Function
|
End Function
|
||||||
Private Function WorkRight(_methode As String, createdFolder As String, _form As Boolean, oWMObject As WINDREAMLib.WMObject, deleteRights As Boolean, folgeRegel As Boolean, _UserOrGroup As String,
|
Private Function WorkRight(_methode As String, createdFolder As String, _form As Boolean, oWMObject As WINDREAMLib.WMObject, deleteRights As Boolean, folgeRegel As Boolean, _UserOrGroup As String,
|
||||||
_GruppenUserRecht As String, _lRight As Integer) As Boolean
|
_GruppenUserRecht As String, _lRight As Integer) As Boolean
|
||||||
|
Dim Object2Change As WINDREAMLib.WMObject = Nothing
|
||||||
Try
|
Try
|
||||||
Dim _Erfolgreich As Boolean = True
|
Dim _Erfolgreich As Boolean = True
|
||||||
Dim UserGroupRelation
|
Dim UserGroupRelation
|
||||||
Dim UserOrGroup
|
Dim UserOrGroup
|
||||||
Dim oGroup
|
Dim oGroup
|
||||||
Dim oUSer
|
Dim oUSer
|
||||||
Dim Object2Change As WINDREAMLib.WMObject
|
|
||||||
If _methode = "AddRightFolder" Then
|
If _methode = "AddRightFolder" Then
|
||||||
Object2Change = oWMObject.aParentWMObject
|
Object2Change = oWMObject.aParentWMObject
|
||||||
ElseIf _methode = "AddRightCreatedFolder" Then
|
ElseIf _methode = "AddRightCreatedFolder" Then
|
||||||
@@ -731,6 +731,13 @@ Public Class ClassWD_Rechte
|
|||||||
Return _Erfolgreich
|
Return _Erfolgreich
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
|
Try
|
||||||
|
If Object2Change IsNot Nothing AndAlso Object2Change.aLocked Then
|
||||||
|
Object2Change.unlock()
|
||||||
|
_Logger.Debug("WorkRight Catch: Object2Change unlocked after error.")
|
||||||
|
End If
|
||||||
|
Catch
|
||||||
|
End Try
|
||||||
Return False
|
Return False
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|||||||
@@ -1913,7 +1913,7 @@ Public Class frmNIHauptseite
|
|||||||
If adReworkOk = False Then
|
If adReworkOk = False Then
|
||||||
_Logger.Warn($"## Nachbearbeitung AD für [{pMyWMDoc.aName}] fehlgeschlagen - Error-Index wird gesetzt")
|
_Logger.Warn($"## Nachbearbeitung AD für [{pMyWMDoc.aName}] fehlgeschlagen - Error-Index wird gesetzt")
|
||||||
File_SetBooleanIndex(True, pMyWMDoc, aktivesProfil.IndexValidation)
|
File_SetBooleanIndex(True, pMyWMDoc, aktivesProfil.IndexValidation)
|
||||||
SetErrorMeldung("Rechtevergabe fehlgeschlagen", pMyWMDoc, aktivesProfil.IndexFehler)
|
File_SetBooleanIndex(True, pMyWMDoc, aktivesProfil.IndexFehler)
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
If aktivesProfil.NachbearbeitungAD = True Then
|
If aktivesProfil.NachbearbeitungAD = True Then
|
||||||
@@ -2547,12 +2547,22 @@ Public Class frmNIHauptseite
|
|||||||
'Ab Hier Error prüfen
|
'Ab Hier Error prüfen
|
||||||
Sub File_SetBooleanIndex(ByVal _value As Boolean, ByVal _dok As WINDREAMLib.WMObject, ByVal _Indexname As String)
|
Sub File_SetBooleanIndex(ByVal _value As Boolean, ByVal _dok As WINDREAMLib.WMObject, ByVal _Indexname As String)
|
||||||
Try
|
Try
|
||||||
|
_Logger.Debug($"File_SetBooleanIndex called: Index=[{_Indexname}] Value=[{_value}] Doc=[{If(_dok IsNot Nothing, _dok.aName, "NULL")}]")
|
||||||
If _Indexname <> "" Then
|
If _Indexname <> "" Then
|
||||||
'Überprüfen ob Boolean-Value bereits gesetzt wurde?
|
'Überprüfen ob Boolean-Value bereits gesetzt wurde?
|
||||||
Dim akt_Status As Boolean = CBool(_dok.GetVariableValue(_Indexname))
|
Dim akt_Status As Boolean = False
|
||||||
|
Try
|
||||||
|
Dim rawValue As Object = _dok.GetVariableValue(_Indexname)
|
||||||
|
_Logger.Debug($"File_SetBooleanIndex: rawValue=[{If(rawValue IsNot Nothing, rawValue.ToString, "NULL")}]")
|
||||||
|
If rawValue IsNot Nothing Then
|
||||||
|
akt_Status = CBool(rawValue)
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
_Logger.Debug($"File_SetBooleanIndex: GetVariableValue threw exception - treating as False. Error: {ex.Message}")
|
||||||
|
akt_Status = False
|
||||||
|
End Try
|
||||||
If akt_Status <> _value Then
|
If akt_Status <> _value Then
|
||||||
'Index muß angepasst werden
|
_Logger.Debug($"File_SetBooleanIndex: writing [{_value}] to index [{_Indexname}]")
|
||||||
_Logger.Debug("Validation Index not set to '" & _value.ToString & "'.")
|
|
||||||
Dim arrIndex() As String = Nothing
|
Dim arrIndex() As String = Nothing
|
||||||
Dim arrValue() As String = Nothing
|
Dim arrValue() As String = Nothing
|
||||||
'Nun die Datei indexieren
|
'Nun die Datei indexieren
|
||||||
@@ -2577,6 +2587,8 @@ Public Class frmNIHauptseite
|
|||||||
'Validation muß nicht angepasst werden
|
'Validation muß nicht angepasst werden
|
||||||
_Logger.Debug("Validation Index already set to '" & _value & "'.")
|
_Logger.Debug("Validation Index already set to '" & _value & "'.")
|
||||||
End If
|
End If
|
||||||
|
Else
|
||||||
|
_Logger.Warn($"File_SetBooleanIndex: _Indexname is empty - no index written! (Doc=[{If(_dok IsNot Nothing, _dok.aName, "NULL")}] Value=[{_value}])")
|
||||||
End If
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Warn("Error in File_SetBooleanIndex")
|
_Logger.Warn("Error in File_SetBooleanIndex")
|
||||||
|
|||||||
Reference in New Issue
Block a user