EDMIAPI: First usable version of DatabaseWithFallback

This commit is contained in:
Jonathan Jenne 2021-11-04 14:28:13 +01:00
parent bd176e3de0
commit a900379704
3 changed files with 5 additions and 47 deletions

View File

@ -47,15 +47,15 @@ Public Class DatabaseWithFallback
End If
End Function
Public Function GetDatatable(DataTable As String, FallbackSQL As String, FallbackType As Constants.DatabaseType, Optional FilterExpression As String = "", Optional SortByColumn As String = "", Optional ForceFallback As Boolean = False) As DataTable
Public Function GetDatatable(pDataTableName As String, pFallbackSQL As String, pFallbackType As Constants.DatabaseType, Optional pFilterExpression As String = "", Optional pSortByColumn As String = "", Optional pForceFallback As Boolean = False) As DataTable
Try
Dim oResult As DataTable = Nothing
If ForceFallback = False Then
If pForceFallback = False Then
Dim oTableResult As TableResult
Try
oTableResult = _Client.GetDatatableByName(DataTable, FilterExpression, SortByColumn)
oTableResult = _Client.GetDatatableByName(pDataTableName, pFilterExpression, pSortByColumn)
Catch ex As Exception
_Logger.Error(ex)
oTableResult = Nothing
@ -63,12 +63,12 @@ Public Class DatabaseWithFallback
If oTableResult Is Nothing OrElse oTableResult.OK = False Then
_Logger.Warn("Datatable [{0}] could not be fetched from AppServer Cache. Falling back to direct Database Access.")
Return GetDatatableFromDatabase(FallbackSQL, FallbackType)
Return GetDatatableFromDatabase(pFallbackSQL, pFallbackType)
End If
Return oTableResult.Table
Else
Return GetDatatableFromDatabase(FallbackSQL, FallbackType)
Return GetDatatableFromDatabase(pFallbackSQL, pFallbackType)
End If
Catch ex As Exception
_Logger.Error(ex)
@ -95,32 +95,5 @@ Public Class DatabaseWithFallback
End Try
End Function
Public Function GetUserData(UserName As String, ModuleCode As String, Client As Integer) As UserData
'Dim oSQL = $"SELECT * FROM FNDD_CHECK_USER_MODULE('{UserName}','{ModuleCode}',{Client})"
'Dim oTable As DataTable = GetDatatable("TBDD_USER_MODULE", $"USERNAME = '{UserName.ToLower}' AND MODULE_SHORT = '{ModuleCode}'", "", oSQL, DatabaseType.ECM)
'If oTable Is Nothing Then
' Return Nothing
'End If
'If oTable.Rows.Count = 0 Then
' Return Nothing
'End If
'Dim oRow As DataRow = oTable.Rows.Item(0)
'Dim oUserData As New UserData With {
' .Id = NotNull(oRow, "USER_ID", -1),
' .Surname = NotNull(oRow, "USER_SURNAME", String.Empty),
' .Prename = NotNull(oRow, "USER_PRENAME", String.Empty),
' .Shortname = NotNull(oRow, "USER_SHORTNAME", String.Empty),
' .Email = NotNull(oRow, "USER_EMAIL", String.Empty),
' .Language = NotNull(oRow, "USER_LANGUAGE", "de-DE"),
' .DateFormat = NotNull(oRow, "USER_DATE_FORMAT", "dd.MM.yyyy")
'}
Throw New NotImplementedException()
End Function
End Class

View File

@ -1,14 +0,0 @@
Public Class UserData
Public Id As Integer
Public Surname As String
Public Prename As String
Public Shortname As String
Public Email As String
Public Language As String
Public DateFormat As String
Public IsAdmin As Boolean
Public HasAccess As Boolean
Public ModuleName As String
End Class

View File

@ -97,7 +97,6 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="DatabaseWithFallback\UserData.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="My Project\Resources.resx">