Windream: Normalize BasePath

This commit is contained in:
Jonathan Jenne 2019-08-29 16:31:14 +02:00
parent dd0f99ebda
commit 81a06966b5
4 changed files with 34 additions and 10 deletions

View File

@ -1,5 +1,7 @@
Imports NLog Imports NLog
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Windream
Imports DigitalData.Modules.Language
Public Class ConnectionBuilder Public Class ConnectionBuilder
Implements IConnectionBuilder Implements IConnectionBuilder
@ -61,6 +63,15 @@ Public Class ConnectionBuilder
Return Me Return Me
End Function End Function
Public Function WithWindreamObjectsOrDriveLetter(BasePath As String, DriveLetter As String) As IConnectionBuilder Implements IConnectionBuilder.WithWindreamObjectsOrDriveLetter
If Utils.NotNull(BasePath, Nothing) IsNot Nothing Then
Return WithWindreamObjects(BasePath)
ElseIf Utils.NotNull(DriveLetter, Nothing) IsNot Nothing Then
Return WithDriveLetter(DriveLetter)
Else
Return WithWindreamObjects()
End If
End Function
''' <summary> ''' <summary>
''' Sets flag in Windream class to indicate 64-bit support ''' Sets flag in Windream class to indicate 64-bit support

View File

@ -3,6 +3,7 @@
Function WithDriveLetter(driveLetter As String) As IConnectionBuilder Function WithDriveLetter(driveLetter As String) As IConnectionBuilder
Function WithWindreamObjects() As IConnectionBuilder Function WithWindreamObjects() As IConnectionBuilder
Function WithWindreamObjects(BasePath As String) As IConnectionBuilder Function WithWindreamObjects(BasePath As String) As IConnectionBuilder
Function WithWindreamObjectsOrDriveLetter(BasePath As String, DriveLetter As String) As IConnectionBuilder
Function With64BitSupport() As IConnectionBuilder Function With64BitSupport() As IConnectionBuilder
Function WithServerName(serverName As String) As IConnectionBuilder Function WithServerName(serverName As String) As IConnectionBuilder
Function WithImpersonation(userName As String, password As String, domain As String) As IConnectionBuilder Function WithImpersonation(userName As String, password As String, domain As String) As IConnectionBuilder

View File

@ -133,7 +133,7 @@ Public Class Windream
Me.ClientDriveLetter = ClientDriveLetter Me.ClientDriveLetter = ClientDriveLetter
Me.ClientSupports64Bit = ClientSupport64Bit Me.ClientSupports64Bit = ClientSupport64Bit
Me.SessionServername = SessionServerName Me.SessionServername = SessionServerName
Me.ClientBasePath = BasePath Me.ClientBasePath = GetNormalizedBasePath(BasePath)
_sessionUsername = SessionUserName _sessionUsername = SessionUserName
_sessionPassword = SessionPassword _sessionPassword = SessionPassword
@ -760,6 +760,18 @@ Public Class Windream
End Try End Try
End Function End Function
Public Function GetNormalizedPath(Path As String) As String
Dim oNormalizedPath = GetCleanedPath(Path)
If ClientDriveLetter <> String.Empty And Path.ToUpper().StartsWith(ClientDriveLetter.ToUpper) Then
oNormalizedPath = Path.Substring(2)
ElseIf Path.ToLower.StartsWith(ClientBasePath) Then
oNormalizedPath = Path.Substring(ClientBasePath.Length)
End If
Return oNormalizedPath
End Function
''' <summary> ''' <summary>
''' Returns the result of a search file ''' Returns the result of a search file
''' </summary> ''' </summary>
@ -1282,16 +1294,12 @@ Public Class Windream
#End Region #End Region
#Region "Private Methods" #Region "Private Methods"
Private Function GetNormalizedPath(Path As String) As String Private Function GetNormalizedBasePath(BasePath As String) As String
Dim oNormalizedPath = GetCleanedPath(Path) If BasePath.EndsWith("\") Then
Return BasePath
If Not Path.StartsWith("\") And Path.ToUpper().StartsWith(ClientDriveLetter.ToUpper) Then Else
oNormalizedPath = Path.Substring(2) Return BasePath & "\"
ElseIf Path.ToLower.StartsWith(ClientBasePath) Then
oNormalizedPath = Path.Substring(ClientBasePath.Length)
End If End If
Return oNormalizedPath
End Function End Function
Private Function GetCleanedPath(Path As String) As String Private Function GetCleanedPath(Path As String) As String

View File

@ -136,6 +136,10 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Modules.Language\Language.vbproj">
<Project>{d3c8cfed-d6f6-43a8-9bdf-454145d0352f}</Project>
<Name>Language</Name>
</ProjectReference>
<ProjectReference Include="..\Modules.Logging\Logging.vbproj"> <ProjectReference Include="..\Modules.Logging\Logging.vbproj">
<Project>{903b2d7d-3b80-4be9-8713-7447b704e1b0}</Project> <Project>{903b2d7d-3b80-4be9-8713-7447b704e1b0}</Project>
<Name>Logging</Name> <Name>Logging</Name>