MS Fehlerhandling FormatString

This commit is contained in:
2023-05-09 15:20:58 +02:00
parent 1e98e4a9ab
commit 440303d299
10 changed files with 65 additions and 300 deletions

View File

@@ -45,24 +45,11 @@ Public Class ClassPMWindream
Private Function IsNotEmpty(ByVal aValue As Object)
If aValue IsNot Nothing Then
Return True
'If TypeOf aValue Is String Then
' ' Änderung 28.08.2018: Auch ein leerer String gilt als Wert, damit indexfelder auch geleert werden können
' 'If Not aValue = "" Then
' ' Return True
' 'End If
' Return False
'Else
' Return True
'End If
Else
Return False
End If
End Function
Private Function return_type(ByVal _wert As Object)
Return _wert.GetType
End Function
Public Function GetValuesfromAuswahlliste(ByVal listname As String)
Try
If listname = "" Then
@@ -99,19 +86,7 @@ Public Class ClassPMWindream
Return Nothing
End Try
End Function
Public Function Return_Type(Indexname As String)
Try
' das entsprechende Attribut aus windream auslesen
Dim oAttribute = Me.oSession.GetWMObjectByName(WINDREAMLib.WMEntity.WMEntityAttribute, Indexname)
' den Variablentyp (String, Integer, ...) auslesen
Dim vType = oAttribute.getVariableValue("dwAttrType")
Return vType.ToString
Catch ex As Exception
LOGGER.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler in Return_Type:")
Return ""
End Try
End Function
Public Function RunIndexing(ByVal oDocument As WMObject, ByVal Indizes() As String, ByVal aValues() As Object)
Dim vType
@@ -472,188 +447,8 @@ Public Class ClassPMWindream
End Try
End Function
Public Sub SetfinalIndex(ByVal oDocument As WMObject, ByVal Indexname As String, ByVal _state As Boolean)
Try
If Indexname IsNot Nothing Then
If Not oDocument.aLocked Then
oDocument.LockFor(WMObjectEditModeIndexEdit)
Dim i As Integer = 0
' das entsprechende Attribut aus windream auslesen
Dim oAttribute = Me.oSession.GetWMObjectByName(WINDREAMLib.WMEntity.WMEntityAttribute, Indexname)
' den Variablentyp (String, Integer, ...) auslesen
Dim vType = oAttribute.getVariableValue("dwAttrType")
'MsgBox("Typ: " & vType.ToString, MsgBoxStyle.Critical, "_state: " & _state.ToString)
' wenn in aValues an Position i ein Wert steht
'MsgBox(oDocument.aName & vbNewLine & aValues(i) & vbNewLine & vType, MsgBoxStyle.Exclamation, "Zeile 87")
Dim value = _state
Dim convertValue
'Den Typ des Index-Feldes auslesen
LOGGER.Debug(">> Typ des windream-Indexes: " & vType.ToString)
Select Case (vType)
Case WMObjectVariableValueTypeBoolean
convertValue = CBool(value)
Case Else
LOGGER.Info(">> Typ des windream-Indexes ist nicht BOOLEAN also Abbruch:")
End Select
'############################################################################################
'####################### Der eigentliche Indexierungsvorgang ################################
oDocument.SetVariableValue(Indexname, convertValue)
LOGGER.Debug(">> Index '" & Indexname & "' wurde gesetzt")
oDocument.Save()
oDocument.unlock()
LOGGER.Info(">> DATEI wurde erfolgreich als fertig nachindexiert gekennzeichnet")
Else
LOGGER.Info(">> Dokument ist gesperrt, Indexierung erst im nächsten Durchlauf!")
End If
End If
Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Info("ClassSearchResult.SetfinalIndex - " & ex.Message, True)
'If My.Settings.vNIMailsenden = True Then
' email.Send_EMail("Fehler bei SetfinalIndex - Datei: " & oDocument.aName.ToString & " - Fehler: " & ex.Message)
'End If
oDocument.Save()
oDocument.unlock()
End Try
End Sub
#End Region
#Region "+++++ Allgemeine Funktionen die Informationen zurückliefern +++++"
Public Function Get_No_Documents(Profil As String, WD_Search As String)
Try
Dim wmsearch_exists As Boolean
Try
wmsearch_exists = System.IO.File.Exists(WD_Search)
Catch ex As Exception
LOGGER.Error(ex)
wmsearch_exists = clsWM.CheckFileExists(WD_Search)
End Try
If wmsearch_exists = False Then
LOGGER.Info(">> Windream Suche für Profil: '" & Profil & "' konnte nicht ausgeführt werden! Die Datei '" & WD_Search & "' existiert nicht!", False)
MsgBox("Windream Suche für Profil: '" & Profil & "' konnte nicht ausgeführt werden!" & vbNewLine & "Die Datei '" & WD_Search & "' existiert nicht!", MsgBoxStyle.Exclamation, "Achtung:")
'wenn die gesuchte File eine Suche ist: per MAil informierne und Indexierung abbrechen
'If My.Settings.vNIMailsenden = True Then
' email.Send_EMail("Fehler bei Nachindexierung: <br> >> Profil: " & Me.aktivesProfil.Profilname & "<br> >> die windream-Suche : " & Me.aktivesProfil.WindreamSuche & " konnte nicht gefunden werden!" & _
' "<br> >> Mögliche Fehlerursache: Das W-Laufwerk ist nicht verfügbar!")
'End If
Return 0
Else
' windream-Suche für Profil starten
Dim windreamSucheErgebnisse As WMObjects = Me.GetSearchDocuments(WD_Search)
If windreamSucheErgebnisse.Count > 0 Then
' neue Anzahl von Dateien
Return windreamSucheErgebnisse.Count
Else
' keine Dateien zum Importieren
Return 0
End If
End If
Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Info(ex.Message)
Return 0
End Try
End Function
Public Function GetSearchDocuments(ByVal wdfLocation As String)
If clsWM.CheckFileExists(wdfLocation) = True Then
Try
Dim ProfileName = wdfLocation.Substring(wdfLocation.LastIndexOf("\") + 1)
Dim ProfilePath = wdfLocation.Substring(0, wdfLocation.Length - ProfileName.Length)
Me.oController.CheckSearchProfile(wdfLocation.ToLower)
Dim suchTyp = Me.oController.SearchProfileTargetProgID
Dim ExSettings As Object
Dim oSearch As Object
ExSettings = Me.oController.SearchProfileExSettings
If ExSettings = 0 Then ExSettings = 7
Dim srchQuick As WMOSRCHLib.WMQuickSearch = CreateObject("WMOSrch.WMQuickSearch")
Dim srchIndex As WMOSRCHLib.WMIndexSearch = CreateObject("WMOSrch.WMIndexSearch")
Dim srchObjectType As WMOSRCHLib.WMObjectTypeSearch = CreateObject("WMOSrch.WMObjectTypeSearch")
Select Case suchTyp.ToString.ToUpper
Case "WMOSRCH.WMQUICKSEARCH"
srchQuick.WMSession = CreateObject("Windream.WMSession", Me.GetCurrentServer)
Me.oConnect.LoginSession(srchQuick.WMSession)
srchQuick.ClearSearch()
srchQuick.SearchProfilePath = ProfilePath
srchQuick.LoadSearchProfile(ProfileName)
oSearch = srchQuick.GetSearch()
Case "WMOSRCH.WMINDEXSEARCH"
srchIndex.WMSession = CreateObject("Windream.WMSession", Me.GetCurrentServer)
Me.oConnect.LoginSession(srchIndex.WMSession)
srchIndex.ClearSearch()
srchIndex.SearchProfilePath = ProfilePath
srchIndex.LoadSearchProfile(ProfileName)
oSearch = srchIndex.GetSearch()
Case "WMOSRCH.WMOBJECTTYPESEARCH"
srchObjectType.WMSession = CreateObject("Windream.WMSession", Me.GetCurrentServer)
Me.oConnect.LoginSession(srchObjectType.WMSession)
srchObjectType.ClearSearch()
srchObjectType.SearchProfilePath = ProfilePath
srchObjectType.LoadSearchProfile(ProfileName)
oSearch = srchObjectType.GetSearch()
Case Else
LOGGER.Info("KEIN GÜLTIGER WINDREAM-SUCHTYP")
Return Nothing
End Select
Dim WMObjects As Object
WMObjects = oSearch.Execute
Return oSearch.execute
Catch ex As Exception
LOGGER.Error(ex)
' bei einem Fehler einen Eintrag in der Logdatei machen
LOGGER.Info("Fehler in GetSearchDocuments - " & ex.Message, True)
Return Nothing
End Try
End If
Return Nothing
End Function
''' Liefert den Wert eines Indexes als String
''' _indexname = Name des zu überprüfenden Indexfeldes
Public Function GetValueforIndex(ByVal _fullfilepath As String, _indexname As String)
Try
Const WMEntityDocument = 1
Dim IndexwertAusWindream As Object = Nothing
Dim _dok As WINDREAMLib.WMObject
_dok = Nothing
_dok = oSession.GetWMObjectByPath(WMEntityDocument, _fullfilepath) 'WINDREAMLib.WMEntity.WMEntityDocument
IndexwertAusWindream = _dok.GetVariableValue(_indexname)
Return IndexwertAusWindream.ToString
Catch ex As Exception
LOGGER.Error(ex)
'MsgBox(ex.Message)
Return Nothing
End Try
End Function
#End Region
End Class