MS Fehler in Automatischer Indexierung
This commit is contained in:
@@ -2273,6 +2273,7 @@ Public Class frmIndex
|
||||
|
||||
' 1. Schritt: Einfach-Indexe und Platzhalter ersetzen
|
||||
For Each oAutoIndexRow As DataRow In oDatatable
|
||||
If LogErrorsOnly = False Then ClassLogger.Add("Working on AutomaticIndex: " & oAutoIndexRow.Item("INDEXNAME") & "...", False)
|
||||
Dim oSqlResult As String = ClassHelper.NotNull(oAutoIndexRow.Item("SQL_RESULT"), "")
|
||||
Dim oSqlActive As Boolean = ClassHelper.NotNull(oAutoIndexRow.Item("SQL_ACTIVE"), False)
|
||||
Dim oSqlConnectionId As Integer = ClassHelper.NotNull(oAutoIndexRow.Item("CONNECTION_ID"), -1)
|
||||
@@ -2328,38 +2329,53 @@ Public Class frmIndex
|
||||
oSqlResult = oSqlResult.Replace(oMatch.Value, oManualIndexResult)
|
||||
End If
|
||||
Next
|
||||
If oSqlResult <> String.Empty Then
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" oSqlResult afrer first Replace: " & oSqlResult, False)
|
||||
End If
|
||||
|
||||
' Ergebnis: Es wurden alle einfachen Platzhalter ersetzt, jetzt haben wir einen SQL Befehl,
|
||||
' der nur noch vektorfelder-platzhalter enthält
|
||||
|
||||
' 2. Schritt: Vektorfelder ersetzen
|
||||
Dim oVectorMatches As MatchCollection = oRegex.Matches(oSqlResult)
|
||||
Dim oIsFirstMatch = True
|
||||
If oVectorMatches.Count > 0 Then
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(" There are " & oVectorMatches.Count & " matches for vectors!", False)
|
||||
Dim oIsFirstMatch = True
|
||||
|
||||
For Each oVectorMatch As Match In oVectorMatches
|
||||
Dim oIndexValue As String = StripPlaceholder(oVectorMatch.Value)
|
||||
Dim oOptionalIndex = False
|
||||
Dim oManualIndexResult As String = Nothing
|
||||
For Each oVectorMatch As Match In oVectorMatches
|
||||
Dim oIndexValue As String = StripPlaceholder(oVectorMatch.Value)
|
||||
Dim oOptionalIndex = False
|
||||
Dim oManualIndexResult As String = Nothing
|
||||
|
||||
oOptionalIndex = ClassDatabase.Execute_Scalar($"SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = {CURRENT_DOKART_ID} AND UPPER(NAME) = UPPER('{oIndexValue}')", MyConnectionString, True)
|
||||
oManualIndexResult = GetManIndex_Value(oIndexValue, "IDX_AUTO", oOptionalIndex)
|
||||
oOptionalIndex = ClassDatabase.Execute_Scalar($"SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = {CURRENT_DOKART_ID} AND UPPER(NAME) = UPPER('{oIndexValue}')", MyConnectionString, True)
|
||||
oManualIndexResult = GetManIndex_Value(oIndexValue, "IDX_AUTO", oOptionalIndex)
|
||||
|
||||
Dim oVectorIndexValues = oManualIndexResult.Split(ClassConstants.VECTORSEPARATOR).ToList()
|
||||
Dim oVectorIndexValues = oManualIndexResult.Split(ClassConstants.VECTORSEPARATOR).ToList()
|
||||
|
||||
For Each oVectorIndexValue In oVectorIndexValues
|
||||
Dim oTempSql = oSqlResult.Replace(oVectorMatch.Value, oVectorIndexValue)
|
||||
Dim oResult = GetAutomaticIndexSQLValue(oTempSql, oSqlConnectionId, oSqlProvider)
|
||||
oEndResult.Add(oResult)
|
||||
For Each oVectorIndexValue In oVectorIndexValues
|
||||
Dim oTempSql = oSqlResult.Replace(oVectorMatch.Value, oVectorIndexValue)
|
||||
Dim oResult = GetAutomaticIndexSQLValue(oTempSql, oSqlConnectionId, oSqlProvider)
|
||||
oEndResult.Add(oResult)
|
||||
Next
|
||||
|
||||
' Verhindert, dass die Schleife mehrmals durchlaufen wird
|
||||
If oIsFirstMatch Then
|
||||
Exit For
|
||||
End If
|
||||
oAutoIndexRow.Item("Indexiert") = True
|
||||
oAutoIndexRow.Item("Indexwert") = String.Join(ClassConstants.VECTORSEPARATOR, oEndResult.ToArray)
|
||||
Next
|
||||
Else
|
||||
Dim oResult = GetAutomaticIndexSQLValue(oSqlResult, oSqlConnectionId, oSqlProvider)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add("Got a simple SQLResult: " & oResult.ToString, False)
|
||||
oAutoIndexRow.Item("Indexiert") = True
|
||||
oAutoIndexRow.Item("Indexwert") = oResult
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
' Verhindert, dass die Schleife mehrmals durchlaufen wird
|
||||
If oIsFirstMatch Then
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
oAutoIndexRow.Item("Indexiert") = True
|
||||
oAutoIndexRow.Item("Indexwert") = String.Join(ClassConstants.VECTORSEPARATOR, oEndResult.ToArray)
|
||||
Next
|
||||
|
||||
Return True
|
||||
|
||||
Reference in New Issue
Block a user