diff --git a/GUIs.ZooFlow/ClassInit.vb b/GUIs.ZooFlow/ClassInit.vb index 789de859..ff9e5ac2 100644 --- a/GUIs.ZooFlow/ClassInit.vb +++ b/GUIs.ZooFlow/ClassInit.vb @@ -3,12 +3,9 @@ Imports System.Threading Imports System.Globalization Imports DevExpress.XtraSplashScreen Imports DigitalData.Modules.Database -Imports DigitalData.Modules.Filesystem Imports DigitalData.Modules.Language.Utils Imports DigitalData.Modules.Logging Imports DigitalData.Modules.EDMI.API -Imports DigitalData.Modules.EDMI.API.Constants -Imports DigitalData.Modules.Encryption Imports DigitalData.GUIs.ZooFlow.ClassConstants Imports DigitalData.GUIs.ZooFlow.ClassInitLoader Imports DigitalData.Controls.SQLConfig @@ -83,7 +80,7 @@ Public Class ClassInit Throw New InitException("Fehler beim Laden der IDB Verbindungsdaten!") End If - oDatatable = My.DatabaseECM.GetDatatable(oSQl) + oDatatable = My.Database.GetDatatableECM(oSQl) End If End If @@ -147,7 +144,7 @@ Public Class ClassInit Private Sub InitializeUser(MyApplication As My.MyApplication) Try 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 Throw New InitException("Benutzer konnte nicht geladen werden!") @@ -195,7 +192,7 @@ Public Class ClassInit Private Sub Initialize3rdParty(MyApplication As My.MyApplication) Try 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 Throw New InitException("Konfiguration konnte nicht geladen werden!") @@ -211,7 +208,7 @@ Public Class ClassInit End Sub Private Sub InitBasicConfig(MyApplication As My.MyApplication) 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) 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 Logger.Error(ex) Return False diff --git a/GUIs.ZooFlow/Globix/frmGlobix_Index.vb b/GUIs.ZooFlow/Globix/frmGlobix_Index.vb index c318e40b..733d168e 100644 --- a/GUIs.ZooFlow/Globix/frmGlobix_Index.vb +++ b/GUIs.ZooFlow/Globix/frmGlobix_Index.vb @@ -80,21 +80,25 @@ Public Class frmGlobix_Index BringToFront() Focus() + Try + DocumentViewer1.Init(LogConfig, My.Application.Settings.GdPictureKey) + Catch ex As Exception + Logger.Error(ex) + End Try + Try Refresh_Dokart() pnlIndex.Controls.Clear() My.Application.Globix.CURRENT_ISATTACHMENT = False 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 SplitContainerControl1.SplitterPosition = My.UIConfig.Globix.SplitterDistanceViewer SourceDeleteItem.Enabled = True SourceDeleteItem.Checked = My.UIConfig.Globix.DeleteOriginalFile - DocumentViewer1.Init(LogConfig, My.Application.Settings.GdPictureKey) - If DropType Is Nothing Then Logger.Debug("File with Id [{0}] was not found in TBGI_FILES_USER. Exiting.", My.Application.Globix.CurrentWorkfile.Id) CancelAttempts = MAX_CANCEL_ATTEMPTS @@ -112,7 +116,7 @@ Public Class frmGlobix_Index 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 If MultifileCount > 0 Then @@ -273,7 +277,7 @@ Public Class frmGlobix_Index End Sub 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 Close() End Sub @@ -492,7 +496,7 @@ Public Class frmGlobix_Index Dim oMeta = DirectCast(pControl.Tag, ControlCreator.ControlMeta) Dim oIndexName As String = oMeta.IndexName 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 Logger.Debug("Found [{0}] depending controls for [{1}]", oDatatable.Rows.Count, pControl.Name) @@ -526,10 +530,7 @@ Public Class frmGlobix_Index Exit Sub End If - Dim oConnectionString = GetConnectionString(SqlConnectionId) - - - Dim oDatatable As DataTable = My.DatabaseECM.GetDatatableWithConnection(pSqlCommand, oConnectionString) + Dim oDatatable As DataTable = My.Database.GetDatatable(pSqlCommand, SqlConnectionId) Dim oFoundControl As Control = Nothing For Each oControl As Control In pnlIndex.Controls @@ -593,7 +594,7 @@ Public Class frmGlobix_Index pSQLCommand = Patterns2.ReplaceInternalValues(pSQLCommand) pSQLCommand = Patterns2.ReplaceUserValues(pSQLCommand, My.Application.User) - Dim oDatatable = My.DatabaseECM.GetDatatableWithConnection(pSQLCommand, oConnectionString) + Dim oDatatable = My.Database.GetDatatable(pSQLCommand, pConnectionId) Return oDatatable End If Else @@ -603,9 +604,9 @@ Public Class frmGlobix_Index End Function Function GetPlaceholderValue(InputValue As String, FileName As String) As String Dim oResult As String = InputValue - Dim oPatterns As New Modules.Patterns.Patterns2(My.LogConfig) Dim oFileInfo As New FileInfo(FileName) + Dim oPatterns As New Modules.Patterns.Patterns2(My.LogConfig) oResult = oPatterns.ReplaceInternalValues(oResult) oResult = oPatterns.ReplaceFileValues(oResult, oFileInfo) oResult = oPatterns.ReplaceUserValues(oResult, My.Application.User) @@ -657,7 +658,7 @@ Public Class frmGlobix_Index Try 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 DT As DataTable = My.DatabaseECM.GetDatatable(sql) + Dim DT As DataTable = My.Database.GetDatatableECM(sql) Dim anz = DT.Rows.Count For Each Filerow As DataRow In DT.Rows @@ -676,7 +677,7 @@ Public Class frmGlobix_Index End If Next '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 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:") diff --git a/GUIs.ZooFlow/frmFlowForm.vb b/GUIs.ZooFlow/frmFlowForm.vb index 3cbec5ca..c730fa16 100644 --- a/GUIs.ZooFlow/frmFlowForm.vb +++ b/GUIs.ZooFlow/frmFlowForm.vb @@ -159,7 +159,7 @@ Public Class frmFlowForm AddHandler Watcher.ClipboardChanged, AddressOf Watcher_ClipboardChanged 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 If Not IsNothing(oDatatable) OrElse oDatatable.Rows.Count > 0 Then IDBSearchActive = True @@ -275,7 +275,7 @@ Public Class frmFlowForm Try 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) @@ -308,21 +308,6 @@ Public Class frmFlowForm 'TODO: Refresh Data 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) If e.KeyCode = Keys.Escape Then If ESCHitCount > 0 Then @@ -338,7 +323,7 @@ Public Class frmFlowForm End Sub 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 Close() Else @@ -506,7 +491,7 @@ Public Class frmFlowForm End If '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 TimerCheckDroppedFiles.Start() @@ -529,7 +514,7 @@ Public Class frmFlowForm End Sub Private Async Function Globix_Check_Dropped_Files() As Threading.Tasks.Task 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 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 & "')" 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 Dim oOnlyFilesFromFilesystem = True @@ -560,7 +545,7 @@ Public Class frmFlowForm If My.Application.Globix.DTACTUAL_FILES.Rows.Count > 1 And oOnlyFilesFromFilesystem = False Then frmGlobix_IndexFileList.ShowDialog() 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 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 '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 & "')" - 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 My.Application.Globix.ABORT_INDEXING = False @@ -759,7 +744,7 @@ Public Class frmFlowForm Else Logger.Info(" File not existing - Row will be deleted!") Dim oDel = String.Format("DELETE FROM TBGI_FILES_USER WHERE GUID = {0}", FILEGUID) - My.DatabaseECM.ExecuteNonQuery(oDel) + My.Database.ExecuteNonQueryECM(oDel) End If Else Logger.Info(" file '" & row.Item(1).ToString & "' could not be opened exclusively - fileInUse!") diff --git a/Modules.EDMIAPI/Client.vb b/Modules.EDMIAPI/Client.vb index 43cc3ee6..7c1a2dea 100644 --- a/Modules.EDMIAPI/Client.vb +++ b/Modules.EDMIAPI/Client.vb @@ -1,6 +1,5 @@ Imports System.IO Imports System.ServiceModel -Imports System.Timers Imports DigitalData.Modules.EDMI.API.Constants Imports DigitalData.Modules.EDMI.API.EDMIServiceReference Imports DigitalData.Modules.EDMI.API.Rights @@ -162,13 +161,14 @@ Public Class Client Return ClientConfig 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 Dim oTables As String() = Await Channel.GetCachedTablesAsync() CachedTables = oTables. Select(Function(table) table.ToUpper). ToList() Catch ex As Exception + Logger.Warn("Update of CachedTable was not successful!") Logger.Error(ex) CachedTables = New List(Of String) End Try diff --git a/Modules.EDMIAPI/DatabaseWithFallback.vb b/Modules.EDMIAPI/DatabaseWithFallback.vb index ed83b916..c00edc51 100644 --- a/Modules.EDMIAPI/DatabaseWithFallback.vb +++ b/Modules.EDMIAPI/DatabaseWithFallback.vb @@ -63,28 +63,52 @@ Public Class DatabaseWithFallback }) 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 Return GetDatatable(New GetDatatableOptions(pSQL, Constants.DatabaseType.IDB) With { .ConnectionId = pConnectionId }) 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 Return GetScalarValue(pSQL, Constants.DatabaseType.ECM, pForceFallback:=False, pConnectionId) 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 Return GetScalarValue(pSQL, Constants.DatabaseType.IDB, pForceFallback:=False, pConnectionId) 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 Return ExecuteNonQuery(pSQL, Constants.DatabaseType.ECM, pForceFallback:=False, pConnectionId) 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 Return ExecuteNonQuery(pSQL, Constants.DatabaseType.IDB, pForceFallback:=False, pConnectionId) 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 + ''' ''' 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. ''' @@ -94,6 +118,10 @@ Public Class DatabaseWithFallback Return GetDatatable(pDataTableName, pOptions.FallbackSQL, pOptions.FallbackType, pOptions.FilterExpression, pOptions.SortByColumn, pOptions.ForceFallback, pOptions.ConnectionId) 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 + ''' ''' Returns a datatable directly from the database. ''' @@ -166,11 +194,8 @@ Public Class DatabaseWithFallback ''' Named Database to use for the fallback SQL Command ''' Force the fallback, skipping the service completely ''' Connection Id to use, references TBDD_CONNECTION - 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 - Dim oResult As DataTable = Nothing - Dim oTableResult As TableResult = Nothing - ' If there is no client, we assume there is no service (configured) If _Client Is Nothing Then Return GetScalarValueFromDatabase(pSQL, pDatabaseType, pConnectionId) @@ -313,7 +338,7 @@ Public Class DatabaseWithFallback Catch ex As Exception _Logger.Warn("GetScalarValueFromService failed. Falling back to direct database access.") _Logger.Error(ex) - Return GetDatatableFromDatabase(pSQLCommand, DatabaseType, pConnectionId) + Return GetScalarValueFromDatabase(pSQLCommand, DatabaseType, pConnectionId) End Try End Function