EDMIService: Add GetFileObject Method
This commit is contained in:
10
Service.EDMIService/Methods/GetFileObject/FileObject.vb
Normal file
10
Service.EDMIService/Methods/GetFileObject/FileObject.vb
Normal 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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user