Merge branch 'master' of http://git.dd:3000/AppStd/Modules
This commit is contained in:
commit
36fe39ee66
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.3.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.3.0.0")>
|
||||
<Assembly: AssemblyVersion("1.6.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.6.0.0")>
|
||||
|
||||
@ -114,6 +114,7 @@ Public Class Windream
|
||||
Public ReadOnly Property SessionServername As String
|
||||
|
||||
Public ReadOnly Property UsesDriveLetter As Boolean = True
|
||||
Public Property NewDocumentID As Int32 = 0
|
||||
|
||||
''' <returns>A list of object types that are available</returns>
|
||||
Public ReadOnly Property ObjectTypes As List(Of String)
|
||||
@ -243,14 +244,45 @@ Public Class Windream
|
||||
Return oItems
|
||||
End Try
|
||||
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
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
pPath = GetNormalizedPath(pPath)
|
||||
pPath = GetNormalizedPath(pPath, False)
|
||||
|
||||
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
|
||||
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
|
||||
Return oWMObject
|
||||
@ -283,7 +315,7 @@ Public Class Windream
|
||||
End If
|
||||
|
||||
Try
|
||||
Path = GetNormalizedPath(Path)
|
||||
Path = GetNormalizedPath(Path, False)
|
||||
Dim oWMObject As WMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
|
||||
|
||||
If oWMObject Is Nothing Then
|
||||
@ -628,7 +660,7 @@ Public Class Windream
|
||||
End If
|
||||
|
||||
Try
|
||||
Path = GetNormalizedPath(Path)
|
||||
Path = GetNormalizedPath(Path, True)
|
||||
Dim oFolders As List(Of String) = Path.Split("\").ToList()
|
||||
Dim oFolderObject As WMObject
|
||||
Dim oCurrentPath As String = String.Empty
|
||||
@ -637,6 +669,8 @@ Public Class Windream
|
||||
For Each oFolder In oFolders
|
||||
If oFolder.ToString.EndsWith(pExtension) Then
|
||||
Exit For
|
||||
ElseIf oFolder = String.Empty Then
|
||||
Continue For
|
||||
End If
|
||||
oCurrentPath = Combine(oCurrentPath, oFolder)
|
||||
|
||||
@ -659,7 +693,7 @@ Public Class Windream
|
||||
End If
|
||||
|
||||
Try
|
||||
Path = GetNormalizedPath(Path)
|
||||
Path = GetNormalizedPath(Path, False)
|
||||
Dim oFileObject As IWMObject6
|
||||
oFileObject = GetObjectByPath(Path, WMEntityDocument)
|
||||
oFileObject.CreateVersion2(False, Constants.HISTORY_NEW_FROM_VERSION, Comment)
|
||||
@ -671,6 +705,7 @@ Public Class Windream
|
||||
End Function
|
||||
|
||||
Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String) As Boolean
|
||||
NewDocumentID = 0
|
||||
Dim oExtension As String = Path.GetExtension(FilenameSource)
|
||||
|
||||
If Not TestSessionLoggedIn() Then
|
||||
@ -678,7 +713,7 @@ Public Class Windream
|
||||
End If
|
||||
|
||||
Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget)
|
||||
FilenameTarget = GetNormalizedPath(FilenameTarget)
|
||||
FilenameTarget = GetNormalizedPath(FilenameTarget, True)
|
||||
|
||||
_logger.NewBlock("File Stream")
|
||||
_logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}")
|
||||
@ -687,6 +722,8 @@ Public Class Windream
|
||||
Dim oFileIO As WMFileIO
|
||||
Dim oWMStream As WMStream
|
||||
|
||||
NewFolder(FilenameTarget, oExtension)
|
||||
|
||||
'Indexierungsdialog der Session unterdrücken
|
||||
Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False)
|
||||
|
||||
@ -749,6 +786,11 @@ Public Class Windream
|
||||
End Try
|
||||
|
||||
_logger.Info($"File '{FilenameTarget}' was streamed.")
|
||||
Dim oDocid = GetIndexValue(FilenameTarget, "Dokument-ID")
|
||||
If Not IsNothing(oDocid) Then
|
||||
NewDocumentID = oDocid(0)
|
||||
End If
|
||||
|
||||
_logger.EndBlock()
|
||||
|
||||
Return True
|
||||
@ -774,11 +816,13 @@ Public Class Windream
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetNormalizedPath(Path As String) As String
|
||||
'Dim oNormalizedPath = GetCleanedPath(Path)
|
||||
Dim oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path)
|
||||
_logger.Debug("Normalizing Path: [{0}]", oNormalizedPath)
|
||||
|
||||
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
|
||||
@ -788,8 +832,8 @@ Public Class Windream
|
||||
|
||||
' Remove Driveletter, eg. W:\
|
||||
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
|
||||
_logger.Debug($"Replacing ClientDriveLetter: [{ClientDriveLetter}]")
|
||||
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
|
||||
_logger.Debug($"path after replaced ClientDriveLetter: [{oNormalizedPath}]")
|
||||
End If
|
||||
|
||||
' Remove Windream Base Path, eg. \\windream\objects\
|
||||
@ -804,7 +848,9 @@ Public Class Windream
|
||||
_logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]")
|
||||
oNormalizedPath = oNormalizedPath.Substring(3)
|
||||
End If
|
||||
|
||||
If oNormalizedPath.StartsWith("\") = False Then
|
||||
oNormalizedPath = $"\{oNormalizedPath}"
|
||||
End If
|
||||
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
|
||||
|
||||
Return oNormalizedPath
|
||||
@ -1041,7 +1087,7 @@ Public Class Windream
|
||||
End If
|
||||
|
||||
Try
|
||||
FolderPath = GetNormalizedPath(FolderPath)
|
||||
FolderPath = GetNormalizedPath(FolderPath, False)
|
||||
|
||||
If TestFolderExists(FolderPath) = False Then
|
||||
_logger.Warn("Folder {0} does not exist!", FolderPath)
|
||||
@ -1312,13 +1358,22 @@ Public Class Windream
|
||||
Exportpath &= "\"
|
||||
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
|
||||
|
||||
_logger.Debug("(Export_WMFile)Working on file: " & oWMObject.aName)
|
||||
|
||||
End If
|
||||
_logger.Debug("(Export_WMFile) Working on file: " & oWMObject.aName)
|
||||
|
||||
|
||||
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
|
||||
_logger.Debug("(Export_WMFile)ExportFileIO created...")
|
||||
_logger.Debug("(Export_WMFile) ExportFileIO created...")
|
||||
' Stream Interface bereitstellen
|
||||
oWMObject.LockFor(WMObjectEditModeFileSystem)
|
||||
Try
|
||||
@ -1354,12 +1409,13 @@ Public Class Windream
|
||||
oWMObject.unlock()
|
||||
_logger.Info($"WMFile has been exported to {tempFilename} ")
|
||||
|
||||
Return True
|
||||
Return tempFilename
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Export_WMFile_DocID(WMPath As String, Exportpath As String, DocId As Integer)
|
||||
Try
|
||||
|
||||
@ -1454,11 +1510,11 @@ Public Class Windream
|
||||
'Return rNewFilepath
|
||||
End Function
|
||||
Public Function TestFolderExists(Path As String) As Boolean
|
||||
Return TestObjectExists(GetNormalizedPath(Path), WMEntityFolder)
|
||||
Return TestObjectExists(GetNormalizedPath(Path, False), WMEntityFolder)
|
||||
End Function
|
||||
|
||||
Public Function TestFileExists(Path As String) As Boolean
|
||||
Return TestObjectExists(GetNormalizedPath(Path), WMEntityDocument)
|
||||
Return TestObjectExists(GetNormalizedPath(Path, False), WMEntityDocument)
|
||||
End Function
|
||||
|
||||
Public Function TestUserExists(Username As String) As Boolean
|
||||
@ -1530,7 +1586,7 @@ Public Class Windream
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oNormalizedPath = GetNormalizedPath(ObjectPath)
|
||||
Dim oNormalizedPath = GetNormalizedPath(ObjectPath, False)
|
||||
Dim oWMObject As WMObject = Session.GetWMObjectByPath(ObjectType, oNormalizedPath)
|
||||
Return oWMObject
|
||||
Catch ex As Exception
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user