ZooFlow: fix init_folderwatch

This commit is contained in:
Jonathan Jenne 2021-01-19 16:23:07 +01:00
parent 2bbdc4c902
commit 4d8d00f6df

View File

@ -280,9 +280,14 @@ Public Class frmFlowForm
Try Try
Dim oSql As String = "SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'DEFAULT' AND USER_ID = " & My.Application.User.UserId Dim oSql As String = "SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'DEFAULT' AND USER_ID = " & My.Application.User.UserId
Dim oDT As DataTable = AppServerOrDB.GetDatatable("IDB", oSql, "TBGI_FOLDERWATCH_USER", $"FOLDER_TYPE = 'DEFAULT' AND USER_ID = {My.Application.User.UserId}") Dim oDT As DataTable = AppServerOrDB.GetDatatable("DD_ECM", oSql, "TBGI_FOLDERWATCH_USER", $"FOLDER_TYPE = 'DEFAULT' AND USER_ID = {My.Application.User.UserId}")
Dim oFolderWatchPath = oDT.Rows(0).Item("FOLDER_PATH")
oFolderWatchPath = NotNull(oFolderWatchPath, String.Empty) If oDT.Rows.Count = 0 Then
Throw New ApplicationException("No Default Path configured for User!")
End If
Dim oFolderWatchPath = oDT.Rows.Item(0).Item("FOLDER_PATH")
oFolderWatchPath = NotNull(oFolderWatchPath, String.Empty).ToString
If oFolderWatchPath = String.Empty Then If oFolderWatchPath = String.Empty Then
Logger.Info("Init_Folderwatch: folderwatchPath is empty") Logger.Info("Init_Folderwatch: folderwatchPath is empty")
@ -302,13 +307,13 @@ Public Class frmFlowForm
End If End If
My.Application.Globix.CURRENT_FOLDERWATCH = oFolderWatchPath My.Application.Globix.CurrentFolderWatchPath = oFolderWatchPath
My.Application.Globix.Folderwatchstarted = True My.Application.Globix.Folderwatchstarted = True
'FWFunction_STARTED = True 'FWFunction_STARTED = True
FolderWatch.StartStop_FolderWatch() FolderWatch.StartStop_FolderWatch()
Catch ex As Exception Catch ex As Exception
MsgBox($"Init_Folderwatch: Unexpected error while starting FolderWatch: {ex.Message}", MsgBoxStyle.Critical) MsgBox($"Init_Folderwatch: Unexpected error while starting FolderWatch: {ex.Message}", MsgBoxStyle.Critical)
Logger.Error(ex)
Logger.Info($"Init_Folderwatch: Unexpected error: {ex.Message}") Logger.Info($"Init_Folderwatch: Unexpected error: {ex.Message}")
End Try End Try
@ -672,7 +677,7 @@ Public Class frmFlowForm
End Try End Try
End Sub End Sub
Sub Start_Folderwatch() Sub Start_Folderwatch()
If My.Application.Globix.CURRENT_FOLDERWATCH = String.Empty Then If My.Application.Globix.CurrentFolderWatchPath = String.Empty Then
My.Application.Globix.Folderwatchstarted = False My.Application.Globix.Folderwatchstarted = False
End If End If
@ -681,7 +686,7 @@ Public Class frmFlowForm
My.UIConfigManager.Save() My.UIConfigManager.Save()
End If End If
If My.Application.Globix.CURRENT_FOLDERWATCH <> "" Or My.Application.Globix.CURRENT_SCAN_FOLDERWATCH <> "" Then If My.Application.Globix.CurrentFolderWatchPath <> "" Or My.Application.Globix.CURRENT_SCAN_FOLDERWATCH <> "" Then
'If My.Application.Globix.Folderwatchstarted = True Then 'If My.Application.Globix.Folderwatchstarted = True Then
' tslblFW.Visible = True ' tslblFW.Visible = True
'Else 'Else
@ -727,8 +732,8 @@ Public Class frmFlowForm
Try Try
If My.Application.Globix.Folderwatchstarted = True Then If My.Application.Globix.Folderwatchstarted = True Then
Logger.Info("Folderwatchstarted - Checking file:" & My.Application.Globix.CURRENT_FOLDERWATCH) Logger.Info("Folderwatchstarted - Checking file:" & My.Application.Globix.CurrentFolderWatchPath)
Dim fileEntries As String() = Directory.GetFiles(My.Application.Globix.CURRENT_FOLDERWATCH) Dim fileEntries As String() = Directory.GetFiles(My.Application.Globix.CurrentFolderWatchPath)
' Process the list of files found in the directory. ' Process the list of files found in the directory.
Dim fileName As String Dim fileName As String
For Each fileName In fileEntries For Each fileName In fileEntries