jj: better logging for folderwatch

This commit is contained in:
Jonathan Jenne 2018-06-27 15:04:57 +02:00
parent 83c3f9d7c2
commit bf43248270
2 changed files with 74 additions and 59 deletions

View File

@ -75,6 +75,8 @@ Public Class ClassInit
End If End If
End If End If
Else
ClassLogger.Add("Init_Folderwatch: folderwatch path is nothing!", True)
End If End If
If Not folderwatch_SCAN Is Nothing Then If Not folderwatch_SCAN Is Nothing Then
CURRENT_SCAN_FOLDERWATCH = folderwatch_SCAN CURRENT_SCAN_FOLDERWATCH = folderwatch_SCAN
@ -82,6 +84,8 @@ Public Class ClassInit
FW_ISSTARTED = True FW_ISSTARTED = True
ClassFolderWatcher.StartStop_FolderWatchSCAN() ClassFolderWatcher.StartStop_FolderWatchSCAN()
End If End If
Else
ClassLogger.Add("Init_Folderwatch: folderwatch_SCAN path is nothing!", True)
End If End If
Catch ex As Exception Catch ex As Exception
ClassLogger.Add("Unexpected Error in Init_Folderwatch: " & ex.Message, True) ClassLogger.Add("Unexpected Error in Init_Folderwatch: " & ex.Message, True)

View File

@ -486,68 +486,79 @@ Public Class frmStart
Else Else
tslblFW.Visible = False tslblFW.Visible = False
End If End If
If FWSCAN_started = True Then
If LogErrorsOnly = False Then ClassLogger.Add(">> FWSCAN started - Checking file:" & CURRENT_SCAN_FOLDERWATCH, False)
Dim fileEntries As String() = Directory.GetFiles(CURRENT_SCAN_FOLDERWATCH)
' Process the list of files found in the directory.
Dim fileName As String
For Each fileName In fileEntries
If LogErrorsOnly = False Then ClassLogger.Add(">> Scanfolder after startup: Checking file:" & fileName, False)
For Each row As DataRow In DTEXCLUDE_FILES.Rows
Dim content As String = row.Item(0).ToString.ToLower
If fileName.ToLower.Contains(content) Then
Exit Sub
End If
Next
Dim handleType As String
If fileName.ToLower.EndsWith(".msg") Then
handleType = "|FW_OUTLOOK_MESSAGE|"
Else
handleType = "|FW_SIMPLEINDEXER|"
End If
'Die Datei übergeben
If LogErrorsOnly = False Then ClassLogger.Add(">> Adding file from Scanfolder after startup:" & fileName, False)
If ClassIndexFunctions.FileExistsinDropTable(fileName) = False Then
ClassFilehandle.Decide_FileHandle(fileName, handleType)
Else
ClassLogger.Add(">> Scanfolder Startup: File already exists:" & fileName, False)
End If
Next fileName
Else Try
If LogErrorsOnly = False Then ClassLogger.Add(">> FWSCAN not started", False) If FWSCAN_started = True Then
End If If LogErrorsOnly = False Then ClassLogger.Add(">> FWSCAN started - Checking file:" & CURRENT_SCAN_FOLDERWATCH, False)
If FW_started = True Then Dim fileEntries As String() = Directory.GetFiles(CURRENT_SCAN_FOLDERWATCH)
If LogErrorsOnly = False Then ClassLogger.Add(">> FW_started started - Checking file:" & CURRENT_FOLDERWATCH, False) ' Process the list of files found in the directory.
Dim fileEntries As String() = Directory.GetFiles(CURRENT_FOLDERWATCH) Dim fileName As String
' Process the list of files found in the directory. For Each fileName In fileEntries
Dim fileName As String If LogErrorsOnly = False Then ClassLogger.Add(">> Scanfolder after startup: Checking file:" & fileName, False)
For Each fileName In fileEntries For Each row As DataRow In DTEXCLUDE_FILES.Rows
If LogErrorsOnly = False Then ClassLogger.Add(">> Folderwach after startup: Checking file:" & fileName, False) Dim content As String = row.Item(0).ToString.ToLower
For Each row As DataRow In DTEXCLUDE_FILES.Rows If fileName.ToLower.Contains(content) Then
Dim content As String = row.Item(0).ToString.ToLower Exit Sub
If fileName.ToLower.Contains(content) Then End If
Exit Sub Next
Dim handleType As String
If fileName.ToLower.EndsWith(".msg") Then
handleType = "|FW_OUTLOOK_MESSAGE|"
Else
handleType = "|FW_SIMPLEINDEXER|"
End If End If
Next 'Die Datei übergeben
Dim handleType As String If LogErrorsOnly = False Then ClassLogger.Add(">> Adding file from Scanfolder after startup:" & fileName, False)
If fileName.ToLower.EndsWith(".msg") Then If ClassIndexFunctions.FileExistsinDropTable(fileName) = False Then
handleType = "|FW_OUTLOOK_MESSAGE|" ClassFilehandle.Decide_FileHandle(fileName, handleType)
Else Else
handleType = "|FW_SIMPLEINDEXER|" ClassLogger.Add(">> Scanfolder Startup: File already exists:" & fileName, False)
End If End If
'Die Datei übergeben Next fileName
If LogErrorsOnly = False Then ClassLogger.Add(">> Adding file from Folderwatch after startup:" & fileName, False)
If ClassIndexFunctions.FileExistsinDropTable(fileName) = False Then Else
ClassFilehandle.Decide_FileHandle(fileName, handleType) If LogErrorsOnly = False Then ClassLogger.Add(">> FWSCAN not started", False)
Else End If
ClassLogger.Add(">> Folderwatch Startup: File already exists:" & fileName, False) Catch ex As Exception
End If ClassLogger.Add(">> Error while starting folderwatch scan: " & ex.Message, False)
Next fileName End Try
Try
If FW_started = True Then
If LogErrorsOnly = False Then ClassLogger.Add(">> FW_started started - Checking file:" & CURRENT_FOLDERWATCH, False)
Dim fileEntries As String() = Directory.GetFiles(CURRENT_FOLDERWATCH)
' Process the list of files found in the directory.
Dim fileName As String
For Each fileName In fileEntries
If LogErrorsOnly = False Then ClassLogger.Add(">> Folderwach after startup: Checking file:" & fileName, False)
For Each row As DataRow In DTEXCLUDE_FILES.Rows
Dim content As String = row.Item(0).ToString.ToLower
If fileName.ToLower.Contains(content) Then
Exit Sub
End If
Next
Dim handleType As String
If fileName.ToLower.EndsWith(".msg") Then
handleType = "|FW_OUTLOOK_MESSAGE|"
Else
handleType = "|FW_SIMPLEINDEXER|"
End If
'Die Datei übergeben
If LogErrorsOnly = False Then ClassLogger.Add(">> Adding file from Folderwatch after startup:" & fileName, False)
If ClassIndexFunctions.FileExistsinDropTable(fileName) = False Then
ClassFilehandle.Decide_FileHandle(fileName, handleType)
Else
ClassLogger.Add(">> Folderwatch Startup: File already exists:" & fileName, False)
End If
Next fileName
Else
If LogErrorsOnly = False Then ClassLogger.Add(">> FW_started not started", False)
End If
Catch ex As Exception
ClassLogger.Add(">> Error while starting folderwatch: " & ex.Message, False)
End Try
Else
If LogErrorsOnly = False Then ClassLogger.Add(">> FW_started not started", False)
End If
If TimerFolderWatch.Enabled = False Then If TimerFolderWatch.Enabled = False Then
TimerFolderWatch.Start() TimerFolderWatch.Start()
End If End If