set logEntireMessage to false to prevent outofmemory exception when importing multiple large files
This commit is contained in:
@@ -53,15 +53,17 @@ Public Class Document
|
||||
''' </summary>
|
||||
''' <param name="FilePath">The filename to import</param>
|
||||
''' <returns>A document object</returns>
|
||||
Public Function ImportFile(FilePath As String) As DocumentResult
|
||||
Public Async Function ImportFileAsync(FilePath As String, Optional [ReadOnly] As Boolean = False, Optional RetentionPeriod As Integer = 0) As Task(Of DocumentResult2)
|
||||
Try
|
||||
Dim oContents As Byte() = File.ReadAllBytes(FilePath)
|
||||
Dim oInfo As New FileInfo(FilePath)
|
||||
Dim oName As String = oInfo.Name
|
||||
Dim oExtension As String = oInfo.Extension.Substring(1)
|
||||
|
||||
Dim oDocObject = _channel.NewFile(oName, oContents)
|
||||
Return oDocObject
|
||||
Using oStream As New FileStream(FilePath, FileMode.Open)
|
||||
Dim oContents As Byte() = {}
|
||||
Dim oBytesRead = Await oStream.ReadAsync(oContents, 0, oStream.Length)
|
||||
Dim oResult = Await _channel.ImportFileAsync(oInfo, oContents, [ReadOnly], RetentionPeriod)
|
||||
|
||||
Return oResult
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
@@ -73,34 +75,11 @@ Public Class Document
|
||||
''' </summary>
|
||||
''' <param name="FilePath">The filename to import</param>
|
||||
''' <returns>A document object</returns>
|
||||
Public Async Function ImportFile2(FilePath As String, Optional [ReadOnly] As Boolean = False, Optional RetentionPeriod As Integer = -1) As Task(Of DocumentResult2)
|
||||
Public Function ImportFile(FilePath As String, Optional [ReadOnly] As Boolean = False, Optional RetentionPeriod As Integer = 0) As DocumentResult2
|
||||
Try
|
||||
Dim oContents As Byte() = File.ReadAllBytes(FilePath)
|
||||
Dim oInfo As New FileInfo(FilePath)
|
||||
Dim oName As String = oInfo.Name
|
||||
Dim oExtension As String = oInfo.Extension.Substring(1)
|
||||
|
||||
Dim oResult = Await _channel.ImportFileAsync(oInfo, oContents, [ReadOnly], RetentionPeriod)
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Imports a file by filename
|
||||
''' </summary>
|
||||
''' <param name="FilePath">The filename to import</param>
|
||||
''' <returns>A document object</returns>
|
||||
Public Async Function ImportFileAsync(FilePath As String) As Task(Of DocumentResult)
|
||||
Try
|
||||
Dim oContents As Byte() = File.ReadAllBytes(FilePath)
|
||||
Dim oInfo As New FileInfo(FilePath)
|
||||
Dim oName As String = oInfo.Name
|
||||
Dim oExtension As String = oInfo.Extension.Substring(1)
|
||||
|
||||
Dim oDocObject = Await _channel.NewFileAsync(oName, oContents)
|
||||
Dim oDocObject = _channel.ImportFile(oInfo, oContents, [ReadOnly], RetentionPeriod)
|
||||
Return oDocObject
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
@@ -108,45 +87,85 @@ Public Class Document
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function NewFileIndexAsync(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As Task(Of IndexResult)
|
||||
Try
|
||||
Dim oResult As IndexResult = Await _channel.NewFileIndexAsync(DocObject, Syskey, LanguageCode, Value)
|
||||
'''' <summary>
|
||||
'''' Imports a file by filename
|
||||
'''' </summary>
|
||||
'''' <param name="FilePath">The filename to import</param>
|
||||
'''' <returns>A document object</returns>
|
||||
'Public Function ImportFile(FilePath As String) As DocumentResult
|
||||
' Try
|
||||
' Dim oContents As Byte() = File.ReadAllBytes(FilePath)
|
||||
' Dim oInfo As New FileInfo(FilePath)
|
||||
' Dim oName As String = oInfo.Name
|
||||
' Dim oExtension As String = oInfo.Extension.Substring(1)
|
||||
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
' Dim oDocObject = _channel.NewFile(oName, oContents)
|
||||
' Return oDocObject
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Throw ex
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
Public Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult
|
||||
Try
|
||||
Dim oResult As IndexResult = _channel.NewFileIndex(DocObject, Syskey, LanguageCode, Value)
|
||||
'''' <summary>
|
||||
'''' Imports a file by filename
|
||||
'''' </summary>
|
||||
'''' <param name="FilePath">The filename to import</param>
|
||||
'''' <returns>A document object</returns>
|
||||
'Public Async Function ImportFileAsync(FilePath As String) As Task(Of DocumentResult)
|
||||
' Try
|
||||
' Dim oContents As Byte() = File.ReadAllBytes(FilePath)
|
||||
' Dim oInfo As New FileInfo(FilePath)
|
||||
' Dim oName As String = oInfo.Name
|
||||
' Dim oExtension As String = oInfo.Extension.Substring(1)
|
||||
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
' Dim oDocObject = Await _channel.NewFileAsync(oName, oContents)
|
||||
' Return oDocObject
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Throw ex
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
Public Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResult
|
||||
Try
|
||||
Return _channel.GetDocumentByDocumentId(DocumentId)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
'Public Async Function NewFileIndexAsync(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As Task(Of IndexResult)
|
||||
' Try
|
||||
' Dim oResult As IndexResult = Await _channel.NewFileIndexAsync(DocObject, Syskey, LanguageCode, Value)
|
||||
|
||||
Public Function GetDocumentByContainerId(ContainerId As String) As DocumentResult
|
||||
Try
|
||||
Return _channel.GetDocumentByContainerId(ContainerId)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
' Return oResult
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Throw ex
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
'Public Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult
|
||||
' Try
|
||||
' Dim oResult As IndexResult = _channel.NewFileIndex(DocObject, Syskey, LanguageCode, Value)
|
||||
|
||||
' Return oResult
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Throw ex
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
'Public Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResult
|
||||
' Try
|
||||
' Return _channel.GetDocumentByDocumentId(DocumentId)
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Throw ex
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
'Public Function GetDocumentByContainerId(ContainerId As String) As DocumentResult
|
||||
' Try
|
||||
' Return _channel.GetDocumentByContainerId(ContainerId)
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Throw ex
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
''' <summary>
|
||||
''' Aborts the channel and creates a new connection
|
||||
|
||||
Reference in New Issue
Block a user