2021-12-16 13:54:41 +01:00

44 lines
1.5 KiB
VB.net

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