WIP: Windream2

This commit is contained in:
Jonathan Jenne
2018-08-27 17:12:30 +02:00
parent feb522ec64
commit 41cd8313a9
4 changed files with 63 additions and 29 deletions

View File

@@ -16,15 +16,43 @@ Imports System.IO
'''
''' VERSION: 0.0.0.1
'''
''' DATE: 24.08.2018
''' DATE: 27.08.2018
'''
''' DESCRIPTION:
'''
''' DEPENDENCIES: NLog, >= 4.5.8
'''
''' PARAMETERS:
''' PARAMETERS: LogFactory, NLog.LogFactory
''' The LogFactory containing the current log config. Used to instanciate the class logger for this and any dependent class
'''
''' ClientDriveLetter, String
''' Drive Letter of the Windream Drive, should default to `W`
'''
''' PROPERTIES:
''' ClientSupport64Bit, Boolean
''' Should this session support 64bit methods/functionality?
'''
''' SessionReconnect, Boolean
''' Should the session reconnect automatically when the connection to the server is lost?
'''
''' SessionServerName, String
''' Name of the server used in the connection. If this is `Nothing`, the current server defined in the client is used
'''
''' SessionUserName, String
''' Name of the user that is used in the connection. If this is `Nothing`, the currently signed in user is used
'''
''' SessionPassword, String
''' User-password that is used in the connection. If this is `Nothing`, the currently signed in user is used
'''
''' SessionDomain, String
''' User-domain that is used in the connection. If this is `Nothing`, the currently signed in user is used
'''
''' PROPERTIES: ClientDriveLetter, String (readonly)
''' ClientSupports64Bit, Boolean (readonly)
''' Session, IWMSession2 (readonly)
''' SessionLoggedin, Boolean (readonly)
''' SessionReconnect, Boolean (readonly)
''' SessionServername, String (readonly)
''' Objecttypes, List(Of String) (readonly)
'''
''' EXAMPLES:
'''
@@ -41,14 +69,13 @@ Public Class Windream2
#End Region
#Region "Public Properties"
Public ReadOnly Property ClientDriveLetter As String
Public ReadOnly Property ClientSupport64Bit As Boolean
Public ReadOnly Property ClientSupports64Bit As Boolean
Public ReadOnly Property Session As IWMSession2
Public ReadOnly Property SessionLoggedin As Boolean
Public ReadOnly Property SessionReconnect As Boolean
Public ReadOnly Property SessionServername As String
''' <returns>A list of object types that are available</returns>
Public ReadOnly Property ObjectTypes As List(Of String)
Get
@@ -97,7 +124,7 @@ Public Class Windream2
Me.SessionReconnect = SessionReconnect
Me.ClientDriveLetter = ClientDriveLetter
Me.ClientSupport64Bit = ClientSupport64Bit
Me.ClientSupports64Bit = ClientSupport64Bit
Me.SessionServername = SessionServerName
_sessionUsername = SessionUserName
@@ -229,9 +256,9 @@ Public Class Windream2
End Try
End Function
Public Function LockFile(FileObject As WMObject) As Boolean
Public Function LockObject(WMObject As WMObject) As Boolean
Try
FileObject.lock()
WMObject.lock()
Return True
Catch ex As Exception
_logger.Error(ex)
@@ -239,9 +266,9 @@ Public Class Windream2
End Try
End Function
Public Function UnlockFile(FileObject As WMObject) As Boolean
Public Function UnlockObject(WMObject As WMObject) As Boolean
Try
FileObject.unlock()
WMObject.unlock()
Return True
Catch ex As Exception
_logger.Error(ex)
@@ -496,13 +523,14 @@ Public Class Windream2
FolderPath = GetNormalizedPath(FolderPath)
If TestFolderExists(FolderPath) = False Then
_logger.Warn("Folder {0} does not exist!", FolderPath)
Return False
End If
Dim oWMFolder As WMObject = GetObjectByPath(FolderPath, WMEntityFolder)
If LockFile(oWMFolder) = False Then
' Nichts tun, Ordner ist bereits gesperrt.
If LockObject(oWMFolder) = False Then
_logger.Warn("Folder {0} could not be locked", FolderPath)
End If
If oWMFolder.aObjectType.aName <> Constants.OBJECT_TYPE_DEFAULT Then
@@ -517,9 +545,16 @@ Public Class Windream2
End If
oWMFolder.aObjectType = oObjecttype
oWMFolder.Save()
If UnlockObject(oWMFolder) Then
_logger.Warn("Folder {0} could not be unlocked", FolderPath)
End If
Return True
Catch ex As Exception
_logger.Error(ex)
Return False
End Try
End Function
@@ -639,8 +674,7 @@ Public Class Windream2
End If
Try
Dim oTempSession As IWMSession2 = DirectCast(Session, IWMSession2)
Dim oWMObject As WMObject = oTempSession.GetWMObjectByName(ObjectType, ObjectName)
Dim oWMObject As WMObject = Session.GetWMObjectByName(ObjectType, ObjectName)
Return oWMObject
Catch ex As Exception
_logger.Error(ex)
@@ -658,8 +692,7 @@ Public Class Windream2
End If
Try
Dim oTempSession As IWMSession2 = DirectCast(Session, IWMSession2)
Dim oWMObject As WMObject = oTempSession.GetWMObjectByPath(ObjectType, ObjectName)
Dim oWMObject As WMObject = Session.GetWMObjectByPath(ObjectType, ObjectName)
Return oWMObject
Catch ex As Exception
_logger.Error(ex)
@@ -686,11 +719,10 @@ Public Class Windream2
Return False
End If
Try
Dim oTempSession = DirectCast(Session, IWMSession2)
Dim oObjectId = 0
Dim oObjectDbId = 0
Return oTempSession.WMObjectExists(ObjectType, ObjectName, oObjectId, oObjectDbId)
Return Session.WMObjectExists(ObjectType, ObjectName, oObjectId, oObjectDbId)
Catch ex As Exception
_logger.Error(ex, "Error while checking existence of WMObject {0} of type {1}", ObjectName, ObjectType.ToString)
Return False