From 8ac01eefa42f5f13c33473ecd0b19d76678e2c8d Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 10 May 2021 11:37:58 +0200 Subject: [PATCH] Windream: use file versioning from Filesystem Module in VersionWMFilename --- Modules.Windream/Windream.vb | 38 ++++++++++++++++++-------------- Modules.Windream/Windream.vbproj | 4 ++++ 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Modules.Windream/Windream.vb b/Modules.Windream/Windream.vb index 0e5c7485..d00448da 100644 --- a/Modules.Windream/Windream.vb +++ b/Modules.Windream/Windream.vb @@ -94,6 +94,7 @@ Public Class Windream #Region "Private Properties" Private ReadOnly _logger As Logger Private ReadOnly _logConfig As LogConfig + Private ReadOnly _fileSystem As Filesystem.File Private ReadOnly _sessionDomain As String Private ReadOnly _sessionPassword As String Private ReadOnly _sessionUsername As String @@ -144,6 +145,7 @@ Public Class Windream ' Create logger and save LogFactory for dependent classes _logger = LogConfig.GetLogger() _logConfig = LogConfig + _fileSystem = New Filesystem.File(LogConfig) ' Create a session Dim oSession As IWMSession2 = NewSession(SessionServerName, SessionUserName, SessionPassword, SessionDomain) @@ -1406,23 +1408,25 @@ Public Class Windream End Try End Function Public Function VersionWMFilename(pPath As String, pExt As String) - Dim rNewFilepath As String = pPath - pPath = GetNormalizedPath(pPath) - Dim oPath = pPath.Substring(0, pPath.LastIndexOf("\")) - Dim oFilename = pPath.Substring(pPath.LastIndexOf("\") + 1, pPath.Length - pPath.LastIndexOf("\") - 1) - Dim oCheck = oFilename - Dim oSplit As List(Of String) = oFilename.Split("~").ToList() - oFilename = oFilename.Replace(pExt, "") - Dim oCount As Integer = 2 - Do While TestFileExists(rNewFilepath) = True - oFilename = oFilename.Replace(pExt, "") - Dim oVersion = "~" + (oCount - 1).ToString - oFilename = oFilename.Replace(oVersion, "") - oFilename = oFilename & "~" & oCount & pExt - oCount += 1 - rNewFilepath = oPath + "\" + oFilename - Loop - Return rNewFilepath + Return _fileSystem.GetVersionedFilename(pPath) + + 'Dim rNewFilepath As String = pPath + 'pPath = GetNormalizedPath(pPath) + 'Dim oPath = pPath.Substring(0, pPath.LastIndexOf("\")) + 'Dim oFilename = pPath.Substring(pPath.LastIndexOf("\") + 1, pPath.Length - pPath.LastIndexOf("\") - 1) + 'Dim oCheck = oFilename + 'Dim oSplit As List(Of String) = oFilename.Split("~").ToList() + 'oFilename = oFilename.Replace(pExt, "") + 'Dim oCount As Integer = 2 + 'Do While TestFileExists(rNewFilepath) = True + ' oFilename = oFilename.Replace(pExt, "") + ' Dim oVersion = "~" + (oCount - 1).ToString + ' oFilename = oFilename.Replace(oVersion, "") + ' oFilename = oFilename & "~" & oCount & pExt + ' oCount += 1 + ' rNewFilepath = oPath + "\" + oFilename + 'Loop + 'Return rNewFilepath End Function Public Function TestFolderExists(Path As String) As Boolean Return TestObjectExists(GetNormalizedPath(Path), WMEntityFolder) diff --git a/Modules.Windream/Windream.vbproj b/Modules.Windream/Windream.vbproj index 0c3367f9..8cb45537 100644 --- a/Modules.Windream/Windream.vbproj +++ b/Modules.Windream/Windream.vbproj @@ -136,6 +136,10 @@ + + {991d0231-4623-496d-8bd0-9ca906029cbc} + Filesystem + {d3c8cfed-d6f6-43a8-9bdf-454145d0352f} Language