EDMIAPI: Encapsulate Zooflow and Globix methods into their own classes
This commit is contained in:
parent
952468a69b
commit
e41ceb83e6
@ -67,7 +67,7 @@ Public Class DocumentLoader
|
|||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function Load_FromZooflow(pObjectId As Long) As DocumentResultInfo
|
Private Function Load_FromZooflow(pObjectId As Long) As DocumentResultInfo
|
||||||
Dim oFileObject As FileObject = Client.GetFileObject(pObjectId, pLoadFileContents:=True)
|
Dim oFileObject As FileObject = Client.Zooflow_GetFileObject(pObjectId, pLoadFileContents:=True)
|
||||||
|
|
||||||
If oFileObject Is Nothing Then
|
If oFileObject Is Nothing Then
|
||||||
Return Nothing
|
Return Nothing
|
||||||
|
|||||||
@ -25,6 +25,7 @@ Public Class DocumentResultInfo
|
|||||||
' Optional properties
|
' Optional properties
|
||||||
Public Property LastWriteTime As Date = Nothing
|
Public Property LastWriteTime As Date = Nothing
|
||||||
Public Property FullPath As String = Nothing
|
Public Property FullPath As String = Nothing
|
||||||
|
Public Property TempPath As String = Nothing
|
||||||
|
|
||||||
Public Sub New(pPrimaryKey As Long)
|
Public Sub New(pPrimaryKey As Long)
|
||||||
Id = pPrimaryKey
|
Id = pPrimaryKey
|
||||||
|
|||||||
@ -60,6 +60,7 @@ Public Class frmDocumentResultList
|
|||||||
Private _ActiveGrid As GridControl = Nothing
|
Private _ActiveGrid As GridControl = Nothing
|
||||||
Private _ActiveGridBand As GridBand = Nothing
|
Private _ActiveGridBand As GridBand = Nothing
|
||||||
Private _documentloader As DocumentLoader
|
Private _documentloader As DocumentLoader
|
||||||
|
Private _tempDocuments As New List(Of DocumentResultList)
|
||||||
|
|
||||||
' TODO: Hashes for checking if the opened file was modified externally
|
' TODO: Hashes for checking if the opened file was modified externally
|
||||||
'Private _HashOriginalFile As String = Nothing
|
'Private _HashOriginalFile As String = Nothing
|
||||||
|
|||||||
@ -765,7 +765,7 @@ Public Class frmGlobix_Index
|
|||||||
|
|
||||||
Logger.Info("Running Import")
|
Logger.Info("Running Import")
|
||||||
|
|
||||||
Dim oResult = Await My.Application.Service.Client.ImportFileAsync(
|
Dim oResult = Await My.Application.Service.Client.Globix_ImportFileAsync(
|
||||||
oFilePath, oProfileId, oAttributes, oObjectStore, oObjectKind, oBusinessEntity, oOptions)
|
oFilePath, oProfileId, oAttributes, oObjectStore, oObjectKind, oBusinessEntity, oOptions)
|
||||||
|
|
||||||
Logger.Info("Import result: [{0}]", oResult.OK)
|
Logger.Info("Import result: [{0}]", oResult.OK)
|
||||||
|
|||||||
@ -37,11 +37,11 @@ Public Class frmtest
|
|||||||
|
|
||||||
|
|
||||||
Private Async Sub btnImportFile_Click_(sender As Object, e As EventArgs) Handles btnImportFile.Click
|
Private Async Sub btnImportFile_Click_(sender As Object, e As EventArgs) Handles btnImportFile.Click
|
||||||
Dim oResponse As ImportFileResponse = Await My.Application.Service.Client.ImportFileAsync(
|
Dim oResponse As ImportFileResponse = Await My.Application.Service.Client.Globix_ImportFileAsync(
|
||||||
txtFile2Import.Text,
|
txtFile2Import.Text,
|
||||||
txtProfileId.Text,
|
txtProfileId.Text,
|
||||||
New List(Of EDMIServiceReference.UserAttributeValue) From {
|
New List(Of UserAttributeValue) From {
|
||||||
New EDMIServiceReference.UserAttributeValue With {
|
New UserAttributeValue With {
|
||||||
.Name = "Attribut String1",
|
.Name = "Attribut String1",
|
||||||
.Values = New List(Of String) From {"SchreiberM"}.ToArray
|
.Values = New List(Of String) From {"SchreiberM"}.ToArray
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,6 @@ Imports DigitalData.Modules.Logging
|
|||||||
|
|
||||||
Public Class Client
|
Public Class Client
|
||||||
Public Const INVALID_OBEJCT_ID As Long = 0
|
Public Const INVALID_OBEJCT_ID As Long = 0
|
||||||
|
|
||||||
Private Const KIND_TYPE_DOC = "DOC"
|
Private Const KIND_TYPE_DOC = "DOC"
|
||||||
|
|
||||||
Private ReadOnly _LogConfig As LogConfig
|
Private ReadOnly _LogConfig As LogConfig
|
||||||
@ -16,10 +15,8 @@ Public Class Client
|
|||||||
Private ReadOnly _channelFactory As ChannelFactory(Of IEDMIServiceChannel)
|
Private ReadOnly _channelFactory As ChannelFactory(Of IEDMIServiceChannel)
|
||||||
Private ReadOnly _IPAddressServer As String
|
Private ReadOnly _IPAddressServer As String
|
||||||
Private ReadOnly _PortServer As Integer
|
Private ReadOnly _PortServer As Integer
|
||||||
|
Private ReadOnly _FileEx As Filesystem.File
|
||||||
Private _dummy_table_attributes As DataTable
|
|
||||||
Private _channel As IEDMIServiceChannel
|
Private _channel As IEDMIServiceChannel
|
||||||
Private _FileEx As Filesystem.File
|
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Creates a new EDMI Client object
|
''' Creates a new EDMI Client object
|
||||||
@ -184,71 +181,24 @@ Public Class Client
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Async Function ImportFileAsync(
|
Public Async Function Globix_ImportFileAsync(
|
||||||
pFilePath As String,
|
pFilePath As String,
|
||||||
pProfileId As Integer,
|
pProfileId As Integer,
|
||||||
pAttributeValues As List(Of UserAttributeValue),
|
pAttributeValues As List(Of UserAttributeValue),
|
||||||
pObjectStoreName As String,
|
pObjectStoreName As String,
|
||||||
pObjectKind As String,
|
pObjectKind As String,
|
||||||
pBusinessEntity As String,
|
pBusinessEntity As String,
|
||||||
Optional pImportOptions As Options.ImportFileOptions = Nothing
|
Optional pImportOptions As Options.ImportFileOptions = Nothing) As Task(Of ImportFileResponse)
|
||||||
) As Task(Of ImportFileResponse)
|
|
||||||
Try
|
Try
|
||||||
' Set default options
|
Dim oImportFile As New Modules.Globix.ImportFile(_LogConfig, _channel)
|
||||||
If pImportOptions Is Nothing Then
|
Return Await oImportFile.RunAsync(pFilePath, pProfileId, pAttributeValues, pObjectStoreName, pObjectKind, pBusinessEntity, pImportOptions)
|
||||||
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
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End Try
|
End Try
|
||||||
End Function
|
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
|
Try
|
||||||
Dim oGetFileObject As New Modules.Zooflow.GetFileObject(_LogConfig, _channel)
|
Dim oGetFileObject As New Modules.Zooflow.GetFileObject(_LogConfig, _channel)
|
||||||
Dim oFileObject = oGetFileObject.Run(pObjectId, pLoadFileContents)
|
Dim oFileObject = oGetFileObject.Run(pObjectId, pLoadFileContents)
|
||||||
|
|||||||
@ -76,6 +76,8 @@
|
|||||||
<Compile Include="Client\Options.vb" />
|
<Compile Include="Client\Options.vb" />
|
||||||
<Compile Include="Client\Rights.vb" />
|
<Compile Include="Client\Rights.vb" />
|
||||||
<Compile Include="Client\Channel.vb" />
|
<Compile Include="Client\Channel.vb" />
|
||||||
|
<Compile Include="Modules\BaseMethod.vb" />
|
||||||
|
<Compile Include="Modules\Globix\ImportFile.vb" />
|
||||||
<Compile Include="Modules\ZooFlow\GetFileObject.vb" />
|
<Compile Include="Modules\ZooFlow\GetFileObject.vb" />
|
||||||
<Compile Include="Connected Services\EDMIServiceReference\Reference.vb">
|
<Compile Include="Connected Services\EDMIServiceReference\Reference.vb">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
@ -245,5 +247,6 @@
|
|||||||
<LastGenOutput>Reference.vb</LastGenOutput>
|
<LastGenOutput>Reference.vb</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
17
Modules.EDMIAPI/Modules/BaseMethod.vb
Normal file
17
Modules.EDMIAPI/Modules/BaseMethod.vb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
|
Namespace Modules
|
||||||
|
Public Class BaseMethod
|
||||||
|
Friend ReadOnly LogConfig As LogConfig
|
||||||
|
Friend ReadOnly Logger As Logger
|
||||||
|
Friend ReadOnly Channel As IEDMIServiceChannel
|
||||||
|
|
||||||
|
Public Sub New(pLogConfig As LogConfig, pChannel As IEDMIServiceChannel)
|
||||||
|
LogConfig = pLogConfig
|
||||||
|
Logger = pLogConfig.GetLogger()
|
||||||
|
Channel = pChannel
|
||||||
|
End Sub
|
||||||
|
End Class
|
||||||
|
|
||||||
|
End Namespace
|
||||||
78
Modules.EDMIAPI/Modules/Globix/ImportFile.vb
Normal file
78
Modules.EDMIAPI/Modules/Globix/ImportFile.vb
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
Imports System.IO
|
||||||
|
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
|
Namespace Modules.Globix
|
||||||
|
Public Class ImportFile
|
||||||
|
Inherits BaseMethod
|
||||||
|
Private ReadOnly FileEx As Filesystem.File
|
||||||
|
|
||||||
|
Public Sub New(pLogConfig As LogConfig, pChannel As IEDMIServiceChannel)
|
||||||
|
MyBase.New(pLogConfig, pChannel)
|
||||||
|
FileEx = New Filesystem.File(pLogConfig)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Async Function RunAsync(pFilePath As String,
|
||||||
|
pProfileId As Integer,
|
||||||
|
pAttributeValues As List(Of UserAttributeValue),
|
||||||
|
pObjectStoreName As String,
|
||||||
|
pObjectKind As String,
|
||||||
|
pBusinessEntity As String,
|
||||||
|
pImportOptions As Options.ImportFileOptions) 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
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return Nothing
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
|
End Namespace
|
||||||
|
|
||||||
@ -3,14 +3,10 @@ Imports DigitalData.Modules.Logging
|
|||||||
|
|
||||||
Namespace Modules.Zooflow
|
Namespace Modules.Zooflow
|
||||||
Public Class GetFileObject
|
Public Class GetFileObject
|
||||||
Private ReadOnly LogConfig As LogConfig
|
Inherits BaseMethod
|
||||||
Private ReadOnly Logger As Logger
|
|
||||||
Private ReadOnly Channel As IEDMIServiceChannel
|
|
||||||
|
|
||||||
Public Sub New(pLogConfig As LogConfig, pChannel As IEDMIServiceChannel)
|
Public Sub New(pLogConfig As LogConfig, pChannel As IEDMIServiceChannel)
|
||||||
LogConfig = pLogConfig
|
MyBase.New(pLogConfig, pChannel)
|
||||||
Logger = pLogConfig.GetLogger()
|
|
||||||
Channel = pChannel
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Async Function RunAsync(pObjectId As Long, pLoadFileContents As Boolean) As Task(Of FileObject)
|
Public Async Function RunAsync(pObjectId As Long, pLoadFileContents As Boolean) As Task(Of FileObject)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user