Compare commits
4 Commits
737320d886
...
7b035bd3f7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b035bd3f7 | ||
|
|
8a0b849479 | ||
|
|
43ba8e534e | ||
|
|
1c4b05d8d2 |
@@ -1,6 +1,7 @@
|
||||
Imports FirebirdSql.Data.FirebirdClient
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports System.ComponentModel
|
||||
|
||||
''' <summary>
|
||||
''' MODULE: Firebird
|
||||
@@ -56,8 +57,11 @@ Public Class Firebird
|
||||
Public _DBInitialized As Boolean = False
|
||||
|
||||
Public Enum TransactionMode
|
||||
<Description("Use no transaction, neither internal nor external")>
|
||||
NoTransaction
|
||||
<Description("Use the transaction supplied in the Transaction Parameter")>
|
||||
ExternalTransaction
|
||||
<Description("Create an internal transaction on the fly")>
|
||||
WithTransaction
|
||||
End Enum
|
||||
|
||||
|
||||
@@ -271,17 +271,24 @@ Public Class ImportZUGFeRDFiles
|
||||
End If
|
||||
Dim oDelSQL = $"DELETE FROM TBEDMI_ITEM_VALUE where REFERENCE_GUID = '{oMessageId}'"
|
||||
Dim oStep As String
|
||||
|
||||
|
||||
oStep = "Firebird TBEDMI_ITEM_VALUE Delete messageID Items"
|
||||
Try
|
||||
oStep = "Firebird TBEDMI_ITEM_VALUE Delete messageID Items"
|
||||
_firebird.ExecuteNonQueryWithConnection(oDelSQL, oConnection, Firebird.TransactionMode.WithTransaction)
|
||||
If oArgs.InsertIntoSQLServer = True Then
|
||||
oStep = "MSSQL TBEDMI_ITEM_VALUE Delete messageID Items"
|
||||
_mssql.ExecuteNonQuery(oDelSQL)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_logger.Warn($"Delete Command [{oDelSQL}] was not successful.")
|
||||
_logger.Error(ex)
|
||||
_logger.Warn("Step [{0}] with SQL [{1}] was not successful.", oStep, oDelSQL)
|
||||
End Try
|
||||
|
||||
If oArgs.InsertIntoSQLServer = True Then
|
||||
oStep = "MSSQL TBEDMI_ITEM_VALUE Delete messageID Items"
|
||||
Try
|
||||
_mssql.ExecuteNonQuery(oDelSQL)
|
||||
Catch ex As Exception
|
||||
_logger.Warn("Step [{0}] with SQL [{1}] was not successful.", oStep, oDelSQL)
|
||||
End Try
|
||||
End If
|
||||
|
||||
For Each oProperty In oCheckResult.ValidProperties
|
||||
Dim oGroupCounterValue = oProperty.GroupCounter
|
||||
|
||||
@@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
|
||||
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
|
||||
<Assembly: AssemblyVersion("1.3.0.8")>
|
||||
<Assembly: AssemblyFileVersion("1.3.0.8")>
|
||||
<Assembly: AssemblyVersion("1.3.0.9")>
|
||||
<Assembly: AssemblyFileVersion("1.3.0.9")>
|
||||
|
||||
@@ -27,36 +27,66 @@ Public Class JobListener
|
||||
End Sub
|
||||
|
||||
Public Sub ReplaceExistingTable(Name As String, Table As DataTable, DataSet As DataSet, Optional ChildTable As DataTable = Nothing)
|
||||
Dim oDatatableNameTemp As String = Name & "-TEMP"
|
||||
Try
|
||||
Dim oDatatableNameTemp As String = Name & "-TEMP"
|
||||
|
||||
_Logger.Debug("DataTable [{0}] exists, renaming and replacing in DataSet", Name)
|
||||
' Rename the new table, add TEMP suffix
|
||||
Table.TableName = oDatatableNameTemp
|
||||
_Logger.Debug("DataTable [{0}] exists, renaming and replacing in DataSet", Name)
|
||||
|
||||
' If child table exists, remove all connections to it
|
||||
If ChildTable IsNot Nothing Then
|
||||
' Get name for relations and constraints
|
||||
Dim oRelationName = GetRelationName(Name, ChildTable.TableName)
|
||||
' Rename the new table, add TEMP suffix
|
||||
_Logger.Debug("Renaming new table [{0}] to [{1}]", Name, oDatatableNameTemp)
|
||||
Table.TableName = oDatatableNameTemp
|
||||
|
||||
' Remove the relation
|
||||
Dim oRelation As DataRelation = DataSet.Relations.Item(oRelationName)
|
||||
DataSet.Relations.Remove(oRelation)
|
||||
' If child table exists, remove all connections to it
|
||||
If ChildTable IsNot Nothing Then
|
||||
_Logger.Debug("Removing relations/constraints on [{0}] and [{1}]", ChildTable.TableName, Name)
|
||||
|
||||
' Remove the constraint
|
||||
Dim oConstraint As Constraint = ChildTable.Constraints.Item(oRelationName)
|
||||
ChildTable.Constraints.Remove(oConstraint)
|
||||
End If
|
||||
' Remove relations/constraints on child table
|
||||
Dim oChildTable As DataTable = DataSet.Tables.Item(ChildTable.TableName)
|
||||
If oChildTable IsNot Nothing Then
|
||||
oChildTable.Constraints.Clear()
|
||||
oChildTable.ChildRelations.Clear()
|
||||
End If
|
||||
|
||||
' Remove the temp table if it exists
|
||||
If DataSet.Tables.Contains(oDatatableNameTemp) Then
|
||||
DataSet.Tables.Remove(Table)
|
||||
End If
|
||||
' Remove relations/constraints on parent table
|
||||
Dim oParentTable As DataTable = DataSet.Tables.Item(Name)
|
||||
If oParentTable IsNot Nothing Then
|
||||
oParentTable.Constraints.Clear()
|
||||
oParentTable.ChildRelations.Clear()
|
||||
End If
|
||||
End If
|
||||
|
||||
' Add the new table to the dataset
|
||||
DataSet.Tables.Add(Table)
|
||||
' Remove the temp table if it exists
|
||||
If DataSet.Tables.Contains(oDatatableNameTemp) Then
|
||||
_Logger.Debug("Removing Table [{0}]", oDatatableNameTemp)
|
||||
|
||||
' Rename the new table
|
||||
DataSet.Tables.Item(oDatatableNameTemp).TableName = Name
|
||||
DataSet.Tables.Item(oDatatableNameTemp).ChildRelations.Clear()
|
||||
DataSet.Tables.Item(oDatatableNameTemp).Constraints.Clear()
|
||||
DataSet.Tables.Remove(oDatatableNameTemp)
|
||||
Else
|
||||
_Logger.Debug("Table [{0}] does not exist, skipping removal.", oDatatableNameTemp)
|
||||
End If
|
||||
|
||||
' Remove the current Table
|
||||
If DataSet.Tables.Contains(Name) Then
|
||||
_Logger.Debug("Removing Table [{0}]", Name)
|
||||
|
||||
DataSet.Tables.Item(Name).Constraints.Clear()
|
||||
DataSet.Tables.Remove(Name)
|
||||
Else
|
||||
_Logger.Debug("Table [{0}] does not exist, skipping removal.", Name)
|
||||
End If
|
||||
|
||||
' Add the new table to the dataset
|
||||
_Logger.Debug("Adding Table [{0}] to Dataset", Table.TableName)
|
||||
DataSet.Tables.Add(Table)
|
||||
|
||||
' Rename the new table
|
||||
_Logger.Debug("Renaming new table [{0}] to [{1}]", oDatatableNameTemp, Name)
|
||||
DataSet.Tables.Item(oDatatableNameTemp).TableName = Name
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub AddNewTable(Name As String, Table As DataTable, DataSet As DataSet)
|
||||
@@ -118,6 +148,9 @@ Public Class JobListener
|
||||
Dim oDetailId As Integer = DetailRow.Item("GUID")
|
||||
Dim oDatatableNameTemp As String = oName & "-TEMP"
|
||||
|
||||
' Used for debugging relations and constraints
|
||||
'ListTables(Dataset)
|
||||
|
||||
If Dataset.Tables.Contains(oName) Then
|
||||
' Replace existing table
|
||||
If Result.ChildTable IsNot Nothing Then
|
||||
@@ -153,6 +186,25 @@ Public Class JobListener
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub ListTables(dataset As DataSet)
|
||||
Dim oIndex As Integer = 1
|
||||
|
||||
For Each oTable As DataTable In dataset.Tables
|
||||
_Logger.Debug("Table: [{0}] ({1})", oTable.TableName, oIndex)
|
||||
|
||||
_Logger.Debug("-> Listing Constraints for [{0}]:", oTable.TableName)
|
||||
For Each oConstraint As Constraint In oTable.Constraints
|
||||
_Logger.Debug("---> Constraint: [{0}]", oConstraint.ConstraintName)
|
||||
Next
|
||||
|
||||
_Logger.Debug("-> Listing Child-Relations for [{0}]:", oTable.TableName)
|
||||
For Each oRelation As DataRelation In oTable.ChildRelations
|
||||
_Logger.Debug("---> Relation: [{0}] ", oRelation.RelationName)
|
||||
Next
|
||||
|
||||
oIndex += 1
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Public Overrides Function JobWasExecuted(context As IJobExecutionContext, jobException As JobExecutionException, Optional cancellationToken As CancellationToken = Nothing) As Task
|
||||
Dim oDetailRow As DataRow = context.MergedJobDataMap.Item("CronJobDetails")
|
||||
|
||||
Reference in New Issue
Block a user