Zugferd/Jobs: Falls DB-Fehler beim Löschen passiert, wird jetzt darauf reagiert.
This commit is contained in:
parent
9957465f59
commit
bb7ed1bdd8
@ -548,25 +548,9 @@ Public Class ImportZUGFeRDFiles
|
||||
|
||||
End If
|
||||
|
||||
DeleteExistingPropertyValues(pMessageId, oConnections)
|
||||
|
||||
' MP 05.06.2024 - Einzel-Inserts durch BULK-Insert abgelöst
|
||||
'Dim oFirstProperty = oCheckResult.ValidProperties.FirstOrDefault()
|
||||
'If oFirstProperty IsNot Nothing Then
|
||||
' InsertPropertyValue(pMessageId, oConnections, New PropertyValues.ValidProperty() With {
|
||||
' .MessageId = pMessageId,
|
||||
' .Description = "ZUGFeRDSpezifikation",
|
||||
' .GroupCounter = 0,
|
||||
' .IsRequired = False,
|
||||
' .Value = oDocument.Specification,
|
||||
' .TableName = oFirstProperty.TableName,
|
||||
' .TableColumn = "ZUGFERD_SPECIFICATION"
|
||||
' })
|
||||
'End If
|
||||
|
||||
'For Each oProperty In oCheckResult.ValidProperties
|
||||
' InsertPropertyValue(pMessageId, oConnections, oProperty)
|
||||
'Next
|
||||
If DeleteExistingPropertyValues(pMessageId, oConnections) = False Then
|
||||
Throw New Exception("Could not cleanup data. Exiting.")
|
||||
End If
|
||||
|
||||
' DataTable vorbereiten
|
||||
Dim oDataTable As DataTable = FillDataTable(pMessageId, oCheckResult, oDocument.Specification, oDocument.UsedXMLSchema)
|
||||
@ -585,6 +569,7 @@ Public Class ImportZUGFeRDFiles
|
||||
|
||||
If oBulkResult = False Then
|
||||
_logger.Error("Bulk Insert for MessageId [{0}] failed!", pMessageId)
|
||||
Throw New Exception("Bulk Insert failed! Exiting.")
|
||||
End If
|
||||
|
||||
_logger.Info("Bulk Insert finished. [{0}] rows inserted for MessageId [{1}].", oDataTable.Rows.Count, pMessageId)
|
||||
@ -661,38 +646,17 @@ Public Class ImportZUGFeRDFiles
|
||||
Return oDataTable
|
||||
End Function
|
||||
|
||||
Private Sub DeleteExistingPropertyValues(pMessageId As String, pConnections As DatabaseConnections)
|
||||
Private Function DeleteExistingPropertyValues(pMessageId As String, pConnections As DatabaseConnections) As Boolean
|
||||
Dim oDelSQL = $"DELETE FROM TBEDMI_ITEM_VALUE where REFERENCE_GUID = '{pMessageId}'"
|
||||
Dim oStep As String
|
||||
Dim oStep As String = "TBEDMI_ITEM_VALUE Delete MessageID Items"
|
||||
|
||||
oStep = "TBEDMI_ITEM_VALUE Delete MessageID Items"
|
||||
Try
|
||||
_mssql.ExecuteNonQueryWithConnectionObject(oDelSQL, pConnections.SQLServerConnection, MSSQLServer.TransactionMode.ExternalTransaction, pConnections.SQLServerTransaction)
|
||||
Dim retValue As Boolean = _mssql.ExecuteNonQueryWithConnectionObject(oDelSQL, pConnections.SQLServerConnection, MSSQLServer.TransactionMode.ExternalTransaction, pConnections.SQLServerTransaction)
|
||||
Return retValue
|
||||
Catch ex As Exception
|
||||
_logger.Warn("Step [{0}] with SQL [{1}] was not successful.", oStep, oDelSQL)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
' Alte Insert-Methode
|
||||
'Private Sub InsertPropertyValue(pMessageId As String, pConnections As DatabaseConnections, pProperty As PropertyValues.ValidProperty)
|
||||
' Dim oGroupCounterValue = pProperty.GroupCounter
|
||||
|
||||
' ' If GroupCounter is -1, it means this is a default property that can only occur once.
|
||||
' ' Set the actual inserted value to 0
|
||||
' If oGroupCounterValue = -1 Then
|
||||
' oGroupCounterValue = 0
|
||||
' End If
|
||||
|
||||
' Dim oCommand = $"INSERT INTO {pProperty.TableName} (REFERENCE_GUID, ITEM_DESCRIPTION, ITEM_VALUE, GROUP_COUNTER, SPEC_NAME, IS_REQUIRED) VALUES
|
||||
' ('{pMessageId}', '{pProperty.Description}', '{pProperty.Value.Replace("'", "''")}', {oGroupCounterValue},'{pProperty.TableColumn}','{pProperty.IsRequired}')"
|
||||
' _logger.Debug("Mapping Property [{0}] with value [{1}], Will be inserted into table [{2}]", pProperty.TableColumn, pProperty.Value.Replace("'", "''"), pProperty.TableName)
|
||||
|
||||
' ' Insert into SQL Server
|
||||
' Dim oResult = _mssql.ExecuteNonQueryWithConnectionObject(oCommand, pConnections.SQLServerConnection, MSSQLServer.TransactionMode.ExternalTransaction, pConnections.SQLServerTransaction)
|
||||
' If oResult = False Then
|
||||
' _logger.Warn($"SQL Command [{oCommand}] was not successful. Check the log.")
|
||||
' End If
|
||||
'End Sub
|
||||
End Function
|
||||
|
||||
Private Function BulkInsert(pConnections As DatabaseConnections, pTable As DataTable, pDestinationTable As String, pColumns As List(Of String)) As Boolean
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user