EDMIService: Add GetFileObject Method

This commit is contained in:
Jonathan Jenne
2021-12-16 13:54:41 +01:00
parent fc9720326e
commit ff60623130
7 changed files with 99 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
Namespace Methods.GetFileObject
<Serializable>
Public Class FileObject
Public Property ObjectId As Long
Public Property AccessRights As String
Public Property FileHash As String
Public Property FileSize As Long
End Class
End Namespace

View File

@@ -0,0 +1,44 @@
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Language
Namespace Methods.GetFileObject
Public Class GetFileObjectMethod
Inherits BaseMethod
Public Sub New(pLogConfig As LogConfig, pMSSQLServer As MSSQLServer, pGlobalState As GlobalState)
MyBase.New(pLogConfig, pMSSQLServer, pGlobalState)
End Sub
Public Function Run(pData As GetFileObjectRequest) As GetFileObjectResponse
Try
If Helpers.TestObjectIdExists(pData.ObjectId) = False Then
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)
If oTable Is Nothing OrElse oTable.Rows.Count = 0 Then
LogAndThrow("Error while getting FileObject data!")
End If
Dim oRow As DataRow = oTable.First()
Dim oFileObject As New FileObject With {
.ObjectId = pData.ObjectId,
.FileHash = oRow.ItemEx("FILE_HASH", ""),
.FileSize = oRow.ItemEx(Of Long)("FILE_SIZE", 0)
}
Return New GetFileObjectResponse(oFileObject)
Catch ex As Exception
Logger.Error(ex)
Return New GetFileObjectResponse(ex)
End Try
End Function
End Class
End Namespace

View File

@@ -0,0 +1,12 @@
Imports System.Runtime.Serialization
Namespace Methods.GetFileObject
<Serializable>
<DataContract>
Public Class GetFileObjectRequest
<DataMember>
Public Property ObjectId As Long
End Class
End Namespace

View File

@@ -0,0 +1,21 @@
Imports System.Runtime.Serialization
Namespace Methods.GetFileObject
<Serializable>
<DataContract>
Public Class GetFileObjectResponse
Inherits Messages.BaseResponse
<DataMember>
Public Property FileObject As FileObject
Public Sub New(pFileObject As FileObject)
MyBase.New()
FileObject = pFileObject
End Sub
Public Sub New(pException As Exception, Optional pDetails As String = "")
MyBase.New(pException, pDetails)
End Sub
End Class
End Namespace