Monorepo/GUIs.ZooFlow/Globix/ClassHelpers.vb
2021-06-30 16:35:21 +02:00

49 lines
1.8 KiB
VB.net

Public Class ClassHelpers
Public Shared Function FileExistsinDropTable(Filename As String) As Date
Dim oSQL As String
Dim oHash As String
Dim oFilesystem As New DigitalData.Modules.Filesystem.File(My.LogConfig)
Try
If Filename.Contains("'") Then
Filename = Filename.Replace("'", "''")
End If
Try
oHash = oFilesystem.GetChecksum(Filename)
Catch ex As Exception
oHash = ""
End Try
oSQL = "SELECT * FROM TBGI_FILES_USER WHERE UPPER(FILE_HASH) = UPPER('" & oHash & "') AND WORKED = 0 ORDER BY ADDED_WHEN"
Dim oResult As DataTable = My.DatabaseECM.GetDatatable(oSQL)
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 = My.DatabaseECM.GetDatatable(oSQL)
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
End Class