EDMI: Client Server Changes to prepare for initial Release
This commit is contained in:
@@ -1,23 +1,24 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Services.EDMIService.Messages
|
||||
Imports DigitalData.Modules.EDMI.API.Client
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Namespace IDB
|
||||
Public Class Helpers
|
||||
Inherits BaseClass
|
||||
|
||||
Private MSSQLServer As MSSQLServer
|
||||
Private Database As MSSQLServer
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pMSSQLServer As MSSQLServer)
|
||||
MyBase.New(pLogConfig)
|
||||
MSSQLServer = pMSSQLServer
|
||||
Database = pMSSQLServer
|
||||
End Sub
|
||||
|
||||
Public Function TestObjectIdExists(pObjectId As Long, Optional ByRef IsDeleted As Boolean = False, Optional ByRef IsActive As Boolean = False) As Boolean
|
||||
Try
|
||||
Dim oSQL As String = $"SELECT IDB_OBJ_ID, ACTIVE, DELETED FROM TBIDB_OBJECT WHERE IDB_OBJ_ID = {pObjectId}"
|
||||
Dim oTable As DataTable = MSSQLServer.GetDatatable(oSQL)
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSQL)
|
||||
|
||||
If IsNothing(oTable) OrElse oTable.Rows.Count = 0 Then
|
||||
Logger.Warn("ObjectId {0} does not exist")
|
||||
@@ -39,6 +40,49 @@ Namespace IDB
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetAttributesForObject(pObjectId As Long, pLanguage As String) As List(Of ObjectAttribute)
|
||||
Dim oAttributes As New List(Of ObjectAttribute)
|
||||
|
||||
Try
|
||||
Dim oTable As DataTable = Database.GetDatatable($"EXEC [PRIDB_GET_VALUE_DT] {pObjectId}, '{pLanguage}'")
|
||||
If oTable Is Nothing OrElse oTable.Rows.Count = 0 Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oAttribute As New ObjectAttribute With {
|
||||
.Id = oRow.Item("AttributeId"),
|
||||
.Title = oRow.Item("AttributeTitle"),
|
||||
.Type = oRow.Item("AttributeType"),
|
||||
.ValueBigInt = Utils.NotNull(oRow.Item("ValueBigInt"), Nothing),
|
||||
.ValueDate = Utils.NotNull(oRow.Item("ValueDate"), Nothing),
|
||||
.ValueDecimal = Utils.NotNull(oRow.Item("ValueDecimal"), Nothing),
|
||||
.ValueText = Utils.NotNull(oRow.Item("ValueText"), Nothing)
|
||||
}
|
||||
|
||||
oAttributes.Add(oAttribute)
|
||||
Next
|
||||
|
||||
Return oAttributes
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function SetAttributeValue(pConnection As SqlConnection, pTransaction As SqlTransaction, pObjectId As Long, pAttributeName As String, pValue As String, pLanguage As String, pWho As String) As Boolean
|
||||
Dim oSql = $"
|
||||
DECLARE @NEW_OBJ_MD_ID BIGINT
|
||||
EXEC PRIDB_NEW_OBJ_DATA {pObjectId}, '{pAttributeName}', '{pWho}', '{pValue}', '{pLanguage}', 0, @OMD_ID = @NEW_OBJ_MD_ID OUTPUT"
|
||||
|
||||
If Database.ExecuteNonQueryWithConnectionObject(oSql, pConnection, MSSQLServer.TransactionMode.ExternalTransaction, pTransaction) = False Then
|
||||
Logger.Warn("Error while setting attribute value.")
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user