jj: change names,add DigitalData Namespace

This commit is contained in:
Jonathan Jenne
2018-08-16 16:43:47 +02:00
parent b8c28b516c
commit 0ccdb7bbc7
19 changed files with 321 additions and 318 deletions

View File

@@ -6,122 +6,129 @@ Imports WINDREAMLib.WMSearchOperator
Imports WINDREAMLib.WMSearchRelation
Imports WMOBRWSLib
Imports WMOSRCHLib
Imports WMCNNCTDLLLib
Public Class Windream
Inherits Constants
#Region "+++++ Variables +++++"
Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
Public CurrentSession = Nothing
Public CurrentSessionIsLoggedIn As Boolean = False
Private CurrentObjecttypes As WINDREAMLib.WMObjects
Private CurrentController As WMOSearchController
Private Shared CurrentWMConnect ' der Typ darf nicht festgelegt werden (warum auch immer... geht sonst nicht)
Public CurrentWMServer As String
Private WMDriveLetter As String = "W"
Private _Session_Reconnect As Boolean = False
' New
Private ServerBrowser As IServerBrowser
Private Session As IWMSession6
Private Connect As IWMConnect2
Private CurrentServer As String
Private CurrentObjecttypes As WMObjects
Private ReconnectSession As Boolean
Private DriveLetter As String
Public LoggedInSession As Boolean = False
#End Region
#Region "+++++ Init +++++"
''' <summary>
''' Initializes windream and creates a windream session with the actual user
''' </summary>
''' <remarks></remarks>
Public Sub New(WMDRIVE As String, SessionReconnect As Boolean)
Public Sub New(Optional DriveLetter As String = "W", Optional ReconnectSession As Boolean = False)
Try
WMDriveLetter = WMDRIVE
NewSession()
Me.DriveLetter = DriveLetter
Me.ReconnectSession = ReconnectSession
If Not NewSession() Then
Logger.Warn("Session could not be created")
End If
CurrentObjecttypes = GetObjectTypes()
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Function GetObjectTypes() As WMObjects
Dim objectTypes As WMObjects
Try
objectTypes = Session.GetWMObjectTypes(WMEntityDocument)
Return objectTypes
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function
Private Function NormalizePath(path As String)
Dim normalizedPath = path
If Not path.StartsWith("\") And path.ToUpper().StartsWith(DriveLetter.ToUpper) Then
normalizedPath = path.Substring(2)
End If
Return normalizedPath
End Function
''' <summary>
''' Creates a windream session with the actual user
''' </summary>
''' <returns>Returns true when created, false if not</returns>
''' <remarks></remarks>
Public Function NewSession()
Public Function NewSession() As Boolean
Try
Dim wmbrwsr
wmbrwsr = CreateObject("WMOBrws.ServerBrowser")
'==================================================================
' get the current DMS-server to log in
'==================================================================
CurrentWMServer = wmbrwsr.GetCurrentServer
Logger.Info("ECMServer: " & CurrentWMServer)
Dim Connect
Try
Connect = CreateObject("Windream.WMConnect")
Logger.Info("...connected to windream!")
Catch ex As Exception
CurrentSession = Nothing
CurrentSessionIsLoggedIn = False
Logger.Error(ex)
Return False
End Try
'==================================================================
' create a session
'==================================================================
'Prüfen ob sich personifiziert angemeldet werden muss?
Try
CurrentSession = CreateObject("Windream.WMSession", CurrentWMServer)
Catch ex As Exception
CurrentSession = Nothing
CurrentSessionIsLoggedIn = False
Logger.Error(ex)
Return False
End Try
'==================================================================
' login session
'==================================================================
Try
Connect.LoginSession(CurrentSession)
If CurrentSession.aLoggedin Then
CurrentWMConnect = Connect
CurrentSessionIsLoggedIn = True
Logger.Info("UserSession has been created!")
Try
'Standardmässig hinterlegen dass abgelegte Dateien keine Indexmaske öffnet
CurrentSession.SwitchEvents(WMCOMEventWMSessionNeedIndex, False)
' der Parameter WMEntityDocument definiert, dass nur Dokumenttypen und keine
' Ordnertypen ausgelesen werden
CurrentObjecttypes = CurrentSession.GetWMObjectTypes(WINDREAMLib.WMEntity.WMEntityDocument)
Catch ex As Exception
Logger.Error(ex)
'clsLogger.Add("Could not get Objecttypes: " & ex.Message, True)
End Try
Return True
Else
CurrentSessionIsLoggedIn = False
Logger.Warn("Session could be built but user cannot be logged in!")
Return False
End If
Catch ex As Exception
If Not IsNothing(CurrentSession) Then
If CurrentSession.aLoggedin Then
Logger.Info("User is already logged in!....")
CurrentSessionIsLoggedIn = True
Else
CurrentSessionIsLoggedIn = False
End If
Return True
Else
Logger.Error(ex)
CurrentSession = Nothing
CurrentSessionIsLoggedIn = False
Return False
End If
End Try
ServerBrowser = New ServerBrowser()
Catch ex As Exception
CurrentSession = Nothing
CurrentSessionIsLoggedIn = False
Logger.Error(ex)
'clsLogger.Add("Unexpected Error in Create Session: " & ex.Message, True)
Logger.Error(ex, "Could not create ServerBrowser")
Return False
End Try
Try
' Create Connect Object for Session
Connect = New WMConnect With {
.ModuleId = 9
}
Catch ex As Exception
Logger.Error(ex, "Could not create WMConnect")
Return False
End Try
Try
Session = New WMSession()
Catch ex As Exception
Logger.Error(ex, "Could not create WMConnect")
Return False
End Try
Try
Connect.LoginSession(Session)
LoggedInSession = True
Catch ex As Exception
Logger.Error(ex, "Could not login session")
Return False
End Try
Try
' Standardmässig hinterlegen dass abgelegte Dateien keine Indexmaske öffnet
Session.SwitchEvents(WMCOMEventWMSessionNeedIndex, False)
Catch ex As Exception
Logger.Error(ex, "Could not SwitchEvents")
Return False
End Try
If Not Session.aLoggedin Then
Logger.Warn("Session created but user {0} could not be logged in", Environment.UserName)
Return False
End If
Return True
End Function
#End Region
#Region "+++++ New +++++"
Public Function NewFile()
End Function
''' <summary>
''' Creates a folder in windream. All folder-parts will be checked
''' </summary>
@@ -130,9 +137,8 @@ Public Class Windream
''' <remarks></remarks>
Public Function NewFolder(ByVal folderpath As String)
Try
If folderpath.StartsWith("\") = False And folderpath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
folderpath = folderpath.Substring(2)
End If
folderpath = NormalizePath(folderpath)
Dim folders() As String = folderpath.Split("\")
For Each folder As String In folders
Dim WMObject As WINDREAMLib.WMObject
@@ -357,9 +363,7 @@ Public Class Windream
Try
Dim result As Boolean = False
Dim WMFolder As WINDREAMLib.WMObject
If folderpath.StartsWith("\") = False And folderpath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
folderpath = folderpath.Substring(2)
End If
folderpath = NormalizePath(folderpath)
If TestFolderExists(folderpath) = True Then
WMFolder = CurrentSession.GetWMObjectByPath(WMEntityFolder, folderpath)
@@ -414,9 +418,7 @@ Public Class Windream
''' <remarks></remarks>
Public Function NewVersion(ByVal WMPath As String, ByVal Comment As String)
Try
If WMPath.StartsWith("\") = False And WMPath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
WMPath = WMPath.Substring(2)
End If
WMPath = NormalizePath(WMPath)
Dim WMObject As WINDREAMLib.WMObject '= CreateObject("WINDREAMLib.WMObject") 'New WINDREAMLib.WMObject
Try
@@ -638,8 +640,8 @@ Public Class Windream
oSearch = srchObjectType.GetSearch()
Case Else
MsgBox("KEIN GÜLTIGER WINDREAM-SUCHTYP")
Return Nothing
Logger.Warn("No valid WM-SearchType")
Return dt
End Select
Dim WMObjects As Object
WMObjects = oSearch.Execute
@@ -803,9 +805,7 @@ Public Class Windream
''' <remarks></remarks>
Public Function GetWMObjectForFile(ByVal WMPath As String) As WMObject
Try
If WMPath.StartsWith("\") = False And WMPath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
WMPath = WMPath.Substring(2)
End If
WMPath = NormalizePath(WMPath)
Dim oWMObject As WINDREAMLib.WMObject
Try
oWMObject = CurrentSession.GetWMObjectByPath(WINDREAMLib.WMEntity.WMEntityDocument, WMPath)
@@ -829,9 +829,7 @@ Public Class Windream
''' <remarks></remarks>
Public Function TestFolderExists(folderpath As String)
Try
If folderpath.StartsWith("\") = False And folderpath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
folderpath = folderpath.Substring(2)
End If
folderpath = NormalizePath(folderpath)
Try
Dim exists = CurrentSession.WMObjectExists(WMEntityFolder, folderpath, 0, 0)
Return exists
@@ -851,9 +849,7 @@ Public Class Windream
''' <remarks></remarks>
Public Function TestFileExists(ByVal WMPath As String)
Try
If WMPath.StartsWith("\") = False And WMPath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
WMPath = WMPath.Substring(2)
End If
WMPath = NormalizePath(WMPath)
Try
Dim WMObject As WINDREAMLib.WMObject = CurrentSession.GetWMObjectByPath(WINDREAMLib.WMEntity.WMEntityDocument, WMPath)
Catch ex As Exception
@@ -888,9 +884,7 @@ Public Class Windream
''' <remarks></remarks>
Public Function RemFile(ByVal WMPath As String)
Try
If WMPath.StartsWith("\") = False And WMPath.ToUpper.StartsWith(WMDriveLetter.ToUpper) Then
WMPath = WMPath.Substring(2)
End If
WMPath = NormalizePath(WMPath)
Dim oWMObject = GetWMObjectForFile(WMPath)
If IsNothing(oWMObject) = False Then
oWMObject.Delete()