BIG CLEANUP

This commit is contained in:
Jonathan Jenne
2022-02-15 16:28:43 +01:00
parent 8d42a486ed
commit 1b7675a1b4
29 changed files with 1117 additions and 2113 deletions

View File

@@ -10,11 +10,15 @@ Imports DigitalData.Modules.Windows
Imports DigitalData.Modules.License
Public Class frmStart
Public _lizenzManager As LicenseManagerLegacy
Public LicenseManager As LicenseManagerLegacy
Private Const WM_WINDOWPOSCHANGING As Integer = &H46
Private IndexForm As frmIndex
Private FileDrop As FileDrop
'Private DroppedFiles As List(Of FileDrop.DroppedFile)
Protected Overrides Sub WndProc(ByRef m As Message)
' Listen for operating system messages
Select Case m.Msg
@@ -25,10 +29,136 @@ Public Class frmStart
MyBase.WndProc(m)
End Sub
Public Sub New()
Dim splash As New frmSplash()
splash.ShowDialog()
Thread.CurrentThread.CurrentUICulture = New CultureInfo(USER_LANGUAGE)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
End Sub
#Region "=== FORM EVENTS ==="
Private Sub frmStart_Load(sender As Object, e As EventArgs) Handles Me.Load
Cursor = Cursors.WaitCursor
Try
IndexForm = New frmIndex()
FileDrop = New FileDrop(LOGCONFIG)
'Lizenz abgellaufen, überprüfen ob User Admin ist
If LICENSE_COUNT < USERCOUNT_LOGGED_IN Then
If USER_IS_ADMIN = True Then
LOGGER.Info(">> User is Admin - Timer will be started")
If USER_LANGUAGE = "de-DE" Then
MsgBox("Sie haben nun 3 Minuten Zeit eine neue Lizenz zu vergeben!", MsgBoxStyle.Information)
Else
MsgBox("You now got 3 minutes to update the license!", MsgBoxStyle.Information)
End If
'Timer starten
If TimerClose3Minutes.Enabled = False Then
TimerClose3Minutes.Start()
End If
End If
End If
If DOCTYPE_COUNT_ACTUAL > LICENSE_DOCTYPE_COUNT Then
If USER_IS_ADMIN = True Then
LOGGER.Info(">> User is Admin - Timer will be started")
If USER_LANGUAGE = "de-DE" Then
MsgBox("Sie haben nun 3 Minuten Zeit eine neue Lizenz zu vergeben!", MsgBoxStyle.Information)
Else
MsgBox("You now got 3 minutes to update the license!", MsgBoxStyle.Information)
End If
'Timer starten
If TimerClose3Minutes.Enabled = False Then
TimerClose3Minutes.Start()
End If
End If
End If
' SetLanguage()
If USER_IS_ADMIN = True Then
ToolStripSeparator1.Visible = True
AdministrationToolStripMenuItem.Visible = True
Else
ToolStripSeparator1.Visible = False
AdministrationToolStripMenuItem.Visible = False
End If
DATABASE_ECM.ExecuteNonQuery("DELETE FROM TBGI_FILES_USER WHERE UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')")
TopMost = True
Catch ex As Exception
MsgBox("Unexpected Error in Load-Form" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
Cursor = Cursors.Default
End Sub
Private Sub frmStart_Shown(sender As Object, e As EventArgs) Handles Me.Shown
' SetLanguage()
If START_INCOMPLETE = True Then
If LICENSE_COUNT = 0 And LICENSE_EXPIRED = True Then
Else
Me.Close()
End If
Else
TimerFolderWatch.Start()
End If
Opacity = 0.7
CURRENT_DT_REGEX = DATABASE_ECM.GetDatatable("SELECT * FROM TBGI_FUNCTION_REGEX")
Start_Folderwatch()
ClassWindowLocation.LoadFormLocationSize(Me, LoadSize:=False)
Try
Me.LabelControl1.Location = New Point(13, 37)
Catch ex As Exception
Me.btnChoosefiles.Location = New Point(269, 37)
End Try
End Sub
Private Sub frmStart_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Try
If START_INCOMPLETE = False Then
Dim Sql = "DELETE FROM TBDD_USER_MODULE_LOG_IN WHERE USER_ID = " & USER_ID & " AND UPPER(MODULE) = UPPER('Global-Indexer')"
DATABASE_ECM.ExecuteNonQuery(Sql)
End If
ClassWindowLocation.SaveFormLocationSize(Me)
Catch ex As Exception
MsgBox("Unexpected Error in Closing Application: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
Try
IndexForm.DisposeViewer()
IndexForm.Dispose()
Catch ex As Exception
LOGGER.Error(ex)
End Try
End Sub
#End Region
#Region "=== DRAG DROP ==="
Private Sub frmMain_DragDrop(sender As Object, e As DragEventArgs) Handles MyBase.DragDrop
DragDropForm(e)
End Sub
Private Sub LabelControl1_DragDrop(sender As Object, e As DragEventArgs) Handles LabelControl1.DragDrop, btnChoosefiles.DragDrop
DragDropForm(e)
End Sub
Private Sub frmMain_DragEnter(sender As Object, e As DragEventArgs) Handles Me.DragEnter
Drag_Enter(sender, e)
End Sub
Private Sub LabelControl1_DragEnter(sender As Object, e As DragEventArgs) Handles LabelControl1.DragEnter, btnChoosefiles.DragEnter
Drag_Enter(sender, e)
End Sub
Sub DragDropForm(e As DragEventArgs)
Dim frmCollection = Application.OpenForms
If frmCollection.OfType(Of frmIndexFileList).Any Then
@@ -37,14 +167,18 @@ Public Class frmStart
End If
'Erstmal alles löschen
DATABASE_ECM.ExecuteNonQuery("DELETE FROM TBGI_FILES_USER WHERE UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')")
If ClassFileDrop.Drop_File(e) = True Then
TimerCheckDroppedFiles.Start()
Dim oDroppedFiles = FileDrop.GetFiles(e)
If oDroppedFiles.Count > 0 Then
Check_Dropped_Files(oDroppedFiles)
End If
' TODO: REMOVE
'If ClassFileDrop.Drop_File(e) = True Then
' TimerCheckDroppedFiles.Start()
'End If
End Sub
Private Sub frmMain_DragEnter(sender As Object, e As DragEventArgs) Handles Me.DragEnter
Drag_Enter(sender, e)
End Sub
Sub Drag_Enter(sender As Object, e As DragEventArgs)
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.All
@@ -62,23 +196,35 @@ Public Class frmStart
End If
End Sub
Sub Check_Dropped_Files()
Sub Check_Dropped_Files(pDroppedFiles As List(Of FileDrop.DroppedFile))
Try
DATABASE_ECM.ExecuteNonQuery($"DELETE FROM TBGI_FILES_USER WHERE WORKED = 1 AND UPPER(USER@WORK) = UPPER('{Environment.UserName}')")
For Each oFiledropString As String In ClassFileDrop.FilesDropped
If oFiledropString IsNot Nothing Then
LOGGER.Info(">> Check Drop-File: " & oFiledropString.ToString)
Dim oLastPipe = oFiledropString.LastIndexOf("|")
Dim oHandleType As String = oFiledropString.Substring(0, oLastPipe + 1)
Dim oFilename As String = oFiledropString.Substring(oLastPipe + 1)
If ClassIndexFunctions.CheckDuplicateFiles(oFilename, "Manuelle Ablage", oHandleType) Then
ClassFilehandle.Decide_FileHandle(oFilename, oHandleType)
End If
'TODO: finish
For Each oDroppedFile In pDroppedFiles
LOGGER.Info("Checking Dropped File: [{0}]", oDroppedFile.FilePath)
Dim oDropType = oDroppedFile.DropType
Dim oFileName = oDroppedFile.FilePath
If ClassIndexFunctions.CheckDuplicateFiles(oFileName, "Manuelle Ablage", oDropType) Then
FILE_HANDLER.Decide_FileHandle(oFileName, oDropType)
End If
Next
'For Each oFiledropString As String In ClassFileDrop.FilesDropped
' If oFiledropString IsNot Nothing Then
' LOGGER.Info(">> Check Drop-File: " & oFiledropString.ToString)
' Dim oLastPipe = oFiledropString.LastIndexOf("|")
' Dim oHandleType As String = oFiledropString.Substring(0, oLastPipe + 1)
' Dim oFilename As String = oFiledropString.Substring(oLastPipe + 1)
' If ClassIndexFunctions.CheckDuplicateFiles(oFilename, "Manuelle Ablage", oHandleType) Then
' ClassFilehandle.Decide_FileHandle(oFilename, oHandleType)
' End If
' End If
'Next
Dim sql As String = $"SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND UPPER(USER@WORK) = UPPER('{Environment.UserName}')"
DTACTUAL_FILES = Nothing
DTACTUAL_FILES = DATABASE_ECM.GetDatatable(sql)
@@ -146,112 +292,103 @@ Public Class frmStart
End Try
End Sub
Private Sub Clear_Tempfiles()
'TempDateien löschen
For Each oFile In TEMP_FILES
'Private Sub TimerCheckDroppedFiles_Tick(sender As Object, e As EventArgs) Handles TimerCheckDroppedFiles.Tick
' TimerCheckDroppedFiles.Stop()
' Check_Dropped_Files()
'End Sub
Private Sub btnChoosefiles_Click(sender As Object, e As EventArgs) Handles btnChoosefiles.Click
Try
Dim oFileName As String
Dim oOpenFileDialog As New OpenFileDialog With {
.RestoreDirectory = True,
.Multiselect = True
}
If oOpenFileDialog.ShowDialog() = DialogResult.OK Then
'TODO: REMOVE
'ClassFileDrop.FilesDropped.Clear()
Dim oDroppedFiles As New List(Of FileDrop.DroppedFile)
For Each oFileName In oOpenFileDialog.FileNames
LOGGER.Info(">> Chosen File: " & oFileName)
'TODO: REMOVE
'ClassFileDrop.FilesDropped.Add("|DROPFROMFSYSTEM|" & oFileName)
Dim oFile = New FileDrop.DroppedFile(oFileName) With {
.FileFormat = FileDrop.FileFormat.LocalFile
}
oDroppedFiles.Add(oFile)
Next
'TimerCheckDroppedFiles.Start()
Check_Dropped_Files(oDroppedFiles)
End If
Catch ex As Exception
MsgBox("Unexpected Error in Choose Files for Indexing:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
#End Region
#Region "=== MENU ==="
Private Sub GlobalIndexerEinstellungenToolStripMenuItem_Click(sender As Object, e As EventArgs)
Try
Me.Hide()
frmAdministration.ShowDialog()
Me.Show()
Catch ex As Exception
MsgBox("Fehler in der Administration:" & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Critical, Text)
LOGGER.Error(ex)
End Try
End Sub
Private Sub HistoryIndexierteDateienToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles HistoryIndexierteDateienToolStripMenuItem.Click
frmHistory.ShowDialog()
End Sub
Private Sub InfoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles InfoToolStripMenuItem.Click
Me.TopMost = False
frmAbout.ShowDialog()
Me.TopMost = True
End Sub
Private Sub AdministrationToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AdministrationToolStripMenuItem.Click
Try
Me.Hide()
frmAdministration.ShowDialog()
Me.Show()
Catch ex As Exception
MsgBox("Fehler in der Administration:" & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Critical, Text)
LOGGER.Error(ex)
End Try
End Sub
Private Sub GrundeinstellungenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles GrundeinstellungenToolStripMenuItem.Click
Me.TopMost = False
frmConfig_Basic.ShowDialog()
'Wurde die Sprache in der Konfiguration geändert
If LANGUAGE_CHANGED = True Then
Try
System.IO.File.Delete(oFile)
If USER_LANGUAGE = "de-DE" Then
MsgBox("Zur letzendlichen Neukonfiguration der Sprache ist ein Neustart notwendig!", MsgBoxStyle.Information, Text)
Else
MsgBox("For the final changing of language, a restart is required!", MsgBoxStyle.Information, Text)
End If
Application.Restart()
Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Please restart the application manually.", MsgBoxStyle.Information, Text)
End Try
Next
Else
Start_Folderwatch()
Me.TopMost = True
End If
End Sub
#End Region
Sub Open_IndexDialog()
Try
Hide()
IndexForm.ShowDialog()
Catch ex As Exception
LOGGER.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical)
Finally
Show()
End Try
End Sub
Private Sub frmStart_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Try
If START_INCOMPLETE = False Then
Dim Sql = "DELETE FROM TBDD_USER_MODULE_LOG_IN WHERE USER_ID = " & USER_ID & " AND UPPER(MODULE) = UPPER('Global-Indexer')"
DATABASE_ECM.ExecuteNonQuery(Sql)
End If
ClassWindowLocation.SaveFormLocationSize(Me)
Catch ex As Exception
MsgBox("Unexpected Error in Closing Application: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
Try
IndexForm.DisposeViewer()
IndexForm.Dispose()
Catch ex As Exception
LOGGER.Error(ex)
End Try
End Sub
Public Sub New()
Dim splash As New frmSplash()
splash.ShowDialog()
Thread.CurrentThread.CurrentUICulture = New CultureInfo(USER_LANGUAGE)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
End Sub
Private Sub frmStart_Load(sender As Object, e As EventArgs) Handles Me.Load
Cursor = Cursors.WaitCursor
Try
IndexForm = New frmIndex()
'Lizenz abgellaufen, überprüfen ob User Admin ist
If LICENSE_COUNT < USERCOUNT_LOGGED_IN Then
If USER_IS_ADMIN = True Then
LOGGER.Info(">> User is Admin - Timer will be started")
If USER_LANGUAGE = "de-DE" Then
MsgBox("Sie haben nun 3 Minuten Zeit eine neue Lizenz zu vergeben!", MsgBoxStyle.Information)
Else
MsgBox("You now got 3 minutes to update the license!", MsgBoxStyle.Information)
End If
'Timer starten
If TimerClose3Minutes.Enabled = False Then
TimerClose3Minutes.Start()
End If
End If
End If
If DOCTYPE_COUNT_ACTUAL > LICENSE_DOCTYPE_COUNT Then
If USER_IS_ADMIN = True Then
LOGGER.Info(">> User is Admin - Timer will be started")
If USER_LANGUAGE = "de-DE" Then
MsgBox("Sie haben nun 3 Minuten Zeit eine neue Lizenz zu vergeben!", MsgBoxStyle.Information)
Else
MsgBox("You now got 3 minutes to update the license!", MsgBoxStyle.Information)
End If
'Timer starten
If TimerClose3Minutes.Enabled = False Then
TimerClose3Minutes.Start()
End If
End If
End If
' SetLanguage()
If USER_IS_ADMIN = True Then
ToolStripSeparator1.Visible = True
AdministrationToolStripMenuItem.Visible = True
Else
ToolStripSeparator1.Visible = False
AdministrationToolStripMenuItem.Visible = False
End If
DATABASE_ECM.ExecuteNonQuery("DELETE FROM TBGI_FILES_USER WHERE UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')")
TopMost = True
Catch ex As Exception
MsgBox("Unexpected Error in Load-Form" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
Cursor = Cursors.Default
End Sub
#Region "=== FOLDERWATCH ==="
Sub Start_Folderwatch()
If CURRENT_FOLDERWATCH = String.Empty Then
FW_started = False
@@ -293,7 +430,7 @@ Public Class frmStart
LOGGER.Info(">> Adding file from Scanfolder after startup:" & oFileName)
If ClassIndexFunctions.CheckDuplicateFiles(oFileName, "FolderWatch/Scan") Then
ClassFilehandle.Decide_FileHandle(oFileName, oHandleType)
FILE_HANDLER.Decide_FileHandle(oFileName, oHandleType)
End If
Next oFileName
@@ -329,7 +466,7 @@ Public Class frmStart
LOGGER.Info(">> Adding file from Folderwatch after startup:" & oFileName)
If ClassIndexFunctions.CheckDuplicateFiles(oFileName, "FolderWatch/Scan") Then
ClassFilehandle.Decide_FileHandle(oFileName, handleType)
FILE_HANDLER.Decide_FileHandle(oFileName, handleType)
End If
Next oFileName
Else
@@ -347,38 +484,7 @@ Public Class frmStart
End Sub
Private Sub GlobalIndexerEinstellungenToolStripMenuItem_Click(sender As Object, e As EventArgs)
Try
Me.Hide()
frmAdministration.ShowDialog()
Me.Show()
Catch ex As Exception
MsgBox("Fehler in der Administration:" & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Critical, Text)
LOGGER.Error(ex)
End Try
End Sub
Private Sub GrundeinstellungenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles GrundeinstellungenToolStripMenuItem.Click
Me.TopMost = False
frmConfig_Basic.ShowDialog()
'Wurde die Sprache in der Konfiguration geändert
If LANGUAGE_CHANGED = True Then
Try
If USER_LANGUAGE = "de-DE" Then
MsgBox("Zur letzendlichen Neukonfiguration der Sprache ist ein Neustart notwendig!", MsgBoxStyle.Information, Text)
Else
MsgBox("For the final changing of language, a restart is required!", MsgBoxStyle.Information, Text)
End If
Application.Restart()
Catch ex As Exception
LOGGER.Error(ex)
MsgBox("Please restart the application manually.", MsgBoxStyle.Information, Text)
End Try
Else
Start_Folderwatch()
Me.TopMost = True
End If
End Sub
Private Sub TimerFolderWatch_Tick(sender As Object, e As EventArgs) Handles TimerFolderWatch.Tick
If DATABASE_ECM.DBInitialized = False Then
@@ -423,7 +529,7 @@ Public Class frmStart
End If
Dim FileForWork As String = row.Item(1)
LOGGER.Info(">> In Timer Folderwatch - File: " & FileForWork)
Dim fileInUse As Boolean = ClassFilehandle.IsFileInUse(FileForWork)
Dim fileInUse As Boolean = FILE_HANDLER.IsFileInUse(FileForWork)
Dim fileexists As Boolean = System.IO.File.Exists(FileForWork)
If fileInUse = False Then
If fileexists = True Then
@@ -459,6 +565,33 @@ Public Class frmStart
End Try
End If
End Sub
#End Region
Private Sub Clear_Tempfiles()
'TempDateien löschen
For Each oFile In FILE_HANDLER.TempFiles
Try
System.IO.File.Delete(oFile)
Catch ex As Exception
LOGGER.Error(ex)
End Try
Next
End Sub
Sub Open_IndexDialog()
Try
Hide()
IndexForm.ShowDialog()
Catch ex As Exception
LOGGER.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical)
Finally
Show()
End Try
End Sub
Private Sub TimerClose3Minutes_Tick(sender As Object, e As EventArgs) Handles TimerClose3Minutes.Tick
If LICENSE_EXPIRED = True Or LICENSE_COUNT < USERCOUNT_LOGGED_IN Then
If USER_LANGUAGE = "de-DE" Then
@@ -472,74 +605,8 @@ Public Class frmStart
TimerClose3Minutes.Stop()
End If
End Sub
Private Sub frmStart_Shown(sender As Object, e As EventArgs) Handles Me.Shown
' SetLanguage()
If START_INCOMPLETE = True Then
If LICENSE_COUNT = 0 And LICENSE_EXPIRED = True Then
Else
Me.Close()
End If
Else
TimerFolderWatch.Start()
End If
Opacity = 0.7
CURRENT_DT_REGEX = DATABASE_ECM.GetDatatable("SELECT * FROM TBGI_FUNCTION_REGEX")
Start_Folderwatch()
ClassWindowLocation.LoadFormLocationSize(Me, LoadSize:=False)
Try
Me.LabelControl1.Location = New Point(13, 37)
Catch ex As Exception
Me.btnChoosefiles.Location = New Point(269, 37)
End Try
End Sub
Private Sub HistoryIndexierteDateienToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles HistoryIndexierteDateienToolStripMenuItem.Click
frmHistory.ShowDialog()
End Sub
Private Sub InfoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles InfoToolStripMenuItem.Click
Me.TopMost = False
AboutBox1.ShowDialog()
Me.TopMost = True
End Sub
Private Sub TimerCheckDroppedFiles_Tick(sender As Object, e As EventArgs) Handles TimerCheckDroppedFiles.Tick
TimerCheckDroppedFiles.Stop()
Check_Dropped_Files()
End Sub
Private Sub LabelControl1_DragDrop(sender As Object, e As DragEventArgs) Handles LabelControl1.DragDrop, btnChoosefiles.DragDrop
DragDropForm(e)
End Sub
Private Sub LabelControl1_DragEnter(sender As Object, e As DragEventArgs) Handles LabelControl1.DragEnter, btnChoosefiles.DragEnter
Drag_Enter(sender, e)
End Sub
Private Sub btnChoosefiles_Click(sender As Object, e As EventArgs) Handles btnChoosefiles.Click
Try
Dim oFileName As String
Dim oOpenFileDialog As New OpenFileDialog With {
.RestoreDirectory = True,
.Multiselect = True
}
If oOpenFileDialog.ShowDialog() = DialogResult.OK Then
ClassFileDrop.FilesDropped.Clear()
For Each oFileName In oOpenFileDialog.FileNames
LOGGER.Info(">> Chosen File: " & oFileName)
ClassFileDrop.FilesDropped.Add("|DROPFROMFSYSTEM|" & oFileName)
Next
TimerCheckDroppedFiles.Start()
End If
Catch ex As Exception
MsgBox("Unexpected Error in Choose Files for Indexing:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub frmStart_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
If e.KeyCode = Keys.F12 Then
@@ -549,14 +616,5 @@ Public Class frmStart
End If
End Sub
Private Sub AdministrationToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AdministrationToolStripMenuItem.Click
Try
Me.Hide()
frmAdministration.ShowDialog()
Me.Show()
Catch ex As Exception
MsgBox("Fehler in der Administration:" & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Critical, Text)
LOGGER.Error(ex)
End Try
End Sub
End Class