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 Implements IConnectionBuilder
Private LogFactory As NLog.LogFactory Private LogFactory As LogFactory
Private SessionReconnect As Boolean = False Private SessionReconnect As Boolean = False
Private DriveLetter As String = "W" Private DriveLetter As String = "W"
Private Support64Bit As Boolean = False Private Support64Bit As Boolean = False
@ -10,7 +12,7 @@
Private Password As String = Nothing Private Password As String = Nothing
Private Domain As String = Nothing Private Domain As String = Nothing
Public Sub New(LogFactory As NLog.LogFactory) Public Sub New(LogFactory As LogFactory)
Me.LogFactory = LogFactory Me.LogFactory = LogFactory
End Sub End Sub

View File

@ -1,6 +1,6 @@
Public Class Helpers Public Class Helpers
Inherits Constants 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 Select Case vType
Case INDEX_TYPE_HASH ' 36865 Case INDEX_TYPE_HASH ' 36865
'Umwandeln in String 'Umwandeln in String

View File

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

View File

@ -16,15 +16,43 @@ Imports System.IO
''' '''
''' VERSION: 0.0.0.1 ''' VERSION: 0.0.0.1
''' '''
''' DATE: 24.08.2018 ''' DATE: 27.08.2018
''' '''
''' DESCRIPTION: ''' DESCRIPTION:
''' '''
''' DEPENDENCIES: NLog, >= 4.5.8 ''' 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: ''' EXAMPLES:
''' '''
@ -41,14 +69,13 @@ Public Class Windream2
#End Region #End Region
#Region "Public Properties" #Region "Public Properties"
Public ReadOnly Property ClientDriveLetter As String 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 Session As IWMSession2
Public ReadOnly Property SessionLoggedin As Boolean Public ReadOnly Property SessionLoggedin As Boolean
Public ReadOnly Property SessionReconnect As Boolean Public ReadOnly Property SessionReconnect As Boolean
Public ReadOnly Property SessionServername As String Public ReadOnly Property SessionServername As String
''' <returns>A list of object types that are available</returns> ''' <returns>A list of object types that are available</returns>
Public ReadOnly Property ObjectTypes As List(Of String) Public ReadOnly Property ObjectTypes As List(Of String)
Get Get
@ -97,7 +124,7 @@ Public Class Windream2
Me.SessionReconnect = SessionReconnect Me.SessionReconnect = SessionReconnect
Me.ClientDriveLetter = ClientDriveLetter Me.ClientDriveLetter = ClientDriveLetter
Me.ClientSupport64Bit = ClientSupport64Bit Me.ClientSupports64Bit = ClientSupport64Bit
Me.SessionServername = SessionServerName Me.SessionServername = SessionServerName
_sessionUsername = SessionUserName _sessionUsername = SessionUserName
@ -229,9 +256,9 @@ Public Class Windream2
End Try End Try
End Function End Function
Public Function LockFile(FileObject As WMObject) As Boolean Public Function LockObject(WMObject As WMObject) As Boolean
Try Try
FileObject.lock() WMObject.lock()
Return True Return True
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
@ -239,9 +266,9 @@ Public Class Windream2
End Try End Try
End Function End Function
Public Function UnlockFile(FileObject As WMObject) As Boolean Public Function UnlockObject(WMObject As WMObject) As Boolean
Try Try
FileObject.unlock() WMObject.unlock()
Return True Return True
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
@ -496,13 +523,14 @@ Public Class Windream2
FolderPath = GetNormalizedPath(FolderPath) FolderPath = GetNormalizedPath(FolderPath)
If TestFolderExists(FolderPath) = False Then If TestFolderExists(FolderPath) = False Then
_logger.Warn("Folder {0} does not exist!", FolderPath)
Return False Return False
End If End If
Dim oWMFolder As WMObject = GetObjectByPath(FolderPath, WMEntityFolder) Dim oWMFolder As WMObject = GetObjectByPath(FolderPath, WMEntityFolder)
If LockFile(oWMFolder) = False Then If LockObject(oWMFolder) = False Then
' Nichts tun, Ordner ist bereits gesperrt. _logger.Warn("Folder {0} could not be locked", FolderPath)
End If End If
If oWMFolder.aObjectType.aName <> Constants.OBJECT_TYPE_DEFAULT Then If oWMFolder.aObjectType.aName <> Constants.OBJECT_TYPE_DEFAULT Then
@ -517,9 +545,16 @@ Public Class Windream2
End If End If
oWMFolder.aObjectType = oObjecttype 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 Catch ex As Exception
_logger.Error(ex)
Return False
End Try End Try
End Function End Function
@ -639,8 +674,7 @@ Public Class Windream2
End If End If
Try Try
Dim oTempSession As IWMSession2 = DirectCast(Session, IWMSession2) Dim oWMObject As WMObject = Session.GetWMObjectByName(ObjectType, ObjectName)
Dim oWMObject As WMObject = oTempSession.GetWMObjectByName(ObjectType, ObjectName)
Return oWMObject Return oWMObject
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
@ -658,8 +692,7 @@ Public Class Windream2
End If End If
Try Try
Dim oTempSession As IWMSession2 = DirectCast(Session, IWMSession2) Dim oWMObject As WMObject = Session.GetWMObjectByPath(ObjectType, ObjectName)
Dim oWMObject As WMObject = oTempSession.GetWMObjectByPath(ObjectType, ObjectName)
Return oWMObject Return oWMObject
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
@ -686,11 +719,10 @@ Public Class Windream2
Return False Return False
End If End If
Try Try
Dim oTempSession = DirectCast(Session, IWMSession2)
Dim oObjectId = 0 Dim oObjectId = 0
Dim oObjectDbId = 0 Dim oObjectDbId = 0
Return oTempSession.WMObjectExists(ObjectType, ObjectName, oObjectId, oObjectDbId) Return Session.WMObjectExists(ObjectType, ObjectName, oObjectId, oObjectDbId)
Catch ex As Exception Catch ex As Exception
_logger.Error(ex, "Error while checking existence of WMObject {0} of type {1}", ObjectName, ObjectType.ToString) _logger.Error(ex, "Error while checking existence of WMObject {0} of type {1}", ObjectName, ObjectType.ToString)
Return False Return False