Tweak logging, ZUGFeRD Import
This commit is contained in:
parent
af00fab575
commit
463f4ce22d
@ -4,7 +4,6 @@ Imports System.Linq
|
|||||||
Imports DigitalData.Modules.Database
|
Imports DigitalData.Modules.Database
|
||||||
Imports DigitalData.Modules.Interfaces
|
Imports DigitalData.Modules.Interfaces
|
||||||
Imports DigitalData.Modules.Logging
|
Imports DigitalData.Modules.Logging
|
||||||
Imports DigitalData.Modules.Filesystem
|
|
||||||
Imports System.Text.RegularExpressions
|
Imports System.Text.RegularExpressions
|
||||||
Imports DigitalData.Modules.Jobs.Exceptions
|
Imports DigitalData.Modules.Jobs.Exceptions
|
||||||
Imports FirebirdSql.Data.FirebirdClient
|
Imports FirebirdSql.Data.FirebirdClient
|
||||||
@ -111,7 +110,7 @@ Public Class ImportZUGFeRDFiles
|
|||||||
|
|
||||||
_firebird.ExecuteNonQuery(oSQLInsert)
|
_firebird.ExecuteNonQuery(oSQLInsert)
|
||||||
|
|
||||||
_logger.Info("Email Queue updated for MessageId {0}.", FileGuid, oEmailTo)
|
_logger.Debug("Email Queue updated for MessageId {0}.", FileGuid, oEmailTo)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
@ -160,6 +159,7 @@ Public Class ImportZUGFeRDFiles
|
|||||||
|
|
||||||
_logger.Info("Starting Job {0}", Me.GetType.Name)
|
_logger.Info("Starting Job {0}", Me.GetType.Name)
|
||||||
|
|
||||||
|
Try
|
||||||
For Each oPath As String In args.WatchDirectories
|
For Each oPath As String In args.WatchDirectories
|
||||||
Dim oDirInfo As New DirectoryInfo(oPath)
|
Dim oDirInfo As New DirectoryInfo(oPath)
|
||||||
|
|
||||||
@ -195,6 +195,7 @@ Public Class ImportZUGFeRDFiles
|
|||||||
Dim oFileGroupId As String = oFileGroup.Key
|
Dim oFileGroupId As String = oFileGroup.Key
|
||||||
Dim oMissingProperties As New List(Of String)
|
Dim oMissingProperties As New List(Of String)
|
||||||
|
|
||||||
|
_logger.NewBlock($"Message Id {oFileGroupId}")
|
||||||
_logger.Info("Start processing file group {0}", oFileGroupId)
|
_logger.Info("Start processing file group {0}", oFileGroupId)
|
||||||
|
|
||||||
Try
|
Try
|
||||||
@ -205,12 +206,12 @@ Public Class ImportZUGFeRDFiles
|
|||||||
oMissingProperties = New List(Of String)
|
oMissingProperties = New List(Of String)
|
||||||
oCurrentFileCount += 1
|
oCurrentFileCount += 1
|
||||||
|
|
||||||
_logger.Info($"({oCurrentFileCount}/{oFileCount}) Start processing file {oFile.Name}")
|
_logger.Info("Start processing file {0}", oFile.Name)
|
||||||
|
|
||||||
Try
|
Try
|
||||||
oDocument = _zugferd.ExtractZUGFeRDFile(oFile.FullName)
|
oDocument = _zugferd.ExtractZUGFeRDFile(oFile.FullName)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_logger.Warn($"({oCurrentFileCount}/{oFileCount}) File is not a valid ZUGFeRD document! Skipping.")
|
_logger.Warn("File is not a valid ZUGFeRD document! Skipping.")
|
||||||
Continue For
|
Continue For
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
@ -284,15 +285,22 @@ Public Class ImportZUGFeRDFiles
|
|||||||
' Move all files of the current group
|
' Move all files of the current group
|
||||||
For Each oFile In oFileGroupFiles
|
For Each oFile In oFileGroupFiles
|
||||||
_filesystem.MoveTo(oFile.FullName, oMoveDirectory)
|
_filesystem.MoveTo(oFile.FullName, oMoveDirectory)
|
||||||
_logger.Info("({1}/{2}) Finished processing file {0}", oFile.Name, oCurrentFileCount, oFileCount)
|
_logger.Info("Finished processing file {0}", oFile.Name)
|
||||||
_logger.Info($"({1}/{2}) File moved to {0}", oMoveDirectory)
|
_logger.Info("File moved to {0}", oMoveDirectory)
|
||||||
Next
|
Next
|
||||||
|
|
||||||
_logger.Info("Finished processing file group {0}", oFileGroupId)
|
_logger.Info("Finished processing file group {0}", oFileGroupId)
|
||||||
|
_logger.EndBlock()
|
||||||
End Try
|
End Try
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
_logger.Info("Finishing Job {0}", Me.GetType.Name)
|
||||||
|
Catch ex As Exception
|
||||||
|
_logger.Error(ex)
|
||||||
|
_logger.Info("Job Failed! See error log for details")
|
||||||
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ Public Class Exceptions
|
|||||||
Inherits ApplicationException
|
Inherits ApplicationException
|
||||||
|
|
||||||
Public Sub New()
|
Public Sub New()
|
||||||
MyBase.New()
|
MyBase.New("More than one ZUGFeRD document found")
|
||||||
End Sub
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ Public Class Exceptions
|
|||||||
Inherits ApplicationException
|
Inherits ApplicationException
|
||||||
|
|
||||||
Public Sub New()
|
Public Sub New()
|
||||||
MyBase.New()
|
MyBase.New("No ZUGFeRD documents found")
|
||||||
End Sub
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -8,7 +8,15 @@ Public Class Logger
|
|||||||
''' </summary>
|
''' </summary>
|
||||||
''' <param name="blockId">A unique Identifier for this block, eg. DocId, FullPath, ..</param>
|
''' <param name="blockId">A unique Identifier for this block, eg. DocId, FullPath, ..</param>
|
||||||
Public Sub NewBlock(blockId As String)
|
Public Sub NewBlock(blockId As String)
|
||||||
Dim message As String = $"=========={vbTab}{vbTab}Start of Block {blockId}{vbTab}{vbTab}=========="
|
Dim message As String = $"-----> Start of Block {blockId}"
|
||||||
|
Dim logEventInfo As New LogEventInfo(LogLevel.Info, Name, message)
|
||||||
|
Dim WrapperType As Type = GetType(Logger)
|
||||||
|
|
||||||
|
Log(WrapperType, logEventInfo)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub EndBlock()
|
||||||
|
Dim message As String = $"<----- End of Block"
|
||||||
Dim logEventInfo As New LogEventInfo(LogLevel.Info, Name, message)
|
Dim logEventInfo As New LogEventInfo(LogLevel.Info, Name, message)
|
||||||
Dim WrapperType As Type = GetType(Logger)
|
Dim WrapperType As Type = GetType(Logger)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user