Modules.Jobs: Version 1.1.0.0
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user