MS TestGui und Logger Daily
This commit is contained in:
@@ -10,15 +10,14 @@ Public Class Windream
|
||||
Inherits Constants
|
||||
#Region "+++++ Variables +++++"
|
||||
Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
|
||||
|
||||
Public Shared CurrentSession As WMObject = Nothing
|
||||
Public Shared CurrentSessionIsLoggedIn As Boolean = False
|
||||
Private Shared CurrentObjecttypes As WINDREAMLib.WMObjects
|
||||
Private Shared CurrentController As WMOSearchController
|
||||
Public CurrentSession = Nothing
|
||||
Public CurrentSessionIsLoggedIn As Boolean = False
|
||||
Private CurrentObjecttypes As WINDREAMLib.WMObjects
|
||||
Private CurrentController As WMOSearchController
|
||||
Private Shared CurrentWMConnect ' der Typ darf nicht festgelegt werden (warum auch immer... geht sonst nicht)
|
||||
Public Shared CurrentWMServer As String
|
||||
Private Shared WMDriveLetter As String = "W"
|
||||
Private Shared _Session_Reconnect As Boolean = False
|
||||
Public CurrentWMServer As String
|
||||
Private WMDriveLetter As String = "W"
|
||||
Private _Session_Reconnect As Boolean = False
|
||||
#End Region
|
||||
#Region "+++++ Init +++++"
|
||||
''' <summary>
|
||||
@@ -38,7 +37,7 @@ Public Class Windream
|
||||
''' </summary>
|
||||
''' <returns>Returns true when created, false if not</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function NewSession()
|
||||
Public Function NewSession()
|
||||
Try
|
||||
Dim wmbrwsr
|
||||
wmbrwsr = CreateObject("WMOBrws.ServerBrowser")
|
||||
@@ -50,6 +49,7 @@ Public Class Windream
|
||||
Dim Connect
|
||||
Try
|
||||
Connect = CreateObject("Windream.WMConnect")
|
||||
Logger.Info("...connected to windream!")
|
||||
Catch ex As Exception
|
||||
CurrentSession = Nothing
|
||||
CurrentSessionIsLoggedIn = False
|
||||
@@ -74,8 +74,11 @@ Public Class Windream
|
||||
Try
|
||||
Connect.LoginSession(CurrentSession)
|
||||
If CurrentSession.aLoggedin Then
|
||||
CurrentWMConnect = Connect
|
||||
CurrentSessionIsLoggedIn = True
|
||||
Logger.Info("UserSession has been created!")
|
||||
Try
|
||||
'Standardmässig hinterlegen dass abgelegte Dateien keine Indexmaske öffnet
|
||||
CurrentSession.SwitchEvents(WMCOMEventWMSessionNeedIndex, False)
|
||||
' der Parameter WMEntityDocument definiert, dass nur Dokumenttypen und keine
|
||||
' Ordnertypen ausgelesen werden
|
||||
@@ -116,7 +119,7 @@ Public Class Windream
|
||||
End Function
|
||||
#End Region
|
||||
#Region "+++++ New +++++"
|
||||
Public Shared Function NewFile()
|
||||
Public Function NewFile()
|
||||
|
||||
End Function
|
||||
''' <summary>
|
||||
@@ -125,7 +128,7 @@ Public Class Windream
|
||||
''' <param name="folderpath">full path of new folder</param>
|
||||
''' <returns>Returns true when folder was created, false if not</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function NewFolder(ByVal folderpath As String)
|
||||
Public Function NewFolder(ByVal folderpath As String)
|
||||
Try
|
||||
If folderpath.StartsWith("\") = False And folderpath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
|
||||
folderpath = folderpath.Substring(2)
|
||||
@@ -159,19 +162,14 @@ Public Class Windream
|
||||
''' <param name="aValues">values as array</param>
|
||||
''' <returns>Returns true when folder was created, false if not</returns>
|
||||
''' <remarks></remarks>
|
||||
Private Shared Function NewIndexFile(WMFile As String, ByVal indexname As String, ByVal aValues() As String)
|
||||
|
||||
If Not WMFile.StartsWith("\") And WMFile.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
|
||||
WMFile = WMFile.Substring(2)
|
||||
End If
|
||||
Dim oWMFile As WINDREAMLib.WMObject
|
||||
Try
|
||||
oWMFile = CurrentSession.GetWMObjectByPath(WINDREAMLib.WMEntity.WMEntityDocument, WMFile) 'WINDREAMLib.WMEntity.WMEntityDocument
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
'clsLogger.Add(">> Could not create oWMFile-Indexing file '" & WD_File & ": " & ex.Message, True)
|
||||
Public Function NewIndexFile(WMFile As String, ByVal indexname As String, ByVal aValues() As String) As Boolean
|
||||
If TestSession() = False Then
|
||||
Return False
|
||||
End Try
|
||||
End If
|
||||
Dim oWMFile As WMObject = GetWMObjectForFile(WMFile)
|
||||
If IsNothing(oWMFile) Then
|
||||
Return False
|
||||
End If
|
||||
Dim vektInsState As Integer = 1
|
||||
Try
|
||||
If Not oWMFile.aLocked Then
|
||||
@@ -287,7 +285,7 @@ Public Class Windream
|
||||
Try
|
||||
If oWMValueConverted.ToString Is Nothing = False Then
|
||||
Logger.Info("Now: oWMFile.SetVariableValue(" & indexname & ", " & oWMValueConverted & ")")
|
||||
oWMFile.SetVariableValue(indexname, CInt(oWMValueConverted))
|
||||
oWMFile.SetVariableValue(indexname, oWMValueConverted)
|
||||
'Die Datei speichern
|
||||
oWMFile.Save()
|
||||
Logger.Info("Index has been written!")
|
||||
@@ -339,7 +337,7 @@ Public Class Windream
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Private Shared Function NewLockWMFile(oWMFile As WMObject) As Boolean
|
||||
Private Function NewLockWMFile(oWMFile As WMObject) As Boolean
|
||||
Try
|
||||
oWMFile.lock()
|
||||
Return True
|
||||
@@ -355,7 +353,7 @@ Public Class Windream
|
||||
''' <param name="folderObjecttype">Obcjectype Name</param>
|
||||
''' <returns>Returns true when Otype was set, false if not</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function NewObjecttypeForFolder(folderpath As String, folderObjecttype As String)
|
||||
Public Function NewObjecttypeForFolder(folderpath As String, folderObjecttype As String)
|
||||
Try
|
||||
Dim result As Boolean = False
|
||||
Dim WMFolder As WINDREAMLib.WMObject
|
||||
@@ -415,7 +413,7 @@ Public Class Windream
|
||||
''' <param name="Comment">Comment</param>
|
||||
''' <returns>Returns true when version was created, false if not</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function NewVersion(ByVal WMPath As String, ByVal Comment As String)
|
||||
Public Function NewVersion(ByVal WMPath As String, ByVal Comment As String)
|
||||
Try
|
||||
If WMPath.StartsWith("\") = False And WMPath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
|
||||
WMPath = WMPath.Substring(2)
|
||||
@@ -442,28 +440,29 @@ Public Class Windream
|
||||
''' </summary>
|
||||
''' <returns>choicelists as String-Array</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function GetChoiceLists() As List(Of String)
|
||||
Public Function GetChoiceLists() As DataTable
|
||||
Dim dtresult As New DataTable
|
||||
dtresult.Columns.Add("RESULT", GetType(String))
|
||||
Try
|
||||
Dim oChoiceLists As WMObjects
|
||||
Dim oChoiceList As IWMObject2
|
||||
' den Objekttyp laden
|
||||
oChoiceLists = CurrentSession.GetAllObjects(WMEntityChoiceList)
|
||||
'Array für Indizes vorbereiten
|
||||
Dim choiceLists As New List(Of String)
|
||||
|
||||
|
||||
For j As Integer = 0 To oChoiceLists.Count() - 1
|
||||
|
||||
' aktuellee Liste ausleseb auslesen
|
||||
oChoiceList = oChoiceLists.Item(j)
|
||||
|
||||
choiceLists.Add(oChoiceList.aName)
|
||||
dtresult.Rows.Add(oChoiceList.aName)
|
||||
Next
|
||||
|
||||
Return choiceLists
|
||||
dtresult.AcceptChanges()
|
||||
Return dtresult
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
Return dtresult
|
||||
End Try
|
||||
End Function
|
||||
''' <summary>
|
||||
@@ -472,7 +471,7 @@ Public Class Windream
|
||||
''' <param name="ObjecttypeName">Name of objecttype</param>
|
||||
''' <returns>Name of containing indices as String-Array</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function GetIndicesByObjecttype(ByVal ObjecttypeName As String) As String()
|
||||
Public Function GetIndicesByObjecttype(ByVal ObjecttypeName As String) As String()
|
||||
Try
|
||||
Dim oObjectType As WMObject
|
||||
Dim oIndexAttributes As WMObjectRelation
|
||||
@@ -519,7 +518,9 @@ Public Class Windream
|
||||
''' <param name="NameChoicelist">name of choicelist</param>
|
||||
''' <returns>items as String-Array</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function GetChoicelistItems(ByVal NameChoicelist As String) As Object
|
||||
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")
|
||||
@@ -539,14 +540,16 @@ Public Class Windream
|
||||
Dim zahl As Integer = 0
|
||||
For Each CLItem In Values
|
||||
If oChoiceList.aName IsNot Nothing Then
|
||||
dtresult.Rows.Add(CLItem)
|
||||
strListe(zahl) = CLItem
|
||||
zahl += 1
|
||||
End If
|
||||
dtresult.AcceptChanges()
|
||||
Next
|
||||
Return strListe
|
||||
Return dtresult
|
||||
Else
|
||||
Logger.Warn("WMchoicelist: " & NameChoicelist & " not found!")
|
||||
Return Nothing
|
||||
Return dtresult
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
@@ -559,16 +562,18 @@ Public Class Windream
|
||||
''' </summary>
|
||||
''' <returns>array(String) of all objecttypes</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function GetObjecttypesAsStrings() As String()
|
||||
Public Function GetObjecttypesAsStrings() As DataTable
|
||||
Dim dtresult As New DataTable
|
||||
dtresult.Columns.Add("RESULT", GetType(String))
|
||||
Try
|
||||
Dim objektTypenStr(CurrentObjecttypes.Count) As String
|
||||
For i As Integer = 0 To CurrentObjecttypes.Count
|
||||
objektTypenStr(i) = CurrentObjecttypes.Item(i).aName
|
||||
dtresult.Rows.Add(CurrentObjecttypes.Item(i).aName)
|
||||
Next
|
||||
Return objektTypenStr
|
||||
dtresult.AcceptChanges()
|
||||
Return dtresult
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
Return dtresult
|
||||
End Try
|
||||
End Function
|
||||
''' <summary>
|
||||
@@ -578,7 +583,7 @@ Public Class Windream
|
||||
''' <param name="NameIndexDocID">Name of the Docid Index </param>
|
||||
''' <returns>Returns datatable</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function GetSearchDocuments(ByVal wdfLocation As String, NameIndexDocID As String)
|
||||
Public Function GetSearchDocuments(ByVal wdfLocation As String, NameIndexDocID As String)
|
||||
Dim dt As New DataTable
|
||||
dt.Columns.Add("DOC_ID", GetType(Integer))
|
||||
dt.Columns.Add("PATH", GetType(String))
|
||||
@@ -661,7 +666,7 @@ Public Class Windream
|
||||
''' <param name="indexname">Name of indexfield</param>
|
||||
''' <returns>Returns integer, which describes the type</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function GetTypeOfIndexAsInt(ByVal indexname As String) As Integer
|
||||
Public Function GetTypeOfIndexAsInt(ByVal indexname As String) As Integer
|
||||
Try
|
||||
Dim oAttribute = CurrentSession.GetWMObjectByName(WINDREAMLib.WMEntity.WMEntityAttribute, indexname)
|
||||
Dim vType = oAttribute.getVariableValue("dwAttrType")
|
||||
@@ -677,10 +682,14 @@ Public Class Windream
|
||||
''' <param name="NameIndex">Name of the index </param>
|
||||
''' <returns>Datatable</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function GetValueforIndex(ByVal WMFile As String, ByVal NameIndex As String) As DataTable
|
||||
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
|
||||
Return dt
|
||||
End If
|
||||
Try
|
||||
|
||||
If Not WMFile.StartsWith("\") And WMFile.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
|
||||
WMFile = WMFile.Substring(2)
|
||||
End If
|
||||
@@ -714,11 +723,11 @@ Public Class Windream
|
||||
''' <summary>
|
||||
''' Returns the values for a vektorfield plus the new ones
|
||||
''' </summary>
|
||||
''' <param name="WMFile">filepath of windream-file</param>
|
||||
''' <param name="NameIndex">Name of the index </param>
|
||||
''' <param name="oDocument">windream-file as Object</param>
|
||||
''' <param name="vktIndexName">Name of the index </param>
|
||||
''' <returns>Returns value as Datatable</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function Return_VektorArray(ByVal oDocument As WMObject, vktIndexName As String, arrIndexwerte As Object, vType As Object)
|
||||
Public Function Return_VektorArray(ByVal oDocument As WMObject, vktIndexName As String, arrIndexwerte As Object, vType As Object)
|
||||
Try
|
||||
Dim missing As Boolean = False
|
||||
Dim valueCount As Integer = 0
|
||||
@@ -791,7 +800,7 @@ Public Class Windream
|
||||
''' <param name="WMPath">full path to the file</param>
|
||||
''' <returns>Returns WMObject</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function GetWMObjectForFile(ByVal WMPath As String) As WMObject
|
||||
Public Function GetWMObjectForFile(ByVal WMPath As String) As WMObject
|
||||
Try
|
||||
If WMPath.StartsWith("\") = False And WMPath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
|
||||
WMPath = WMPath.Substring(2)
|
||||
@@ -817,7 +826,7 @@ Public Class Windream
|
||||
''' <param name="folderpath">The path of the folder</param>
|
||||
''' <returns>True if exists or false if not or error occured</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function TestFolderExists(folderpath As String)
|
||||
Public Function TestFolderExists(folderpath As String)
|
||||
Try
|
||||
If folderpath.StartsWith("\") = False And folderpath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
|
||||
folderpath = folderpath.Substring(2)
|
||||
@@ -839,7 +848,7 @@ Public Class Windream
|
||||
''' <param name="WMPath">full path to the file</param>
|
||||
''' <returns>Returns true when file was deleted, false if not</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function TestFileExists(ByVal WMPath As String)
|
||||
Public Function TestFileExists(ByVal WMPath As String)
|
||||
Try
|
||||
If WMPath.StartsWith("\") = False And WMPath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
|
||||
WMPath = WMPath.Substring(2)
|
||||
@@ -856,6 +865,18 @@ Public Class Windream
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Private Function TestSession() As Boolean
|
||||
Try
|
||||
If CurrentSession.aLoggedin Then
|
||||
Return True
|
||||
Else
|
||||
Logger.Warn("There is no active WM-SSession!")
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
#Region "+++++ Remove +++++"
|
||||
''' <summary>
|
||||
@@ -864,7 +885,7 @@ Public Class Windream
|
||||
''' <param name="WMPath">full path to the file</param>
|
||||
''' <returns>Returns true when file was deleted, false if not</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function RemFile(ByVal WMPath As String)
|
||||
Public Function RemFile(ByVal WMPath As String)
|
||||
Try
|
||||
If WMPath.StartsWith("\") = False And WMPath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
|
||||
WMPath = WMPath.Substring(2)
|
||||
@@ -890,7 +911,7 @@ Public Class Windream
|
||||
''' <param name="deleteValue">Value which is to be deleted</param>
|
||||
''' <returns>Returns true when indexing was successfull, false if not</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Shared Function REMOVE_VEKTOR_LINK(ByVal WMPath As String, vktIndexName As String, deleteValue As String)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user