This commit is contained in:
Digital Data - Marlon Schreiber
2019-01-23 18:01:24 +01:00
parent 6c9fc1c9e6
commit 00924416ec
5 changed files with 60 additions and 32 deletions

View File

@@ -1083,22 +1083,47 @@ Public Class Windream
#End Region
#Region "+++++ Remove +++++"
''' <summary>
''' Deletes a file in windream
''' Deletes a file in windream including all preversions
''' </summary>
''' <param name="WMPath">full path to the file</param>
''' <returns>Returns true when file was deleted, false if not</returns>
''' <remarks></remarks>
Public Function RemFile(ByVal WMPath As String)
Try
Const COL_Document_VersionID = "dwVersionID"
Const WMObjectPartVersion = 128
Dim oUnexpected_Error As Boolean = False
WMPath = NormalizePath(WMPath)
Dim oWMObject = GetWMObjectForFile(WMPath)
If IsNothing(oWMObject) = False Then
oWMObject.Delete()
Return True
Try
If (oWMObject.aPart And WMObjectPartVersion) Then
Dim oWMObjects As WMObjects
Dim oWMVersion As WMObject
Dim iCount As Integer
oWMObjects = oWMObject.aVersions
iCount = oWMObjects.Count
If iCount > 0 Then
For Each oWMVersion In oWMObjects
oWMVersion.Delete()
Logger.Info($">> Deleted version '{oWMVersion.GetVariableValue(COL_Document_VersionID)}' of file '{oWMVersion.aName}'!")
Next
End If
End If
Catch ex As Exception
Logger.Warn($"Unexpected Error in CheckingDeleting Prevesions: {ex.Message}")
oUnexpected_Error = True
End Try
If oUnexpected_Error = False Then
oWMObject.Delete()
Logger.Info($">> File '{oWMObject.aName}' has been deleted!")
Return True
Else
Return False
End If
Else
Return False
End If
Catch ex As Exception
Logger.Error(ex)
Return False

View File

@@ -197,7 +197,7 @@ Public Class Windream2
If TestSessionLoggedIn() = False Then
Return Nothing
End If
Path = GetNormalizedPath(Path)
Dim oWMObject As WMObject
Try
@@ -951,13 +951,14 @@ Public Class Windream2
End If
Try
Dim oWMObject As WMObject = Session.GetWMObjectByName(WMEntityAttribute, Path)
Dim oWMObject As WMObject = GetFileByPath(Path)
If oWMObject Is Nothing Then
Return False
End If
oWMObject.Delete()
_logger.Warn($"file {Path} has been deleted!")
Return True
Catch ex As Exception
_logger.Error(ex)