EDMI: Method NewFileAsync Improvements
This commit is contained in:
@@ -78,20 +78,38 @@ Public Class Client
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Import options for NewFileAsync
|
||||
''' </summary>
|
||||
Public Class ImportFileOptions
|
||||
Public KeepExtension As Boolean
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' Imports a file by filename
|
||||
''' TODO: Platzhalter
|
||||
''' </summary>
|
||||
''' <returns>A document object</returns>
|
||||
Public Async Function ImportFileAsync(pFilePath As String, pWho As String, pWhen As Date, pObjectStoreType As String, pObjectStoreId As Long, pBusinessEntity As String, ImportOptions As ImportFileOptions) As Task(Of String)
|
||||
'pObjectId As Long, pStoreType As String, pDate As String, pExtension As String, pKeepExtension As String
|
||||
Dim oKindType = "DOC"
|
||||
''' <returns></returns>
|
||||
Public Async Function NewObjectAsync() As Task
|
||||
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="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>
|
||||
''' <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 Long)
|
||||
Const oKindType = "DOC"
|
||||
|
||||
Try
|
||||
If File.Exists(pFilePath) = False Then
|
||||
Throw New ApplicationException("ImportFileAsync: Path does not exist")
|
||||
Throw New FileNotFoundException("ImportFileAsync: Path does not exist")
|
||||
End If
|
||||
|
||||
Dim oFileInfo As New FileInfo(pFilePath)
|
||||
@@ -125,10 +143,10 @@ Public Class Client
|
||||
Dim oContents = oMemoryStream.ToArray()
|
||||
|
||||
Dim oFileImportResponse = Await _channel.ImportFileIntoFileObjectAsync(New ImportFileIntoFileObjectRequest With {
|
||||
.pIDBFilePath = oFilePathResponse.FileObjectPath,
|
||||
.pIDB_OBJ_ID = oObjectIdResponse.ObjectId,
|
||||
.pObjectStoreID = pObjectStoreId,
|
||||
.pWho = pWho,
|
||||
.FilePath = oFilePathResponse.FileObjectPath,
|
||||
.ObjectId = oObjectIdResponse.ObjectId,
|
||||
.ObjectStoreType = pObjectStoreType,
|
||||
.Who = pWho,
|
||||
.Contents = oContents
|
||||
})
|
||||
|
||||
@@ -138,39 +156,12 @@ Public Class Client
|
||||
End Using
|
||||
End Using
|
||||
|
||||
Return oFilePathResponse.FileObjectPath
|
||||
Return oObjectIdResponse.ObjectId
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
'Public Async Function ImportFileAsync(FilePath As String, DocumentType As String, ObjectStoreId As Long, Optional RetentionDays As Integer = 0) As Task(Of Long)
|
||||
' Try
|
||||
' Dim oFileInfo As New FileInfo(FilePath)
|
||||
' If oFileInfo.Exists = False Then
|
||||
' Throw New FileNotFoundException("Cannot import non-existing file.", FilePath)
|
||||
' End If
|
||||
|
||||
' Using oStream As New FileStream(FilePath, FileMode.Open)
|
||||
' Dim oContents(oStream.Length) As Byte
|
||||
' Dim oBytesRead = Await oStream.ReadAsync(oContents, 0, oStream.Length)
|
||||
' Dim oData As New DocumentImportRequest() With {
|
||||
' .FileName = oFileInfo.Name,
|
||||
' .Contents = oContents,
|
||||
' .DocumentType = DocumentType,
|
||||
' .ObjectStoreId = ObjectStoreId,
|
||||
' .RetentionDays = RetentionDays
|
||||
' }
|
||||
|
||||
' Dim oResponse = Await _channel.ImportFileAsync(oData)
|
||||
|
||||
' Return oResponse.ObjectId
|
||||
' End Using
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Throw ex
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
Public Function CreateObjectId(pKindType As String, pWho As String, pBusinessEntity As String) As Long
|
||||
Try
|
||||
@@ -209,14 +200,14 @@ Public Class Client
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function ImportFileObjectAsync(pContent As Byte(), pWho As String, pObjectId As Long, pObjectStoreID As Short, pFileObjectPath As String) As Task(Of Boolean)
|
||||
Public Async Function ImportFileObjectAsync(pContent As Byte(), pWho As String, pObjectId As Long, pObjectStoreType As String, pFileObjectPath As String) As Task(Of Boolean)
|
||||
Try
|
||||
Dim oData As New ImportFileIntoFileObjectRequest() With {
|
||||
.Contents = pContent,
|
||||
.pWho = pWho,
|
||||
.pIDBFilePath = pFileObjectPath,
|
||||
.pIDB_OBJ_ID = pObjectId,
|
||||
.pObjectStoreID = pObjectStoreID
|
||||
.Who = pWho,
|
||||
.FilePath = pFileObjectPath,
|
||||
.ObjectId = pObjectId,
|
||||
.ObjectStoreType = pObjectStoreType
|
||||
}
|
||||
|
||||
Dim oResponse = Await _channel.ImportFileIntoFileObjectAsync(oData)
|
||||
|
||||
Reference in New Issue
Block a user