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,10 +1,20 @@
Namespace Methods.GetFileObject
Imports System.Runtime.Serialization
Namespace Methods.GetFileObject
<Serializable>
Public Class FileObject
<DataMember>
Public Property ObjectId As Long
<DataMember>
Public Property AccessRights As String
<DataMember>
Public Property FileExtension As String
<DataMember>
Public Property FileHash As String
<DataMember>
Public Property FileSize As Long
<DataMember>
Public Property FileContents As Byte()
End Class
End Namespace

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

View File

@@ -6,6 +6,8 @@ Namespace Methods.GetFileObject
Public Class GetFileObjectRequest
<DataMember>
Public Property ObjectId As Long
<DataMember>
Public Property LoadFileContents As Boolean = False
End Class
End Namespace

View File

@@ -83,12 +83,12 @@ Public Class NewFileMethod
Dim oFileObjectInfo As IO.FileInfo = New IO.FileInfo(oFilePath)
Dim oFileObjectSize As Long = pData.File.FileContents.Length
Dim oFileObjectExtension As String = oFileObjectInfo.Extension.Substring(1)
Dim oFileObjectName As String = oFileObjectInfo.Name
Dim oOriginalExtension As String = pData.File.FileInfoRaw.Extension.Substring(1)
Logger.Debug("File Information for [{0}]:", oFileObjectName)
Logger.Debug("Size: [{0}]", oFileObjectSize)
Logger.Debug("Extension: [{0}]", oFileObjectExtension)
Logger.Debug("Original Extension: [{0}]", oOriginalExtension)
Logger.Debug("Checksum: [{0}]", pData.File.FileChecksum)
Try
@@ -110,7 +110,7 @@ Public Class NewFileMethod
Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO
'{oFinalPath}',
'{oFileObjectName}',
'{oFileObjectExtension}',
'{oOriginalExtension}',
{oFileObjectSize},
'{pData.File.FileChecksum}' ,
'{pData.User.UserName}',
@@ -218,6 +218,7 @@ Public Class NewFileMethod
End Function
Private Function GetFileObjectFileName(IDB_OBJ_ID As Long, pFilename As String, pKeepFilename As Boolean) As String
' TODO: save actual extensions
If pKeepFilename Then
Return pFilename
Else