EDMI.API: Improvements to NewFileAsync
This commit is contained in:
parent
f213a6b6ae
commit
dfb6e5cf5c
@ -7,7 +7,8 @@ Imports DigitalData.Modules.Language.Utils
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Client
|
||||
Private Const INVALID_OBEJCT_ID As Long = 0
|
||||
Public Const INVALID_OBEJCT_ID As Long = 0
|
||||
|
||||
Private Const KIND_TYPE_DOC = "DOC"
|
||||
|
||||
Private ReadOnly _logger As Logger
|
||||
@ -143,27 +144,33 @@ Public Class Client
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Import options for NewFileAsync. Contains default values for all options
|
||||
''' Import options for NewFileAsync.
|
||||
''' </summary>
|
||||
Public Class NewFileOptions
|
||||
Public KeepExtension As Boolean = True
|
||||
Public Username As String = String.Empty
|
||||
Public Language As String = String.Empty
|
||||
''' <summary>
|
||||
''' Option to keep the original extension when importing. Defaults to false.
|
||||
''' </summary>
|
||||
Public KeepExtension As Boolean = False
|
||||
''' <summary>
|
||||
''' Windows username of the user responsible for the import. Defaults to the currently logged in user.
|
||||
''' </summary>
|
||||
Public Username As String = Environment.UserName
|
||||
''' <summary>
|
||||
''' Date when the file was imported. Can be in the past. Defaults to now.
|
||||
''' </summary>
|
||||
Public DateImported As Date = Date.Now
|
||||
End Class
|
||||
|
||||
''' <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="pAddedWho">Windows username of the user responsible for the import.</param>
|
||||
''' <param name="pAddedWhen">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="pImportOptions">Other file import options</param>
|
||||
''' <exception cref="FileNotFoundException">When local filepath was not found</exception>
|
||||
''' <exception cref="ApplicationException">When there was a error in the Service</exception>
|
||||
''' <returns>The ObjectId of the newly generated filesystem object</returns>
|
||||
Public Async Function NewFileAsync(pFilePath As String, pAddedWho As String, pAddedWhen As Date, pObjectStoreType As String, pBusinessEntity As String, Optional pImportOptions As NewFileOptions = Nothing) As Task(Of Long)
|
||||
Public Async Function NewFileAsync(pFilePath As String, pObjectStoreType As String, pBusinessEntity As String, Optional pImportOptions As NewFileOptions = Nothing) As Task(Of Long)
|
||||
Try
|
||||
' Set default options
|
||||
If pImportOptions Is Nothing Then
|
||||
@ -182,7 +189,7 @@ Public Class Client
|
||||
Dim oObjectIdResponse = Await _channel.NewObjectIdAsync(New NewObjectIdRequest With {
|
||||
.BusinessEntity = pBusinessEntity,
|
||||
.KindType = KIND_TYPE_DOC,
|
||||
.Who = pAddedWho
|
||||
.Who = pImportOptions.Username
|
||||
})
|
||||
|
||||
If oObjectIdResponse.ObjectId = Nothing OrElse oObjectIdResponse.ObjectId = 0 Then
|
||||
@ -191,7 +198,7 @@ Public Class Client
|
||||
|
||||
' Create new FileObject for ObjectId
|
||||
Dim oFilePathResponse = Await _channel.NewFileObjectAsync(New NewFileObjectRequest With {
|
||||
.DateImported = pAddedWhen,
|
||||
.DateImported = pImportOptions.DateImported,
|
||||
.Extension = oExtension,
|
||||
.KeepExtension = pImportOptions.KeepExtension,
|
||||
.ObjectId = oObjectIdResponse.ObjectId,
|
||||
@ -212,7 +219,7 @@ Public Class Client
|
||||
.FilePath = oFilePathResponse.FileObjectPath,
|
||||
.ObjectId = oObjectIdResponse.ObjectId,
|
||||
.ObjectStoreType = pObjectStoreType,
|
||||
.Who = pAddedWho,
|
||||
.Who = pImportOptions.Username,
|
||||
.Contents = oContents
|
||||
})
|
||||
|
||||
@ -408,25 +415,6 @@ Public Class Client
|
||||
Where(Function(pRow As DataRow) pRow.Item("AttributeTitle") = pAttributeName).
|
||||
ToList()
|
||||
|
||||
If oVectorAttribute = False Then
|
||||
Dim oRow As DataRow = oRows.FirstOrDefault()
|
||||
Dim oType As String = oRow.Item("AttributeType")
|
||||
|
||||
Dim oValue = GetValueByType(oRow, oType)
|
||||
'oValues.Add(oValue)
|
||||
|
||||
Return New VariableValue(oValue)
|
||||
Else
|
||||
For Each oRow As DataRow In oRows
|
||||
Dim oType As String = oRow.Item("AttributeType")
|
||||
|
||||
Dim oValue = GetValueByType(oRow, oType)
|
||||
oValues.Add(oValue)
|
||||
Next
|
||||
|
||||
Return New VariableValue(oValues)
|
||||
End If
|
||||
|
||||
'If Not IsNothing(oAttributes) Then
|
||||
' If oVectorAttribute = True And _dummy_table_attributes.Rows.Count = 1 And pOptions.FromIDB = False Then
|
||||
' Try
|
||||
@ -466,6 +454,25 @@ Public Class Client
|
||||
'If oDatatable.Table.Rows.Count = 1 Then
|
||||
' oAttributeValue = oDatatable.Table.Rows.Item(0).Item(0)
|
||||
'End If
|
||||
|
||||
If oVectorAttribute = False Then
|
||||
Dim oRow As DataRow = oRows.FirstOrDefault()
|
||||
Dim oType As String = oRow.Item("AttributeType")
|
||||
|
||||
Dim oValue = GetValueByType(oRow, oType)
|
||||
'oValues.Add(oValue)
|
||||
|
||||
Return New VariableValue(oValue)
|
||||
Else
|
||||
For Each oRow As DataRow In oRows
|
||||
Dim oType As String = oRow.Item("AttributeType")
|
||||
|
||||
Dim oValue = GetValueByType(oRow, oType)
|
||||
oValues.Add(oValue)
|
||||
Next
|
||||
|
||||
Return New VariableValue(oValues)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user