MS windream Mod

This commit is contained in:
SchreiberM 2022-11-17 17:09:07 +01:00
parent 0fe90141b1
commit 5f8e1a8608
2 changed files with 79 additions and 23 deletions

View File

@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.3.0.0")> <Assembly: AssemblyVersion("1.6.0.0")>
<Assembly: AssemblyFileVersion("1.3.0.0")> <Assembly: AssemblyFileVersion("1.6.0.0")>

View File

@ -114,6 +114,7 @@ Public Class Windream
Public ReadOnly Property SessionServername As String Public ReadOnly Property SessionServername As String
Public ReadOnly Property UsesDriveLetter As Boolean = True Public ReadOnly Property UsesDriveLetter As Boolean = True
Public Property NewDocumentID As Int32 = 0
''' <returns>A list of object types that are available</returns> ''' <returns>A list of object types that are available</returns>
Public ReadOnly Property ObjectTypes As List(Of String) Public ReadOnly Property ObjectTypes As List(Of String)
@ -243,14 +244,45 @@ Public Class Windream
Return oItems Return oItems
End Try End Try
End Function End Function
Public Function CheckFileExistsinWM(pPath As String) As Boolean
If TestSessionLoggedIn() = False Then
Return Nothing
End If
pPath = GetNormalizedPath(pPath, False)
_logger.Info($"CheckFileExistsinWM: {pPath} ...")
Dim oWMObject As WMObject
Try
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
Return True
Catch ex As Exception
_logger.Info($"Unexpected Error in windream.GetFileByPath: {ex.Message}")
_logger.Error(ex)
Return False
End Try
End Function
Public Function GetFileByPath(pPath As String) As WMObject Public Function GetFileByPath(pPath As String) As WMObject
If TestSessionLoggedIn() = False Then If TestSessionLoggedIn() = False Then
Return Nothing Return Nothing
End If End If
pPath = GetNormalizedPath(pPath) pPath = GetNormalizedPath(pPath, False)
Dim oWMObject As WMObject Dim oWMObject As WMObject
Try
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
Return oWMObject
Catch ex As Exception
_logger.Info($"Unexpected Error in windream.GetFileByPath: {ex.Message}")
_logger.Error(ex)
Return Nothing
End Try
End Function
Public Function GetFileByPathObj6(pPath As String) As IWMObject6
If TestSessionLoggedIn() = False Then
Return Nothing
End If
pPath = GetNormalizedPath(pPath, False)
Dim oWMObject As IWMObject6
Try Try
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath) oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
Return oWMObject Return oWMObject
@ -283,7 +315,7 @@ Public Class Windream
End If End If
Try Try
Path = GetNormalizedPath(Path) Path = GetNormalizedPath(Path, False)
Dim oWMObject As WMObject = Session.GetWMObjectByPath(WMEntityDocument, Path) Dim oWMObject As WMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
If oWMObject Is Nothing Then If oWMObject Is Nothing Then
@ -628,7 +660,7 @@ Public Class Windream
End If End If
Try Try
Path = GetNormalizedPath(Path) Path = GetNormalizedPath(Path, True)
Dim oFolders As List(Of String) = Path.Split("\").ToList() Dim oFolders As List(Of String) = Path.Split("\").ToList()
Dim oFolderObject As WMObject Dim oFolderObject As WMObject
Dim oCurrentPath As String = String.Empty Dim oCurrentPath As String = String.Empty
@ -637,6 +669,8 @@ Public Class Windream
For Each oFolder In oFolders For Each oFolder In oFolders
If oFolder.ToString.EndsWith(pExtension) Then If oFolder.ToString.EndsWith(pExtension) Then
Exit For Exit For
ElseIf oFolder = String.Empty Then
Continue For
End If End If
oCurrentPath = Combine(oCurrentPath, oFolder) oCurrentPath = Combine(oCurrentPath, oFolder)
@ -659,7 +693,7 @@ Public Class Windream
End If End If
Try Try
Path = GetNormalizedPath(Path) Path = GetNormalizedPath(Path, False)
Dim oFileObject As IWMObject6 Dim oFileObject As IWMObject6
oFileObject = GetObjectByPath(Path, WMEntityDocument) oFileObject = GetObjectByPath(Path, WMEntityDocument)
oFileObject.CreateVersion2(False, Constants.HISTORY_NEW_FROM_VERSION, Comment) oFileObject.CreateVersion2(False, Constants.HISTORY_NEW_FROM_VERSION, Comment)
@ -671,6 +705,7 @@ Public Class Windream
End Function End Function
Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String) As Boolean Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String) As Boolean
NewDocumentID = 0
Dim oExtension As String = Path.GetExtension(FilenameSource) Dim oExtension As String = Path.GetExtension(FilenameSource)
If Not TestSessionLoggedIn() Then If Not TestSessionLoggedIn() Then
@ -678,7 +713,7 @@ Public Class Windream
End If End If
Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget) Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget)
FilenameTarget = GetNormalizedPath(FilenameTarget) FilenameTarget = GetNormalizedPath(FilenameTarget, True)
_logger.NewBlock("File Stream") _logger.NewBlock("File Stream")
_logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}") _logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}")
@ -687,6 +722,8 @@ Public Class Windream
Dim oFileIO As WMFileIO Dim oFileIO As WMFileIO
Dim oWMStream As WMStream Dim oWMStream As WMStream
NewFolder(FilenameTarget, oExtension)
'Indexierungsdialog der Session unterdrücken 'Indexierungsdialog der Session unterdrücken
Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False) Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False)
@ -749,6 +786,11 @@ Public Class Windream
End Try End Try
_logger.Info($"File '{FilenameTarget}' was streamed.") _logger.Info($"File '{FilenameTarget}' was streamed.")
Dim oDocid = GetIndexValue(FilenameTarget, "Dokument-ID")
If Not IsNothing(oDocid) Then
NewDocumentID = oDocid(0)
End If
_logger.EndBlock() _logger.EndBlock()
Return True Return True
@ -774,11 +816,13 @@ Public Class Windream
End Try End Try
End Function End Function
Public Function GetNormalizedPath(Path As String) As String Public Function GetNormalizedPath(Path As String, pCleanPath As Boolean) As String
'Dim oNormalizedPath = GetCleanedPath(Path) _logger.Debug("Normalizing Path: [{0}]", Path)
Dim oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path) Dim oNormalizedPath As String = Path
_logger.Debug("Normalizing Path: [{0}]", oNormalizedPath) If pCleanPath = True Then
oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path)
_logger.Debug("path after RemoveInvalidCharacters: [{0}]", oNormalizedPath)
End If
Try Try
' Convert any forward slashes / and double slashes \\ into backslashes \ ' Convert any forward slashes / and double slashes \\ into backslashes \
' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes ' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes
@ -788,8 +832,8 @@ Public Class Windream
' Remove Driveletter, eg. W:\ ' Remove Driveletter, eg. W:\
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
_logger.Debug($"Replacing ClientDriveLetter: [{ClientDriveLetter}]")
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2) oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
_logger.Debug($"path after replaced ClientDriveLetter: [{oNormalizedPath}]")
End If End If
' Remove Windream Base Path, eg. \\windream\objects\ ' Remove Windream Base Path, eg. \\windream\objects\
@ -804,7 +848,9 @@ Public Class Windream
_logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]") _logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]")
oNormalizedPath = oNormalizedPath.Substring(3) oNormalizedPath = oNormalizedPath.Substring(3)
End If End If
If oNormalizedPath.StartsWith("\") = False Then
oNormalizedPath = $"\{oNormalizedPath}"
End If
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]") _logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
Return oNormalizedPath Return oNormalizedPath
@ -1041,7 +1087,7 @@ Public Class Windream
End If End If
Try Try
FolderPath = GetNormalizedPath(FolderPath) FolderPath = GetNormalizedPath(FolderPath, False)
If TestFolderExists(FolderPath) = False Then If TestFolderExists(FolderPath) = False Then
_logger.Warn("Folder {0} does not exist!", FolderPath) _logger.Warn("Folder {0} does not exist!", FolderPath)
@ -1312,8 +1358,17 @@ Public Class Windream
Exportpath &= "\" Exportpath &= "\"
End If End If
Dim oWMObject As WMObject = GetFileByPath(WMPath) Dim oWMObject As Object = GetFileByPath(WMPath)
If IsNothing(oWMObject) Then
Return False
'_logger.Debug("GetFileByPath failed - Trying GetFileByPathObj6...")
'oWMObject = GetFileByPathObj6(WMPath)
'If IsNothing(oWMObject) Then
' Return False
'End If
End If
_logger.Debug("(Export_WMFile) Working on file: " & oWMObject.aName) _logger.Debug("(Export_WMFile) Working on file: " & oWMObject.aName)
@ -1354,12 +1409,13 @@ Public Class Windream
oWMObject.unlock() oWMObject.unlock()
_logger.Info($"WMFile has been exported to {tempFilename} ") _logger.Info($"WMFile has been exported to {tempFilename} ")
Return True Return tempFilename
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
Return False Return False
End Try End Try
End Function End Function
Public Function Export_WMFile_DocID(WMPath As String, Exportpath As String, DocId As Integer) Public Function Export_WMFile_DocID(WMPath As String, Exportpath As String, DocId As Integer)
Try Try
@ -1454,11 +1510,11 @@ Public Class Windream
'Return rNewFilepath 'Return rNewFilepath
End Function End Function
Public Function TestFolderExists(Path As String) As Boolean Public Function TestFolderExists(Path As String) As Boolean
Return TestObjectExists(GetNormalizedPath(Path), WMEntityFolder) Return TestObjectExists(GetNormalizedPath(Path, False), WMEntityFolder)
End Function End Function
Public Function TestFileExists(Path As String) As Boolean Public Function TestFileExists(Path As String) As Boolean
Return TestObjectExists(GetNormalizedPath(Path), WMEntityDocument) Return TestObjectExists(GetNormalizedPath(Path, False), WMEntityDocument)
End Function End Function
Public Function TestUserExists(Username As String) As Boolean Public Function TestUserExists(Username As String) As Boolean
@ -1530,7 +1586,7 @@ Public Class Windream
End If End If
Try Try
Dim oNormalizedPath = GetNormalizedPath(ObjectPath) Dim oNormalizedPath = GetNormalizedPath(ObjectPath, False)
Dim oWMObject As WMObject = Session.GetWMObjectByPath(ObjectType, oNormalizedPath) Dim oWMObject As WMObject = Session.GetWMObjectByPath(ObjectType, oNormalizedPath)
Return oWMObject Return oWMObject
Catch ex As Exception Catch ex As Exception