Imports System.IO Public Class ClassIndexFunctions Public Shared Function FileExistsinDropTable(Filename As String) As Date Dim oSQL As String Dim oHash As String Try If Filename.Contains("'") Then Filename = Filename.Replace("'", "''") End If ' If file cannot be accessed, checksum cannot be generated ' In this case, the file should be treated as not yet existing oHash = FILESYSTEM.GetChecksum(Filename) If oHash Is Nothing Then LOGGER.Warn("Checksum for file {0} could not be generated. Treating as new file.", Filename) Return Nothing End If oSQL = "SELECT * FROM TBGI_FILES_USER WHERE UPPER(FILE_HASH) = UPPER('" & oHash & "') AND WORKED = 0 ORDER BY ADDED_WHEN" Dim oResult As DataTable = ClassDatabase.Return_Datatable_CS(oSQL, MyConnectionString, True) If oResult Is Nothing Then Return Nothing End If If oResult.Rows.Count = 0 Then oSQL = "SELECT * FROM TBGI_HISTORY WHERE UPPER(FILE_HASH) = UPPER('" & oHash & "') ORDER BY ADDED_WHEN" oResult = ClassDatabase.Return_Datatable_CS(oSQL, MyConnectionString, True) If oResult Is Nothing Then Return Nothing End If If oResult.Rows.Count = 0 Then Return Nothing Else Dim oFirstRow As DataRow = oResult.Rows.Item(0) Return oFirstRow.Item("ADDED_WHEN") End If Else Dim oFirstRow As DataRow = oResult.Rows.Item(0) Return oFirstRow.Item("ADDED_WHEN") End If Catch ex As Exception MsgBox("Error in FileExistsinDropTable - Error-Message:" & vbNewLine & ex.Message & vbNewLine & "SQL-Command:" & vbNewLine & oSQL, MsgBoxStyle.Critical) 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