Modules.Jobs: Version 1.1.0.0
This commit is contained in:
parent
3e795a1a6d
commit
204151b78c
@ -13,6 +13,7 @@ Imports DigitalData.Modules.Interfaces.Exceptions
|
||||
Imports DigitalData.Modules.Jobs.Exceptions
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports FirebirdSql.Data.FirebirdClient
|
||||
Imports GdPicture14
|
||||
|
||||
Public Class ImportZUGFeRDFiles
|
||||
Implements IJob
|
||||
@ -333,6 +334,10 @@ Public Class ImportZUGFeRDFiles
|
||||
|
||||
_logger.Debug("Starting Job {0}", [GetType].Name)
|
||||
|
||||
_logger.Debug("Registering GDPicture License")
|
||||
Dim oLicenseManager As New LicenseManager
|
||||
oLicenseManager.RegisterKEY(oArgs.GDPictureKey)
|
||||
|
||||
Try
|
||||
For Each oPath As String In oArgs.WatchDirectories
|
||||
Dim oDirInfo As New DirectoryInfo(oPath)
|
||||
@ -418,11 +423,14 @@ Public Class ImportZUGFeRDFiles
|
||||
End Select
|
||||
End Try
|
||||
|
||||
' Extract all attachments other than the zugferd-invoice.xml
|
||||
Dim oAttachments = oAttachmentExtractor.Extract(oFile.FullName, AllowedExtensions)
|
||||
If oAttachments Is Nothing Then
|
||||
_logger.Warn("Attachments for file [{0}] could not be extracted", oFile.FullName)
|
||||
Else
|
||||
oFileAttachmentFiles.AddRange(oFileGroupFiles)
|
||||
'oFileAttachmentFiles.AddRange(oFileGroupFiles)
|
||||
'oFileAttachmentFiles.AddRange(oAttachments)
|
||||
|
||||
oFileAttachmentFiles.AddRange(oAttachments)
|
||||
End If
|
||||
|
||||
@ -741,18 +749,27 @@ Public Class ImportZUGFeRDFiles
|
||||
End Sub
|
||||
|
||||
Private Sub MoveFiles(Args As WorkerArgs, Files As List(Of FileInfo), AttachmentFiles As List(Of FileInfo), MoveDirectory As String)
|
||||
Dim oFinalMoveDirectory As String = MoveDirectory
|
||||
Dim oAttachmentDirectory As String = Path.Combine(MoveDirectory, Args.AttachmentsSubDirectory)
|
||||
|
||||
If Not Directory.Exists(oFinalMoveDirectory) Then
|
||||
Try
|
||||
Directory.CreateDirectory(oFinalMoveDirectory)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
End If
|
||||
|
||||
If Not Directory.Exists(oAttachmentDirectory) And AttachmentFiles.Count > 0 Then
|
||||
Try
|
||||
Directory.CreateDirectory(oAttachmentDirectory)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
End If
|
||||
|
||||
For Each oFile In Files
|
||||
Try
|
||||
Dim oFinalMoveDirectory As String = MoveDirectory
|
||||
|
||||
If AttachmentFiles.Contains(oFile) Then
|
||||
oFinalMoveDirectory = Path.Combine(MoveDirectory, Args.AttachmentsSubDirectory)
|
||||
|
||||
If Not Directory.Exists(oFinalMoveDirectory) Then
|
||||
Directory.CreateDirectory(oFinalMoveDirectory)
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim oFileName = _filesystem.GetVersionedFilename(Path.Combine(oFinalMoveDirectory, oFile.Name))
|
||||
|
||||
_filesystem.MoveTo(oFile.FullName, oFileName, oFinalMoveDirectory)
|
||||
@ -764,6 +781,20 @@ Public Class ImportZUGFeRDFiles
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
For Each oFile In AttachmentFiles
|
||||
Try
|
||||
Dim oFileName = _filesystem.GetVersionedFilename(Path.Combine(oAttachmentDirectory, oFile.Name))
|
||||
|
||||
_filesystem.MoveTo(oFile.FullName, oFileName, oAttachmentDirectory)
|
||||
|
||||
_logger.Info("Finished processing file {0}", oFile.Name)
|
||||
_logger.Info("Attachment moved to {0}", oFileName)
|
||||
Catch ex As Exception
|
||||
_logger.Warn("Could not move attachment {0}", oFile.FullName)
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
@ -5,11 +5,13 @@ Imports GdPicture14
|
||||
|
||||
Public Class PDFAttachments
|
||||
Private Logger As Logger
|
||||
Private Filesystem As Filesystem.File
|
||||
|
||||
Private Const ZUGFERD_XML_FILENAME = "ZUGFeRD-invoice.xml"
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, GdPictureKey As String)
|
||||
Logger = LogConfig.GetLogger
|
||||
Filesystem = New Filesystem.File(LogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Extract(FileName As String, AllowedExtensions As List(Of String)) As List(Of FileInfo)
|
||||
@ -36,7 +38,8 @@ Public Class PDFAttachments
|
||||
Dim status As GdPictureStatus = oGDPicturePDF.ExtractEmbeddedFile(index, FileData)
|
||||
|
||||
If status = GdPictureStatus.OK Then
|
||||
Dim oTempName As String = Path.Combine(Path.GetTempPath(), oFileName)
|
||||
Dim oVersionedName = Filesystem.GetVersionedFilename(oFileName)
|
||||
Dim oTempName As String = Path.Combine(Path.GetTempPath(), oVersionedName)
|
||||
Using oFileStream As New FileStream(oTempName, FileMode.OpenOrCreate)
|
||||
oFileStream.Write(FileData, 0, FileData.Length)
|
||||
End Using
|
||||
|
||||
@ -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.0.0.0")>
|
||||
<Assembly: AssemblyVersion("1.1.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user