MS Baget
This commit is contained in:
@@ -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("2.8.3.0")>
|
||||
<Assembly: AssemblyFileVersion("2.8.3.0")>
|
||||
<Assembly: AssemblyVersion("2.8.4.0")>
|
||||
<Assembly: AssemblyFileVersion("2.8.4.0")>
|
||||
|
||||
@@ -80,7 +80,6 @@ Namespace ZUGFeRD
|
||||
For Each oFile In pAttachmentFiles
|
||||
Try
|
||||
Dim oFilePath = _filesystem.GetVersionedFilename(Path.Combine(oAttachmentDirectory, oFile.Name))
|
||||
|
||||
_filesystem.MoveTo(oFile.FullName, oFilePath, oAttachmentDirectory)
|
||||
_logger.Info("Attachment moved to {0}", oFilePath)
|
||||
Catch ex As Exception
|
||||
@@ -98,11 +97,22 @@ Namespace ZUGFeRD
|
||||
If Not File.Exists(oAttachmentDirectory) Then
|
||||
Directory.CreateDirectory(oAttachmentDirectory)
|
||||
End If
|
||||
System.IO.File.WriteAllBytes(oFilePath, oResult.FileContents)
|
||||
If CheckBytes(oFilePath, oResult.FileContents) = True Then
|
||||
If FileOpenwithError(oFilePath) Then
|
||||
_logger.Info("Embedded Attachment moved to {0}", oFilePath)
|
||||
Else
|
||||
_logger.Info("File is corrupt. Deleting the created file ...")
|
||||
File.Delete(oFilePath)
|
||||
End If
|
||||
Else
|
||||
_logger.Info("File is corrupt (CheckBytes). Deleting the created file ...")
|
||||
File.Delete(oFilePath)
|
||||
End If
|
||||
'Using oWriter As New FileStream(oFilePath, FileMode.Create)
|
||||
' oWriter.Write(oResult.FileContents, 0, oResult.FileContents.Length)
|
||||
|
||||
Using oWriter As New FileStream(oFilePath, FileMode.Create)
|
||||
oWriter.Write(oResult.FileContents, 0, oResult.FileContents.Length)
|
||||
_logger.Info("Embedded Attachment moved to {0}", oFilePath)
|
||||
End Using
|
||||
'End Using
|
||||
Catch ex As Exception
|
||||
_logger.Warn("Could not save embedded attachment {0}", oResult.FileName)
|
||||
_logger.Error(ex)
|
||||
@@ -111,7 +121,15 @@ Namespace ZUGFeRD
|
||||
|
||||
_logger.Info("Finished moving files")
|
||||
End Sub
|
||||
Private Function CheckBytes(oFilePath As String, oFileContents As IEnumerable(Of Byte)) As Boolean
|
||||
Dim savedBytes() As Byte = System.IO.File.ReadAllBytes(oFilePath)
|
||||
|
||||
If savedBytes.SequenceEqual(oFileContents) Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
Public Function MoveAndRenameEmailToRejected(pArgs As WorkerArgs, pMessageId As String) As EmailData
|
||||
_logger.Info("Moving Mail with MessageId [{0}] to Rejected folder", pMessageId)
|
||||
_logger.Debug("Fetching Email Data")
|
||||
@@ -177,7 +195,19 @@ Namespace ZUGFeRD
|
||||
|
||||
Return oEmailData
|
||||
End Function
|
||||
|
||||
Private Function FileOpenwithError(pFilePath As String) As Boolean
|
||||
Try
|
||||
Using fs As FileStream = File.Open(pFilePath, FileMode.Open, FileAccess.Read, FileShare.None)
|
||||
Return True ' Datei kann geöffnet werden
|
||||
End Using
|
||||
Catch ex As IOException
|
||||
_logger.Info("file [{0}] could not be opened! Error IOException: [{1}]", pFilePath, ex.Message)
|
||||
Return False ' Datei ist gesperrt oder existiert nicht
|
||||
Catch ex As Exception
|
||||
_logger.Info("file [{0}] could not be opened! Error: [{1}]", pFilePath, ex.Message)
|
||||
Return False ' Andere Fehler
|
||||
End Try
|
||||
End Function
|
||||
Public Function GetEmailPathWithSubjectAsName(RejectedEmailDirectory As String, UncleanedSubject As String) As String
|
||||
Dim oCleanSubject = String.Join("", UncleanedSubject.Split(Path.GetInvalidPathChars()))
|
||||
Dim oAttachmentDirectory = RejectedEmailDirectory
|
||||
|
||||
@@ -131,7 +131,7 @@ Public Class ImportZUGFeRDFiles
|
||||
' Group files by messageId
|
||||
Dim oGrouped As Dictionary(Of String, List(Of FileInfo)) = _zugferd.FileGroup.GroupFiles(oFiles)
|
||||
|
||||
_logger.Info("Found {0} file groups", oGrouped.Count)
|
||||
_logger.Info("Found [{0}] file groups", oGrouped.Count)
|
||||
|
||||
'Process each file group together
|
||||
'oGrouped equals one e-invoice
|
||||
|
||||
Reference in New Issue
Block a user