EDMIServer: Move creating new objects into helpers class
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Database.MSSQLServer
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.EDMI.API.Client
|
||||
@@ -72,6 +73,87 @@ Namespace IDB
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function TestFileChecksumExists(pChecksum As String) As Long
|
||||
Try
|
||||
Dim oChecksumSQL = $"SELECT IDB_OBJ_ID FROM TBIDB_FILE_OBJECT WHERE FILE_HASH = '{pChecksum}'"
|
||||
Dim oExistingObjectId As Long = Database.GetScalarValue(oChecksumSQL)
|
||||
|
||||
If oExistingObjectId > 0 Then
|
||||
Logger.Info("Returning early with ObjectId [{0}] because Checksum [{1}] already exists.", oExistingObjectId, pChecksum)
|
||||
Return oExistingObjectId
|
||||
End If
|
||||
|
||||
Return Nothing
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function NewObjectId(pKindType As String, pBusinessEntity As String, pWho As String) As Long
|
||||
Try
|
||||
Dim oNewObjectIdSQL = $"DECLARE @NEW_IDB_OBJ_ID BIGINT
|
||||
EXEC PRIDB_NEW_OBJECT '{pKindType}','{pWho}','{pBusinessEntity}',0, @IDB_OBJ_ID = @NEW_IDB_OBJ_ID OUTPUT;
|
||||
SELECT @NEW_IDB_OBJ_ID"
|
||||
Dim oObjectId As Long = Database.GetScalarValue(oNewObjectIdSQL)
|
||||
|
||||
Logger.Info("New Object with Id [{0}] created!", oObjectId)
|
||||
|
||||
If IsNothing(oObjectId) Then
|
||||
LogAndThrow("Could not create new ObjectId!")
|
||||
End If
|
||||
|
||||
Return oObjectId
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function NewObjectIdWithTransaction(pKindType As String, pBusinessEntity As String, pWho As String, pConnection As SqlConnection, pTransaction As SqlTransaction) As Long
|
||||
Try
|
||||
Dim oNewObjectIdSQL = $"DECLARE @NEW_IDB_OBJ_ID BIGINT
|
||||
EXEC PRIDB_NEW_OBJECT '{pKindType}','{pWho}','{pBusinessEntity}',0, @IDB_OBJ_ID = @NEW_IDB_OBJ_ID OUTPUT;
|
||||
SELECT @NEW_IDB_OBJ_ID"
|
||||
Dim oObjectId As Long = Database.GetScalarValueWithConnectionObject(oNewObjectIdSQL,
|
||||
pConnection,
|
||||
TransactionMode.ExternalTransaction,
|
||||
pTransaction)
|
||||
|
||||
Logger.Info("New Object with Id [{0}] created!", oObjectId)
|
||||
|
||||
If IsNothing(oObjectId) Then
|
||||
LogAndThrow("Could not create new ObjectId!")
|
||||
End If
|
||||
|
||||
Return oObjectId
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetObject(pObjectId As Long) As IDBObject
|
||||
Try
|
||||
Dim oGetObjectSQL = $"SELECT * FROM VWIDB_OBJECT WHERE IDB_OBJ_ID = {pObjectId}"
|
||||
Dim oRow As DataTable = Database.GetDatatable(oGetObjectSQL)
|
||||
|
||||
If oRow Is Nothing Then
|
||||
Logger.Warn("Object with Id [{0}] not found.", pObjectId)
|
||||
Return Nothing
|
||||
|
||||
End If
|
||||
|
||||
'TODO: Return object data
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
'Public Function GetAttributesForObject(pObjectId As Long, pLanguage As String) As List(Of ObjectAttribute)
|
||||
' Dim oAttributes As New List(Of ObjectAttribute)
|
||||
|
||||
|
||||
7
Service.EDMIService/IDB/IDBObject.vb
Normal file
7
Service.EDMIService/IDB/IDBObject.vb
Normal file
@@ -0,0 +1,7 @@
|
||||
Namespace IDB
|
||||
Public Class IDBObject
|
||||
Public Property ObjectId As Long
|
||||
Public Property ObjectKind As Long
|
||||
Public Property BusinessEntity As Long
|
||||
End Class
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user