ZooFlow: Include more databasewithfallback calls in zooflow

This commit is contained in:
Jonathan Jenne 2022-01-14 14:15:34 +01:00
parent bcbfba37b2
commit 6f417bb24e
5 changed files with 61 additions and 53 deletions

View File

@ -3,12 +3,9 @@ Imports System.Threading
Imports System.Globalization Imports System.Globalization
Imports DevExpress.XtraSplashScreen Imports DevExpress.XtraSplashScreen
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Filesystem
Imports DigitalData.Modules.Language.Utils Imports DigitalData.Modules.Language.Utils
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.EDMI.API Imports DigitalData.Modules.EDMI.API
Imports DigitalData.Modules.EDMI.API.Constants
Imports DigitalData.Modules.Encryption
Imports DigitalData.GUIs.ZooFlow.ClassConstants Imports DigitalData.GUIs.ZooFlow.ClassConstants
Imports DigitalData.GUIs.ZooFlow.ClassInitLoader Imports DigitalData.GUIs.ZooFlow.ClassInitLoader
Imports DigitalData.Controls.SQLConfig Imports DigitalData.Controls.SQLConfig
@ -83,7 +80,7 @@ Public Class ClassInit
Throw New InitException("Fehler beim Laden der IDB Verbindungsdaten!") Throw New InitException("Fehler beim Laden der IDB Verbindungsdaten!")
End If End If
oDatatable = My.DatabaseECM.GetDatatable(oSQl) oDatatable = My.Database.GetDatatableECM(oSQl)
End If End If
End If End If
@ -147,7 +144,7 @@ Public Class ClassInit
Private Sub InitializeUser(MyApplication As My.MyApplication) Private Sub InitializeUser(MyApplication As My.MyApplication)
Try Try
Dim oSql As String = My.Queries.Common.FNDD_MODULE_INIT(Environment.UserName) Dim oSql As String = My.Queries.Common.FNDD_MODULE_INIT(Environment.UserName)
Dim oDatatable As DataTable = My.DatabaseECM.GetDatatable(oSql) Dim oDatatable As DataTable = My.Database.GetDatatableECM(oSql)
If oDatatable Is Nothing Then If oDatatable Is Nothing Then
Throw New InitException("Benutzer konnte nicht geladen werden!") Throw New InitException("Benutzer konnte nicht geladen werden!")
@ -195,7 +192,7 @@ Public Class ClassInit
Private Sub Initialize3rdParty(MyApplication As My.MyApplication) Private Sub Initialize3rdParty(MyApplication As My.MyApplication)
Try Try
Dim oSql = "Select LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'" Dim oSql = "Select LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"
Dim oDatatable As DataTable = My.DatabaseECM.GetDatatable(oSql) Dim oDatatable As DataTable = My.Database.GetDatatableECM(oSql)
If oDatatable.Rows.Count = 0 Then If oDatatable.Rows.Count = 0 Then
Throw New InitException("Konfiguration konnte nicht geladen werden!") Throw New InitException("Konfiguration konnte nicht geladen werden!")
@ -211,7 +208,7 @@ Public Class ClassInit
End Sub End Sub
Private Sub InitBasicConfig(MyApplication As My.MyApplication) Private Sub InitBasicConfig(MyApplication As My.MyApplication)
Try Try
My.Tables.DTIDB_COMMON_SQL = My.DatabaseIDB.GetDatatable("SELECT * FROM TBIDB_COMMON_SQL WHERE ACTIVE = 1") My.Tables.DTIDB_COMMON_SQL = My.Database.GetDatatableIDB("SELECT * FROM TBIDB_COMMON_SQL WHERE ACTIVE = 1")
@ -252,7 +249,7 @@ Public Class ClassInit
(BEZEICHNUNG, SQL_PROVIDER, SERVER, DATENBANK, USERNAME, PASSWORD, BEMERKUNG, AKTIV, ERSTELLTWER) (BEZEICHNUNG, SQL_PROVIDER, SERVER, DATENBANK, USERNAME, PASSWORD, BEMERKUNG, AKTIV, ERSTELLTWER)
VALUES ('IDB', 'MS-SQLServer', '{oBuilder.DataSource}', '{oBuilder.InitialCatalog}', '{oBuilder.UserID}', '{oBuilder.Password}', 'Created by Zooflow', 1, '{Environment.UserName}')" VALUES ('IDB', 'MS-SQLServer', '{oBuilder.DataSource}', '{oBuilder.InitialCatalog}', '{oBuilder.UserID}', '{oBuilder.Password}', 'Created by Zooflow', 1, '{Environment.UserName}')"
Return My.DatabaseECM.ExecuteNonQuery(oSql) Return My.Database.ExecuteNonQueryECM(oSql)
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
Return False Return False

View File

@ -80,21 +80,25 @@ Public Class frmGlobix_Index
BringToFront() BringToFront()
Focus() Focus()
Try
DocumentViewer1.Init(LogConfig, My.Application.Settings.GdPictureKey)
Catch ex As Exception
Logger.Error(ex)
End Try
Try Try
Refresh_Dokart() Refresh_Dokart()
pnlIndex.Controls.Clear() pnlIndex.Controls.Clear()
My.Application.Globix.CURRENT_ISATTACHMENT = False My.Application.Globix.CURRENT_ISATTACHMENT = False
Dim oSql = $"SELECT HANDLE_TYPE FROM TBGI_FILES_USER WHERE GUID = {My.Application.Globix.CurrentWorkfile.Id}" Dim oSql = $"SELECT HANDLE_TYPE FROM TBGI_FILES_USER WHERE GUID = {My.Application.Globix.CurrentWorkfile.Id}"
DropType = Await My.DatabaseECM.GetScalarValueAsync(oSql) DropType = Await My.Database.GetScalarValueECMAsync(oSql)
My.Application.Globix.DeleteOriginalFile = My.UIConfig.Globix.DeleteOriginalFile My.Application.Globix.DeleteOriginalFile = My.UIConfig.Globix.DeleteOriginalFile
SplitContainerControl1.SplitterPosition = My.UIConfig.Globix.SplitterDistanceViewer SplitContainerControl1.SplitterPosition = My.UIConfig.Globix.SplitterDistanceViewer
SourceDeleteItem.Enabled = True SourceDeleteItem.Enabled = True
SourceDeleteItem.Checked = My.UIConfig.Globix.DeleteOriginalFile SourceDeleteItem.Checked = My.UIConfig.Globix.DeleteOriginalFile
DocumentViewer1.Init(LogConfig, My.Application.Settings.GdPictureKey)
If DropType Is Nothing Then If DropType Is Nothing Then
Logger.Debug("File with Id [{0}] was not found in TBGI_FILES_USER. Exiting.", My.Application.Globix.CurrentWorkfile.Id) Logger.Debug("File with Id [{0}] was not found in TBGI_FILES_USER. Exiting.", My.Application.Globix.CurrentWorkfile.Id)
CancelAttempts = MAX_CANCEL_ATTEMPTS CancelAttempts = MAX_CANCEL_ATTEMPTS
@ -112,7 +116,7 @@ Public Class frmGlobix_Index
SetFilePreview(My.UIConfig.Globix.FilePreview) SetFilePreview(My.UIConfig.Globix.FilePreview)
MultifileCount = Await My.DatabaseECM.GetScalarValueAsync("SELECT COUNT(*) FROM TBGI_FILES_USER WHERE WORKED = 0 AND GUID <> " & My.Application.Globix.CurrentWorkfile.Id & " AND UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')") MultifileCount = Await My.Database.GetScalarValueECMAsync("SELECT COUNT(*) FROM TBGI_FILES_USER WHERE WORKED = 0 AND GUID <> " & My.Application.Globix.CurrentWorkfile.Id & " AND UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')")
My.Application.Globix.MULTIINDEXING_ACTIVE = False My.Application.Globix.MULTIINDEXING_ACTIVE = False
If MultifileCount > 0 Then If MultifileCount > 0 Then
@ -273,7 +277,7 @@ Public Class frmGlobix_Index
End Sub End Sub
Private Sub SkipItem_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SkipItem.ItemClick Private Sub SkipItem_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SkipItem.ItemClick
My.DatabaseECM.ExecuteNonQuery($"DELETE FROM TBGI_FILES_USER WHERE GUID = {My.Application.Globix.CurrentWorkfile.Id}") My.Database.ExecuteNonQueryECM($"DELETE FROM TBGI_FILES_USER WHERE GUID = {My.Application.Globix.CurrentWorkfile.Id}")
CancelAttempts = MAX_CANCEL_ATTEMPTS CancelAttempts = MAX_CANCEL_ATTEMPTS
Close() Close()
End Sub End Sub
@ -492,7 +496,7 @@ Public Class frmGlobix_Index
Dim oMeta = DirectCast(pControl.Tag, ControlCreator.ControlMeta) Dim oMeta = DirectCast(pControl.Tag, ControlCreator.ControlMeta)
Dim oIndexName As String = oMeta.IndexName Dim oIndexName As String = oMeta.IndexName
Dim oSQL = $"SELECT * FROM TBDD_INDEX_MAN WHERE SQL_RESULT LIKE '%{oIndexName}%' AND DOK_ID = {SelectedDocType.Guid}" Dim oSQL = $"SELECT * FROM TBDD_INDEX_MAN WHERE SQL_RESULT LIKE '%{oIndexName}%' AND DOK_ID = {SelectedDocType.Guid}"
Dim oDatatable As DataTable = My.DatabaseECM.GetDatatable(oSQL) Dim oDatatable As DataTable = My.Database.GetDatatableECM(oSQL)
If Not IsNothing(oDatatable) Then If Not IsNothing(oDatatable) Then
Logger.Debug("Found [{0}] depending controls for [{1}]", oDatatable.Rows.Count, pControl.Name) Logger.Debug("Found [{0}] depending controls for [{1}]", oDatatable.Rows.Count, pControl.Name)
@ -526,10 +530,7 @@ Public Class frmGlobix_Index
Exit Sub Exit Sub
End If End If
Dim oConnectionString = GetConnectionString(SqlConnectionId) Dim oDatatable As DataTable = My.Database.GetDatatable(pSqlCommand, SqlConnectionId)
Dim oDatatable As DataTable = My.DatabaseECM.GetDatatableWithConnection(pSqlCommand, oConnectionString)
Dim oFoundControl As Control = Nothing Dim oFoundControl As Control = Nothing
For Each oControl As Control In pnlIndex.Controls For Each oControl As Control In pnlIndex.Controls
@ -593,7 +594,7 @@ Public Class frmGlobix_Index
pSQLCommand = Patterns2.ReplaceInternalValues(pSQLCommand) pSQLCommand = Patterns2.ReplaceInternalValues(pSQLCommand)
pSQLCommand = Patterns2.ReplaceUserValues(pSQLCommand, My.Application.User) pSQLCommand = Patterns2.ReplaceUserValues(pSQLCommand, My.Application.User)
Dim oDatatable = My.DatabaseECM.GetDatatableWithConnection(pSQLCommand, oConnectionString) Dim oDatatable = My.Database.GetDatatable(pSQLCommand, pConnectionId)
Return oDatatable Return oDatatable
End If End If
Else Else
@ -603,9 +604,9 @@ Public Class frmGlobix_Index
End Function End Function
Function GetPlaceholderValue(InputValue As String, FileName As String) As String Function GetPlaceholderValue(InputValue As String, FileName As String) As String
Dim oResult As String = InputValue Dim oResult As String = InputValue
Dim oPatterns As New Modules.Patterns.Patterns2(My.LogConfig)
Dim oFileInfo As New FileInfo(FileName) Dim oFileInfo As New FileInfo(FileName)
Dim oPatterns As New Modules.Patterns.Patterns2(My.LogConfig)
oResult = oPatterns.ReplaceInternalValues(oResult) oResult = oPatterns.ReplaceInternalValues(oResult)
oResult = oPatterns.ReplaceFileValues(oResult, oFileInfo) oResult = oPatterns.ReplaceFileValues(oResult, oFileInfo)
oResult = oPatterns.ReplaceUserValues(oResult, My.Application.User) oResult = oPatterns.ReplaceUserValues(oResult, My.Application.User)
@ -657,7 +658,7 @@ Public Class frmGlobix_Index
Try Try
My.Application.Globix.ABORT_INDEXING = True My.Application.Globix.ABORT_INDEXING = True
Dim sql As String = $"SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND UPPER(USER@WORK) = UPPER('{My.Application.User.UserName}')" Dim sql As String = $"SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND UPPER(USER@WORK) = UPPER('{My.Application.User.UserName}')"
Dim DT As DataTable = My.DatabaseECM.GetDatatable(sql) Dim DT As DataTable = My.Database.GetDatatableECM(sql)
Dim anz = DT.Rows.Count Dim anz = DT.Rows.Count
For Each Filerow As DataRow In DT.Rows For Each Filerow As DataRow In DT.Rows
@ -676,7 +677,7 @@ Public Class frmGlobix_Index
End If End If
Next Next
'Zuerst die Daten des Ablaufs löschen 'Zuerst die Daten des Ablaufs löschen
If My.DatabaseECM.ExecuteNonQuery($"DELETE FROM TBGI_FILES_USER WHERE UPPER(USER@WORK) = UPPER('{My.Application.User.UserName}')") = True Then If My.Database.ExecuteNonQueryECM($"DELETE FROM TBGI_FILES_USER WHERE UPPER(USER@WORK) = UPPER('{My.Application.User.UserName}')") = True Then
If containsfw_file = True Then If containsfw_file = True Then
If My.Application.User.Language = "de-DE" Then If My.Application.User.Language = "de-DE" Then
MsgBox("Der Indexierungsprozess beinhaltete (auch) Dateien per Folderwatch!" & vbNewLine & "Diese Dateien wurden nicht gelöscht und verbleiben im Folderwatch-Verzeichnis!" & vbNewLine & "Bitte verschieben Sie die Dateien ggfls.", MsgBoxStyle.Information, "Achtung - Hinweis:") MsgBox("Der Indexierungsprozess beinhaltete (auch) Dateien per Folderwatch!" & vbNewLine & "Diese Dateien wurden nicht gelöscht und verbleiben im Folderwatch-Verzeichnis!" & vbNewLine & "Bitte verschieben Sie die Dateien ggfls.", MsgBoxStyle.Information, "Achtung - Hinweis:")

View File

@ -159,7 +159,7 @@ Public Class frmFlowForm
AddHandler Watcher.ClipboardChanged, AddressOf Watcher_ClipboardChanged AddHandler Watcher.ClipboardChanged, AddressOf Watcher_ClipboardChanged
Dim oSQL = My.Queries.Common.FNIDB_GET_SEARCH_PROFILES(My.Application.User.UserId, My.Application.User.Language) Dim oSQL = My.Queries.Common.FNIDB_GET_SEARCH_PROFILES(My.Application.User.UserId, My.Application.User.Language)
Dim oDatatable As DataTable = My.DatabaseIDB.GetDatatable(oSQL) Dim oDatatable As DataTable = My.Database.GetDatatableIDB(oSQL)
PictureBoxSearch1.Visible = False PictureBoxSearch1.Visible = False
If Not IsNothing(oDatatable) OrElse oDatatable.Rows.Count > 0 Then If Not IsNothing(oDatatable) OrElse oDatatable.Rows.Count > 0 Then
IDBSearchActive = True IDBSearchActive = True
@ -275,7 +275,7 @@ Public Class frmFlowForm
Try Try
Dim oSql As String = "SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'SCAN' AND USER_ID = " & My.Application.User.UserId Dim oSql As String = "SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'SCAN' AND USER_ID = " & My.Application.User.UserId
Dim oFolderwatchScanPath = My.DatabaseECM.GetScalarValue(oSql) Dim oFolderwatchScanPath = My.Database.GetScalarValueECM(oSql)
oFolderwatchScanPath = IIf(IsDBNull(oFolderwatchScanPath), "", oFolderwatchScanPath) oFolderwatchScanPath = IIf(IsDBNull(oFolderwatchScanPath), "", oFolderwatchScanPath)
@ -308,21 +308,6 @@ Public Class frmFlowForm
'TODO: Refresh Data 'TODO: Refresh Data
End Sub End Sub
'Private Sub frmFlowForm_MouseLeave(sender As Object, e As EventArgs) Handles MyBase.MouseLeave
' Opacity = OPACITY_HIDDEN
'End Sub
'Private Sub frmFlowForm_MouseEnter(sender As Object, e As EventArgs) Handles Me.MouseEnter
' Opacity = OPACITY_SHOWN
'End Sub
'Private Sub frmFlowForm_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.MouseMove, PictureBoxDragDrop.MouseMove
' If e.Button = MouseButtons.Left Then
' NativeMethods.ReleaseCapture()
' NativeMethods.SendMessage(Handle, NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTCAPTION, 0)
' End If
'End Sub
Private Sub frmFlowForm_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Private Sub frmFlowForm_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
If e.KeyCode = Keys.Escape Then If e.KeyCode = Keys.Escape Then
If ESCHitCount > 0 Then If ESCHitCount > 0 Then
@ -338,7 +323,7 @@ Public Class frmFlowForm
End Sub End Sub
Sub ExitZooflow() Sub ExitZooflow()
Dim oResult As DialogResult = MessageBox.Show("Exit Zooflow", "Are you sure you want to close ZooFlow?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) Dim oResult As DialogResult = MessageBox.Show("Are you sure you want to close ZooFlow?", "Exit Zooflow", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If oResult = DialogResult.Yes Then If oResult = DialogResult.Yes Then
Close() Close()
Else Else
@ -506,7 +491,7 @@ Public Class frmFlowForm
End If End If
'Erstmal alles löschen 'Erstmal alles löschen
My.DatabaseECM.ExecuteNonQuery("DELETE FROM TBGI_FILES_USER WHERE UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')") My.Database.ExecuteNonQueryECM("DELETE FROM TBGI_FILES_USER WHERE UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')")
If FileDrop.Drop_File(e) = True Then If FileDrop.Drop_File(e) = True Then
TimerCheckDroppedFiles.Start() TimerCheckDroppedFiles.Start()
@ -529,7 +514,7 @@ Public Class frmFlowForm
End Sub End Sub
Private Async Function Globix_Check_Dropped_Files() As Threading.Tasks.Task Private Async Function Globix_Check_Dropped_Files() As Threading.Tasks.Task
Try Try
Await My.DatabaseECM.ExecuteNonQueryAsync($"DELETE FROM TBGI_FILES_USER WHERE WORKED = 1 AND UPPER(USER@WORK) = UPPER('{Environment.UserName}')") Await My.Database.ExecuteNonQueryECMAsync($"DELETE FROM TBGI_FILES_USER WHERE WORKED = 1 AND UPPER(USER@WORK) = UPPER('{Environment.UserName}')")
Dim i As Integer Dim i As Integer
For Each pFile As String In FileDrop.files_dropped For Each pFile As String In FileDrop.files_dropped
@ -546,7 +531,7 @@ Public Class frmFlowForm
Dim sql As String = "SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')" Dim sql As String = "SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')"
My.Application.Globix.DTACTUAL_FILES = Nothing My.Application.Globix.DTACTUAL_FILES = Nothing
My.Application.Globix.DTACTUAL_FILES = Await My.DatabaseECM.GetDatatableAsync(sql) My.Application.Globix.DTACTUAL_FILES = Await My.Database.GetDatatableECMAsync(sql)
My.Application.Globix.ABORT_INDEXING = False My.Application.Globix.ABORT_INDEXING = False
Dim oOnlyFilesFromFilesystem = True Dim oOnlyFilesFromFilesystem = True
@ -560,7 +545,7 @@ Public Class frmFlowForm
If My.Application.Globix.DTACTUAL_FILES.Rows.Count > 1 And oOnlyFilesFromFilesystem = False Then If My.Application.Globix.DTACTUAL_FILES.Rows.Count > 1 And oOnlyFilesFromFilesystem = False Then
frmGlobix_IndexFileList.ShowDialog() frmGlobix_IndexFileList.ShowDialog()
My.Application.Globix.DTACTUAL_FILES = Nothing My.Application.Globix.DTACTUAL_FILES = Nothing
My.Application.Globix.DTACTUAL_FILES = My.DatabaseECM.GetDatatable(sql) My.Application.Globix.DTACTUAL_FILES = My.Database.GetDatatableECM(sql)
End If End If
For Each oRow As DataRow In My.Application.Globix.DTACTUAL_FILES.Rows For Each oRow As DataRow In My.Application.Globix.DTACTUAL_FILES.Rows
@ -733,7 +718,7 @@ Public Class frmFlowForm
If My.Application.Globix.Folderwatchstarted = True Or My.UIConfig.Globix.FolderWatchScanStarted = True Then If My.Application.Globix.Folderwatchstarted = True Or My.UIConfig.Globix.FolderWatchScanStarted = True Then
'Prüfen ob alle Files abgearbeitet wurden 'Prüfen ob alle Files abgearbeitet wurden
Dim sql = "SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND HANDLE_TYPE like '%|FW%' AND UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')" Dim sql = "SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND HANDLE_TYPE like '%|FW%' AND UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')"
My.Application.Globix.DTACTUAL_FILES = My.DatabaseECM.GetDatatable(sql) My.Application.Globix.DTACTUAL_FILES = My.Database.GetDatatableECM(sql)
If My.Application.Globix.DTACTUAL_FILES.Rows.Count > 0 Then If My.Application.Globix.DTACTUAL_FILES.Rows.Count > 0 Then
My.Application.Globix.ABORT_INDEXING = False My.Application.Globix.ABORT_INDEXING = False
@ -759,7 +744,7 @@ Public Class frmFlowForm
Else Else
Logger.Info(" File not existing - Row will be deleted!") Logger.Info(" File not existing - Row will be deleted!")
Dim oDel = String.Format("DELETE FROM TBGI_FILES_USER WHERE GUID = {0}", FILEGUID) Dim oDel = String.Format("DELETE FROM TBGI_FILES_USER WHERE GUID = {0}", FILEGUID)
My.DatabaseECM.ExecuteNonQuery(oDel) My.Database.ExecuteNonQueryECM(oDel)
End If End If
Else Else
Logger.Info(" file '" & row.Item(1).ToString & "' could not be opened exclusively - fileInUse!") Logger.Info(" file '" & row.Item(1).ToString & "' could not be opened exclusively - fileInUse!")

View File

@ -1,6 +1,5 @@
Imports System.IO Imports System.IO
Imports System.ServiceModel Imports System.ServiceModel
Imports System.Timers
Imports DigitalData.Modules.EDMI.API.Constants Imports DigitalData.Modules.EDMI.API.Constants
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
Imports DigitalData.Modules.EDMI.API.Rights Imports DigitalData.Modules.EDMI.API.Rights
@ -162,13 +161,14 @@ Public Class Client
Return ClientConfig Return ClientConfig
End Function End Function
Private Async Function UpdateTimer_Elapsed(sender As Object, e As ElapsedEventArgs) As Task Handles UpdateTimer.Elapsed Private Async Function UpdateTimer_Elapsed(sender As Object, e As Timers.ElapsedEventArgs) As Task Handles UpdateTimer.Elapsed
Try Try
Dim oTables As String() = Await Channel.GetCachedTablesAsync() Dim oTables As String() = Await Channel.GetCachedTablesAsync()
CachedTables = oTables. CachedTables = oTables.
Select(Function(table) table.ToUpper). Select(Function(table) table.ToUpper).
ToList() ToList()
Catch ex As Exception Catch ex As Exception
Logger.Warn("Update of CachedTable was not successful!")
Logger.Error(ex) Logger.Error(ex)
CachedTables = New List(Of String) CachedTables = New List(Of String)
End Try End Try

View File

@ -63,28 +63,52 @@ Public Class DatabaseWithFallback
}) })
End Function End Function
Public Async Function GetDatatableECMAsync(pSQL As String, Optional pConnectionId As Integer = 0) As Task(Of DataTable)
Return Await Task.Run(Function() GetDatatableECM(pSQL, pConnectionId))
End Function
Public Function GetDatatableIDB(pSQL As String, Optional pConnectionId As Integer = 0) As DataTable Public Function GetDatatableIDB(pSQL As String, Optional pConnectionId As Integer = 0) As DataTable
Return GetDatatable(New GetDatatableOptions(pSQL, Constants.DatabaseType.IDB) With { Return GetDatatable(New GetDatatableOptions(pSQL, Constants.DatabaseType.IDB) With {
.ConnectionId = pConnectionId .ConnectionId = pConnectionId
}) })
End Function End Function
Public Async Function GetDatatableIDBAsync(pSQL As String, Optional pConnectionId As Integer = 0) As Task(Of DataTable)
Return Await Task.Run(Function() GetDatatableIDB(pSQL, pConnectionId))
End Function
Public Function GetScalarValueECM(pSQL As String, Optional pConnectionId As Integer = 0) As Object Public Function GetScalarValueECM(pSQL As String, Optional pConnectionId As Integer = 0) As Object
Return GetScalarValue(pSQL, Constants.DatabaseType.ECM, pForceFallback:=False, pConnectionId) Return GetScalarValue(pSQL, Constants.DatabaseType.ECM, pForceFallback:=False, pConnectionId)
End Function End Function
Public Async Function GetScalarValueECMAsync(pSQL As String, Optional pConnectionId As Integer = 0) As Task(Of Object)
Return Await Task.Run(Function() GetScalarValueECM(pSQL, pConnectionId))
End Function
Public Function GetScalarValueIDB(pSQL As String, Optional pConnectionId As Integer = 0) As Object Public Function GetScalarValueIDB(pSQL As String, Optional pConnectionId As Integer = 0) As Object
Return GetScalarValue(pSQL, Constants.DatabaseType.IDB, pForceFallback:=False, pConnectionId) Return GetScalarValue(pSQL, Constants.DatabaseType.IDB, pForceFallback:=False, pConnectionId)
End Function End Function
Public Async Function GetScalarValueIDBAsync(pSQL As String, Optional pConnectionId As Integer = 0) As Task(Of Object)
Return Await Task.Run(Function() GetScalarValueIDB(pSQL, pConnectionId))
End Function
Public Function ExecuteNonQueryECM(pSQL As String, Optional pConnectionId As Integer = 0) As Boolean Public Function ExecuteNonQueryECM(pSQL As String, Optional pConnectionId As Integer = 0) As Boolean
Return ExecuteNonQuery(pSQL, Constants.DatabaseType.ECM, pForceFallback:=False, pConnectionId) Return ExecuteNonQuery(pSQL, Constants.DatabaseType.ECM, pForceFallback:=False, pConnectionId)
End Function End Function
Public Async Function ExecuteNonQueryECMAsync(pSQL As String, Optional pConnectionId As Integer = 0) As Task(Of Boolean)
Return Await Task.Run(Function() ExecuteNonQueryECM(pSQL, pConnectionId))
End Function
Public Function ExecuteNonQueryIDB(pSQL As String, Optional pConnectionId As Integer = 0) As Boolean Public Function ExecuteNonQueryIDB(pSQL As String, Optional pConnectionId As Integer = 0) As Boolean
Return ExecuteNonQuery(pSQL, Constants.DatabaseType.IDB, pForceFallback:=False, pConnectionId) Return ExecuteNonQuery(pSQL, Constants.DatabaseType.IDB, pForceFallback:=False, pConnectionId)
End Function End Function
Public Async Function ExecuteNonQueryIDBAsync(pSQL As String, Optional pConnectionId As Integer = 0) As Task(Of Boolean)
Return Await Task.Run(Function() ExecuteNonQueryIDB(pSQL, pConnectionId))
End Function
''' <summary> ''' <summary>
''' Returns a Datatable by trying to fetch a cached version from the service, then querying the database through the service and querying the database directly as fallback. ''' Returns a Datatable by trying to fetch a cached version from the service, then querying the database through the service and querying the database directly as fallback.
''' </summary> ''' </summary>
@ -94,6 +118,10 @@ Public Class DatabaseWithFallback
Return GetDatatable(pDataTableName, pOptions.FallbackSQL, pOptions.FallbackType, pOptions.FilterExpression, pOptions.SortByColumn, pOptions.ForceFallback, pOptions.ConnectionId) Return GetDatatable(pDataTableName, pOptions.FallbackSQL, pOptions.FallbackType, pOptions.FilterExpression, pOptions.SortByColumn, pOptions.ForceFallback, pOptions.ConnectionId)
End Function End Function
Public Function GetDatatable(pSQL As String, pConnectionId As Integer) As DataTable
Return GetDatatable("FORCE_FALLBACK", pSQL, Constants.DatabaseType.ECM, pSortByColumn:=Nothing, pForceFallback:=False, pConnectionId:=pConnectionId)
End Function
''' <summary> ''' <summary>
''' Returns a datatable directly from the database. ''' Returns a datatable directly from the database.
''' </summary> ''' </summary>
@ -166,11 +194,8 @@ Public Class DatabaseWithFallback
''' <param name="pDatabaseType">Named Database to use for the fallback SQL Command</param> ''' <param name="pDatabaseType">Named Database to use for the fallback SQL Command</param>
''' <param name="pForceFallback">Force the fallback, skipping the service completely</param> ''' <param name="pForceFallback">Force the fallback, skipping the service completely</param>
''' <param name="pConnectionId">Connection Id to use, references TBDD_CONNECTION</param> ''' <param name="pConnectionId">Connection Id to use, references TBDD_CONNECTION</param>
Public Function GetScalarValue(pSQL As String, pDatabaseType As Constants.DatabaseType, Optional pForceFallback As Boolean = False, Optional pConnectionId As Integer = 0) As DataTable Public Function GetScalarValue(pSQL As String, pDatabaseType As Constants.DatabaseType, Optional pForceFallback As Boolean = False, Optional pConnectionId As Integer = 0) As Object
Try Try
Dim oResult As DataTable = Nothing
Dim oTableResult As TableResult = Nothing
' If there is no client, we assume there is no service (configured) ' If there is no client, we assume there is no service (configured)
If _Client Is Nothing Then If _Client Is Nothing Then
Return GetScalarValueFromDatabase(pSQL, pDatabaseType, pConnectionId) Return GetScalarValueFromDatabase(pSQL, pDatabaseType, pConnectionId)
@ -313,7 +338,7 @@ Public Class DatabaseWithFallback
Catch ex As Exception Catch ex As Exception
_Logger.Warn("GetScalarValueFromService failed. Falling back to direct database access.") _Logger.Warn("GetScalarValueFromService failed. Falling back to direct database access.")
_Logger.Error(ex) _Logger.Error(ex)
Return GetDatatableFromDatabase(pSQLCommand, DatabaseType, pConnectionId) Return GetScalarValueFromDatabase(pSQLCommand, DatabaseType, pConnectionId)
End Try End Try
End Function End Function