This commit is contained in:
2023-01-03 16:03:51 +01:00
26 changed files with 391 additions and 138 deletions

View File

@@ -637,6 +637,7 @@ Public Class Windream
Return False
End Try
End Function
''' <summary>
''' Archives windream object immediately
''' </summary>
@@ -653,7 +654,7 @@ Public Class Windream
End Try
End Function
Public Function NewFolder(Path As String, pExtension As String) As Boolean
Public Function NewFolder(Path As String) As Boolean
If Not TestSessionLoggedIn() Then
Return False
End If
@@ -664,13 +665,11 @@ Public Class Windream
Dim oFolderObject As WMObject
Dim oCurrentPath As String = String.Empty
For Each oFolder In oFolders
If oFolder.ToString.EndsWith(pExtension) Then
Exit For
ElseIf oFolder = String.Empty Then
If oFolder = String.Empty Then
Continue For
End If
oCurrentPath = Combine(oCurrentPath, oFolder)
If TestFolderExists(oCurrentPath) = False Then
@@ -706,13 +705,13 @@ Public Class Windream
Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String, ByVal WMObjecttypeName As String) As Boolean
NewDocumentID = 0
Dim oExtension As String = Path.GetExtension(FilenameSource)
If Not TestSessionLoggedIn() Then
Return False
End If
Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget)
FilenameTarget = GetNormalizedPath(FilenameTarget, True)
_logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}")
@@ -721,7 +720,7 @@ Public Class Windream
Dim oFileIO As WMFileIO
Dim oWMStream As WMStream
NewFolder(FilenameTarget, oExtension)
NewFolder(oTargetDrive)
'Indexierungsdialog der Session unterdrücken
Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False)
@@ -777,7 +776,6 @@ Public Class Windream
oWMStream.Close()
_logger.Debug("Saving new object")
oWMObject.aObjectType = GetObjectByName(WMObjecttypeName, WMEntityObjectType)
oWMObject.Save()
@@ -817,24 +815,20 @@ Public Class Windream
End Try
End Function
Public Function GetNormalizedPath(Path As String, pCleanPath As Boolean) As String
_logger.Debug("Normalizing Path: [{0}]", Path)
Dim oNormalizedPath As String = Path
If pCleanPath = True Then
oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path)
_logger.Debug("path after RemoveInvalidCharacters: [{0}]", oNormalizedPath)
End If
Try
' 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
If IsPathRooted(oNormalizedPath) Then
oNormalizedPath = GetFullPath(oNormalizedPath)
End If
Public Function GetNormalizedPath(pPath As String, pCleanPath As Boolean) As String
_logger.Debug("Normalizing Path: [{0}]", pPath)
Dim oNormalizedPath As String = pPath
If pCleanPath = True Then
oNormalizedPath = Utils.RemoveInvalidCharacters(pPath)
_logger.Debug("Path after RemoveInvalidCharacters: [{0}]", oNormalizedPath)
End If
Try
' Remove Driveletter, eg. W:\
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
_logger.Debug($"path after replaced ClientDriveLetter: [{oNormalizedPath}]")
_logger.Debug($"Path after replaced ClientDriveLetter: [{oNormalizedPath}]")
End If
' Remove Windream Base Path, eg. \\windream\objects\
@@ -845,22 +839,41 @@ Public Class Windream
' Handle misconfigured drive-letter
If oNormalizedPath.Contains(":") Then
_logger.Warn($"oNormalizedPath still contains a drive name!!")
_logger.Warn($"NormalizedPath [{oNormalizedPath}] still contains a drive name!!")
_logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]")
oNormalizedPath = oNormalizedPath.Substring(3)
End If
' 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
If IsPathRooted(oNormalizedPath) Then
' This breaks because it converts the path "\SomeFolder" into "C:\SomeFolder" LOL
'oNormalizedPath = GetFullPath(oNormalizedPath)
' Lets just be pragmatic here
oNormalizedPath = oNormalizedPath.Replace("\\", "\")
oNormalizedPath = oNormalizedPath.Replace("/", "\")
_logger.Debug("Path after converting slashes: [{0}]", oNormalizedPath)
End If
If oNormalizedPath.StartsWith("\") = False Then
oNormalizedPath = $"\{oNormalizedPath}"
End If
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
_logger.Debug($"NormalizedPath: [{oNormalizedPath}]")
Return oNormalizedPath
Catch ex As Exception
_logger.Warn($"Unexpected error in GetNormalizedPath - oNormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]")
_logger.Warn($"Unexpected error in GetNormalizedPath - NormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]")
Return ""
End Try
End Function
Public Function GetAbsolutePath(pPath As String) As String
Dim oNormalizedPath = GetNormalizedPath(pPath, False)
Return $"\\windream\objects{oNormalizedPath}"
End Function
''' <summary>
''' Returns the result of a search file
''' </summary>