EDMIService: Update client and fix wrnog extension at import

This commit is contained in:
Jonathan Jenne
2021-12-17 10:25:14 +01:00
parent 977fff6999
commit cb00685085
14 changed files with 443 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Language
Imports System.IO
Namespace Methods.GetFileObject
Public Class GetFileObjectMethod
@@ -16,7 +17,6 @@ Namespace Methods.GetFileObject
LogAndThrow("ObjectId does not exist!")
End If
Dim oSQL = $"SELECT * FROM VWIDB_FILE_OBJECT WHERE IDB_OBJ_ID = {pData.ObjectId}"
Dim oTable = Database.GetDatatable(oSQL)
@@ -25,20 +25,64 @@ Namespace Methods.GetFileObject
End If
Dim oRow As DataRow = oTable.First()
Dim oFileHash As String = oRow.ItemEx("FILE_HASH", "")
Dim oFileSize As Long = oRow.ItemEx(Of Long)("FILE_SIZE", 0)
Dim oFileObject As New FileObject With {
.ObjectId = pData.ObjectId,
.FileHash = oRow.ItemEx("FILE_HASH", ""),
.FileSize = oRow.ItemEx(Of Long)("FILE_SIZE", 0)
.FileHash = oFileHash,
.FileSize = oFileSize
}
If pData.LoadFileContents = True Then
Dim oFilePath = oRow.ItemEx("RELPATH", "")
Dim oFileName = oRow.ItemEx("Filename", "")
Dim oFullFileName = Path.Combine(oFilePath, oFileName)
If File.Exists(oFullFileName) = False Then
Throw New FileNotFoundException("FileObject not Found!", oFullFileName)
End If
Dim oContents As Byte() = LoadFileContents(oFullFileName)
If oContents Is Nothing Then
Throw New FileNotFoundException("FileObject not Found!", oFullFileName)
End If
oFileObject.FileContents = oContents
End If
Return New GetFileObjectResponse(oFileObject)
Catch ex As FileNotFoundException
Logger.Error(ex)
Return New GetFileObjectResponse(ex, ex.FileName)
Catch ex As Exception
Logger.Error(ex)
Return New GetFileObjectResponse(ex)
End Try
End Function
Private Function LoadFileContents(pFilePath As String) As Byte()
Try
Using oFileStream As New FileStream(pFilePath, FileMode.Open, FileAccess.Read)
Using oMemoryStream As New MemoryStream()
oFileStream.CopyTo(oMemoryStream)
Dim oContents = oMemoryStream.ToArray()
Return oContents
End Using
End Using
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function
End Class
End Namespace