Compare commits
3 Commits
fd22b6a3bf
...
dfb6e5cf5c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfb6e5cf5c | ||
|
|
f213a6b6ae | ||
|
|
2bd253d4f5 |
@@ -102,7 +102,7 @@ Public Class frmtest
|
||||
cmbObjectStoreType.Text,
|
||||
"DEFAULT",
|
||||
New Client.NewFileOptions With {
|
||||
.KeepExtension = True
|
||||
.KeepExtension = CheckBoxKeepExtension.Checked
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -506,7 +506,7 @@ Public Class EDMIService
|
||||
oStoreType = ClassConstants.FileStoreWork
|
||||
End If
|
||||
|
||||
Dim oRelpath As String = GetFileStorePraefix(oStoreType)
|
||||
Dim oBasePath As String = GetFileStorePraefix(oStoreType)
|
||||
Dim oSubDirectory As String
|
||||
|
||||
If IsNothing(Data.DateImported) Then
|
||||
@@ -517,21 +517,23 @@ Public Class EDMIService
|
||||
|
||||
_Logger.Debug("Subdirectory is [{0}]", oSubDirectory)
|
||||
|
||||
oRelpath = Path.Combine(oRelpath, oSubDirectory)
|
||||
Dim oFinalPath = Path.Combine(oBasePath, oSubDirectory)
|
||||
|
||||
If Not Directory.Exists(oRelpath) Then
|
||||
If Not Directory.Exists(oFinalPath) Then
|
||||
Try
|
||||
_Logger.Debug("Path does not exist, creating: [{0}]", oRelpath)
|
||||
Directory.CreateDirectory(oRelpath)
|
||||
_Logger.Debug("Created folder [{0}]", oRelpath)
|
||||
_Logger.Debug("Path does not exist, creating: [{0}]", oFinalPath)
|
||||
Directory.CreateDirectory(oFinalPath)
|
||||
_Logger.Debug("Created folder [{0}]", oFinalPath)
|
||||
Catch ex As Exception
|
||||
Throw GetFault(ex)
|
||||
End Try
|
||||
End If
|
||||
|
||||
_Logger.Debug("Relative Path is [{0}]", oRelpath)
|
||||
_Logger.Debug("Final Directory is [{0}]", oFinalPath)
|
||||
|
||||
Dim oFileObjectPath As String = Path.Combine(oRelpath, GetFileObjectFileName(Data.ObjectId, Data.Extension, Data.KeepExtension))
|
||||
Dim oFileName As String = GetFileObjectFileName(Data.ObjectId, Data.Extension, Data.KeepExtension)
|
||||
|
||||
Dim oFileObjectPath As String = Path.Combine(oFinalPath, oFileName)
|
||||
_Logger.Debug("Final Path is [{0}]", oFileObjectPath)
|
||||
|
||||
Return New NewFileObjectResponse With {.FileObjectPath = oFileObjectPath}
|
||||
@@ -562,8 +564,8 @@ Public Class EDMIService
|
||||
oStream.Close()
|
||||
End Using
|
||||
|
||||
' insert into db
|
||||
Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO '{Data.FilePath}','{Data.Who}','{Data.ObjectId}',{oObjectStore.Id}"
|
||||
' Insert into DB
|
||||
Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO '{Data.FilePath}',{Data.Contents.Length},'{Data.Who}','{Data.ObjectId}',{oObjectStore.Id}"
|
||||
Dim oResult As Boolean = MSSQL_IDB.ExecuteNonQuery(oSQL)
|
||||
|
||||
Return New ImportFileIntoFileObjectResponse() With {.Result = oResult}
|
||||
|
||||
Reference in New Issue
Block a user