Compare commits
3 Commits
6b389bfed2
...
9d51074991
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d51074991 | ||
|
|
cbb343bb17 | ||
|
|
a29f058d58 |
@@ -10,7 +10,7 @@ Public Class DatabaseWithFallback
|
||||
Private ReadOnly _Client As Client
|
||||
Private ReadOnly _ClientConfig As ConfigClientConfiguration
|
||||
Private ReadOnly _DatabaseECM As MSSQLServer
|
||||
Private ReadOnly _DatabaseIDB As MSSQLServer
|
||||
Private _DatabaseIDB As MSSQLServer
|
||||
|
||||
''' <summary>
|
||||
''' Options for GetDatatable
|
||||
@@ -57,6 +57,14 @@ Public Class DatabaseWithFallback
|
||||
_ClientConfig = Client.TryGetClientConfig()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Set the IDB Database class after initializing the class.
|
||||
''' It is now your responsibility to make sure to not use any IDB calls before calling this method.
|
||||
''' </summary>
|
||||
Public Sub InitializeIDB(pDatabaseIDB As MSSQLServer)
|
||||
_DatabaseIDB = pDatabaseIDB
|
||||
End Sub
|
||||
|
||||
Public Function GetDatatableECM(pSQL As String, Optional pConnectionId As Integer = 0) As DataTable
|
||||
Return GetDatatable(New GetDatatableOptions(pSQL, Constants.DatabaseType.ECM) With {
|
||||
.ConnectionId = pConnectionId
|
||||
|
||||
@@ -17,18 +17,18 @@ Namespace Methods.Database.GetScalarValue
|
||||
''' </summary>
|
||||
Public Function Run(pData As GetScalarValueRequest) As GetScalarValueResponse
|
||||
Try
|
||||
Dim oDatatable As DataTable = Nothing
|
||||
Dim oResult As Object = Nothing
|
||||
|
||||
Select Case pData.DatabaseType
|
||||
Case DatabaseType.MSSQL
|
||||
If pData.NamedDatabase = DatabaseName.None Then
|
||||
oDatatable = GetScalarValueByConnectionId(pData.SqlCommand, pData.ConnectionId)
|
||||
oResult = GetScalarValueByConnectionId(pData.SqlCommand, pData.ConnectionId)
|
||||
|
||||
ElseIf pData.NamedDatabase = DatabaseName.ECM Then
|
||||
oDatatable = DatabaseECM.GetScalarValue(pData.SqlCommand)
|
||||
oResult = DatabaseECM.GetScalarValue(pData.SqlCommand)
|
||||
|
||||
ElseIf pData.NamedDatabase = DatabaseName.IDB Then
|
||||
oDatatable = DatabaseIDB.GetScalarValue(pData.SqlCommand)
|
||||
oResult = DatabaseIDB.GetScalarValue(pData.SqlCommand)
|
||||
|
||||
Else
|
||||
LogAndThrow($"Unsupported Named Database supplied. SQL Command [{pData.SqlCommand}] was not executed!")
|
||||
@@ -40,11 +40,12 @@ Namespace Methods.Database.GetScalarValue
|
||||
|
||||
End Select
|
||||
|
||||
If oDatatable Is Nothing Then
|
||||
LogAndThrow($"SQL Command did not return any results: [{pData.SqlCommand}]!")
|
||||
End If
|
||||
' Remove this in the future, empty return values for scalar should be allowed
|
||||
'If oResult Is Nothing Then
|
||||
' LogAndThrow($"SQL Command did not return any results: [{pData.SqlCommand}]!")
|
||||
'End If
|
||||
|
||||
Return New GetScalarValueResponse(oDatatable)
|
||||
Return New GetScalarValueResponse(oResult)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while getting database scalar value!")
|
||||
Logger.Error(ex)
|
||||
@@ -52,7 +53,7 @@ Namespace Methods.Database.GetScalarValue
|
||||
End Try
|
||||
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
|
||||
Return DatabaseECM.GetScalarValue(pSQLCommand)
|
||||
Else
|
||||
|
||||
Reference in New Issue
Block a user