189 lines
8.3 KiB
VB.net
189 lines
8.3 KiB
VB.net
Imports WINDREAMLib
|
|
Imports WMOSRCHLib
|
|
Public Class ClassPMWindream
|
|
Inherits ClassWindream_allgemein
|
|
Private email As New ClassEmail
|
|
|
|
#Region "+++++ Konstanten +++++"
|
|
Protected Const WMObjectEditModeObject = &H1F
|
|
Protected Const WMObjectStreamOpenModeReadWrite = 2
|
|
Protected Const WMEntityObjectType = 10
|
|
Protected Const WMEntityDocument = 1
|
|
|
|
Const WMObjectVariableValueTypeUndefined = 0
|
|
Const WMObjectVariableValueTypeString = 1
|
|
Const WMObjectVariableValueTypeInteger = 2
|
|
Const WMObjectVariableValueTypeFloat = 3
|
|
Const WMObjectVariableValueTypeBoolean = 4
|
|
Const WMObjectVariableValueTypeDate = 5
|
|
Const WMObjectVariableValueTypeFixedPoint = 6
|
|
Const WMObjectVariableValueTypeTimeStamp = 7
|
|
Const WMObjectVariableValueTypeCurrency = 8
|
|
Const WMObjectVariableValueTypeTime = 9
|
|
Const WMObjectVariableValueTypeVariant = 10
|
|
Const WMObjectVariableValueTypeMask = &HFFF
|
|
Const WMObjectVariableValueFlagMask = &HFFFFF000
|
|
Const WMObjectVariableValueTypeVector = &H1000
|
|
Const WMObjectVariableValueTypeFulltext = &H2000
|
|
Const WMObjectVariableValueTypeDefaultValue = &H4000
|
|
#End Region
|
|
|
|
#Region "+++++ Variablen +++++"
|
|
Private oController As New WMOSearchController
|
|
#End Region
|
|
|
|
#Region "+++++ Allgemeine Methoden und Funktionen +++++"
|
|
Sub New()
|
|
MyBase.New()
|
|
End Sub
|
|
Private Function IsNotEmpty(ByVal aValue As Object)
|
|
|
|
If aValue IsNot Nothing Then
|
|
Dim itsType As Type = aValue.GetType
|
|
If itsType Is GetType(String) Then
|
|
|
|
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
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "+++++ Allgemeine Funktionen die Informationen zurückliefern +++++"
|
|
|
|
Public Function Get_No_Documents(Profil As String, WD_Search As String)
|
|
Try
|
|
|
|
If System.IO.File.Exists(WD_Search) = False Then
|
|
ClassLogger.Add(">> 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.Email_senden = True Then
|
|
email.Send_Error_Mail("Fehler in Get_No_Documents: <br> >> Profil: '" & Profil & "'<br> >> die windream-Suche : " & WD_Search & " konnte nicht gefunden werden!" & _
|
|
"<br> >> Mögliche Fehlerursache: Das " & My.Settings.WD_LW & "-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
|
|
ClassLogger.Add("Achtung: Fehler in Get_No_Documents: " & ex.Message)
|
|
Return 0
|
|
End Try
|
|
|
|
End Function
|
|
|
|
Public Function GetSearchDocuments(ByVal wdfLocation As String)
|
|
|
|
If System.IO.File.Exists(wdfLocation) Then
|
|
Dim Marker As String
|
|
Try
|
|
Dim ProfileName = wdfLocation.Substring(wdfLocation.LastIndexOf("\") + 1)
|
|
Marker = "ProfileName: " & ProfileName
|
|
Dim ProfilePath = wdfLocation.Substring(0, wdfLocation.Length - ProfileName.Length)
|
|
Marker &= "ProfilePath: " & ProfilePath
|
|
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")
|
|
Marker &= "SuchTyp: " & suchTyp.ToString.ToUpper
|
|
Select Case suchTyp.ToString.ToUpper
|
|
Case "WMOSRCH.WMQUICKSEARCH"
|
|
srchQuick.WMSession = CreateObject("Windream.WMSession", Me.GetCurrentServer)
|
|
Marker &= "Session Created"
|
|
Me.oConnect.LoginSession(srchQuick.WMSession)
|
|
Marker &= "login erfolgreich"
|
|
srchQuick.ClearSearch()
|
|
srchQuick.SearchProfilePath = ProfilePath
|
|
srchQuick.LoadSearchProfile(ProfileName)
|
|
Marker &= "Parameter / Profile geladen"
|
|
oSearch = srchQuick.GetSearch()
|
|
Marker &= "oSearch geladen"
|
|
Case "WMOSRCH.WMINDEXSEARCH"
|
|
srchIndex.WMSession = CreateObject("Windream.WMSession", Me.GetCurrentServer)
|
|
Marker &= "Session Created"
|
|
Me.oConnect.LoginSession(srchIndex.WMSession)
|
|
Marker &= "login erfolgreich"
|
|
srchIndex.ClearSearch()
|
|
srchIndex.SearchProfilePath = ProfilePath
|
|
srchIndex.LoadSearchProfile(ProfileName)
|
|
Marker &= "Parameter / Profile geladen"
|
|
oSearch = srchIndex.GetSearch()
|
|
Marker &= "oSearch geladen"
|
|
Case "WMOSRCH.WMOBJECTTYPESEARCH"
|
|
srchObjectType.WMSession = CreateObject("Windream.WMSession", Me.GetCurrentServer)
|
|
Marker &= "Session Created"
|
|
Me.oConnect.LoginSession(srchObjectType.WMSession)
|
|
Marker &= "login erfolgreich"
|
|
srchObjectType.ClearSearch()
|
|
srchObjectType.SearchProfilePath = ProfilePath
|
|
srchObjectType.LoadSearchProfile(ProfileName)
|
|
Marker &= "Parameter / Profile geladen"
|
|
oSearch = srchObjectType.GetSearch()
|
|
Marker &= "oSearch geladen"
|
|
Case Else
|
|
ClassLogger.Add("KEIN GÜLTIGER WINDREAM-SUCHTYP")
|
|
Return Nothing
|
|
End Select
|
|
Return oSearch.execute
|
|
|
|
Catch ex As Exception
|
|
' bei einem Fehler einen Eintrag in der Logdatei machen
|
|
ClassLogger.Add("Unvorhergesehener Fehler in Klasse PMWindream - GetSearchDocuments - " & ex.Message, True)
|
|
ClassLogger.Add("Bisheriger Marker: " & Marker, False)
|
|
Return Nothing
|
|
End Try
|
|
Else
|
|
ClassLogger.Add("Achtung: windream-Suche '" & wdfLocation & "' existiert nicht!", False)
|
|
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
|
|
'MsgBox(ex.Message)
|
|
Return Nothing
|
|
End Try
|
|
End Function
|
|
#End Region
|
|
End Class
|