This commit is contained in:
2023-12-21 17:25:29 +01:00
parent d5e084ac6b
commit 2bc0f6a6d7
4 changed files with 211 additions and 151 deletions

View File

@@ -55,9 +55,9 @@ Public Class frmWM_IndexFile
Dim existsonlyasMaster = False
If _wm.TestFileExists(CURRENT_NEWFILENAME) = True Then
Dim msg = "Eine Datei mit identischem Namen existiert bereits! Wollen Sie die bestehende Datei ersetzen?"
Dim msg = "Eine Datei mit identischem Namen existiert bereits! Wollen Sie die bestehende Datei ersetzen? (KEINE VERSIONIERUNG)" & vbNewLine & "Beachten Sie das vorhandene Versionen beim Ersetzen mit gelöscht werden!"
If USER_LANGUAGE <> "de-DE" Then
msg = "There is already a file with the same name! Would You like to replace the file?"
msg = "There is already a file with the same name! Would You like to replace the file?" & vbNewLine & "All versions will also be deleted!"
End If
Dim result As MsgBoxResult
result = MessageBox.Show(msg, "File alredy exists:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
@@ -105,7 +105,7 @@ Public Class frmWM_IndexFile
End If
End If
Dim sql = "SELECT * FROM TBDD_INDEX_AUTOM WHERE ACTIVE = 1 AND UPPER(INDEXNAME) NOT LIKE UPPER('%ONLY %') AND SQL_ACTIVE = 0 AND DOCTYPE_ID = " & vDokart_ID
Dim sql = "SELECT * FROM TBDD_INDEX_AUTOM WHERE ACTIVE = 1 AND UPPER(INDEXNAME) NOT LIKE UPPER('%ONLY %') AND SQL_ACTIVE = 0 AND LEN(INDEXNAME) > 1 AND DOCTYPE_ID = " & vDokart_ID
Dim DT_AUTO_INDEXE As DataTable = MYDB_ECM.GetDatatable(sql)
Try
sql = "SELECT * FROM VWCUST_DOCTYPE_CONFIG WHERE DOCTYPE_ID = " & vDokart_ID
@@ -161,89 +161,89 @@ Public Class frmWM_IndexFile
If DT_AUTO_INDEXE.Rows.Count > 0 Then
Dim Count As Integer = 0
For Each row As DataRow In DT_AUTO_INDEXE.Rows
Dim indexname = row.Item("INDEXNAME").ToString
Dim idxvalue = row.Item("VALUE")
If idxvalue.ToString.StartsWith("@") Then
Select Case idxvalue.ToString.ToUpper
Case "@RECORD-ID"
idxvalue = idxvalue.ToString.Replace("@Record-ID", CURRENT_RECORD_ID)
Case "@DOKART"
idxvalue = idxvalue.ToString.Replace("@Dokart", vDokart)
End Select
Else 'Es wird nicht über einen @PAttern indexiert
' Regulären Ausdruck zum Auslesen der Indexe definieren
Dim preg As String = "\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}"
' einen Regulären Ausdruck laden
Dim regulärerAusdruck As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(preg)
' die Vorkommen im SQL-String auslesen
Dim elemente As System.Text.RegularExpressions.MatchCollection = regulärerAusdruck.Matches(idxvalue)
'####
' alle Vorkommen innerhalbd er Namenkonvention durchlaufen
For Each element As System.Text.RegularExpressions.Match In elemente
Dim oAutoIndexname = row.Item("INDEXNAME").ToString
Dim oAutoIndexValue = row.Item("VALUE")
If oAutoIndexValue.ToString.StartsWith("@") Then
Select Case oAutoIndexValue.ToString.ToUpper
Case "@RECORD-ID"
oAutoIndexValue = oAutoIndexValue.ToString.Replace("@Record-ID", CURRENT_RECORD_ID)
Case "@DOKART"
oAutoIndexValue = oAutoIndexValue.ToString.Replace("@Dokart", vDokart)
End Select
Else 'Es wird nicht über einen @PAttern indexiert
' Regulären Ausdruck zum Auslesen der Indexe definieren
Dim preg As String = "\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}"
' einen Regulären Ausdruck laden
Dim regulärerAusdruck As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(preg)
' die Vorkommen im SQL-String auslesen
Dim elemente As System.Text.RegularExpressions.MatchCollection = regulärerAusdruck.Matches(oAutoIndexValue)
'####
' alle Vorkommen innerhalbd er Namenkonvention durchlaufen
For Each element As System.Text.RegularExpressions.Match In elemente
LOGGER.Debug("element in RegeX: " & element.Value)
Select Case element.Value.Substring(2, 1).ToUpper
'Nur automatische Indizes auswerten
Case "A"
Dim APattern = element.Value.Substring(3, element.Value.Length - 4)
If APattern.Contains("#") Then
Case "A"
Dim APattern = element.Value.Substring(3, element.Value.Length - 4)
If APattern.Contains("#") Then
LOGGER.Debug("element filled with Record-Data.......: ")
Dim split() As String = APattern.Split("#")
If split.Length = 2 Then
Dim CONTROL_ID = split(1)
If split.Length = 2 Then
Dim CONTROL_ID = split(1)
LOGGER.Debug("CONTROL_ID: " & CONTROL_ID)
If IsNumeric(CONTROL_ID) Then
Dim CONTROLVALUE = ClassControlValues.Get_Control_Value_for_ID(CONTROL_ID, CURRENT_RECORD_ID)
If IsNothing(CONTROLVALUE) Then
Dim CONTROLVALUE = ClassControlValues.Get_Control_Value_for_ID(CONTROL_ID, CURRENT_RECORD_ID)
If IsNothing(CONTROLVALUE) Then
LOGGER.Warn("Index should be filled with value of Control-ID '" & CONTROL_ID & "', but result was nothing.")
LOGGER.Warn("SQL-Command: " & CURRENT_LAST_SQL)
idxvalue = ""
Else
If IsDBNull(CONTROLVALUE) Then
oAutoIndexValue = ""
Else
If IsDBNull(CONTROLVALUE) Then
LOGGER.Warn("Index should be filled with value of Control-ID '" & CONTROL_ID & "', but result was DBNULL.")
LOGGER.Warn("SQL-Command: " & CURRENT_LAST_SQL)
idxvalue = ""
Else
idxvalue = CONTROLVALUE
End If
oAutoIndexValue = ""
Else
oAutoIndexValue = CONTROLVALUE
End If
Else
End If
Else
End If
End If
End Select
End If
End Select
Next
End If
LOGGER.Debug("Value for Indexing : '" & idxvalue.ToString & "'")
Next
End If
LOGGER.Debug($"Autovalue used for Indexing: '" & oAutoIndexValue.ToString & "'")
Count += 1
indexierung_erfolgreich = _wm.SetFileIndex(CURRENT_FILEIN_WD, indexname, idxvalue, oWMObjecttype) 'clsWM_SET.IndexFile(CURRENT_FILEIN_WD, indexname, idxvalue, oWMObjecttype) 'clsWM.MY_WDOBJECTTYPE)
indexierung_erfolgreich = _wm.SetFileIndex(CURRENT_FILEIN_WD, oAutoIndexname, oAutoIndexValue, oWMObjecttype) 'clsWM_SET.IndexFile(CURRENT_FILEIN_WD, indexname, idxvalue, oWMObjecttype) 'clsWM.MY_WDOBJECTTYPE)
If indexierung_erfolgreich = False Then
MsgBox("Unexpected Error in indexing file - See log", MsgBoxStyle.Critical)
err = True
Exit For
End If
Next
If err = True Then
swWORK_FILE.Done()
Return False
MsgBox("Unexpected Error in indexing file - See log", MsgBoxStyle.Critical)
err = True
Exit For
End If
Else
'MsgBox("Attention in Work-File:" & vbNewLine & "No indices were defined (1)!", MsgBoxStyle.Critical)
'Return False
Next
If err = True Then
swWORK_FILE.Done()
Return False
End If
Else
swWORK_FILE.Done()
MsgBox("Attention in Work-File:" & vbNewLine & "No indices were defined (0)!", MsgBoxStyle.Critical)
Return False
'MsgBox("Attention in Work-File:" & vbNewLine & "No indices were defined (1)!", MsgBoxStyle.Critical)
'Return False
End If
'Nun alles aufrüumen und die neue DocID holen
Else
swWORK_FILE.Done()
MsgBox("Attention in Work-File:" & vbNewLine & "No indices were defined (0)!", MsgBoxStyle.Critical)
If indexierung_erfolgreich = True Then
Return False
End If
'Nun alles aufrüumen und die neue DocID holen
If indexierung_erfolgreich = True Then
LOGGER.Info("File was correctly imported and indexed: " & CURRENT_FILEIN_WD)
Dim oReldocpath = ClassHelper.GetRelPath(CURRENT_FILEIN_WD)
LOGGER.Info("oReldocpath: " & oReldocpath)
@@ -252,55 +252,55 @@ Public Class frmWM_IndexFile
MsgBox("Attention in Work-File:" & vbNewLine & "Could not create final windream-object!", MsgBoxStyle.Critical)
Return False
End If
LOGGER.Info("..CURRENT_WM_OBJECT created: " & oReldocpath)
LOGGER.Info("...CURRENT_WM_OBJECT created: " & oReldocpath)
Dim stg As String = "Datei erfolgreich nach windream übertragen"
Dim stg1 As String = "Erfolgsmeldung"
If USER_LANGUAGE <> "de-DE" Then
stg = "File was successfully transfered to windream"
stg1 = "Success:"
End If
If multiindex = False Then CURRENT_NOTIFICATION_MSG = stg
Dim stg1 As String = "Erfolgsmeldung"
If USER_LANGUAGE <> "de-DE" Then
stg = "File was successfully transfered to windream"
stg1 = "Success:"
End If
If multiindex = False Then CURRENT_NOTIFICATION_MSG = stg
MYDB_ECM.GetScalarValue("UPDATE TBPMO_FILES_USER SET WORKED = 1 WHERE GUID = " & CURRENT_FILEID)
For Each row As DataRow In CURRENT_TBPMO_FILES_USER.Rows
If row.Item("GUID") = CURRENT_FILEID Then
row.Item("WORKED") = 1
If IsNothing(droptype) Then
droptype = row.Item("HANDLE_TYPE")
End If
If row.Item("GUID") = CURRENT_FILEID Then
row.Item("WORKED") = 1
If IsNothing(droptype) Then
droptype = row.Item("HANDLE_TYPE")
End If
Next
If IsNothing(CURRENT_DOC_ID) Then
sw = New SW("GettingDocID")
sql = String.Format("SELECT DocID FROM VWPMO_DOC_SYNC WHERE FULL_FILENAME = '{0}' AND CONVERT(DATE,Change_DateTime) = CONVERT(DATE,GETDATE())", CURRENT_FILEIN_WD)
CURRENT_DOC_ID = MYDB_ECM.GetScalarValue(SQL)
sw.Done()
End If
Next
If IsNothing(CURRENT_DOC_ID) Then
sw = New SW("GettingDocID")
sql = String.Format("SELECT DocID FROM VWPMO_DOC_SYNC WHERE FULL_FILENAME = '{0}' AND CONVERT(DATE,Change_DateTime) = CONVERT(DATE,GETDATE())", CURRENT_FILEIN_WD)
CURRENT_DOC_ID = MYDB_ECM.GetScalarValue(sql)
sw.Done()
End If
If Not IsNothing(CURRENT_DOC_ID) Then
ClassHelper.InsertEssential_Log(CURRENT_DOC_ID, "DOC_ID", "File was imported and indexed!")
If Not IsNothing(CURRENT_DOC_ID) Then
ClassHelper.InsertEssential_Log(CURRENT_DOC_ID, "DOC_ID", "File was imported and indexed!")
LOGGER.Info(String.Format("File-Import was finished - DocID: {0} ", CURRENT_DOC_ID))
Dim delete = False
'Die Originaldatei löschen
If droptype = "dragdrop file" And indexierung_erfolgreich = True Then
If chkdelete_origin.Checked = True Then
'Die temporäre Datei löschen
File.Delete(aktFiledropped)
'Die Originaldatei löschen
If droptype = "dragdrop file" And indexierung_erfolgreich = True Then
If chkdelete_origin.Checked = True Then
'Die temporäre Datei löschen
File.Delete(aktFiledropped)
End If
ElseIf (droptype = "@ATTMNTEXTRACTED@" Or droptype = "SCAN") And indexierung_erfolgreich = True Then
'Die temporäre Datei löschen
delete = True
ElseIf droptype = "dragdrop message" And indexierung_erfolgreich = True Then
'Die temporäre Datei löschen
delete = True
End If
If delete = True Then
For Each row As DataRow In CURRENT_TBPMO_FILES_USER.Rows
If row.Item("GUID") = CURRENT_FILEID Then
row.Item("DELETE_FILE") = True
End If
ElseIf (droptype = "@ATTMNTEXTRACTED@" Or droptype = "SCAN") And indexierung_erfolgreich = True Then
'Die temporäre Datei löschen
delete = True
ElseIf droptype = "dragdrop message" And indexierung_erfolgreich = True Then
'Die temporäre Datei löschen
delete = True
End If
If delete = True Then
For Each row As DataRow In CURRENT_TBPMO_FILES_USER.Rows
If row.Item("GUID") = CURRENT_FILEID Then
row.Item("DELETE_FILE") = True
End If
Next
End If
Next
End If
If _wm.SessionLoggedin = False Then 'clsWM.Create_Session() = False Then
MsgBox("Could not create a windream-session!", MsgBoxStyle.Critical)
@@ -323,27 +323,27 @@ Public Class frmWM_IndexFile
ClassHelper.InsertEssential_Log(CURRENT_DOC_ID, "DOC-ID", "NEW FILE INDEXING - RIGHTS COULD NOT BE SET!!")
End If
sw.Done()
End If
End If
Else
stg = "Unerwarteter Fehler: Es konnte keine DocID für die übertragene Datei erzeugt werden!"
If USER_LANGUAGE <> "de-DE" Then
stg = "Unexpected Error: Could not get a docId for transmitted file!"
End If
LOGGER.Warn(stg)
MsgBox(stg, MsgBoxStyle.Critical, stg1)
End If
Else
MsgBox("An unexpected error occured while indexing file. Please check the log!", MsgBoxStyle.Exclamation)
swWORK_FILE.Done()
Return False
stg = "Unerwarteter Fehler: Es konnte keine DocID für die übertragene Datei erzeugt werden!"
If USER_LANGUAGE <> "de-DE" Then
stg = "Unexpected Error: Could not get a docId for transmitted file!"
End If
LOGGER.Warn(stg)
MsgBox(stg, MsgBoxStyle.Critical, stg1)
End If
swWORK_FILE.Done()
Return True
Else
MsgBox("An unexpected error occured while indexing file. Please check the log!", MsgBoxStyle.Exclamation)
swWORK_FILE.Done()
Return False
End If
swWORK_FILE.Done()
Return True
Else
swWORK_FILE.Done()
Return False
End If
Catch ex As Exception