Modules/GUIs.ZooFlow/frmGlobix_Index.vb

216 lines
9.7 KiB
VB.net

Imports DigitalData.Modules.Logging
Public Class frmGlobix_Index
#Region "+++++ Variablen ++++++"
Public vPathFile As String
Private MULTIFILES As Integer
Private akttxtbox As TextBox
Dim DT_INDEXEMAN As DataTable
Dim DT_DOKART As DataTable
Public FormLoaded As Boolean = False
Dim DropType As String
Private Shared WDDirect As Boolean = False
Dim sql_history_INSERT_INTO As String
Dim sql_history_Index_Values As String
Private NewFileString As String
Private CancelAttempts As Integer = 0
Private Const MaxCancelAttempts = 2
Private Property ViewerString As String
Private Const TEXT_MISSING_INPUT = "Bitte vervollständigen Sie die Eingaben!"
Private _LogConfig As LogConfig
Private _Logger As Logger
Private clswindowLocation As ClassWindowLocation
#End Region
Public Sub New(LogConfig As LogConfig)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
_Logger = LogConfig.GetLogger()
_LogConfig = LogConfig
clswindowLocation = New ClassWindowLocation(_LogConfig)
End Sub
Private Sub frmGlobix_Index_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Abbruchzähler zurücksetzen
CancelAttempts = 0
My.Application.Globix.INDEXING_ACTIVE = True
Try
My.Application.Globix.CURRENT_ISATTACHMENT = False
DropType = My.Database.GetScalarValue("SELECT HANDLE_TYPE FROM TBGI_FILES_USER WHERE GUID = " & My.Application.Globix.CURRENT_WORKFILE_GUID).ToString
My.Application.Globix.CURR_DELETE_ORIGIN = My.UIConfig.Globix.DeleteOriginalFile
SourceDeleteItem.Enabled = True
SourceDeleteItem.Checked = My.UIConfig.Globix.DeleteOriginalFile
My.Application.GDPictureLicense = My.Database.GetScalarValue("SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'")
DocumentViewer1.Init(_LogConfig, My.Application.GDPictureLicense)
If DropType Is Nothing Then
_Logger.Debug("File with Id [{0}] was not found in TBGI_FILES_USER. Exiting.", My.Application.Globix.CURRENT_WORKFILE_GUID)
CancelAttempts = MaxCancelAttempts
Close()
Else
My.Application.Globix.CURRENT_DROPTYPE = DropType.Replace("|", "")
If DropType.StartsWith("|FW") Then
' Eine Datei aus FolderWatch wird IMMER gelöscht, egal wie die Einstellung in der Config lautet
My.Application.Globix.CURR_DELETE_ORIGIN = True
SourceDeleteItem.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
ElseIf DropType.Contains("|OUTLOOK_MESSAGE|") Then
' Eine (DragDrop)-Outlook Nachricht wird NIE gelöscht, egal wie die Einstellung in der Config lautet
My.Application.Globix.CURR_DELETE_ORIGIN = False
SourceDeleteItem.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
Else
SourceDeleteItem.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
End If
If DropType = "|DROPFROMFSYSTEM|" Then
If My.Application.User.Language <> "de-DE" Then
Me.Text = "Indexing of dropped file"
Else
Me.Text = "Indexierung der gedroppten Datei"
End If
ElseIf DropType = "|OUTLOOK_MESSAGE|" Or DropType = "|FW_MSGONLY|" Then
Select Case DropType
Case "|FW_MSGONLY|"
_Logger.Info(".msg-file from folderwatch")
If My.Application.User.Language <> "de-DE" Then
Me.Text = "Indexing of msg-File (without Attachments) - from Folderwatch"
Else
Me.Text = "Indexierung der msg-Datei (ohne Anhang) - aus Folderwatch"
End If
Case "|OUTLOOK_MESSAGE|"
_Logger.Info(".msg-file through dragdrop")
If My.Application.User.Language <> "de-DE" Then
Me.Text = "Indexing of msg-File (without Attachments)"
Else
Me.Text = "Indexierung der msg-Datei (ohne Anhang)"
End If
End Select
ElseIf DropType = "|MSGONLY|" Then
If My.Application.User.Language = "de-DE" Then
Me.Text = "Indexierung der msg-Datei (ohne Anhang)"
Else
Me.Text = "Indexing of msg-File (without Attachments)"
End If
ElseIf DropType = "|ATTMNTEXTRACTED|" Or DropType = "|OUTLOOK_ATTACHMENT|" Then
My.Application.Globix.CURRENT_ISATTACHMENT = True
If My.Application.User.Language = "de-DE" Then
Me.Text = "Indexierung eines Email-Attachments"
Else
Me.Text = "Indexing of email-Attachment"
End If
ElseIf DropType = "|FW_SIMPLEINDEXER|" Then
If My.Application.User.Language = "de-DE" Then
Me.Text = "Indexierung einer Folderwatch-Datei"
Else
Me.Text = "Indexing of Folderwatch-File"
End If
End If
labelFilePath.Caption = My.Application.Globix.CURRENT_WORKFILE
clswindowLocation.LoadFormLocationSize(Me)
SetFilePreview(My.UIConfig.Globix.FilePreview)
SplitContainerControl1.SplitterPosition = My.UIConfig.Globix.SplitterDistanceViewer
My.Application.Globix.DTTBGI_REGEX_DOCTYPE = My.Database.GetDatatable("SELECT DISTINCT T1.DOCTYPE as DocType, T.* FROM TBGI_REGEX_DOCTYPE T, VWGI_DOCTYPE T1 WHERE T.DOCTYPE_ID = T1.DOCTYPE_ID")
MULTIFILES = My.Database.GetScalarValue("SELECT COUNT(*) FROM TBGI_FILES_USER WHERE WORKED = 0 AND GUID <> " & My.Application.Globix.CURRENT_WORKFILE_GUID & " AND UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')")
My.Application.Globix.MULTIINDEXING_ACTIVE = False
If MULTIFILES > 0 Then
If My.Application.User.Language = "de-DE" Then
RibbonPageGroupMultiIndex.Text = "Alle nachfolgenden Dateien (" & MULTIFILES & ") identisch indexieren"
Else
RibbonPageGroupMultiIndex.Text = "All following files (" & MULTIFILES & ") will be indexed identically"
End If
chkMultiindexing.Checked = False
chkMultiindexing.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
Else
chkMultiindexing.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End If
End If
Catch ex As Exception
_Logger.Warn(" - Unexpected error in Öffnen des Formulares - Fehler: " & vbNewLine & ex.Message)
_Logger.Error(ex.Message)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Öffnen des Formulares:")
End Try
End Sub
Private Sub SetFilePreview(ShowPreview As Boolean)
If ShowPreview Then
SplitContainerControl1.Collapsed = False
PreviewFile()
PreviewItem.Checked = True
Else
SplitContainerControl1.Collapsed = True
PreviewItem.Checked = False
End If
End Sub
Sub PreviewFile()
Try
DocumentViewer1.LoadFile(My.Application.Globix.CURRENT_WORKFILE)
Catch ex As Exception
_Logger.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler in PreviewFile:")
End Try
End Sub
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SourceDeleteItem.ItemClick
If SourceDeleteItem.Visibility <> DevExpress.XtraBars.BarItemVisibility.Never Then
My.Application.Globix.CURR_DELETE_ORIGIN = SourceDeleteItem.Checked
My.UIConfig.Globix.DeleteOriginalFile = SourceDeleteItem.Checked
My.SystemConfigManager.Save()
End If
End Sub
Private Sub BarCheckItem5_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles PreviewItem.CheckedChanged
End Sub
Private Sub SourceDeleteItem_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SourceDeleteItem.CheckedChanged
End Sub
Private Sub SaveProfileItem_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SaveProfileItem.CheckedChanged
My.UIConfig.Globix.ProfilePreselection = SaveProfileItem.Checked
My.SystemConfigManager.Save()
End Sub
Private Sub SkipItem_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles SkipItem.ItemClick
My.Database.ExecuteNonQuery($"DELETE FROM TBGI_FILES_USER WHERE GUID = {My.Application.Globix.CURRENT_WORKFILE_GUID}")
CancelAttempts = 2
Close()
End Sub
Private Sub BarCheckItem3_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles chkMultiindexing.CheckedChanged
If chkMultiindexing.Checked Then
chkMultiindexing.Caption = "Active"
Else
chkMultiindexing.Caption = "Inactive"
End If
End Sub
End Class