Customize Msgbox title, handle minDate when file not found, show filename in msgbox

This commit is contained in:
Jonathan Jenne
2021-05-04 14:06:08 +02:00
parent 580597569d
commit e029c20ae9
3 changed files with 35 additions and 81 deletions

View File

@@ -194,25 +194,9 @@ Public Class ClassFolderWatcher
'Die Datei übergeben
LOGGER.Info(">> OnCreated-File:" & e.FullPath)
Dim oFileExists As Date = ClassIndexFunctions.FileExistsinDropTable(e.FullPath)
If IsNothing(oFileExists) Then
If ClassIndexFunctions.CheckDuplicateFiles(e.FullPath, "FolderWatch/Scan") Then
ClassFilehandle.Decide_FileHandle(e.FullPath, oHandleType)
Else
Dim oResult As DialogResult
Dim oDate As String = oFileExists.ToString("d")
If USER_LANGUAGE = "de-DE" Then
oResult = MsgBox($"Die Datei wurde bereits am [{oDate}] verarbeitet. Wollen Sie die gleiche Datei noch einmal verarbeiten?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, "GLOBIX - FolderWatch")
Else
oResult = MsgBox($"This file has already been processed at [{oDate}]. Do you want to process the same file again?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, "GLOBIX - FolderWatch")
End If
If oResult = DialogResult.Yes Then
ClassFilehandle.Decide_FileHandle(e.FullPath, oHandleType)
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in folder_watch_Created")
End Try

View File

@@ -1,5 +1,7 @@
Public Class ClassIndexFunctions
Public Shared Function FileExistsinDropTable(Filename As String) As DateTime
Imports System.IO
Public Class ClassIndexFunctions
Public Shared Function FileExistsinDropTable(Filename As String) As Date
Dim oSQL As String
Dim oHash As String
@@ -45,4 +47,31 @@
Return Nothing
End Try
End Function
Public Shared Function CheckDuplicateFiles(Filepath As String, ModuleTitle As String)
Dim oFileInfo As New FileInfo(Filepath)
Dim oFilename As String = oFileInfo.Name
Dim oFileExists As Date = FileExistsinDropTable(Filepath)
If oFileExists.Equals(Date.MinValue) Then
Return True
Else
Dim oResult As DialogResult
Dim oDate As String = oFileExists.ToString("d")
Dim oBoxTitle = $"GLOBIX - {ModuleTitle}"
Dim oBoxOptions = MsgBoxStyle.Question Or MsgBoxStyle.YesNo
If USER_LANGUAGE = "de-DE" Then
oResult = MsgBox($"Die Datei [{oFilename}] wurde bereits am [{oDate}] verarbeitet. Wollen Sie die gleiche Datei noch einmal verarbeiten?", oBoxOptions, oBoxTitle)
Else
oResult = MsgBox($"The file [{oFilename}] has already been processed at [{oDate}]. Do you want to process the same file again?", oBoxOptions, oBoxTitle)
End If
If oResult = DialogResult.Yes Then
Return True
End If
End If
Return False
End Function
End Class

View File

@@ -168,25 +168,10 @@ Public Class frmStart
Dim oLastPipe = oFiledropString.LastIndexOf("|")
Dim oHandleType As String = oFiledropString.Substring(0, oLastPipe + 1)
Dim oFilename As String = oFiledropString.Substring(oLastPipe + 1)
Dim oFileExists As Date = ClassIndexFunctions.FileExistsinDropTable(oFilename)
If IsNothing(oFileExists) Then
If ClassIndexFunctions.CheckDuplicateFiles(oFilename, "Manuelle Ablage") Then
ClassFilehandle.Decide_FileHandle(oFilename, oHandleType)
oIndex += 1
Else
Dim oResult As DialogResult
Dim oDate As String = oFileExists.ToString("d")
If USER_LANGUAGE = "de-DE" Then
oResult = MsgBox($"Die Datei wurde bereits am [{oDate}] verarbeitet. Wollen Sie die gleiche Datei noch einmal verarbeiten?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, "GLOBIX - FolderWatch")
Else
oResult = MsgBox($"This file has already been processed at [{oDate}]. Do you want to process the same file again?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, "GLOBIX - FolderWatch")
End If
If oResult = DialogResult.Yes Then
ClassFilehandle.Decide_FileHandle(oFilename, oHandleType)
oIndex += 1
End If
End If
End If
Next
@@ -373,30 +358,9 @@ Public Class frmStart
'Die Datei übergeben
LOGGER.Info(">> Adding file from Scanfolder after startup:" & oFileName)
Dim oFileExists As Date = ClassIndexFunctions.FileExistsinDropTable(oFileName)
If IsNothing(oFileExists) Then
If ClassIndexFunctions.CheckDuplicateFiles(oFileName, "FolderWatch/Scan") Then
ClassFilehandle.Decide_FileHandle(oFileName, oHandleType)
Else
Dim oResult As DialogResult
Dim oDate As String = oFileExists.ToString("d")
If USER_LANGUAGE = "de-DE" Then
oResult = MsgBox($"Die Datei wurde bereits am [{oDate}] verarbeitet. Wollen Sie die gleiche Datei noch einmal verarbeiten?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, "GLOBIX - FolderWatch")
Else
oResult = MsgBox($"This file has already been processed at [{oDate}]. Do you want to process the same file again?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, "GLOBIX - FolderWatch")
End If
If oResult = DialogResult.Yes Then
ClassFilehandle.Decide_FileHandle(oFileName, oHandleType)
End If
End If
'If ClassIndexFunctions.FileExistsinDropTable(fileName) = False Then
' ClassFilehandle.Decide_FileHandle(fileName, handleType)
'Else
' LOGGER.Info(">> Scanfolder Startup: File already exists:" & fileName)
'End If
Next oFileName
Else
@@ -430,33 +394,10 @@ Public Class frmStart
'Die Datei übergeben
LOGGER.Info(">> Adding file from Folderwatch after startup:" & oFileName)
'If ClassIndexFunctions.FileExistsinDropTable(fileName) = False Then
' ClassFilehandle.Decide_FileHandle(fileName, handleType)
'Else
' LOGGER.Info(">> Folderwatch Startup: File already exists:" & fileName)
'End If
Dim oFileExists As Date = ClassIndexFunctions.FileExistsinDropTable(oFileName)
If IsNothing(oFileExists) Then
If ClassIndexFunctions.CheckDuplicateFiles(oFileName, "FolderWatch/Scan") Then
ClassFilehandle.Decide_FileHandle(oFileName, handleType)
Else
Dim oResult As DialogResult
Dim oDate As String = oFileName.ToString("d")
If USER_LANGUAGE = "de-DE" Then
oResult = MsgBox($"Die Datei wurde bereits am [{oDate}] verarbeitet. Wollen Sie die gleiche Datei noch einmal verarbeiten?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, "GLOBIX - FolderWatch")
Else
oResult = MsgBox($"This file has already been processed at [{oDate}]. Do you want to process the same file again?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, "GLOBIX - FolderWatch")
End If
If oResult = DialogResult.Yes Then
ClassFilehandle.Decide_FileHandle(oFileName, handleType)
End If
End If
Next oFileName
Else
LOGGER.Info(">> FW_started not started")
End If