ms
This commit is contained in:
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("0.0.0.4")>
|
||||
<Assembly: AssemblyVersion("1.0.0.2")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
|
||||
@@ -203,17 +203,18 @@ Public Class Windream
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFileByPath(Path As String) As WMObject
|
||||
Public Function GetFileByPath(pPath As String) As WMObject
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
Path = GetNormalizedPath(Path)
|
||||
Dim oWMObject As WMObject
|
||||
pPath = GetNormalizedPath(pPath)
|
||||
|
||||
Dim oWMObject As WMObject
|
||||
Try
|
||||
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
|
||||
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
|
||||
Return oWMObject
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
@@ -725,22 +726,29 @@ Public Class Windream
|
||||
|
||||
Public Function GetNormalizedPath(Path As String) As String
|
||||
Dim oNormalizedPath = GetCleanedPath(Path)
|
||||
Try
|
||||
|
||||
If UsesDriveLetter Then
|
||||
' Remove Driveletter eg. W:\
|
||||
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
|
||||
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter + 2)
|
||||
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 - 1)
|
||||
End If
|
||||
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("\\", "\")
|
||||
oNormalizedPath = oNormalizedPath.Replace("\\", "\")
|
||||
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
|
||||
Return oNormalizedPath
|
||||
Catch ex As Exception
|
||||
_logger.Warn($"Unexpected error in GetNormalizedPath - oNormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]")
|
||||
Return ""
|
||||
End Try
|
||||
|
||||
|
||||
Return oNormalizedPath
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
@@ -993,6 +1001,7 @@ Public Class Windream
|
||||
|
||||
Public Function RemoveFile(Path As String) As Boolean
|
||||
If TestSessionLoggedIn() = False Then
|
||||
_logger.Warn("TestSession = False!")
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
@@ -1000,11 +1009,12 @@ Public Class Windream
|
||||
Dim oWMObject As WMObject = GetFileByPath(Path)
|
||||
|
||||
If oWMObject Is Nothing Then
|
||||
_logger.Warn("Error RemoveFile (oWMObject is nothing)")
|
||||
Return False
|
||||
End If
|
||||
|
||||
_logger.Info($"Deleting WMObject [{Path}]")
|
||||
oWMObject.Delete()
|
||||
_logger.Warn($"file {Path} has been deleted!")
|
||||
_logger.Info($"[RemoveFile] - File [{Path}] has been deleted!")
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
@@ -1215,11 +1225,11 @@ Public Class Windream
|
||||
|
||||
Dim oWMObject As WMObject = GetFileByPath(WMPath)
|
||||
|
||||
_logger.Debug("Working on file: " & oWMObject.aName)
|
||||
_logger.Debug("(Export_WMFile)Working on file: " & oWMObject.aName)
|
||||
|
||||
|
||||
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
|
||||
_logger.Debug("ExportFileIO created...")
|
||||
_logger.Debug("(Export_WMFile)ExportFileIO created...")
|
||||
' Stream Interface bereitstellen
|
||||
oWMObject.LockFor(WMObjectEditModeFileSystem)
|
||||
Try
|
||||
@@ -1263,39 +1273,69 @@ Public Class Windream
|
||||
End Function
|
||||
Public Function Export_WMFile_DocID(WMPath As String, Exportpath As String, DocId As Integer)
|
||||
Try
|
||||
|
||||
|
||||
If Not Exportpath.EndsWith("\") Then
|
||||
Exportpath &= "\"
|
||||
End If
|
||||
Dim Extension = WMPath.Substring(WMPath.LastIndexOf("."))
|
||||
Dim oTempFilename As String = Exportpath & DocId & Extension
|
||||
_logger.Info($"(Export_WMFile_DocID)Working on file [{WMPath}] ")
|
||||
|
||||
If IO.File.Exists(oTempFilename) Then
|
||||
_logger.Info($"(Export_WMFile_DocID) DocID [{DocId}] already existing!! No action necessary!")
|
||||
Return True
|
||||
End If
|
||||
|
||||
Dim oWMObject As WMObject
|
||||
|
||||
|
||||
|
||||
Dim oWMObject As WMObject = GetFileByPath(WMPath)
|
||||
Try
|
||||
_logger.Info("Working on file: " & oWMObject.aName)
|
||||
oWMObject = GetFileByPath(WMPath)
|
||||
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_logger.Warn("No object created: " & WMPath)
|
||||
Return False
|
||||
End Try
|
||||
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
|
||||
_logger.Debug("ExportFileIO created...")
|
||||
_logger.Debug("(Export_WMFile_DocID)ExportFileIO created...")
|
||||
Dim oWMStream = oWMObject.OpenStream("BinaryObject", 1)
|
||||
'### VERSIONIERUNG ###
|
||||
Dim version As Integer = 2
|
||||
Dim Extension = oWMObject.aName.Substring(oWMObject.aName.LastIndexOf("."))
|
||||
Dim tempFilename As String = Exportpath & DocId & Extension
|
||||
|
||||
_logger.Debug($"Checking (FileExists) on [{oTempFilename}]... ")
|
||||
'Überprüfen ob File existiert
|
||||
Do While IO.File.Exists(tempFilename) = True
|
||||
tempFilename = Exportpath & DocId & "_" & version & Extension
|
||||
Do While IO.File.Exists(oTempFilename) = True
|
||||
oTempFilename = Exportpath & DocId & "_" & version & Extension
|
||||
version = version + 1
|
||||
Loop
|
||||
_logger.Debug("Exportfilename is: " & tempFilename)
|
||||
_logger.Debug($"(Export_WMFile_DocID)Exportfilename is [{oTempFilename}] ")
|
||||
' den Dateiinhalt der neuen Datei zuweisen
|
||||
ExportFileIO.aWMStream = oWMStream
|
||||
ExportFileIO.bstrOriginalFileName = tempFilename
|
||||
ExportFileIO.bstrOriginalFileName = oTempFilename
|
||||
'Das eigentliche kopieren
|
||||
ExportFileIO.ExportOriginal(True)
|
||||
|
||||
Dim oCounter = 0
|
||||
Dim oError As Boolean = False
|
||||
Do While IO.File.Exists(oTempFilename) = False
|
||||
oCounter += 1
|
||||
If oCounter = 30000 Then
|
||||
_logger.Warn($"WMStream took too long...Check the file [{WMPath}]")
|
||||
oError = True
|
||||
Exit Do
|
||||
End If
|
||||
Loop
|
||||
If oError = True Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
|
||||
'close the windream file stream
|
||||
oWMStream.Close()
|
||||
_logger.Info($"WMFile DocID {DocId} has been exported to {tempFilename} ")
|
||||
_logger.Info($"WMFile DocID [{DocId}] has been exported to [{oTempFilename}]")
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
|
||||
Reference in New Issue
Block a user