4 Commits

Author SHA1 Message Date
Jonathan Jenne
cf543e7ee9 EDMI.API: Version 1.5.4.0 2022-07-08 10:13:34 +02:00
Jonathan Jenne
942421e051 EDMI.API/DatabaseWithFallback: Fix empty connection string 2022-07-08 10:13:03 +02:00
Jonathan Jenne
914a3464d7 Database: Version 2.2.7, fix connection id = 0 2022-07-08 10:12:41 +02:00
Jonathan Jenne
55e484308c ZUGFeRDService: Fix updating rejection status 2022-07-07 13:53:09 +02:00
6 changed files with 51 additions and 24 deletions

View File

@@ -146,7 +146,12 @@ Public Class MSSQLServer
End Function
Public Function Get_ConnectionStringforID(pConnectionId As Integer) As String
Dim oConnectionString As String = ""
Dim oConnectionString As String = String.Empty
If pConnectionId = 0 Then
_Logger.Warn("ConnectionId was 0. Falling back to default connection.")
Return String.Empty
End If
Try
Dim oTable As DataTable = GetDatatable($"SELECT * FROM TBDD_CONNECTION WHERE GUID = {pConnectionId}")
@@ -174,17 +179,17 @@ Public Class MSSQLServer
End If
Case Else
_Logger.Warn("Provider {0} nicht unterstützt!", oProvider)
_Logger.Warn("Provider [{0}] not supported!", oProvider)
End Select
Else
_Logger.Info("No entry for Connection-ID: " & pConnectionId.ToString)
_Logger.Warn("No entry for Connection-ID: [{0}] ", pConnectionId.ToString)
End If
Catch ex As Exception
_Logger.Error(ex)
_Logger.Info("Error in bei Get_ConnectionStringforID")
_Logger.Warn("Error in Get_ConnectionStringforID")
End Try
Return DecryptConnectionString(oConnectionString)

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Database")>
<Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("")>
<Assembly: AssemblyTrademark("2.2.7.0")>
<Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.2.6.0")>
<Assembly: AssemblyFileVersion("2.2.6.0")>
<Assembly: AssemblyVersion("2.2.7.0")>
<Assembly: AssemblyFileVersion("2.2.7.0")>

View File

@@ -345,7 +345,11 @@ Public Class DatabaseWithFallback
Case Else
Dim oConnectionString = _DatabaseECM.Get_ConnectionStringforID(pConnectionId)
Return _DatabaseECM.GetDatatableWithConnection(pSQLCommand, oConnectionString)
If oConnectionString = String.Empty Then
Return _DatabaseECM.GetDatatable(pSQLCommand)
Else
Return _DatabaseECM.GetDatatableWithConnection(pSQLCommand, oConnectionString)
End If
End Select
Catch ex As Exception
@@ -401,8 +405,11 @@ Public Class DatabaseWithFallback
Case Else
Dim oConnectionString = _DatabaseECM.Get_ConnectionStringforID(pConnectionId)
Return _DatabaseECM.GetScalarValueWithConnection(pSQLCommand, oConnectionString)
If oConnectionString = String.Empty Then
Return _DatabaseECM.GetScalarValue(pSQLCommand)
Else
Return _DatabaseECM.GetScalarValueWithConnection(pSQLCommand, oConnectionString)
End If
End Select
Catch ex As Exception
_Logger.Error(ex)
@@ -456,7 +463,11 @@ Public Class DatabaseWithFallback
Case Else
Dim oConnectionString = _DatabaseECM.Get_ConnectionStringforID(pConnectionId)
Return _DatabaseECM.ExecuteNonQueryWithConnection(pSQLCommand, oConnectionString)
If oConnectionString = String.Empty Then
Return _DatabaseECM.ExecuteNonQuery(pSQLCommand)
Else
Return _DatabaseECM.ExecuteNonQueryWithConnection(pSQLCommand, oConnectionString)
End If
End Select
Catch ex As Exception

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("EDMIAPI")>
<Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("1.5.3.0")>
<Assembly: AssemblyTrademark("1.5.4.0")>
<Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.5.3.0")>
<Assembly: AssemblyFileVersion("1.5.3.0")>
<Assembly: AssemblyVersion("1.5.4.0")>
<Assembly: AssemblyFileVersion("1.5.4.0")>

View File

@@ -29,6 +29,10 @@
''' there's no size limit.
''' </summary>
Public Property MaxAttachmentSizeInMegaBytes As Integer = -1
Public Property RejectionTransferTimeUnit As String = "HOUR"
Public Property RejectionTransferTimeValue As Integer = 12
End Class
Public Class FirebirdConfig

View File

@@ -142,12 +142,12 @@ Public Class ThreadRunner
Private Sub MaybeUpdateRejected()
Try
Dim oTimeUnit = "HOUR"
Dim oTimeValue = 12
Dim oTimeUnit = _config.Config.Custom.RejectionTransferTimeUnit
Dim oTimeValue = _config.Config.Custom.RejectionTransferTimeValue
Dim oDifference As TimeSpan = Now - RejectedLastRun
If oDifference.TotalMinutes < RejectedMaxDifferenceInMinutes Then
_logger.Info("Updating rejected files: Waiting for next run.")
_logger.Debug("Updating rejected files: Waiting for next run.")
Exit Sub
End If
@@ -156,20 +156,27 @@ Public Class ThreadRunner
Dim oSQL = $"
SELECT [EMAIL_MSGID]
FROM TBEMLP_HISTORY
WHERE (STATUS = 'REJECTED' OR CUST_REJECTED = 1)
WHERE (STATUS = 'REJECTED' OR CUST_REJECTED = 1) AND FB_UPDATED = 0
AND DATEDIFF({oTimeUnit}, CHANGED_WHEN, GETDATE()) <= {oTimeValue}
ORDER BY GUID DESC"
Dim oDT As DataTable = _mssql.GetDatatable(oSQL)
If Not IsNothing(oDT) Then
For Each oROW As DataRow In oDT.Rows
Dim oTable As DataTable = _mssql.GetDatatable(oSQL)
If Not IsNothing(oTable) Then
For Each oROW As DataRow In oTable.Rows
Dim oUpdate = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET REJECTED = True WHERE MESSAGE_ID = '{oROW.Item(0)}' and REJECTED = false"
_firebird.ExecuteNonQuery(oUpdate)
If _firebird.ExecuteNonQuery(oUpdate) = True Then
Dim oUpdateSQL = $"
UPDATE TBEMLP_HISTORY
SET FB_UPDATED = 1
WHERE [EMAIL_MSGID] = '{oROW.Item(0)}' AND FB_UPDATED = 0"
_mssql.ExecuteNonQuery(oUpdateSQL)
End If
Next
RejectedLastRun = Now
End If
Catch ex As Exception
_logger.Warn("Error while Updating REJECTED State: " & ex.Message)
Finally
RejectedLastRun = Now
End Try
End Sub