EDMIService: fix wrong return type of getscalarvaluemethod

This commit is contained in:
Jonathan Jenne 2022-01-18 15:25:12 +01:00
parent 6b389bfed2
commit a29f058d58

View File

@ -17,18 +17,18 @@ Namespace Methods.Database.GetScalarValue
''' </summary> ''' </summary>
Public Function Run(pData As GetScalarValueRequest) As GetScalarValueResponse Public Function Run(pData As GetScalarValueRequest) As GetScalarValueResponse
Try Try
Dim oDatatable As DataTable = Nothing Dim oResult As Object = Nothing
Select Case pData.DatabaseType Select Case pData.DatabaseType
Case DatabaseType.MSSQL Case DatabaseType.MSSQL
If pData.NamedDatabase = DatabaseName.None Then If pData.NamedDatabase = DatabaseName.None Then
oDatatable = GetScalarValueByConnectionId(pData.SqlCommand, pData.ConnectionId) oResult = GetScalarValueByConnectionId(pData.SqlCommand, pData.ConnectionId)
ElseIf pData.NamedDatabase = DatabaseName.ECM Then ElseIf pData.NamedDatabase = DatabaseName.ECM Then
oDatatable = DatabaseECM.GetScalarValue(pData.SqlCommand) oResult = DatabaseECM.GetScalarValue(pData.SqlCommand)
ElseIf pData.NamedDatabase = DatabaseName.IDB Then ElseIf pData.NamedDatabase = DatabaseName.IDB Then
oDatatable = DatabaseIDB.GetScalarValue(pData.SqlCommand) oResult = DatabaseIDB.GetScalarValue(pData.SqlCommand)
Else Else
LogAndThrow($"Unsupported Named Database supplied. SQL Command [{pData.SqlCommand}] was not executed!") LogAndThrow($"Unsupported Named Database supplied. SQL Command [{pData.SqlCommand}] was not executed!")
@ -40,11 +40,11 @@ Namespace Methods.Database.GetScalarValue
End Select End Select
If oDatatable Is Nothing Then If oResult Is Nothing Then
LogAndThrow($"SQL Command did not return any results: [{pData.SqlCommand}]!") LogAndThrow($"SQL Command did not return any results: [{pData.SqlCommand}]!")
End If End If
Return New GetScalarValueResponse(oDatatable) Return New GetScalarValueResponse(oResult)
Catch ex As Exception Catch ex As Exception
Logger.Warn("Error occurred while getting database scalar value!") Logger.Warn("Error occurred while getting database scalar value!")
Logger.Error(ex) Logger.Error(ex)
@ -52,7 +52,7 @@ Namespace Methods.Database.GetScalarValue
End Try End Try
End Function End Function
Private Function GetScalarValueByConnectionId(pSQLCommand As String, pConnectionId As Integer) As DataTable Private Function GetScalarValueByConnectionId(pSQLCommand As String, pConnectionId As Integer) As Object
If pConnectionId = 0 Then If pConnectionId = 0 Then
Return DatabaseECM.GetScalarValue(pSQLCommand) Return DatabaseECM.GetScalarValue(pSQLCommand)
Else Else