EDMI: Bring Service and Client up to date

This commit is contained in:
Jonathan Jenne
2021-06-30 14:49:38 +02:00
parent a2374ce427
commit 6963505fe9
5 changed files with 114 additions and 108 deletions

View File

@@ -5,9 +5,12 @@ Imports System.ServiceModel
Imports System.IO
Public Class Client
Private Const INVALID_OBEJCT_ID As Long = 0
Private Const KIND_TYPE_DOC = "DOC"
Private ReadOnly _logger As Logger
Private ReadOnly _channelFactory As ChannelFactory(Of IEDMIServiceChannel)
Private _IPAddressServer As String
Private ReadOnly _IPAddressServer As String
Private _channel As IEDMIServiceChannel
Public Class StreamedFile
@@ -25,10 +28,10 @@ Public Class Client
End Class
''' <summary>
''' Creates a new EDMIAPI object
''' Creates a new EDMI Client object
''' </summary>
''' <param name="LogConfig">LogConfig object</param>
''' <param name="ServiceAdress">The full service url to connect to</param>
''' <param name="ServiceAdress">The full service url to connect to, for example: net.tcp://1.1.1.1:1111/some/path</param>
Public Sub New(LogConfig As LogConfig, ServiceAdress As String)
_logger = LogConfig.GetLogger()
@@ -43,6 +46,12 @@ Public Class Client
End Try
End Sub
''' <summary>
''' Creates a new EDMI Client object
''' </summary>
''' <param name="LogConfig">LogConfig object</param>
''' <param name="IPAddress">The IP address to connect to</param>
''' <param name="PortNumber">The Port number to use for the connection</param>
Public Sub New(LogConfig As LogConfig, IPAddress As String, PortNumber As Integer)
_logger = LogConfig.GetLogger()
@@ -79,34 +88,33 @@ Public Class Client
End Function
''' <summary>
''' Import options for NewFileAsync
''' Import options for NewFileAsync. Contains default values for all options
''' </summary>
Public Class ImportFileOptions
Public KeepExtension As Boolean
Public KeepExtension As Boolean = True
End Class
''' <summary>
''' TODO: Platzhalter
''' TODO: Creates a new object
''' </summary>
''' <returns></returns>
Public Async Function NewObjectAsync() As Task
Throw New NotImplementedException()
End Function
''' <summary>
''' Imports a file from a filepath, creating a IDB ObjectId and Filesystem Object
''' </summary>
''' <param name="pFilePath">Local filepath to a file.</param>
''' <param name="pWho">Windows username of the user responsible for the import.</param>
''' <param name="pWhen">Date when the file was imported. Can be in the past.</param>
''' <param name="pAddedWho">Windows username of the user responsible for the import.</param>
''' <param name="pAddedWhen">Date when the file was imported. Can be in the past.</param>
''' <param name="pObjectStoreType">Type of ObjectStore. Can be WORK or ARCHIVE.</param>
''' <param name="pBusinessEntity">Business entity that the new file object should belong to.</param>
''' <param name="ImportOptions">Other file import options</param>
''' <returns>The ObjectId of the newly generated filesystem object</returns>
''' <param name="pImportOptions">Other file import options</param>
''' <exception cref="FileNotFoundException">When local filepath was not found</exception>
''' <exception cref="ApplicationException">When there was a error in the Service</exception>
Public Async Function NewFileAsync(pFilePath As String, pWho As String, pWhen As Date, pObjectStoreType As String, pBusinessEntity As String, ImportOptions As ImportFileOptions) As Task(Of FileMeta)
Const oKindType = "DOC"
''' <returns>The ObjectId of the newly generated filesystem object</returns>
Public Async Function NewFileAsync(pFilePath As String, pAddedWho As String, pAddedWhen As Date, pObjectStoreType As String, pBusinessEntity As String, pImportOptions As ImportFileOptions) As Task(Of Long)
Try
If File.Exists(pFilePath) = False Then
Throw New FileNotFoundException("ImportFileAsync: Path does not exist")
@@ -117,8 +125,8 @@ Public Class Client
Dim oObjectIdResponse = Await _channel.NewObjectIdAsync(New NewObjectIdRequest With {
.BusinessEntity = pBusinessEntity,
.KindType = oKindType,
.Who = pWho
.KindType = KIND_TYPE_DOC,
.Who = pAddedWho
})
If oObjectIdResponse.ObjectId = Nothing OrElse oObjectIdResponse.ObjectId = 0 Then
@@ -126,9 +134,9 @@ Public Class Client
End If
Dim oFilePathResponse = Await _channel.NewFileObjectAsync(New NewFileObjectRequest With {
.DateImported = pWhen,
.DateImported = pAddedWhen,
.Extension = oExtension,
.KeepExtension = ImportOptions.KeepExtension,
.KeepExtension = pImportOptions.KeepExtension,
.ObjectId = oObjectIdResponse.ObjectId,
.StoreType = pObjectStoreType
})
@@ -146,7 +154,7 @@ Public Class Client
.FilePath = oFilePathResponse.FileObjectPath,
.ObjectId = oObjectIdResponse.ObjectId,
.ObjectStoreType = pObjectStoreType,
.Who = pWho,
.Who = pAddedWho,
.Contents = oContents
})
@@ -156,24 +164,20 @@ Public Class Client
End Using
End Using
Return New FileMeta With {
.ObjectId = oObjectIdResponse.ObjectId,
.FilePath = oFilePathResponse.FileObjectPath
}
Return oObjectIdResponse.ObjectId
Catch ex As Exception
_logger.Error(ex)
Return Nothing
Return INVALID_OBEJCT_ID
End Try
End Function
Public Function CreateObjectId(pKindType As String, pWho As String, pBusinessEntity As String) As Long
Try
Dim oArgs As New NewObjectIdRequest With {
Dim oResponse = _channel.NewObjectId(New NewObjectIdRequest With {
.KindType = pKindType,
.BusinessEntity = pBusinessEntity,
.Who = pWho
}
Dim oResponse = _channel.NewObjectId(oArgs)
})
Return oResponse.ObjectId
Catch ex As Exception
_logger.Error(ex)