ZooFlow: Include Globix fixes

This commit is contained in:
Jonathan Jenne
2021-06-14 11:53:03 +02:00
parent ebef306a72
commit 8530005b6b
9 changed files with 212 additions and 112 deletions

View File

@@ -0,0 +1,56 @@
Public Class ClassExclusions
Public Function Load(ExclusionPath As String) As Boolean
Dim rowresult As String = ""
Try
'if file doesn't exist, create the file with its default xml table
If Not IO.File.Exists(My.Application.Globix.PATH_FileExclusions) Then
My.Application.Globix.DTEXCLUDE_FILES = CreateExclusionTable()
My.Application.Globix.DTEXCLUDE_FILES.WriteXml(My.Application.Globix.PATH_FileExclusions)
End If
My.Application.Globix.DTEXCLUDE_FILES = GetTablefromXML(ExclusionPath)
Return True
Catch ex As Exception
MsgBox("Error in ModuleUserSavings-LoadFileExclusion" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
End Function
Private Function CreateExclusionTable() As DataTable
Try
Dim oMyExclusions As New DataTable
oMyExclusions.TableName = "TBEXCLUSION"
' Create two columns, ID and Name.
oMyExclusions.Columns.Add("FILE_CONTAIN", GetType(System.String))
Dim newRow As DataRow = oMyExclusions.NewRow()
newRow("FILE_CONTAIN") = "Thumbs"
oMyExclusions.Rows.Add(newRow)
Dim newRow1 As DataRow = oMyExclusions.NewRow()
newRow1("FILE_CONTAIN") = "\~$"
oMyExclusions.Rows.Add(newRow1)
Dim newRow2 As DataRow = oMyExclusions.NewRow()
newRow2("FILE_CONTAIN") = ".db"
oMyExclusions.Rows.Add(newRow2)
Dim newRow3 As DataRow = oMyExclusions.NewRow()
newRow3("FILE_CONTAIN") = "desktop.ini"
oMyExclusions.Rows.Add(newRow3)
oMyExclusions.AcceptChanges()
Return oMyExclusions
Catch ex As Exception
MsgBox("Error in CreateExclusionTable" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
Private Function GetTablefromXML(FileExclusionPath As String) As DataTable
Try
Dim DS As New DataSet
DS.ReadXml(FileExclusionPath)
Return DS.Tables(0)
Catch ex As Exception
MsgBox("Error in GetTablefromXML" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
End Class

View File

@@ -23,6 +23,33 @@ Public Class ClassFilehandle
Dim r = New Regex(String.Format("[{0}]", Regex.Escape(regexSearch)))
Return r.Replace(Input, replacement)
End Function
Public Function CheckDuplicateFiles(Filepath As String, ModuleTitle As String)
Dim oFileInfo As New FileInfo(Filepath)
Dim oFilename As String = oFileInfo.Name
Dim oFileExists As Date = ClassHelpers.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 My.Application.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
Public Function Decide_FileHandle(filename As String, handletype As String) As Boolean
Try
If filename.EndsWith(".msg") Then

View File

@@ -182,7 +182,8 @@ Public Class ClassFolderwatcher
End If
'Die Datei übergeben
Logger.Info(">> OnCreated-File:" & e.FullPath)
If My.Application.Globix.FileExistsinDropTable(e.FullPath) = False Then
If clsFilehandle.CheckDuplicateFiles(e.FullPath, "FolderWatch/Scan") Then
clsFilehandle.Decide_FileHandle(e.FullPath, handleType)
Else
Logger.Info(">> Folderwatcher: File already exists:" & e.FullPath)

View File

@@ -0,0 +1,48 @@
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.Database.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.Database.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

View File

@@ -1,6 +1,7 @@
Imports System.IO
Namespace Globix
Public Class State
Public Property DT_FUNCTION_REGEX As DataTable
Public Property DTACTUAL_FILES As DataTable
@@ -42,91 +43,7 @@ Namespace Globix
Public Property Folderwatchstarted As Boolean = False
Public Property DTEXCLUDE_FILES As DataTable
Public PATH_FileExclusions As String = Path.Combine(Application.UserAppDataPath(), "FileExclusions.xml")
Public Function FileExistsinDropTable(Filename As String) As Boolean
Dim oSQL As String
Try
If Filename.Contains("'") Then
Filename = Filename.Replace("'", "''")
End If
oSQL = "SELECT COUNT(*) FROM TBGI_FILES_USER WHERE UPPER(FILENAME2WORK) = UPPER('" & Filename & "') AND WORKED = 0"
Dim result = My.Database.GetScalarValue(oSQL)
If result >= 1 Then
result = True
Else
result = False
End If
Return result
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 Function LoadFileExclusion() As Boolean
Dim rowresult As String = ""
Try
'if file doesn't exist, create the file with its default xml table
If Not File.Exists(PATH_FileExclusions) Then
DTEXCLUDE_FILES = CreateExclusionTable()
DTEXCLUDE_FILES.WriteXml(PATH_FileExclusions)
End If
DTEXCLUDE_FILES = GetTablefromXML()
'For Each Row As DataRow In DT.Rows
' rowresult &= Row.Item("FILE_CONTAIN")
' Select Case Row.Item("FILE_^^CONTAIN")
' End Select
'Next
Return True
Catch ex As Exception
MsgBox("Error in ModuleUserSavings-LoadFileExclusion" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
Return True
End Function
Private Function CreateExclusionTable() As DataTable
Try
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim oMyExclusions As New DataTable
oMyExclusions.TableName = "TBEXCLUSION"
' Create two columns, ID and Name.
oMyExclusions.Columns.Add("FILE_CONTAIN", GetType(System.String))
Dim newRow As DataRow = oMyExclusions.NewRow()
newRow("FILE_CONTAIN") = "Thumbs"
oMyExclusions.Rows.Add(newRow)
Dim newRow1 As DataRow = oMyExclusions.NewRow()
newRow1("FILE_CONTAIN") = "\~$"
oMyExclusions.Rows.Add(newRow1)
Dim newRow2 As DataRow = oMyExclusions.NewRow()
newRow2("FILE_CONTAIN") = ".db"
oMyExclusions.Rows.Add(newRow2)
Dim newRow3 As DataRow = oMyExclusions.NewRow()
newRow3("FILE_CONTAIN") = "desktop.ini"
oMyExclusions.Rows.Add(newRow3)
oMyExclusions.AcceptChanges()
Return oMyExclusions
Catch ex As Exception
MsgBox("Error in CreateExclusionTable" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
Private Function GetTablefromXML() As DataTable
Try
Dim DS As New DataSet
DS.ReadXml(PATH_FileExclusions)
Return DS.Tables(0)
Catch ex As Exception
MsgBox("Error in GetTablefromXML" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
Public Property PATH_FileExclusions As String = Path.Combine(Application.UserAppDataPath(), "FileExclusions.xml")
End Class
End Namespace

View File

@@ -10,6 +10,7 @@ Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Language.Utils
Imports DigitalData.Controls.LookupGrid
Imports Independentsoft
Imports DevExpress.XtraEditors.Controls
Public Class frmGlobix_Index
#Region "+++++ Variablen ++++++"
@@ -68,6 +69,8 @@ Public Class frmGlobix_Index
clsPostProcessing = New GlobixPostprocessing(LogConfig)
_idbdata = New ClassIDBData(LogConfig)
_Patterns = New GlobixPatterns(LogConfig)
Localizer.Active = New LookupGridLocalizer()
End Sub
Private Sub frmGlobix_Index_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@@ -388,14 +391,20 @@ Public Class frmGlobix_Index
End Sub
Private Sub LoadIndexe_Man()
Try
Dim oScreen As New DigitalData.Modules.Windows.Screen()
Dim oDpiScale = oScreen.GetScreenScaling(Me)
Dim oControlCount As Integer = 1
Dim oLabelPosition As Integer = 11
Dim oControlPosition As Integer = 33
Dim oLabelPosition As Integer = 11 * oDpiScale
Dim oControlPosition As Integer = 33 * oDpiScale
' Dim oControls As New GlobixControls(_LogConfig, pnlIndex, Me)
Dim oControls As New DigitalData.GUIs.GlobalIndexer.ControlCreator(_LogConfig, pnlIndex, Me) With {
.OnControlChanged = AddressOf PrepareDependingControl,
.OnLookupData = AddressOf GetLookupData
}
_Logger.Info("Loading Indicies for Screen Scaling Factor [{0}]", oDpiScale)
_Controls = oControls
If DT_INDEXEMAN.Rows.Count = 0 Then
ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & ComboBoxEdit1.Text & " definiert")
@@ -474,8 +483,8 @@ Public Class frmGlobix_Index
End Select
oControlCount += 1
oLabelPosition += 50
oControlPosition += 50
oLabelPosition += 50 * oDpiScale
oControlPosition += 50 * oDpiScale
'make y as height in fom
Next
Dim oPanelHeight = oControlPosition - 30
@@ -501,7 +510,7 @@ Public Class frmGlobix_Index
Try
Dim oMeta = DirectCast(pControl.Tag, ControlMeta)
Dim oIndexName As String = oMeta.IndexName
Dim oSQL = $"SELECT * FROM TBDD_INDEX_MAN WHERE SQL_RESULT LIKE '%{oIndexName}%'"
Dim oSQL = $"SELECT * FROM TBDD_INDEX_MAN WHERE SQL_RESULT LIKE '%{oIndexName}%' AND DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID}"
Dim oDatatable As DataTable = My.Database.GetDatatable(oSQL)
If Not IsNothing(oDatatable) Then
@@ -882,6 +891,17 @@ Public Class frmGlobix_Index
_Logger.Info("Datei '" & My.Application.Globix.CURRENT_NEWFILENAME & "' erfolgreich erzeugt.")
Dim oDEL As String = "DELETE FROM TBGI_FILES_USER WHERE GUID = " & My.Application.Globix.CURRENT_WORKFILE_GUID
My.Database.ExecuteNonQuery(oDEL)
If My.Application.Globix.CURR_DELETE_ORIGIN = True Then
_Logger.Info("Datei [" & My.Application.Globix.CURRENT_WORKFILE & "] wird gelöscht.")
Try
System.IO.File.Delete(My.Application.Globix.CURRENT_WORKFILE)
Catch ex As Exception
_Logger.Error(ex)
End Try
_Logger.Info("Datei [" & My.Application.Globix.CURRENT_WORKFILE & "] wurde gelöscht.")
End If
Return True
End If
@@ -1246,12 +1266,15 @@ Public Class frmGlobix_Index
If Directory.Exists(opath) = False Then
Directory.CreateDirectory(opath)
End If
'Die Datei wird nun verschoben
If My.Application.Globix.CURR_DELETE_ORIGIN = True Then
My.Computer.FileSystem.MoveFile(My.Application.Globix.CURRENT_WORKFILE, My.Application.Globix.CURRENT_NEWFILENAME)
Else
My.Computer.FileSystem.CopyFile(My.Application.Globix.CURRENT_WORKFILE, My.Application.Globix.CURRENT_NEWFILENAME)
End If
''Die Datei wird nun verschoben
'If My.Application.Globix.CURR_DELETE_ORIGIN = True Then
' My.Computer.FileSystem.MoveFile(My.Application.Globix.CURRENT_WORKFILE, My.Application.Globix.CURRENT_NEWFILENAME)
'Else
' My.Computer.FileSystem.CopyFile(My.Application.Globix.CURRENT_WORKFILE, My.Application.Globix.CURRENT_NEWFILENAME)
'End If
'Die Datei wird nun an den neuen Ort kopiert
My.Computer.FileSystem.MoveFile(My.Application.Globix.CURRENT_WORKFILE, My.Application.Globix.CURRENT_NEWFILENAME)
Dim Insert_String As String
Try