jj: Fix reading the server from DCOM settings
This commit is contained in:
parent
8562450ca8
commit
d7f490d298
@ -12,14 +12,12 @@ Public Class Windream
|
||||
#Region "+++++ Variables +++++"
|
||||
Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
|
||||
|
||||
Private CurrentController As WMOSearchController
|
||||
Private WMDriveLetter As String = "W"
|
||||
|
||||
Private ServerBrowser As IServerBrowser
|
||||
Private CurrentSession As IWMSession6
|
||||
Private CurrentConnect As IWMConnect2
|
||||
|
||||
Private CurrentWMServer As String
|
||||
Private CurrentController As WMOSearchController
|
||||
Private CurrentSession As WMSession
|
||||
Private CurrentConnect As WMConnect
|
||||
Private CurrentServer As String
|
||||
Private CurrentObjecttypes As WMObjects
|
||||
|
||||
Private ReconnectSession As Boolean
|
||||
@ -48,6 +46,7 @@ Public Class Windream
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
Private Function GetObjectTypes() As WMObjects
|
||||
Dim objectTypes As WMObjects
|
||||
|
||||
@ -60,6 +59,25 @@ Public Class Windream
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Returns all Objecttypes of current server as list of strings
|
||||
''' </summary>
|
||||
''' <returns>List of String of all objecttypes</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function GetObjecttypeNames() As List(Of String)
|
||||
Dim objectTypes As New List(Of String)
|
||||
|
||||
Try
|
||||
For i As Integer = 0 To CurrentObjecttypes.Count
|
||||
objectTypes.Add(CurrentObjecttypes.Item(i).aName)
|
||||
Next
|
||||
Return objectTypes
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function NormalizePath(path As String)
|
||||
Dim normalizedPath = path
|
||||
|
||||
@ -78,6 +96,7 @@ Public Class Windream
|
||||
Public Function NewSession() As Boolean
|
||||
Try
|
||||
ServerBrowser = New ServerBrowser()
|
||||
CurrentServer = ServerBrowser.GetCurrentServer
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, "Could not create ServerBrowser")
|
||||
Return False
|
||||
@ -85,16 +104,15 @@ Public Class Windream
|
||||
|
||||
Try
|
||||
' Create Connect Object for Session
|
||||
CurrentConnect = New WMConnect With {
|
||||
.ModuleId = 9
|
||||
}
|
||||
CurrentConnect = New WMConnect
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, "Could not create WMConnect")
|
||||
Return False
|
||||
End Try
|
||||
|
||||
Try
|
||||
CurrentSession = New WMSession()
|
||||
' Create session object with severname set
|
||||
CurrentSession = CreateObject("Windream.WMSession", ServerBrowser.GetCurrentServer)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, "Could not create WMConnect")
|
||||
Return False
|
||||
@ -116,7 +134,7 @@ Public Class Windream
|
||||
Return False
|
||||
End Try
|
||||
|
||||
If Not CurrentSession.aLoggedin Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Logger.Warn("Session created but user {0} could not be logged in", Environment.UserName)
|
||||
Return False
|
||||
End If
|
||||
@ -133,7 +151,7 @@ Public Class Windream
|
||||
''' <remarks></remarks>
|
||||
Public Function NewFolder(ByVal folderpath As String)
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return False
|
||||
End If
|
||||
folderpath = NormalizePath(folderpath)
|
||||
@ -167,7 +185,7 @@ Public Class Windream
|
||||
''' <returns>Returns true when folder was created, false if not</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function NewIndexFile(WMFile As String, ByVal indexname As String, ByVal aValues() As String) As Boolean
|
||||
If TestSession() = False Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return False
|
||||
End If
|
||||
Dim oWMFile As WMObject = GetWMObjectForFile(WMFile)
|
||||
@ -196,7 +214,7 @@ Public Class Windream
|
||||
' das entsprechende Attribut aus windream auslesen
|
||||
Dim oAttribute = CurrentSession.GetWMObjectByName(WINDREAMLib.WMEntity.WMEntityAttribute, indexname)
|
||||
' den Variablentyp (String, Integer, ...) auslesen
|
||||
oWMType = oAttribute.getVariableValue("dwAttrType")
|
||||
oWMType = oAttribute.GetVariableValue("dwAttrType")
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
@ -359,7 +377,7 @@ Public Class Windream
|
||||
''' <remarks></remarks>
|
||||
Public Function NewObjecttypeForFolder(folderpath As String, folderObjecttype As String) As Boolean
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return False
|
||||
End If
|
||||
Dim result As Boolean = False
|
||||
@ -419,14 +437,14 @@ Public Class Windream
|
||||
''' <remarks></remarks>
|
||||
Public Function NewVersion(ByVal WMPath As String, ByVal Comment As String)
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return False
|
||||
End If
|
||||
WMPath = NormalizePath(WMPath)
|
||||
|
||||
Dim WMObject As WINDREAMLib.WMObject '= CreateObject("WINDREAMLib.WMObject") 'New WINDREAMLib.WMObject
|
||||
Dim WMObject As WMObject '= CreateObject("WINDREAMLib.WMObject") 'New WINDREAMLib.WMObject
|
||||
Try
|
||||
WMObject = CurrentSession.GetWMObjectByPath(WINDREAMLib.WMEntity.WMEntityDocument, WMPath) 'WINDREAMLib.WMEntity.WMEntityDocument
|
||||
WMObject = CurrentSession.GetWMObjectByPath(WMEntityDocument, WMPath) 'WINDREAMLib.WMEntity.WMEntityDocument
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Could not create WMObject in Create_Version for file '" & WMPath & "': " & ex.Message)
|
||||
Return False
|
||||
@ -443,47 +461,43 @@ Public Class Windream
|
||||
''' <summary>
|
||||
''' Returns all choicelists
|
||||
''' </summary>
|
||||
''' <returns>choicelists as String-Array</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function GetChoiceLists() As DataTable
|
||||
Dim dtresult As New DataTable
|
||||
dtresult.Columns.Add("RESULT", GetType(String))
|
||||
If CurrentSession.aLoggedin Then
|
||||
Return dtresult
|
||||
''' <returns>Choicelists as List of Strings or empty list if no choice lists are found</returns>
|
||||
Public Function GetChoiceLists() As List(Of String)
|
||||
Dim items As New List(Of String)
|
||||
|
||||
If TestLoggedInSession() = False Then
|
||||
Return items
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oChoiceLists As WMObjects
|
||||
Dim oChoiceList As IWMObject2
|
||||
' den Objekttyp laden
|
||||
oChoiceLists = CurrentSession.GetAllObjects(WMEntityChoiceList)
|
||||
'Array für Indizes vorbereiten
|
||||
Dim choiceLists As WMObjects
|
||||
Dim choiceList As IWMObject2
|
||||
'load list of choicelists
|
||||
choiceLists = CurrentSession.GetAllObjects(WMEntityChoiceList)
|
||||
|
||||
|
||||
For j As Integer = 0 To oChoiceLists.Count() - 1
|
||||
|
||||
' aktuellee Liste ausleseb auslesen
|
||||
oChoiceList = oChoiceLists.Item(j)
|
||||
dtresult.Rows.Add(oChoiceList.aName)
|
||||
For Each choiceList In choiceLists
|
||||
items.Add(choiceList.aName)
|
||||
Next
|
||||
dtresult.AcceptChanges()
|
||||
Return dtresult
|
||||
|
||||
Return items
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return dtresult
|
||||
Return items
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Returns all indices for an objecttype
|
||||
''' </summary>
|
||||
''' <param name="ObjecttypeName">Name of objecttype</param>
|
||||
''' <returns>Name of containing indices as String-Array</returns>
|
||||
''' <returns>Names of indices as list of String</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function GetIndicesByObjecttype(ByVal ObjecttypeName As String) As String()
|
||||
Public Function GetIndicesByObjecttype(ByVal ObjecttypeName As String) As List(Of String)
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oObjectType As WMObject
|
||||
Dim oIndexAttributes As WMObjectRelation
|
||||
Dim oIndexAttribute As WMObject
|
||||
@ -497,7 +511,8 @@ Public Class Windream
|
||||
oIndexAttributes = oObjectType.GetWMObjectRelationByName("TypeAttributes")
|
||||
|
||||
' Array für Indizes vorbereiten
|
||||
Dim aIndexNames(oIndexAttributes.Count - 1) As String
|
||||
'Dim aIndexNames(oIndexAttributes.Count - 1) As String
|
||||
Dim indexNames As New List(Of String)
|
||||
|
||||
' alle Indizes durchlaufen
|
||||
For j As Integer = 0 To oIndexAttributes.Count - 1
|
||||
@ -512,81 +527,64 @@ Public Class Windream
|
||||
oIndex = oRelProperties.Item(0)
|
||||
|
||||
' Indexname speichern
|
||||
aIndexNames(j) = oIndex.aName
|
||||
'aIndexNames(j) = oIndex.aName
|
||||
indexNames.Add(oIndex.aName)
|
||||
Next
|
||||
|
||||
' Indexarray zurückgeben
|
||||
Return aIndexNames
|
||||
'Return aIndexNames
|
||||
Return indexNames
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
'''' <summary>
|
||||
'''' Returns all items of a choicelist
|
||||
'''' </summary>
|
||||
'''' <param name="NameChoicelist">name of choicelist</param>
|
||||
'''' <returns>items as String-Array</returns>
|
||||
'''' <remarks></remarks>
|
||||
'Public Function GetChoicelistItems(ByVal NameChoicelist As String) As DataTable
|
||||
' Dim dtresult As New DataTable
|
||||
' dtresult.Columns.Add("RESULT", GetType(String))
|
||||
' Try
|
||||
' 'Dim oAttribute = Me.oSession.GetWMObjectByName(WINDREAMLib.WMEntity.WMEntityAttribute, indexname)
|
||||
' 'Dim vType = oAttribute.getVariableValue("vItems")
|
||||
' 'Return vType
|
||||
' Dim oChoiceList = CurrentSession.GetWMObjectByName(WMEntityChoiceList, NameChoicelist)
|
||||
' If Err.Number = 0 And TypeName(oChoiceList) <> "Nothing" Then
|
||||
' Dim oValues = oChoiceList
|
||||
' oValues = oChoiceList.GetVariableValue("vItems")
|
||||
' Dim anz As Integer = 0
|
||||
|
||||
' For Each CLItem In oValues
|
||||
' If oChoiceList.aName IsNot Nothing Then
|
||||
' anz += 1
|
||||
' End If
|
||||
' Next
|
||||
' Dim strListe(anz - 1)
|
||||
' Dim zahl As Integer = 0
|
||||
' For Each CLItem In oValues
|
||||
' If oChoiceList.aName IsNot Nothing Then
|
||||
' dtresult.Rows.Add(CLItem)
|
||||
' strListe(zahl) = CLItem
|
||||
' zahl += 1
|
||||
' End If
|
||||
' dtresult.AcceptChanges()
|
||||
' Next
|
||||
' Return dtresult
|
||||
' Else
|
||||
' Logger.Warn("WMchoicelist: " & NameChoicelist & " not found!")
|
||||
' Return dtresult
|
||||
' End If
|
||||
|
||||
' Catch ex As Exception
|
||||
' Logger.Error(ex)
|
||||
' Return Nothing
|
||||
' End Try
|
||||
'End Function
|
||||
''' <summary>
|
||||
''' Returns all Objecttypes of current server as array of strings
|
||||
''' Returns all items of a choicelist
|
||||
''' </summary>
|
||||
''' <returns>array(String) of all objecttypes</returns>
|
||||
''' <param name="NameChoicelist">name of choicelist</param>
|
||||
''' <returns>Items as list of String</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function GetObjecttypesAsStrings() As DataTable
|
||||
Dim dtresult As New DataTable
|
||||
dtresult.Columns.Add("RESULT", GetType(String))
|
||||
Public Function GetChoicelistItems(ByVal NameChoicelist As String) As List(Of String)
|
||||
Dim items As New List(Of String)
|
||||
|
||||
If TestLoggedInSession() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim choiceList As WMObject
|
||||
|
||||
' Try to get the choicelist first and abort if an error occurs
|
||||
Try
|
||||
For i As Integer = 0 To CurrentObjecttypes.Count
|
||||
dtresult.Rows.Add(CurrentObjecttypes.Item(i).aName)
|
||||
Next
|
||||
dtresult.AcceptChanges()
|
||||
Return dtresult
|
||||
Dim session As IWMSession2 = DirectCast(CurrentSession, IWMSession2)
|
||||
choiceList = session.GetWMObjectByName(WMEntityChoiceList, NameChoicelist)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return dtresult
|
||||
Return Nothing
|
||||
End Try
|
||||
|
||||
' Try to get choicelist items
|
||||
Try
|
||||
Dim values As Object = choiceList.GetVariableValue("vItems")
|
||||
|
||||
' If values is nothing, the list is empty
|
||||
If values Is Nothing Then
|
||||
Return items
|
||||
End If
|
||||
|
||||
For Each value In values
|
||||
items.Add(value)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
|
||||
Return items
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Returns the result of windream-search
|
||||
''' </summary>
|
||||
@ -598,7 +596,7 @@ Public Class Windream
|
||||
Dim dtresult As New DataTable
|
||||
dtresult.Columns.Add("DOC_ID", GetType(Integer))
|
||||
dtresult.Columns.Add("PATH", GetType(String))
|
||||
If Not CurrentSession.aLoggedin Then
|
||||
If Not TestLoggedInSession() = False Then
|
||||
Return dtresult
|
||||
End If
|
||||
If TestWMFileExists(wdfLocation) = False Then
|
||||
@ -623,7 +621,7 @@ Public Class Windream
|
||||
'' Der öffentliche Member CheckSearchProfile für den Typ IWMQuickSearch7 wurde nicht gefunden. [Microsoft.VisualBasic] => GetSearchDocuments()
|
||||
Select Case suchTyp.ToString.ToUpper
|
||||
Case "WMOSRCH.WMQUICKSEARCH"
|
||||
srchQuick.WMSession = CreateObject("Windream.WMSession", CurrentWMServer)
|
||||
srchQuick.WMSession = CreateObject("Windream.WMSession", CurrentServer)
|
||||
|
||||
CurrentConnect.LoginSession(srchQuick.WMSession)
|
||||
|
||||
@ -634,7 +632,7 @@ Public Class Windream
|
||||
oSearch = srchQuick.GetSearch()
|
||||
|
||||
Case "WMOSRCH.WMINDEXSEARCH"
|
||||
srchIndex.WMSession = CreateObject("Windream.WMSession", CurrentWMServer)
|
||||
srchIndex.WMSession = CreateObject("Windream.WMSession", CurrentServer)
|
||||
|
||||
CurrentConnect.LoginSession(srchIndex.WMSession)
|
||||
|
||||
@ -645,7 +643,7 @@ Public Class Windream
|
||||
oSearch = srchIndex.GetSearch()
|
||||
|
||||
Case "WMOSRCH.WMOBJECTTYPESEARCH"
|
||||
srchObjectType.WMSession = CreateObject("Windream.WMSession", CurrentWMServer)
|
||||
srchObjectType.WMSession = CreateObject("Windream.WMSession", CurrentServer)
|
||||
|
||||
CurrentConnect.LoginSession(srchObjectType.WMSession)
|
||||
|
||||
@ -687,7 +685,7 @@ Public Class Windream
|
||||
''' <remarks></remarks>
|
||||
Public Function GetTypeOfIndexAsInt(ByVal indexname As String) As Integer
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return False
|
||||
End If
|
||||
Dim oAttribute = CurrentSession.GetWMObjectByName(WINDREAMLib.WMEntity.WMEntityAttribute, indexname)
|
||||
@ -707,12 +705,12 @@ Public Class Windream
|
||||
Public Function GetValueforIndex(ByVal WMFile As String, ByVal NameIndex As String) As DataTable
|
||||
Dim dt As New DataTable
|
||||
dt.Columns.Add("RESULT", GetType(String))
|
||||
If TestSession() = False Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return dt
|
||||
End If
|
||||
Try
|
||||
|
||||
If Not WMFile.StartsWith("\") And WMFile.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
|
||||
If Not WMFile.StartsWith("\") And WMFile.ToUpper.StartsWith(DriveLetter.ToUpper) Then
|
||||
WMFile = WMFile.Substring(2)
|
||||
End If
|
||||
Dim WMObject As WINDREAMLib.WMObject '= CreateObject("WINDREAMLib.WMObject") 'New WINDREAMLib.WMObject
|
||||
@ -751,7 +749,7 @@ Public Class Windream
|
||||
''' <remarks></remarks>
|
||||
Public Function Return_VektorArray(ByVal oDocument As WMObject, vktIndexName As String, arrIndexwerte As Object, vType As Object)
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return False
|
||||
End If
|
||||
Dim missing As Boolean = False
|
||||
@ -827,7 +825,7 @@ Public Class Windream
|
||||
''' <remarks></remarks>
|
||||
Public Function GetWMObjectForFile(ByVal WMPath As String) As WMObject
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
WMPath = NormalizePath(WMPath)
|
||||
@ -854,7 +852,7 @@ Public Class Windream
|
||||
''' <remarks></remarks>
|
||||
Public Function TestFolderExists(folderpath As String)
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return False
|
||||
End If
|
||||
folderpath = NormalizePath(folderpath)
|
||||
@ -877,7 +875,7 @@ Public Class Windream
|
||||
''' <remarks></remarks>
|
||||
Public Function TestWMFileExists(ByVal WMPath As String)
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return False
|
||||
End If
|
||||
WMPath = NormalizePath(WMPath)
|
||||
@ -891,7 +889,9 @@ Public Class Windream
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Private Function TestSession() As Boolean
|
||||
|
||||
|
||||
Private Function TestLoggedInSession() As Boolean
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
Return True
|
||||
@ -911,10 +911,10 @@ Public Class Windream
|
||||
''' <remarks></remarks>
|
||||
Public Function TestWMUSerExists(username As String) As Boolean
|
||||
Try
|
||||
If TestSession() = False Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return False
|
||||
End If
|
||||
Return CurrentSession.WMObjectExists(WINDREAMLib.WMEntity.WMEntityUser, username, 0, 0)
|
||||
Return CurrentSession.WMObjectExists(WMEntityUser, username, 0, 0)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
@ -928,10 +928,10 @@ Public Class Windream
|
||||
''' <remarks></remarks>
|
||||
Public Function TestWMGroupExists(groupname As String)
|
||||
Try
|
||||
If TestSession() = False Then
|
||||
If TestLoggedInSession() = False Then
|
||||
Return False
|
||||
End If
|
||||
Return CurrentSession.WMObjectExists(WINDREAMLib.WMEntity.WMEntityGroups, groupname, 0, 0)
|
||||
Return CurrentSession.WMObjectExists(WMEntityGroups, groupname, 0, 0)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
@ -972,7 +972,7 @@ Public Class Windream
|
||||
Public Function REMOVE_VEKTOR_LINK(ByVal WMPath As String, vktIndexName As String, deleteValue As String)
|
||||
Try
|
||||
Logger.Info("Removing Value '" & deleteValue & "' of Index '" & vktIndexName & "' " & WMPath)
|
||||
Dim oWMFile As WINDREAMLib.WMObject = GetWMObjectForFile(WMPath)
|
||||
Dim oWMFile As WMObject = GetWMObjectForFile(WMPath)
|
||||
If IsNothing(oWMFile) Then
|
||||
Logger.Warn("Exit from REMOVE_VEKTOR_LINK...")
|
||||
Return False
|
||||
@ -985,7 +985,7 @@ Public Class Windream
|
||||
'Nochmals prüfen ob wirklich Array
|
||||
If WMValue.GetType.ToString.Contains("System.Object") Then
|
||||
' das entsprechende Attribut aus windream auslesen
|
||||
Dim oAttribute = CurrentSession.GetWMObjectByName(WINDREAMLib.WMEntity.WMEntityAttribute, vktIndexName)
|
||||
Dim oAttribute = CurrentSession.GetWMObjectByName(WMEntityAttribute, vktIndexName)
|
||||
' den Variablentyp (String, Integer, ...) auslesen
|
||||
Dim vType = oAttribute.getVariableValue("dwAttrType")
|
||||
Dim Anzahl As Integer = 0
|
||||
@ -1043,6 +1043,4 @@ Public Class Windream
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user