EDMI: First version of Updating files by replacing them!
This commit is contained in:
@@ -10,29 +10,43 @@ Namespace Modules.IDB
|
||||
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
|
||||
Public Async Function RunAsync(pFilePath As String, pObjectId As Long, Optional pOptions As UpdateFileOptions = Nothing) As Task(Of Long)
|
||||
Try
|
||||
' 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
|
||||
' 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
|
||||
' }
|
||||
'})
|
||||
' Importing the file now
|
||||
Dim oFileProperties = Helpers.GetFileProperties(pFilePath, Date.Now)
|
||||
|
||||
|
||||
Dim oUpdateFileResponse = Await Channel.UpdateFileAsync(New UpdateFileRequest With {
|
||||
.File = oFileProperties,
|
||||
.ObjectId = pObjectId,
|
||||
.CreateNewVersion = pOptions.CreateNewFileVersion,
|
||||
.User = New UserState With {
|
||||
.Language = pOptions.Language,
|
||||
.UserName = pOptions.Username
|
||||
}
|
||||
})
|
||||
|
||||
If oUpdateFileResponse.OK = False Then
|
||||
Throw New ApplicationException("Could not Import File Contents!")
|
||||
End If
|
||||
|
||||
Return oUpdateFileResponse.ObjectId
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Constants.INVALID_OBEJCT_ID
|
||||
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user