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

@ -1,7 +1,9 @@
Public Class ConnectionBuilder
Imports NLog
Public Class ConnectionBuilder
Implements IConnectionBuilder
Private LogFactory As NLog.LogFactory
Private LogFactory As LogFactory
Private SessionReconnect As Boolean = False
Private DriveLetter As String = "W"
Private Support64Bit As Boolean = False
@ -10,7 +12,7 @@
Private Password As String = Nothing
Private Domain As String = Nothing
Public Sub New(LogFactory As NLog.LogFactory)
Public Sub New(LogFactory As LogFactory)
Me.LogFactory = LogFactory
End Sub

View File

@ -1,6 +1,6 @@
Public Class Helpers
Inherits Constants
Friend Shared Function Convert_VectorType(vType As Object, value As String)
Friend Shared Function ConvertVectorType(vType As Object, value As String)
Select Case vType
Case INDEX_TYPE_HASH ' 36865
'Umwandeln in String

View File

@ -475,7 +475,7 @@ Public Class Windream
If Anzahl = 1 Then
Logger.Info("Vectorfield will be filled with ONE VALUE!")
ReDim myArray(0)
myArray(0) = Helpers.Convert_VectorType(oWMType, value)
myArray(0) = Helpers.ConvertVectorType(oWMType, value)
'Jetzt überprüfen ob Werte in Vektorfeld angefügt oder überschrieben werden sollen
Logger.Info("Converted Value: " & myArray(0).ToString)
Dim VektorArray()
@ -906,7 +906,7 @@ Public Class Windream
ReDim Preserve ValueArray(valueCount)
'Den Wert im Array speichern
ValueArray(valueCount) = Helpers.Convert_VectorType(vType, row.Item(0))
ValueArray(valueCount) = Helpers.ConvertVectorType(vType, row.Item(0))
valueCount += 1
Next
'Jetzt die Neuen Werte auf Duplikate überprüfen
@ -916,7 +916,7 @@ Public Class Windream
'Das Array anpassen
ReDim Preserve ValueArray(valueCount)
'Den Wert im Array speichern
ValueArray(valueCount) = Helpers.Convert_VectorType(vType, NewValue)
ValueArray(valueCount) = Helpers.ConvertVectorType(vType, NewValue)
valueCount += 1
Else
Logger.Info("Value '" & NewValue.ToString & "' already existing in vectorfield(1)")
@ -935,7 +935,7 @@ Public Class Windream
'Das Array anpassen
ReDim Preserve ValueArray(valueCount)
'Den Wert im Array speichern
ValueArray(valueCount) = Helpers.Convert_VectorType(vType, NewValue)
ValueArray(valueCount) = Helpers.ConvertVectorType(vType, NewValue)
valueCount += 1
Else
Logger.Info("Value '" & NewValue.ToString & "' already existing in vectorfield(2)")
@ -945,7 +945,7 @@ Public Class Windream
'Das Array anpassen
ReDim Preserve ValueArray(valueCount)
'Den Wert im Array speichern
ValueArray(valueCount) = Helpers.Convert_VectorType(vType, NewValue)
ValueArray(valueCount) = Helpers.ConvertVectorType(vType, NewValue)
valueCount += 1
End If
@ -1142,7 +1142,7 @@ Public Class Windream
'Erst die ALten Werte schreiben
ReDim Preserve ValueArray(Anzahl)
'Den Wert im Array speichern
ValueArray(Anzahl) = Helpers.Convert_VectorType(vType, WDValue)
ValueArray(Anzahl) = Helpers.ConvertVectorType(vType, WDValue)
Anzahl += 1
End If
End If

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