This commit is contained in:
2022-02-23 15:20:59 +01:00
45 changed files with 2004 additions and 2880 deletions

View File

@@ -11,15 +11,16 @@ Imports DigitalData.GUIs.GlobalIndexer
Imports DevExpress.XtraEditors.Controls
Imports Limilabs.Mail
Imports Limilabs.Mail.Headers
Imports DevExpress.XtraEditors
Public Class frmIndex
#Region "+++++ Variablen ++++++"
Public vPathFile As String
Private MULTIFILES As Integer
Private akttxtbox As TextBox
Private ReadOnly akttxtbox As TextBox
Dim DT_INDEXEMAN As DataTable
Public FormLoaded As Boolean = False
Private Shared _Instance As frmIndex = Nothing
Private Shared ReadOnly _Instance As frmIndex = Nothing
Dim DropType As String
Private Shared WDDirect As Boolean = False
@@ -43,7 +44,9 @@ Public Class frmIndex
Private Const LANG_DE = "de-DE"
Private _Logger As Logger
Private Property DocTypes As New List(Of DocType)
Private ReadOnly _Logger As Logger
#End Region
@@ -289,7 +292,10 @@ Public Class frmIndex
Dim oErgebnis
'Welcher Provider?
If vProvider.ToLower = "oracle" Then
oErgebnis = ClassDatabase.OracleExecute_Scalar(SQLCommand, oConnectionString)
'oErgebnis = ClassDatabase.OracleExecute_Scalar(SQLCommand, oConnectionString)
LOGGER.Warn("Oracle Database Queries are not supported")
Else 'im Moment nur SQL-Server
oErgebnis = DATABASE_ECM.GetScalarValueWithConnection(SQLCommand, oConnectionString)
End If
@@ -455,7 +461,7 @@ Public Class frmIndex
End If
End If
If oControl.Name.StartsWith("chk") Then
Dim chk As CheckBox = oControl
Dim chk As CheckEdit = oControl
Indexwert_Postprocessing(Replace(chk.Name, "chk", ""), chk.Checked)
oResult = True
End If
@@ -677,7 +683,7 @@ Public Class frmIndex
NewFileString = _neuername
Else
Do While File.Exists(_neuername)
version = version + 1
version += 1
_neuername = Stammname.Replace(extension, "") & VERSION_DELIMITER & version & extension
NewFileString = _neuername
Loop
@@ -712,7 +718,7 @@ Public Class frmIndex
End Try
End Function
Private Function Write_Indizes()
Private Function Write_Indizes() As Boolean
Try
_Logger.NewBlock("Write_Indizes")
_Logger.Info("Indexing file [{0}]", CURRENT_NEWFILENAME)
@@ -752,13 +758,13 @@ Public Class frmIndex
End If
End If
_Logger.Debug($"Manueller Indexvalue [{idxvalue.ToString}]...NOW THE INDEXING...")
_Logger.Debug($"Manueller Indexvalue [{idxvalue}]...NOW THE INDEXING...")
Count += 1
' den Typ des Zielindexes auslesen
Dim oIndexType As Integer = WINDREAM.GetIndexType(indexname)
_Logger.Debug($"oIndexType [{oIndexType.ToString}]...")
_Logger.Debug($"oIndexType [{oIndexType}]...")
If oIndexType < WINDREAM.WMObjectVariableValueTypeVector Then
_Logger.Debug($"Indexing oIndexType < WINDREAM.WMObjectVariableValueTypeVector...")
indexierung_erfolgreich = WINDREAM.SetFileIndex(CURRENT_NEWFILENAME, indexname, idxvalue, CURR_DOKART_OBJECTTYPE)
@@ -860,7 +866,7 @@ Public Class frmIndex
End Function
Private Function WriteIndex2File(pIndexName As String, pIndexValue As String)
Try
_Logger.Info($"Indexing with Name {pIndexName} and Value: {pIndexValue.ToString}")
_Logger.Info($"Indexing with Name {pIndexName} and Value: {pIndexValue}")
Return WINDREAM.SetFileIndex(CURRENT_NEWFILENAME, pIndexName, pIndexValue, CURR_DOKART_OBJECTTYPE)
Catch ex As Exception
ShowErrorMessage(ex, "WriteIndex2File")
@@ -895,17 +901,23 @@ Public Class frmIndex
' If file is an email files (eml,msg) parse it to extract email data and save for later
' If file is an attachment, rely on the previously extracted value
If pIndexAttachment = False Then
LOGGER.Debug("Indexing Email File: [{0}]", CURRENT_NEWFILENAME)
Dim oMsgFilePath As String = Path.Combine(WINDREAM_BASEPATH, CURRENT_NEWFILENAME)
Dim oMail As IMail = EMAIL.Load_Email(oMsgFilePath)
Dim oMessageId As String = oMail.MessageID
LOGGER.Debug("MessageId: [{0}]", oMessageId)
Dim oMessageFrom As String = EMAIL.Get_MessageSender(oMail)
Dim oMessageTo As String = EMAIL.Get_MessageReceiver(oMail)
Dim oDateIn As Date = EMAIL.Get_MessageDate(oMail)
Dim oSubject As String = oMail.Subject
Dim oDateIn As Date = oMail.Date
CURRENT_MESSAGEID = oMessageFrom
CURRENT_MESSAGEID = oMessageId
CURRENT_MESSAGEDATE = oDateIn
CURRENT_MESSAGESUBJECT = oSubject
@@ -930,17 +942,16 @@ Public Class frmIndex
Try
If oIndex.Value Is Nothing Then
LOGGER.Warn("Value for Index [{0}] was empty. Skipping.", oIndex.Key)
Return False
Continue For
End If
If TypeOf oIndex.Value Is String AndAlso oIndex.Value = String.Empty Then
LOGGER.Warn("Value for Index [{0}] was empty. Skipping.", oIndex.Key)
Return False
Continue For
End If
Dim oIndexingSuccessful = WriteIndex2File(oRow.Item(oIndex.Key), oIndex.Value)
If oIndexingSuccessful = False Then
@@ -1373,7 +1384,7 @@ Public Class frmIndex
Dim Stammname As String = _NewFilename
Dim neuername As String = _NewFilename
Do While File.Exists(neuername)
version = version + 1
version += 1
neuername = Stammname.Replace(extension, "") & _versionTz & version & extension
CURRENT_NEWFILENAME = neuername
Loop
@@ -1432,7 +1443,7 @@ Public Class frmIndex
Else
MsgBox($"Please Index file completely{vbNewLine}(Abort 1 of Indexdialog)", MsgBoxStyle.Information)
End If
CancelAttempts = CancelAttempts + 1
CancelAttempts += 1
e.Cancel = True
Case 1
Dim result As MsgBoxResult
@@ -1662,40 +1673,48 @@ Public Class frmIndex
FormLoaded = True
Try
_Logger.Info("Profile Preselected enabled: {0}", CONFIG.Config.ProfilePreselection)
' Letzte Auswahl merken überschreibt die automatische selektion
If CONFIG.Config.ProfilePreselection Then
checkItemPreselection.Checked = True
If CURRENT_LASTDOKART <> "" Then
Dim oFoundDocType = ComboboxDoctype.Properties.Items.
Cast(Of DocType)().
_Logger.Info("Last Saved DocType: {0}", CURRENT_LASTDOKART)
Dim oDocTypes As List(Of DocType) = DocTypes
Dim oFoundDocType = oDocTypes.
Where(Function(dt) dt.Name = CURRENT_LASTDOKART).
FirstOrDefault()
If oFoundDocType IsNot Nothing Then
ComboboxDoctype.SelectedItem = oFoundDocType
_Logger.Info("Setting Last Saved DocType: {0}", CURRENT_LASTDOKART)
ComboboxDoctype.EditValue = oFoundDocType
End If
'cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(CURRENT_LASTDOKART)
End If
End If
If ComboboxDoctype.SelectedItem Is Nothing And DTTBGI_REGEX_DOCTYPE.Rows.Count > 0 Then
Dim oApplyRegex = ComboboxDoctype.EditValue Is Nothing And DTTBGI_REGEX_DOCTYPE.Rows.Count > 0
_Logger.Info("Applying Profile Selection Regex: [{0}]", oApplyRegex)
If oApplyRegex Then
For Each oRoW As DataRow In DTTBGI_REGEX_DOCTYPE.Rows
Dim oOnlyFilename = Path.GetFileName(CURRENT_WORKFILE)
If Regex.IsMatch(oOnlyFilename, oRoW.Item("Regex")) Then
_Logger.Debug("There is a match on REGEX_DOCTYPE: [{0}]", oRoW.Item("DOCTYPE"))
_Logger.Debug("Regex: [{0}], FileName: [{1}]", oRoW.Item("Regex"), oOnlyFilename)
'cmbDokumentart.SelectedIndex = cmbDokumentart.FindStringExact(oRoW.Item("DOCTYPE"))
Dim oFoundDocType = ComboboxDoctype.Properties.Items.
Cast(Of DocType)().
Dim oDoctypes As List(Of DocType) = DocTypes
Dim oFoundDocType As DocType = oDoctypes.
Where(Function(dt) dt.Guid = oRoW.Item("DOCTYPE_ID")).
FirstOrDefault()
If oFoundDocType IsNot Nothing Then
ComboboxDoctype.SelectedItem = oFoundDocType
_Logger.Debug("DocType found: [{0}]", oFoundDocType)
ComboboxDoctype.EditValue = oFoundDocType
Exit For
End If
End If
@@ -1710,33 +1729,31 @@ Public Class frmIndex
Dim sql = String.Format("SELECT DISTINCT DOCTYPE_ID, DOCTYPE, SEQUENCE FROM VWGI_DOCTYPE where USERNAME = '{0}' ORDER BY SEQUENCE", Environment.UserName)
_Logger.Info("SQL DoctypeList: " & sql)
Dim oDoctypes = DATABASE_ECM.GetDatatable(sql)
'cmbDokumentart.DataSource = oDoctypes
'cmbDokumentart.ValueMember = oDoctypes.Columns("DOCTYPE_ID").ColumnName
'cmbDokumentart.DisplayMember = oDoctypes.Columns("DOCTYPE").ColumnName
'cmbDokumentart.AutoCompleteMode = AutoCompleteMode.Suggest
'cmbDokumentart.AutoCompleteSource = AutoCompleteSource.ListItems
'cmbDokumentart.SelectedIndex = -1
ComboboxDoctype.Properties.Items.Clear()
ComboboxDoctype.EditValue = Nothing
ComboboxDoctype.Properties.DataSource = Nothing
DocTypes.Clear()
For Each oRow As DataRow In oDoctypes.Rows
Dim oDocType = New DocType With {.Guid = oRow.Item("DOCTYPE_ID"), .Name = oRow.Item("DOCTYPE")}
ComboboxDoctype.Properties.Items.Add(oDocType)
Dim oDocType = New DocType With {
.Guid = oRow.Item("DOCTYPE_ID"),
.Name = oRow.Item("DOCTYPE")
}
DocTypes.Add(oDocType)
Next
ComboboxDoctype.SelectedIndex = -1
ComboboxDoctype.Properties.DataSource = DocTypes
Catch ex As Exception
ShowErrorMessage(ex, "Refresh_Dokart")
End Try
End Sub
Private Sub ComboBoxEdit1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboboxDoctype.SelectedIndexChanged
If ComboboxDoctype.SelectedIndex <> -1 And FormLoaded = True Then
Dim oSelectedItem As DocType = ComboboxDoctype.SelectedItem
Private Sub ComboBoxEdit1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboboxDoctype.EditValueChanged
If ComboboxDoctype.EditValue IsNot Nothing And FormLoaded = True Then
Dim oSelectedItem As DocType = ComboboxDoctype.EditValue
CURRENT_DOKART_ID = oSelectedItem.Guid
CURRENT_LASTDOKART = oSelectedItem.Name
'lblhinweis.Visible = False
ClearNotice()
@@ -1753,8 +1770,11 @@ Public Class frmIndex
Dim oNormalized As String = WINDREAM.GetNormalizedPath(oDestination)
Dim oNewDestination = Path.Combine(WINDREAM.ClientBasePath, oNormalized)
If Directory.Exists(oDestination) = False Then
Dim oMessage = ""
LOGGER.Debug("Path from Database is [{0}]", oDestination)
LOGGER.Debug("Checking for path [{0}]", oNewDestination)
If Directory.Exists(oNewDestination) = False Then
Dim oMessage As String
If USER_LANGUAGE = "de-DE" Then
oMessage = $"Der Pfad für das ausgewählte Profil ist nicht erreichbar:{vbNewLine}[{oNewDestination}].{vbNewLine}{vbNewLine}Bitte wählen Sie ein anderes Profil."
@@ -1763,7 +1783,7 @@ Public Class frmIndex
End If
MsgBox(oMessage, MsgBoxStyle.Information, Text)
ComboboxDoctype.SelectedIndex = -1
ComboboxDoctype.EditValue = Nothing
Else
WDDirect = oDocType.Item("WINDREAM_DIRECT")
CURRENT_DOKART_DUPLICATE_HANDLING = oDocType.Item("DUPLICATE_HANDLING")
@@ -1855,7 +1875,7 @@ Public Class frmIndex
Select Case oDataType
Case ClassConstants.INDEX_TYPE_BOOLEAN
Dim chk As CheckBox = oControls.AddCheckBox(oControlName, oControlPosition, DefaultValue, oRow.Item("COMMENT").ToString)
Dim chk As CheckEdit = oControls.AddCheckBox(oControlName, oControlPosition, DefaultValue, oRow.Item("COMMENT").ToString)
If Not IsNothing(chk) Then
pnlIndex.Controls.Add(chk)
End If
@@ -2042,9 +2062,9 @@ Public Class frmIndex
oLookupControl.Properties.ValueMember = oDatatable.Columns.Item(0).ColumnName
oLookupControl.Properties.DisplayMember = oDatatable.Columns.Item(0).ColumnName
End If
Case GetType(ComboBox).Name
Case GetType(Windows.Forms.ComboBox).Name
LOGGER.Debug("Setting Value for Combobox [{0}]: [{1}]", oFoundControl.Name, "DATATABLE")
DirectCast(oFoundControl, ComboBox).DataSource = oDatatable
DirectCast(oFoundControl, Windows.Forms.ComboBox).DataSource = oDatatable
Case Else
LOGGER.Debug("Could not set depending control result for [{0}]", oFoundControl.GetType.Name)
End Select
@@ -2176,7 +2196,7 @@ Public Class frmIndex
If oSqlResult <> String.Empty Then
_Logger.Debug("oSqlResult after Replace [" & oSqlResult & "]")
End If
' Ergebnis: Es wurden alle einfachen Platzhalter ersetzt, jetzt haben wir einen SQL Befehl,
' Ergebnis: Es wurden alle einfachen Platzhalter ersetz't, jetzt haben wir einen SQL Befehl,
' der nur noch vektorfelder-platzhalter enthält
' 2. Schritt: Vektorfelder ersetzen
@@ -2259,7 +2279,7 @@ Public Class frmIndex
_Logger.Debug("Manuelle Indexe geladen")
If MyDataset.VWDDINDEX_MAN.Rows.Count > 0 Then
Dim oDokart As DocType = ComboboxDoctype.SelectedItem
Dim oDokart As DocType = ComboboxDoctype.EditValue
CURRENT_DOKART_ID = oDokart.Guid
If CheckWrite_IndexeMan(oDokart.Guid) = True Then
@@ -2278,7 +2298,7 @@ Public Class frmIndex
'Die Datei verschieben
If Move_File2_Target() = True Then
_Logger.Debug(" ...Move_File2_Target durchlaufen")
CURRENT_LASTDOKART = oDokart.Name
_Logger.Info("Datei '" & CURRENT_NEWFILENAME & "' erfolgreich erzeugt.")
Dim oDEL As String = "DELETE FROM TBGI_FILES_USER WHERE GUID = " & CURRENT_WORKFILE_GUID
DATABASE_ECM.ExecuteNonQuery(oDEL)
@@ -2634,7 +2654,7 @@ Public Class frmIndex
Else
MsgBox("Please Index file completely" & vbNewLine & "(Abort 1 of Indexdialog)", MsgBoxStyle.Information)
End If
CancelAttempts = CancelAttempts + 1
CancelAttempts += 1
Case 1
Dim result As MsgBoxResult
If USER_LANGUAGE = LANG_DE Then
@@ -2736,7 +2756,7 @@ Public Class frmIndex
If WORK_FILE() = True Then
'Und nun die folgenden
Dim DTFiles2Work As DataTable = DATABASE_ECM.GetDatatable("SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND GUID <> " & CURRENT_WORKFILE_GUID & " AND UPPER(USER@WORK) = UPPER('" & Environment.UserName & "')")
If Not DTFiles2Work Is Nothing Then
If DTFiles2Work IsNot Nothing Then
Dim err = False
For Each filerow As DataRow In DTFiles2Work.Rows
CURRENT_WORKFILE_GUID = filerow.Item("GUID")
@@ -2783,33 +2803,13 @@ Public Class frmIndex
Me.Close()
End If
End If
' Clear all temp files after indexing
Clear_Tempfiles()
EMAIL.Clear_TempFiles()
Catch ex As Exception
MsgBox("Uncaught error while indexing: " & vbNewLine & ex.Message, MsgBoxStyle.Critical, Text)
' Clear all temp files in case of an error
Clear_Tempfiles()
EMAIL.Clear_TempFiles()
Finally
Me.Cursor = Cursors.Default
End Try
End Sub
Private Sub Clear_Tempfiles()
'TempDateien löschen
For Each oFile In TEMP_FILES
Try
System.IO.File.Delete(oFile)
Catch ex As Exception
LOGGER.Error(ex)
End Try
Next
End Sub
Private Sub checkItemPreview_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles checkItemPreview.CheckedChanged
SetFilePreview(checkItemPreview.Checked)
CONFIG.Config.FilePreview = checkItemPreview.Checked