EDMI: UpdateFile WIP
This commit is contained in:
@@ -6,11 +6,15 @@ Namespace Modules
|
||||
Friend ReadOnly LogConfig As LogConfig
|
||||
Friend ReadOnly Logger As Logger
|
||||
Friend ReadOnly Channel As IEDMIServiceChannel
|
||||
Friend ReadOnly FileEx As Filesystem.File
|
||||
Friend ReadOnly Helpers As Helpers
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pChannel As IEDMIServiceChannel)
|
||||
LogConfig = pLogConfig
|
||||
Logger = pLogConfig.GetLogger()
|
||||
Channel = pChannel
|
||||
FileEx = New Filesystem.File(pLogConfig)
|
||||
Helpers = New Helpers(pLogConfig)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
49
Modules.EDMIAPI/Modules/IDB/NewFile.vb
Normal file
49
Modules.EDMIAPI/Modules/IDB/NewFile.vb
Normal file
@@ -0,0 +1,49 @@
|
||||
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
|
||||
Namespace Modules.IDB
|
||||
Public Class NewFile
|
||||
Inherits BaseMethod
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pChannel As IEDMIServiceChannel)
|
||||
MyBase.New(pLogConfig, pChannel)
|
||||
End Sub
|
||||
|
||||
Public Async Function RunAsync(pFilePath As String, pObjectStoreName As String, pObjectKind As String, pBusinessEntity As String, Optional pOptions As Options.NewFileOptions = Nothing) As Task(Of Long)
|
||||
Try
|
||||
' Set default options
|
||||
If pOptions Is Nothing Then
|
||||
pOptions = New Options.NewFileOptions()
|
||||
End If
|
||||
|
||||
' Check if file exists
|
||||
If IO.File.Exists(pFilePath) = False Then
|
||||
Throw New IO.FileNotFoundException("Path does not exist")
|
||||
End If
|
||||
|
||||
' Importing the file now
|
||||
Dim oFileProperties = Helpers.GetFileProperties(pFilePath, pOptions.DateImported)
|
||||
Dim oFileImportResponse = Await Channel.NewFileAsync(New NewFileRequest With {
|
||||
.BusinessEntity = pBusinessEntity,
|
||||
.File = oFileProperties,
|
||||
.KindType = pObjectKind,
|
||||
.StoreName = pObjectStoreName,
|
||||
.User = New UserState With {
|
||||
.Language = pOptions.Language,
|
||||
.UserName = pOptions.Username
|
||||
}
|
||||
})
|
||||
|
||||
If oFileImportResponse.OK = False Then
|
||||
Throw New ApplicationException("Could not Import File Contents!")
|
||||
End If
|
||||
|
||||
Return oFileImportResponse.ObjectId
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Constants.INVALID_OBEJCT_ID
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
39
Modules.EDMIAPI/Modules/IDB/UpdateFile.vb
Normal file
39
Modules.EDMIAPI/Modules/IDB/UpdateFile.vb
Normal file
@@ -0,0 +1,39 @@
|
||||
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
|
||||
Imports DigitalData.Modules.EDMI.API.Options
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules.IDB
|
||||
Public Class UpdateFile
|
||||
Inherits BaseMethod
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pChannel As IEDMIServiceChannel)
|
||||
MyBase.New(pLogConfig, pChannel)
|
||||
End Sub
|
||||
|
||||
Public Async Function RunAsync(pFilePath As String, pObjectId As Long, Optional pOptions As UpdateFileOptions = Nothing) As Task
|
||||
' Set default options
|
||||
If pOptions Is Nothing Then
|
||||
pOptions = New UpdateFileOptions()
|
||||
End If
|
||||
|
||||
' Check if file exists
|
||||
If IO.File.Exists(pFilePath) = False Then
|
||||
Throw New IO.FileNotFoundException("Path does not exist")
|
||||
End If
|
||||
|
||||
' Importing the file now
|
||||
Dim oFileProperties = Helpers.GetFileProperties(pFilePath, Date.Now)
|
||||
'Dim oFileImportResponse = Await Channel.(New NewFileRequest With {
|
||||
' .BusinessEntity = pBusinessEntity,
|
||||
' .File = oFileProperties,
|
||||
' .KindType = pObjectKind,
|
||||
' .StoreName = pObjectStoreName,
|
||||
' .User = New UserState With {
|
||||
' .Language = pOptions.Language,
|
||||
' .UserName = pOptions.Username
|
||||
' }
|
||||
'})
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user