ZUGFeRDService: Fix updating rejection status
This commit is contained in:
parent
3658326547
commit
55e484308c
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user