jj: WIP - VectorIndexing
This commit is contained in:
@@ -1,51 +1,112 @@
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
Public Class ClassPostprocessing
|
||||
Public Shared Function Get_Nachbearbeitung_Wert(idxvalue As String, DTNB As DataTable) As String
|
||||
Dim result As String = idxvalue
|
||||
Try
|
||||
For Each row As DataRow In DTNB.Rows
|
||||
Select Case row.Item("TYPE").ToString.ToUpper
|
||||
Case "VBSPLIT"
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" ...Nachbearbeitung mit VBSPLIT", False)
|
||||
Dim strSplit() As String
|
||||
strSplit = result.Split(row.Item("TEXT1"))
|
||||
For i As Integer = 0 To strSplit.Length - 1
|
||||
If i = CInt(row.Item("TEXT2")) Then
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" ...Split-Ergebnis für Index (" & i.ToString & "): " & strSplit(i), False)
|
||||
result = strSplit(i).ToString
|
||||
End If
|
||||
Next
|
||||
Case "VBREPLACE"
|
||||
If LogErrorsOnly = False Then
|
||||
ClassLogger.Add(" ...Nachbearbeitung mit VBREPLACE", False)
|
||||
ClassLogger.Add(" ...Ersetze '" & row.Item("TEXT1") & "' mit '" & row.Item("TEXT2") & "'", False)
|
||||
result = result.Replace(row.Item("TEXT1"), row.Item("TEXT2"))
|
||||
End If
|
||||
|
||||
result = result.Replace(row.Item("TEXT1"), row.Item("TEXT2"))
|
||||
Case "REG. EXPRESSION"
|
||||
Private Const VBSPLIT = "VBSPLIT"
|
||||
Private Const VBREPLACE = "VBREPLACE"
|
||||
Private Const REGEXPRESSION = "REG. EXPRESSION"
|
||||
|
||||
Public Shared Function Get_Nachbearbeitung_Wert(idxvalue As String, Datatable As DataTable) As String
|
||||
Dim oIndexValues As List(Of String) = idxvalue.Split(ClassConstants.VECTORSEPARATOR).ToList()
|
||||
|
||||
Try
|
||||
For Each oDataRow As DataRow In Datatable.Rows
|
||||
Dim oResult As New List(Of String)
|
||||
Dim oType As String = oDataRow.Item("TYPE").ToString.ToUpper
|
||||
|
||||
Select Case oType
|
||||
Case VBSPLIT
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" ...Nachbearbeitung mit VBSPLIT", False)
|
||||
|
||||
Dim oSeparator As String = oDataRow.Item("TEXT1")
|
||||
Dim oSplitIndex As Integer = 0
|
||||
Integer.TryParse(oDataRow.Item("TEXT2"), oSplitIndex)
|
||||
|
||||
For Each oIndexValue In oIndexValues
|
||||
Dim oSplitted As List(Of String) = oIndexValue.Split(oSeparator).ToList()
|
||||
oResult.Add(oSplitted.Item(oSplitIndex))
|
||||
Next
|
||||
|
||||
Case VBREPLACE
|
||||
Dim oFindString = oDataRow.Item("TEXT1")
|
||||
Dim oReplaceString = oDataRow.Item("TEXT2")
|
||||
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" ...Nachbearbeitung mit VBREPLACE", False)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" ...Ersetze '" & oFindString & "' mit '" & oReplaceString & "'", False)
|
||||
|
||||
For Each oIndexValue In oIndexValues
|
||||
Dim oReplaceResult = oIndexValue.Replace(oFindString, oReplaceString)
|
||||
oResult.Add(oReplaceResult)
|
||||
Next
|
||||
Case REGEXPRESSION
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" ...Nachbearbeitung mit RegEx", False)
|
||||
Dim RegexList As New List(Of System.Text.RegularExpressions.Regex)
|
||||
Dim Regex As New System.Text.RegularExpressions.Regex(row.Item("TEXT1"), System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
||||
RegexList.Add(Regex)
|
||||
'
|
||||
Dim resultRegex = ClassPostprocessing.extractFromStringviaRE(result, RegexList)
|
||||
If Not IsNothing(resultRegex) Then
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" ...Ergebnis des RegEx: " & resultRegex.ToString, False)
|
||||
result = resultRegex.ToString
|
||||
Else
|
||||
ClassLogger.Add("Postprocessing RegEx konnte kein Ergebnis auswerten!", True)
|
||||
End If
|
||||
|
||||
Dim oRegexList As New List(Of Regex)
|
||||
Dim oRegex As New Regex(oDataRow.Item("TEXT1"), RegexOptions.IgnoreCase)
|
||||
|
||||
oRegexList.Add(oRegex)
|
||||
|
||||
For Each oIndexValue In oIndexValues
|
||||
Dim oProcessedString = extractFromStringviaRE(oIndexValue, oRegexList)
|
||||
oResult.Add(oProcessedString)
|
||||
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" ...Ergebnis des RegEx: " & oProcessedString, False)
|
||||
Next
|
||||
End Select
|
||||
|
||||
oIndexValues = oResult
|
||||
Next
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add(" - Unvorhergesehener Unexpected error in Get_Nachbearbeitung_Wert - result: " & result & " - Fehler: " & vbNewLine & ex.Message)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Get_Nachbearbeitung_Wert:")
|
||||
Return result
|
||||
ClassLogger.Add(" - Unvorhergesehener Unexpected error in Get_Nachbearbeitung_Wert - result: " & idxvalue & " - Fehler: " & vbNewLine & ex.Message)
|
||||
End Try
|
||||
|
||||
Return String.Join(ClassConstants.VECTORSEPARATOR, oIndexValues.ToArray)
|
||||
|
||||
'Dim result As String = idxvalue
|
||||
'Try
|
||||
' For Each row As DataRow In Datatable.Rows
|
||||
' Select Case row.Item("TYPE").ToString.ToUpper
|
||||
' Case "VBSPLIT"
|
||||
' If LogErrorsOnly = False Then ClassLogger.Add(" ...Nachbearbeitung mit VBSPLIT", False)
|
||||
' Dim strSplit() As String
|
||||
' strSplit = result.Split(row.Item("TEXT1"))
|
||||
' For i As Integer = 0 To strSplit.Length - 1
|
||||
' If i = CInt(row.Item("TEXT2")) Then
|
||||
' If LogErrorsOnly = False Then ClassLogger.Add(" ...Split-Ergebnis für Index (" & i.ToString & "): " & strSplit(i), False)
|
||||
' result = strSplit(i).ToString
|
||||
' End If
|
||||
' Next
|
||||
' Case "VBREPLACE"
|
||||
' If LogErrorsOnly = False Then
|
||||
' ClassLogger.Add(" ...Nachbearbeitung mit VBREPLACE", False)
|
||||
' ClassLogger.Add(" ...Ersetze '" & row.Item("TEXT1") & "' mit '" & row.Item("TEXT2") & "'", False)
|
||||
' result = result.Replace(row.Item("TEXT1"), row.Item("TEXT2"))
|
||||
' End If
|
||||
|
||||
' result = result.Replace(row.Item("TEXT1"), row.Item("TEXT2"))
|
||||
' Case "REG. EXPRESSION"
|
||||
' If LogErrorsOnly = False Then ClassLogger.Add(" ...Nachbearbeitung mit RegEx", False)
|
||||
' Dim RegexList As New List(Of System.Text.RegularExpressions.Regex)
|
||||
' Dim Regex As New System.Text.RegularExpressions.Regex(row.Item("TEXT1"), System.Text.RegularExpressions.RegexOptions.IgnoreCase)
|
||||
' RegexList.Add(Regex)
|
||||
' '
|
||||
' Dim resultRegex = ClassPostprocessing.extractFromStringviaRE(result, RegexList)
|
||||
' If Not IsNothing(resultRegex) Then
|
||||
' If LogErrorsOnly = False Then ClassLogger.Add(" ...Ergebnis des RegEx: " & resultRegex.ToString, False)
|
||||
' result = resultRegex.ToString
|
||||
' Else
|
||||
' ClassLogger.Add("Postprocessing RegEx konnte kein Ergebnis auswerten!", True)
|
||||
' End If
|
||||
' End Select
|
||||
' Next
|
||||
' Return result
|
||||
'Catch ex As Exception
|
||||
' ClassLogger.Add(" - Unvorhergesehener Unexpected error in Get_Nachbearbeitung_Wert - result: " & result & " - Fehler: " & vbNewLine & ex.Message)
|
||||
' MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Get_Nachbearbeitung_Wert:")
|
||||
' Return result
|
||||
'End Try
|
||||
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
|
||||
Reference in New Issue
Block a user