work on windream
This commit is contained in:
parent
81a06966b5
commit
46b11aaf47
@ -40,11 +40,18 @@
|
||||
Public Const HISTORY_NEW_FROM_VERSION = "HISTORY_New_From_Version"
|
||||
Public Const HISTORY_USER_DEFINED = "HISTORY_User_Defined"
|
||||
|
||||
' Entity Types
|
||||
Public Const ENTITY_TYPE_OBJECTTYPE = 10
|
||||
|
||||
'Search Types
|
||||
Public Const SEARCH_TYPE_QUICK_SEARCH = "WMOSRCH.WMQUICKSEARCH"
|
||||
Public Const SEARCH_TYPE_INDEX_SEARCH = "WMOSRCH.WMINDEXSEARCH"
|
||||
Public Const SEARCH_TYPE_OBJECTTYPE_SEARCH = "WMOSRCH.WMOBJECTTYPESEARCH"
|
||||
|
||||
' Attribute Types
|
||||
Public Const ATTRIBUTE_TYPE_SYSTEMINDEX = 1
|
||||
Public Const ATTRIBUTE_TYPE_TYPEINDEX = 2
|
||||
|
||||
' Misc
|
||||
Public Const OBJECT_TYPE_DEFAULT = "Standard"
|
||||
|
||||
|
||||
@ -56,10 +56,14 @@ Public Class Helpers
|
||||
|
||||
Select Case Type
|
||||
Case INDEX_TYPE_HASH
|
||||
Return Value
|
||||
Case INDEX_TYPE_STRING
|
||||
Return Value
|
||||
Case INDEX_TYPE_VECTOR_STRING
|
||||
Return Value
|
||||
Case INDEX_TYPE_INTEGER
|
||||
Value = Value.Replace(" ", String.Empty)
|
||||
Return Convert.ToInt16(Value)
|
||||
Case INDEX_TYPE_VECTOR_INTEGER
|
||||
Value = Value.Replace(" ", String.Empty)
|
||||
Return Convert.ToInt16(Value)
|
||||
@ -67,17 +71,25 @@ Public Class Helpers
|
||||
Value = Value.Replace(" ", String.Empty)
|
||||
Return Convert.ToInt64(Value)
|
||||
Case INDEX_TYPE_VECTOR_BOOLEAN
|
||||
Return Convert.ToBoolean(Value)
|
||||
Case INDEX_TYPE_BOOLEAN
|
||||
Return Convert.ToBoolean(Value)
|
||||
Case INDEX_TYPE_DATE
|
||||
Return Convert.ToDateTime(Value)
|
||||
Case INDEX_TYPE_DATE_TIME
|
||||
Return Convert.ToDateTime(Value)
|
||||
Case INDEX_TYPE_TIME
|
||||
Return Convert.ToDateTime(Value)
|
||||
Case INDEX_TYPE_VECTOR_DATE_TIME
|
||||
Return Convert.ToDateTime(Value)
|
||||
Case INDEX_TYPE_VECTOR_DATE
|
||||
Return Convert.ToDateTime(Value)
|
||||
Case INDEX_TYPE_FLOAT
|
||||
Return Convert.ToDouble(Value)
|
||||
Case INDEX_TYPE_VECTOR_FLOAT
|
||||
Return Convert.ToDouble(Value)
|
||||
Case Else
|
||||
Return Value
|
||||
End Select
|
||||
End Function
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ Imports WMOSRCHLib
|
||||
Imports WMCNNCTDLLLib
|
||||
Imports WMOTOOLLib
|
||||
Imports System.IO
|
||||
Imports System.IO.Path
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
@ -69,10 +70,9 @@ Public Class Windream
|
||||
#Region "Private Properties"
|
||||
Private ReadOnly _logger As Logger
|
||||
Private ReadOnly _logConfig As LogConfig
|
||||
|
||||
Private ReadOnly Property _sessionDomain As String
|
||||
Private ReadOnly Property _sessionPassword As String
|
||||
Private ReadOnly Property _sessionUsername As String
|
||||
Private ReadOnly _sessionDomain As String
|
||||
Private ReadOnly _sessionPassword As String
|
||||
Private ReadOnly _sessionUsername As String
|
||||
|
||||
#End Region
|
||||
#Region "Public Properties"
|
||||
@ -85,6 +85,8 @@ Public Class Windream
|
||||
Public ReadOnly Property SessionReconnect As Boolean
|
||||
Public ReadOnly Property SessionServername As String
|
||||
|
||||
Public ReadOnly Property UsesDriveLetter As Boolean = True
|
||||
|
||||
''' <returns>A list of object types that are available</returns>
|
||||
Public ReadOnly Property ObjectTypes As List(Of String)
|
||||
Get
|
||||
@ -135,6 +137,10 @@ Public Class Windream
|
||||
Me.SessionServername = SessionServerName
|
||||
Me.ClientBasePath = GetNormalizedBasePath(BasePath)
|
||||
|
||||
If ClientDriveLetter = String.Empty Then
|
||||
UsesDriveLetter = False
|
||||
End If
|
||||
|
||||
_sessionUsername = SessionUserName
|
||||
_sessionPassword = SessionPassword
|
||||
_sessionDomain = SessionDomain
|
||||
@ -311,6 +317,41 @@ Public Class Windream
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetTypeIndiciesByObjecttype(ObjectTypeName As String, Optional SystemIndicies As Boolean = False) As List(Of String)
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oObjectType As IWMObject6
|
||||
Dim oTempSession As IWMSession2
|
||||
Dim oIndicies As New List(Of String)
|
||||
Dim oAttributeFlag As Integer = 0
|
||||
|
||||
Try
|
||||
' den Objekttyp laden
|
||||
oTempSession = DirectCast(Session, IWMSession2)
|
||||
oObjectType = Session.GetWMObjectByName(WMEntityObjectType, ObjectTypeName)
|
||||
|
||||
If SystemIndicies = True Then
|
||||
oAttributeFlag = Constants.ATTRIBUTE_TYPE_SYSTEMINDEX
|
||||
Else
|
||||
oAttributeFlag = Constants.ATTRIBUTE_TYPE_TYPEINDEX
|
||||
End If
|
||||
|
||||
Dim oVariableNames As WMObjectVariableNames = oObjectType.GetVariableNames(oAttributeFlag, False)
|
||||
|
||||
For oIndex = 0 To oVariableNames.Count - 1
|
||||
oIndicies.Add(oVariableNames.Item(oIndex))
|
||||
Next
|
||||
|
||||
Return oIndicies
|
||||
Catch ex As Exception
|
||||
_logger.Warn("Type Indicies could not be read")
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function NewSession(Optional ServerName As String = Nothing, Optional UserName As String = Nothing, Optional Password As String = Nothing, Optional Domain As String = Nothing) As IWMSession2
|
||||
Dim oBrowser As ServerBrowser
|
||||
Dim oConnect As IWMConnect2
|
||||
@ -541,12 +582,16 @@ Public Class Windream
|
||||
|
||||
Try
|
||||
Path = GetNormalizedPath(Path)
|
||||
Dim oFolders As List(Of String) = Path.Split().ToList()
|
||||
Dim oFolders As List(Of String) = Path.Split("\").ToList()
|
||||
Dim oFolderObject As WMObject
|
||||
Dim oCurrentPath As String = String.Empty
|
||||
|
||||
|
||||
For Each oFolder In oFolders
|
||||
If TestFolderExists(Path) = False Then
|
||||
oFolderObject = Session.GetNewWMObjectFS(WMEntityFolder, oFolder, WMObjectEditModeNoEdit)
|
||||
oCurrentPath = Combine(oCurrentPath, oFolder)
|
||||
|
||||
If TestFolderExists(oCurrentPath) = False Then
|
||||
oFolderObject = Session.GetNewWMObjectFS(WMEntityFolder, oCurrentPath, WMObjectEditModeNoEdit)
|
||||
End If
|
||||
Next
|
||||
|
||||
@ -575,9 +620,8 @@ Public Class Windream
|
||||
End Function
|
||||
|
||||
Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String) As Boolean
|
||||
'Try
|
||||
Dim oExtension As String = Path.GetExtension(FilenameSource)
|
||||
_logger.Debug("Stream_File was started...")
|
||||
|
||||
If Not TestSessionLoggedIn() Then
|
||||
Return False
|
||||
End If
|
||||
@ -585,23 +629,18 @@ Public Class Windream
|
||||
Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget)
|
||||
FilenameTarget = GetNormalizedPath(FilenameTarget)
|
||||
|
||||
_logger.Debug($"Streaming file from {FilenameSource} to {FilenameTarget}")
|
||||
_logger.NewBlock("File Stream")
|
||||
_logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}")
|
||||
|
||||
Dim oWMObject As IWMObject6 = Nothing
|
||||
Dim oFileIO As WMFileIO
|
||||
Dim oWMStream As WMStream
|
||||
|
||||
'_logger.Debug("Try to access file and lock it...")
|
||||
'Err.Clear()
|
||||
|
||||
'Indexierungsdialog der Session unterdrücken
|
||||
Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False)
|
||||
|
||||
'==================================================================
|
||||
' create an object
|
||||
'==================================================================
|
||||
|
||||
Try
|
||||
' GetNewWMObjectFS already locks the WMObject
|
||||
_logger.Debug("Creating WMObject for file {0}", FilenameTarget)
|
||||
oWMObject = Session.GetNewWMObjectFS(WMEntityDocument, FilenameTarget, WMObjectEditModeObject)
|
||||
Catch ex As Exception
|
||||
@ -614,12 +653,6 @@ Public Class Windream
|
||||
Return False
|
||||
End If
|
||||
|
||||
_logger.Debug("Locking object for {0}", FilenameTarget)
|
||||
If LockObject(oWMObject) = False Then
|
||||
_logger.Warn("Document {0} could not be locked", FilenameTarget)
|
||||
Return False
|
||||
End If
|
||||
|
||||
Try
|
||||
_logger.Debug("Opening stream for {0}", FilenameTarget)
|
||||
oWMStream = oWMObject.OpenStream(Constants.STREAM_BINARY_OBJECT, Constants.STREAM_OPEN_MODE_READ_WRITE)
|
||||
@ -664,80 +697,10 @@ Public Class Windream
|
||||
Return False
|
||||
End Try
|
||||
|
||||
_logger.Info($"File '{FilenameTarget}' was imported.")
|
||||
_logger.Info($"File '{FilenameTarget}' was streamed.")
|
||||
_logger.EndBlock()
|
||||
|
||||
Return True
|
||||
|
||||
'If Err.Number > 0 Then
|
||||
' _logger.Warn($"WMObject could not be created - Error: ' {Err.Description}'")
|
||||
'End If
|
||||
' If oWMObject IsNot Nothing Then
|
||||
' ' lock object for file system access (to change the file itself)
|
||||
' LockObject(oWMObject)
|
||||
' ' set fileIO the local source file
|
||||
' oFileIO.bstrOriginalFileName = FilenameSource
|
||||
' If Err.Number > 0 Then
|
||||
' 'MsgBox(Err.Number.ToString)
|
||||
' _logger.Warn($"fileIO could not be set - Error: '{Err.Description}'")
|
||||
' If UnlockObject(oWMObject) Then RemoveFile(FilenameTarget)
|
||||
' Return False
|
||||
' End If
|
||||
' ' open the windream object's file stream for writing
|
||||
' oWMStream = oWMObject.OpenStream(Constants.STREAM_BINARY_OBJECT, Constants.STREAM_OPEN_MODE_READ_WRITE)
|
||||
' If Err.Number > 0 Then
|
||||
' _logger.Warn($"Error whhile creating stream - Error: '{Err.Description}'")
|
||||
' If UnlockObject(oWMObject) Then RemoveFile(FilenameTarget)
|
||||
' Return False
|
||||
' End If
|
||||
' _logger.Debug("oWMStream created!")
|
||||
' ' give fileIO helper object the windream stream
|
||||
' oFileIO.aWMStream = oWMStream
|
||||
' If Err.Number > 0 Then
|
||||
' _logger.Warn($"Error while adding aWMStream to aFileIO - Error: '{Err.Description}'")
|
||||
' If UnlockObject(oWMObject) Then RemoveFile(FilenameTarget)
|
||||
' Return False
|
||||
' End If
|
||||
' ' let fileIO object import the original file into windream
|
||||
' oFileIO.ImportOriginal(True)
|
||||
' If Err.Number > 0 Then
|
||||
' _logger.Warn($"Error while FileIO.ImportOriginal(True) Error: '{Err.Description}'")
|
||||
' If UnlockObject(oWMObject) Then RemoveFile(FilenameTarget)
|
||||
|
||||
' Return False
|
||||
' End If
|
||||
' _logger.Debug("Content of file was transferred!")
|
||||
' ' close the windream file stream
|
||||
' oWMStream.Close()
|
||||
' If Err.Number > 0 Then
|
||||
' _logger.Warn($"Error in aWMStream.Close() - Error: '{Err.Description}'")
|
||||
' If UnlockObject(oWMObject) Then RemoveFile(FilenameTarget)
|
||||
' Return False
|
||||
' 'MsgBox(Err.Description)
|
||||
' End If
|
||||
' ' save new windream object
|
||||
' oWMObject.Save()
|
||||
' If Err.Number > 0 Then
|
||||
' _logger.Warn($"Error while WMObject.save() - Error: '{Err.Description}'")
|
||||
' If UnlockObject(oWMObject) Then RemoveFile(FilenameTarget)
|
||||
' Return False
|
||||
' 'MsgBox(Err.Description)
|
||||
' End If
|
||||
' _logger.Debug("File was saved correctly.")
|
||||
' ' unlock the windream object
|
||||
' If oWMObject.unlock() = False Then
|
||||
' RemoveFile(FilenameTarget)
|
||||
' Return False
|
||||
' End If
|
||||
' _logger.Info($"File '{FilenameTarget}' was imported.")
|
||||
' Return True
|
||||
' Else
|
||||
' _logger.Warn($"WMObject could not be created!")
|
||||
' Return False
|
||||
' End If
|
||||
'Catch ex As Exception
|
||||
' _logger.Warn("Unexpected Error in NewStream_File:")
|
||||
' _logger.Error(ex)
|
||||
' Return False
|
||||
'End Try
|
||||
End Function
|
||||
|
||||
Public Function LockObject(WMObject As WMObject, Optional EditMode As WMObjectEditMode = WMObjectEditModeNoEdit) As Boolean
|
||||
@ -763,11 +726,19 @@ Public Class Windream
|
||||
Public Function GetNormalizedPath(Path As String) As String
|
||||
Dim oNormalizedPath = GetCleanedPath(Path)
|
||||
|
||||
If ClientDriveLetter <> String.Empty And Path.ToUpper().StartsWith(ClientDriveLetter.ToUpper) Then
|
||||
oNormalizedPath = Path.Substring(2)
|
||||
ElseIf Path.ToLower.StartsWith(ClientBasePath) Then
|
||||
oNormalizedPath = Path.Substring(ClientBasePath.Length)
|
||||
If UsesDriveLetter Then
|
||||
' Remove Driveletter eg. W:\
|
||||
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
|
||||
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter + 2)
|
||||
End If
|
||||
Else
|
||||
If oNormalizedPath.ToLower.StartsWith(ClientBasePath.ToLower) Then
|
||||
' Remove Windream Base Path eg. \\windream\objects\
|
||||
oNormalizedPath = oNormalizedPath.Substring(ClientBasePath.Length)
|
||||
End If
|
||||
End If
|
||||
|
||||
oNormalizedPath = oNormalizedPath.Replace("\\", "\")
|
||||
|
||||
Return oNormalizedPath
|
||||
End Function
|
||||
@ -1089,18 +1060,27 @@ Public Class Windream
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function SetFileIndex(Path As String, IndexName As String, Value As String) As Boolean
|
||||
Public Function SetFileIndex(Path As String, IndexName As String, Value As String, ObjectType As String) As Boolean
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oWMObject As WMObject = GetFileByPath(Path)
|
||||
If TestFileExists(Path) = False Then
|
||||
_logger.Warn("File '{0}' does not exist", Path)
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oWMObject As IWMObject6 = GetFileByPath(Path)
|
||||
|
||||
If LockObject(oWMObject, WMObjectEditModeIndexEdit) = False Then
|
||||
_logger.Warn("File {0} could not be locked")
|
||||
Return False
|
||||
End If
|
||||
|
||||
If oWMObject.aObjectType.aName = Constants.OBJECT_TYPE_DEFAULT Then
|
||||
oWMObject.aObjectType = GetObjectByName(ObjectType, WMEntityObjectType)
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oType As Integer = GetIndexType(IndexName)
|
||||
Dim oConvertedValue As Object = Helpers.ConvertIndexValue(oType, Value)
|
||||
@ -1118,6 +1098,53 @@ Public Class Windream
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function SetFileIndex(Path As String, IndexName As String, Values As List(Of String), ObjectType As String) As Boolean
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
If TestFileExists(Path) = False Then
|
||||
_logger.Warn("File '{0}' does not exist", Path)
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oWMObject As IWMObject6 = GetFileByPath(Path)
|
||||
|
||||
If LockObject(oWMObject, WMObjectEditModeIndexEdit) = False Then
|
||||
_logger.Warn("File {0} could not be locked")
|
||||
Return False
|
||||
End If
|
||||
|
||||
If oWMObject.aObjectType.aName = Constants.OBJECT_TYPE_DEFAULT Then
|
||||
oWMObject.aObjectType = GetObjectByName(ObjectType, WMEntityObjectType)
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oType As Integer = GetIndexType(IndexName)
|
||||
Dim oConvertedValues As New List(Of String)
|
||||
Dim oArray As Object
|
||||
|
||||
ReDim oArray(Values.Count - 1)
|
||||
|
||||
For oIndex = 0 To Values.Count - 1
|
||||
Dim oValue As Object = Helpers.ConvertIndexValue(oType, Values.Item(oIndex))
|
||||
oArray(oIndex) = oValue
|
||||
Next
|
||||
|
||||
oWMObject.SetVariableValue(IndexName, oArray)
|
||||
oWMObject.Save()
|
||||
|
||||
If UnlockObject(oWMObject) = False Then
|
||||
_logger.Warn("File {0} could not be unlocked", Path)
|
||||
End If
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ExportFile(WMObject As WMObject, ExportPath As String) As Boolean
|
||||
Try
|
||||
Dim oWMObject As IWMObject6 = DirectCast(WMObject, IWMObject6)
|
||||
@ -1291,6 +1318,15 @@ Public Class Windream
|
||||
Public Function TestGroupExists(Groupname As String) As Boolean
|
||||
Return TestObjectExists(Groupname, WMEntityGroups)
|
||||
End Function
|
||||
|
||||
Public Function TestIndexTypeIsVectorIndex(IndexType As Integer) As Boolean
|
||||
Return Helpers.IsVectorIndex(IndexType)
|
||||
End Function
|
||||
|
||||
Public Function TestIndexNameIsVectorIndex(IndexName As String) As Boolean
|
||||
Dim oIndexType As Integer = GetIndexType(IndexName)
|
||||
Return Helpers.IsVectorIndex(oIndexType)
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#Region "Private Methods"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user