MS Sichtbeleg
This commit is contained in:
@@ -40,11 +40,15 @@ Public Class ImportZUGFeRDFiles
|
||||
Private ReadOnly _hash As HashFunctions
|
||||
Private ReadOnly _embeds As PDFEmbeds
|
||||
|
||||
Private ReadOnly _gdpictureLicenseKey As String
|
||||
Private SQL_xRechnung_ItemTemplate As String = ""
|
||||
|
||||
Private ReadOnly _gdpictureLicenseKey As String
|
||||
Private _xRechnungCreator As XRechnungViewDocument
|
||||
Private _zugferd As ZUGFeRDInterface
|
||||
Private _EmailOutAccountId As Integer
|
||||
|
||||
Private MyTemplateValues_xInvDT As DataTable
|
||||
|
||||
Private Class ProcessFileResult
|
||||
Public ZugferdFileFound As Boolean = False
|
||||
|
||||
@@ -70,7 +74,7 @@ Public Class ImportZUGFeRDFiles
|
||||
_history = New ZUGFeRD.HistoryFunctions(LogConfig, _mssql)
|
||||
_embeds = New PDFEmbeds(LogConfig)
|
||||
_hash = New HashFunctions(_logConfig, _mssql)
|
||||
|
||||
_xRechnungCreator = New XRechnungViewDocument(_logConfig, _mssql, _gdpictureLicenseKey)
|
||||
_logger.Debug("Registering GDPicture License")
|
||||
If _mssql IsNot Nothing Then
|
||||
_gdpictureLicenseKey = ConfigDbFunct.GetProductLicense("GDPICTURE", "11.2024", _logConfig, _mssql.CurrentConnectionString)
|
||||
@@ -92,6 +96,11 @@ Public Class ImportZUGFeRDFiles
|
||||
})
|
||||
|
||||
_logger.Debug("Starting Job {0}", [GetType].Name)
|
||||
If oArgs.AllowXRechnung Then
|
||||
Dim oSQL = "Select SQL_COMMAND from TBDD_SQL_COMMANDS WHERE TITLE = 'VWDD_ZUGFERD_VIEW_RECEIPT_TEMPLATE_ITEMS'"
|
||||
SQL_xRechnung_ItemTemplate = _mssql.GetScalarValue(oSQL)
|
||||
End If
|
||||
|
||||
|
||||
Try
|
||||
'For Each oPath As String In oArgs.WatchDirectory
|
||||
@@ -123,12 +132,23 @@ Public Class ImportZUGFeRDFiles
|
||||
|
||||
_logger.Info("Found {0} file groups", oGrouped.Count)
|
||||
|
||||
' Process each file group together
|
||||
'Process each file group together
|
||||
'oGrouped equals one e-invoice
|
||||
For Each oFileGroup In oGrouped
|
||||
' Start a new transaction for each file group.
|
||||
' This way we can rollback database changes for the whole filegroup in case something goes wrong.
|
||||
|
||||
Dim oSQLConnection As SqlConnection = _mssql.GetConnection()
|
||||
|
||||
If oArgs.AllowXRechnung Then
|
||||
'but before we need to get all Data we need
|
||||
MyTemplateValues_xInvDT = Nothing
|
||||
Dim oSQL_MsgIDReplacec = SQL_xRechnung_ItemTemplate
|
||||
oSQL_MsgIDReplacec = oSQL_MsgIDReplacec.Replace("@MSG_ID", oFileGroup.Key)
|
||||
MyTemplateValues_xInvDT = _mssql.GetDatatable(oSQL_MsgIDReplacec)
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Dim oSQLTransaction As SqlTransaction = oSQLConnection?.BeginTransaction()
|
||||
|
||||
Dim oConnections As New DatabaseConnections() With {
|
||||
@@ -151,7 +171,7 @@ Public Class ImportZUGFeRDFiles
|
||||
Dim oExpectedError As Boolean = True
|
||||
|
||||
' Create file lists
|
||||
Dim oFileGroupFiles As List(Of FileInfo) = oFileGroup.Value
|
||||
Dim oEInvoiceFileGroup As List(Of FileInfo) = oFileGroup.Value
|
||||
Dim oEmailAttachmentFiles As New List(Of FileInfo)
|
||||
Dim oEmbeddedAttachmentFiles As New List(Of PDFEmbeds.EmbeddedFile)
|
||||
|
||||
@@ -160,7 +180,7 @@ Public Class ImportZUGFeRDFiles
|
||||
|
||||
_logger.Info("START processing file group {0}", oMessageId)
|
||||
|
||||
If _file.CheckFileAge(oFileGroupFiles, oArgs.MinFileAgeInMinutes) Then
|
||||
If _file.CheckFileAge(oEInvoiceFileGroup, oArgs.MinFileAgeInMinutes) Then
|
||||
_logger.Info("At least one file was created less than [{0}] minutes ago. Skipping file group.", oArgs.MinFileAgeInMinutes)
|
||||
Continue For
|
||||
End If
|
||||
@@ -169,7 +189,8 @@ Public Class ImportZUGFeRDFiles
|
||||
Dim oFileCounter As Integer = 0
|
||||
|
||||
Try
|
||||
For Each oFile In oFileGroupFiles
|
||||
|
||||
For Each oFile In oEInvoiceFileGroup
|
||||
oFileCounter += 1
|
||||
Dim oResult As ProcessFileResult
|
||||
|
||||
@@ -395,15 +416,28 @@ Public Class ImportZUGFeRDFiles
|
||||
|
||||
Finally
|
||||
Try
|
||||
Dim oxRechnungHandle As Boolean = False
|
||||
Dim oRegularMove As Boolean = False
|
||||
' If an application error occurred, dont move files so they will be processed again later
|
||||
If oMoveDirectory = DIRECTORY_DONT_MOVE Then
|
||||
_logger.Info("Application Error occurred. Files for message Id {0} will not be moved.", oMessageId)
|
||||
|
||||
ElseIf (1 = 0) Then
|
||||
ElseIf oArgs.AllowXRechnung And oIsSuccess And oEInvoiceFileGroup.Item(0).Extension = ".xml" Then
|
||||
oxRechnungHandle = True
|
||||
' Hier das neue PDF erzeugen
|
||||
If Not IsNothing(MyTemplateValues_xInvDT) Then
|
||||
Dim oViewReceiptFileInfo As FileInfo = _xRechnungCreator.Create_PDFfromXML(oEInvoiceFileGroup.Item(0), MyTemplateValues_xInvDT)
|
||||
If Not IsNothing(oViewReceiptFileInfo) Then
|
||||
oEInvoiceFileGroup.Item(0) = oViewReceiptFileInfo
|
||||
oRegularMove = True
|
||||
End If
|
||||
End If
|
||||
|
||||
Else
|
||||
oRegularMove = True
|
||||
End If
|
||||
If oRegularMove Then
|
||||
' Move all files of the current group
|
||||
_file.MoveFiles(oArgs, oMessageId, oFileGroupFiles, oEmailAttachmentFiles, oEmbeddedAttachmentFiles, oMoveDirectory, oIsSuccess)
|
||||
_file.MoveFiles(oArgs, oMessageId, oEInvoiceFileGroup, oEmailAttachmentFiles, oEmbeddedAttachmentFiles, oMoveDirectory, oIsSuccess)
|
||||
End If
|
||||
_logger.Info("END processing file group {0}", oMessageId)
|
||||
Catch ex As Exception
|
||||
|
||||
Reference in New Issue
Block a user