EDMIAPI: Encapsulate Zooflow and Globix methods into their own classes
This commit is contained in:
@@ -8,7 +8,6 @@ Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Client
|
||||
Public Const INVALID_OBEJCT_ID As Long = 0
|
||||
|
||||
Private Const KIND_TYPE_DOC = "DOC"
|
||||
|
||||
Private ReadOnly _LogConfig As LogConfig
|
||||
@@ -16,10 +15,8 @@ Public Class Client
|
||||
Private ReadOnly _channelFactory As ChannelFactory(Of IEDMIServiceChannel)
|
||||
Private ReadOnly _IPAddressServer As String
|
||||
Private ReadOnly _PortServer As Integer
|
||||
|
||||
Private _dummy_table_attributes As DataTable
|
||||
Private ReadOnly _FileEx As Filesystem.File
|
||||
Private _channel As IEDMIServiceChannel
|
||||
Private _FileEx As Filesystem.File
|
||||
|
||||
''' <summary>
|
||||
''' Creates a new EDMI Client object
|
||||
@@ -184,71 +181,24 @@ Public Class Client
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function ImportFileAsync(
|
||||
pFilePath As String,
|
||||
pProfileId As Integer,
|
||||
pAttributeValues As List(Of UserAttributeValue),
|
||||
pObjectStoreName As String,
|
||||
pObjectKind As String,
|
||||
pBusinessEntity As String,
|
||||
Optional pImportOptions As Options.ImportFileOptions = Nothing
|
||||
) As Task(Of ImportFileResponse)
|
||||
Public Async Function Globix_ImportFileAsync(
|
||||
pFilePath As String,
|
||||
pProfileId As Integer,
|
||||
pAttributeValues As List(Of UserAttributeValue),
|
||||
pObjectStoreName As String,
|
||||
pObjectKind As String,
|
||||
pBusinessEntity As String,
|
||||
Optional pImportOptions As Options.ImportFileOptions = Nothing) As Task(Of ImportFileResponse)
|
||||
Try
|
||||
' Set default options
|
||||
If pImportOptions Is Nothing Then
|
||||
pImportOptions = New Options.ImportFileOptions()
|
||||
End If
|
||||
|
||||
' Check if file exists
|
||||
If File.Exists(pFilePath) = False Then
|
||||
Throw New FileNotFoundException("Path does not exist")
|
||||
End If
|
||||
|
||||
Dim oFileInfo As New FileInfo(pFilePath)
|
||||
Dim oExtension As String = oFileInfo.Extension
|
||||
|
||||
Dim oFileName As String = oFileInfo.Name
|
||||
Dim oFileCreatedAt As Date = oFileInfo?.CreationTime
|
||||
Dim oFileModifiedAt As Date = oFileInfo?.LastWriteTime
|
||||
Dim oFileHash As String = _FileEx.GetChecksum(oFileInfo.FullName)
|
||||
|
||||
' Importing the file now
|
||||
Using oFileStream As New FileStream(pFilePath, FileMode.Open, FileAccess.Read)
|
||||
Using oMemoryStream As New MemoryStream()
|
||||
oFileStream.CopyTo(oMemoryStream)
|
||||
Dim oContents = oMemoryStream.ToArray()
|
||||
|
||||
Dim oFileImportResponse = Await _channel.ImportFileAsync(New ImportFileRequest With {
|
||||
.BusinessEntity = pBusinessEntity,
|
||||
.File = New FileProperties With {
|
||||
.FileName = oFileInfo.Name,
|
||||
.FileCreatedAt = oFileCreatedAt,
|
||||
.FileChangedAt = oFileModifiedAt,
|
||||
.FileContents = oContents,
|
||||
.FileImportedAt = pImportOptions.DateImported,
|
||||
.FileChecksum = oFileHash,
|
||||
.FileInfoRaw = oFileInfo
|
||||
},
|
||||
.KindType = pObjectKind,
|
||||
.StoreName = pObjectStoreName,
|
||||
.User = New UserState() With {
|
||||
.UserName = pImportOptions.Username,
|
||||
.Language = pImportOptions.Language
|
||||
},
|
||||
.ProfileId = pProfileId,
|
||||
.AttributeValues = pAttributeValues.ToArray
|
||||
})
|
||||
|
||||
Return oFileImportResponse
|
||||
End Using
|
||||
End Using
|
||||
Dim oImportFile As New Modules.Globix.ImportFile(_LogConfig, _channel)
|
||||
Return Await oImportFile.RunAsync(pFilePath, pProfileId, pAttributeValues, pObjectStoreName, pObjectKind, pBusinessEntity, pImportOptions)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFileObject(pObjectId As Long, pLoadFileContents As Boolean) As FileObject
|
||||
Public Function Zooflow_GetFileObject(pObjectId As Long, pLoadFileContents As Boolean) As FileObject
|
||||
Try
|
||||
Dim oGetFileObject As New Modules.Zooflow.GetFileObject(_LogConfig, _channel)
|
||||
Dim oFileObject = oGetFileObject.Run(pObjectId, pLoadFileContents)
|
||||
|
||||
Reference in New Issue
Block a user