Zooflow: Massive Clean up

This commit is contained in:
Jonathan Jenne
2022-02-17 15:47:52 +01:00
parent 2ce576d54e
commit c6c548afe4
45 changed files with 1039 additions and 2090 deletions

View File

@@ -24,7 +24,6 @@ Public Class frmFlowForm
Public Shared Function RegisterWindowMessage(ByVal msg As String) As Integer
End Function
#End Region
#Region "Sidebar Variablen"
Private AppDeskData As AppDeskBar
Private fBarRegistered As Boolean = False
@@ -70,7 +69,6 @@ Public Class frmFlowForm
ABN_WINDOWARRANGE
End Enum
#End Region
#Region "Sidebar Enum Properties Register"
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = uCallBack Then
@@ -152,12 +150,12 @@ Public Class frmFlowForm
' Common Helpers Classes
Private Init As ClassInit
Private FileClass As Filesystem.File
Private FileEx As Filesystem.File
Private ErrorHandler As BaseErrorHandler
Private Logger As Logger
' Globix Helper Classes
Private FileDrop As ClassFileDrop
Private FileDropNew As FileDrop
Private FileHandle As ClassFilehandle
Private FolderWatch As ClassFolderwatcher
@@ -194,8 +192,6 @@ Public Class frmFlowForm
' === Register Sidebar ===
RegisterBar(ABEdge.ABE_RIGHT)
End Sub
Private Sub frmFlowForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
@@ -212,11 +208,6 @@ Public Class frmFlowForm
Logger = My.LogConfig.GetLogger()
ErrorHandler = New BaseErrorHandler(My.LogConfig, Logger, Me)
' Register Form as Sidebar
My.Application.Sidebar = New Sidebar2(Me)
My.Application.Sidebar.RegisterBar(Sidebar2.ABEdge.ABE_RIGHT)
'RegisterBar(ABEdge.ABE_RIGHT)
' === Setup Timers ===
AddHandler TimerRefreshData.Tick, AddressOf TimerRefreshData_Tick
TimerRefreshData.Enabled = True
@@ -290,7 +281,7 @@ Public Class frmFlowForm
End If
If My.Application.ModulesActive.Contains(MODULE_GLOBAL_INDEXER) Then
FileDrop = New ClassFileDrop(My.LogConfig)
FileDropNew = New FileDrop(My.LogConfig, "ZooFlow")
FileHandle = New ClassFilehandle(My.LogConfig)
FolderWatch = New ClassFolderwatcher(My.LogConfig)
@@ -518,8 +509,8 @@ Public Class frmFlowForm
Drag_Enter(sender, e)
End Sub
Private Sub frmFlowForm_DragDrop(sender As Object, e As DragEventArgs) Handles MyBase.DragDrop
DragDropForm(e)
Private Async Sub frmFlowForm_DragDrop(sender As Object, e As DragEventArgs) Handles MyBase.DragDrop
Await DragDropForm(e)
End Sub
Private Sub frmFlowForm_DragLeave(sender As Object, e As EventArgs) Handles Me.DragLeave
@@ -563,7 +554,6 @@ Public Class frmFlowForm
End If
Next
'TimerCheckActiveForms.Enabled = False
Return True
End Function
@@ -571,19 +561,11 @@ Public Class frmFlowForm
frmConfigDatabase.ShowDialog()
End Sub
'Private Sub TimerCheckActiveForms_Tick(sender As Object, e As EventArgs) Handles TimerCheckActiveForms.Tick
' Visible = FormLoaded_Visible()
' If Visible = False Then Exit Sub
'End Sub
Private Sub NotifyIcon_DoubleClick(sender As Object, e As EventArgs) Handles NotifyIcon.DoubleClick
If Visible = False Then
Visible = True
Else
Visible = False
'TimerCheckActiveForms.Enabled = False
End If
End Sub
@@ -607,52 +589,59 @@ Public Class frmFlowForm
End If
End Sub
Sub DragDropForm(e As DragEventArgs)
Async Function DragDropForm(e As DragEventArgs) As Threading.Tasks.Task
If Not My.Application.ModulesActive.Contains(ClassConstants.MODULE_GLOBAL_INDEXER) Then
Exit Sub
Exit Function
End If
If TheFormIsAlreadyLoaded("frmIndexFileList") Then
Cursor = Cursors.Default
MsgBox("Please index the active file first!", MsgBoxStyle.Exclamation, "Drag 'n Drop not allowed!")
Exit Sub
Exit Function
End If
'Erstmal alles löschen
My.Database.ExecuteNonQueryECM("DELETE FROM TBGI_FILES_USER WHERE USER@WORK = '" & My.Application.User.UserName & "'")
If FileDrop.Drop_File(e) = True Then
TimerCheckDroppedFiles.Start()
Me.Cursor = Cursors.WaitCursor
End If
End Sub
Private Sub PictureBox1_DragDrop(sender As Object, e As DragEventArgs) Handles PictureBoxDragDrop.DragDrop
DragDropForm(e)
End Sub
Private Async Sub TimerCheckDroppedFiles_Tick(sender As Object, e As EventArgs) Handles TimerCheckDroppedFiles.Tick
If Not My.Application.ModulesActive.Contains(ClassConstants.MODULE_GLOBAL_INDEXER) Then
Exit Sub
Dim oDroppedFiles = FileDropNew.GetFiles(e)
If oDroppedFiles.Count > 0 Then
Await Globix_Check_Dropped_Files(oDroppedFiles)
End If
TimerCheckDroppedFiles.Stop()
Await Globix_Check_Dropped_Files()
Me.Cursor = Cursors.Default
'If FileDrop.Drop_File(e) = True Then
' Me.Cursor = Cursors.WaitCursor
' Await Globix_Check_Dropped_Files()
'End If
End Function
Private Async Sub PictureBox1_DragDrop(sender As Object, e As DragEventArgs) Handles PictureBoxDragDrop.DragDrop
Await DragDropForm(e)
End Sub
Private Async Function Globix_Check_Dropped_Files() As Threading.Tasks.Task
'Private Async Sub TimerCheckDroppedFiles_Tick(sender As Object, e As EventArgs)
' If Not My.Application.ModulesActive.Contains(ClassConstants.MODULE_GLOBAL_INDEXER) Then
' Exit Sub
' End If
' Dim oDroppedFiles = FileDropNew.GetFiles(e)
' If oDroppedFiles.Count > 0 Then
' Await Globix_Check_Dropped_Files()
' End If
' 'TimerCheckDroppedFiles.Stop()
' Await Globix_Check_Dropped_Files()
' Me.Cursor = Cursors.Default
'End Sub
Private Async Function Globix_Check_Dropped_Files(pDroppedFiles As List(Of FileDrop.DroppedFile)) As Threading.Tasks.Task
Try
Await My.Database.ExecuteNonQueryECMAsync($"DELETE FROM TBGI_FILES_USER WHERE WORKED = 1 AND USER@WORK = '{My.Application.User.UserName}'")
Dim i As Integer
For Each pFile As String In FileDrop.files_dropped
If Not pFile Is Nothing Then
Logger.Info(" Check Drop-File: " & pFile.ToString)
Dim handleType As String = pFile.Substring(0, pFile.LastIndexOf("|") + 1)
Dim filename As String = pFile.Substring(pFile.LastIndexOf("|") + 1)
If FileHandle.CheckDuplicateFiles(filename, "Manuelle Ablage") Then
FileHandle.Decide_FileHandle(filename, handleType)
i += 1
End If
For Each oDroppedFile In pDroppedFiles
Logger.Info("Checking Dropped File: [{0}]", oDroppedFile.FilePath)
Dim oDropType = oDroppedFile.DropType
Dim oFileName = oDroppedFile.FilePath
If FileHandle.CheckDuplicateFiles(oFileName, "Manuelle Ablage") Then
FileHandle.Decide_FileHandle(oFileName, oDropType)
End If
Next
@@ -685,29 +674,44 @@ Public Class frmFlowForm
}
Logger.Info(" CURRENT_WORKFILE: {0}", My.Application.Globix.CurrentWorkfile)
If IO.File.Exists(My.Application.Globix.CurrentWorkfile.FilePath) = True And My.Application.Globix.DTACTUAL_FILES.Rows.Count > 0 Then
If IO.File.Exists(My.Application.Globix.CurrentWorkfile.FilePath) = True And
My.Application.Globix.DTACTUAL_FILES.Rows.Count > 0 Then
Globix_Open_IndexDialog()
PictureBoxDragDrop.Image = My.Resources._1_LOGO_ZOO_FLOW1
End If
Next
Show()
Catch ex As Exception
ShowErrorMessage(ex)
Finally
CleanTempFiles()
Show()
End Try
End Function
Private Sub CleanTempFiles()
Dim oTempFiles = My.Application.Globix.TEMP_FILES
For Each oFile In oTempFiles
Try
IO.File.Delete(oFile)
Logger.Debug("Temp file [{0}] was deleted.", oFile)
Catch ex As Exception
Logger.Warn("Temp file [{0}] could not be deleted", oFile)
Logger.Error(ex)
End Try
Next
My.Application.Globix.TEMP_FILES.Clear()
FileHandle.ClearTempFiles()
FileDropNew.RemoveTempDirectory()
End Sub
Sub Globix_Open_IndexDialog()
Try
IndexForm = New frmGlobix_Index(My.LogConfig)
NotifyIconReset()
AddHandler IndexForm.FormClosed, AddressOf GlobixClosed
IndexForm.Show()
IndexForm.ShowDialog()
Cursor = Cursors.Default
'If TimerCheckActiveForms.Enabled = False Then
' TimerCheckActiveForms.Enabled = True
'End If
Catch ex As Exception
ShowErrorMessage(ex)
End Try
@@ -858,7 +862,9 @@ Public Class frmFlowForm
End If
Dim FileForWork As String = row.Item(1).ToString
Logger.Info(" In Timer Folderwatch - File: " & FileForWork)
Dim fileInUse As Boolean = FileHandle.IsFileInUse(FileForWork)
Dim fileInUse As Boolean = FileEx.TestFileIsLocked(FileForWork)
'Dim fileInUse As Boolean = FileHandle.IsFileInUse(FileForWork)
Dim fileexists As Boolean = System.IO.File.Exists(FileForWork)
If fileInUse = False Then
If fileexists = True Then
@@ -905,47 +911,40 @@ Public Class frmFlowForm
oState.CurrentClipboardContents = ClipboardContents
' TODO: These messages are so fucking annoying
If oState.MonitoringActive = False Then
Dim oMessage As String = "Clipboard Watcher is not active!"
Logger.Warn(oMessage)
'If oState.MonitoringActive = False Then
' Dim oMessage As String = "Clipboard Watcher is not active!"
' Logger.Info(oMessage)
' MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Exit Sub
End If
' Exit Sub
'End If
If oState.UserProfiles Is Nothing Then
Dim oMessage As String = "User Profiles are empty!"
Logger.Warn(oMessage)
'If oState.UserProfiles Is Nothing Then
' Dim oMessage As String = "User Profiles are empty!"
' Logger.Info(oMessage)
' MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Exit Sub
End If
' Exit Sub
'End If
If oState.ProfileProcesses Is Nothing OrElse oState.ProfileProcesses.Rows.Count = 0 Then
Dim oMessage As String = "Profile Processes are empty!"
Logger.Warn(oMessage)
'If oState.ProfileProcesses Is Nothing OrElse oState.ProfileProcesses.Rows.Count = 0 Then
' Dim oMessage As String = "Profile Processes are empty!"
' Logger.Info(oMessage)
' MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Exit Sub
End If
' Exit Sub
'End If
If oState.ProfileWindows Is Nothing OrElse oState.ProfileWindows.Rows.Count = 0 Then
Dim oMessage As String = "Profile Windows are empty!"
Logger.Warn(oMessage)
'If oState.ProfileWindows Is Nothing OrElse oState.ProfileWindows.Rows.Count = 0 Then
' Dim oMessage As String = "Profile Processes are empty!"
' Logger.Info(oMessage)
' MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Exit Sub
End If
' Exit Sub
'End If
If oState.ProfileControls Is Nothing OrElse oState.ProfileControls.Rows.Count = 0 Then
Dim oMessage As String = "Profile Processes are empty!"
Logger.Warn(oMessage)
'If oState.ProfileProcesses Is Nothing OrElse oState.ProfileProcesses.Rows.Count = 0 Then
' Dim oMessage As String = "Profile Processes are empty!"
' Logger.Info(oMessage)
' MsgBox(oMessage, MsgBoxStyle.Critical, Text)
' Exit Sub
'End If
Exit Sub
End If
Dim oWindowInfo = ClassWindow.GetWindowInfo()