diff --git a/GUIs.Test.TestGUI/TestGUI.vbproj b/GUIs.Test.TestGUI/TestGUI.vbproj
index 95ee6b2a..3c1f704d 100644
--- a/GUIs.Test.TestGUI/TestGUI.vbproj
+++ b/GUIs.Test.TestGUI/TestGUI.vbproj
@@ -172,7 +172,7 @@
{44982f9b-6116-44e2-85d0-f39650b1ef99}
Config
-
+
{991d0231-4623-496d-8bd0-9ca906029cbc}
Filesystem
diff --git a/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb
index 80ab60d1..6de7503e 100644
--- a/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb
+++ b/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb
@@ -76,11 +76,11 @@ Public Class ImportZUGFeRDFiles
_logger.Warn("Got no results for MessageId {0}", MessageId)
Return Nothing
ElseIf oDatatable.Rows.Count > 1 Then
- _logger.Warn("Got too many results for MessageId {0}. Using first row.", MessageId)
+ _logger.Warn("Got too many results for MessageId {0}. Using last row.", MessageId)
End If
_logger.Debug("Got Email Data for FileId {0}", MessageId)
- oRow = oDatatable.Rows.Item(0)
+ oRow = oDatatable.Rows.Item(oDatatable.Rows.Count - 1)
Return New EmailData() With {
.From = oRow.Item("EMAIL_FROM"),
@@ -207,8 +207,8 @@ Public Class ImportZUGFeRDFiles
_logger.Error(ex)
End Try
End Sub
- Private Sub AddToEmailQueueMSSQL(MessageId As String, BodyText As String, EmailData As EmailData, SourceProcedure As String)
- If EmailData Is Nothing Then
+ Private Sub AddToEmailQueueMSSQL(MessageId As String, BodyText As String, pEmailData As EmailData, SourceProcedure As String)
+ If pEmailData Is Nothing Then
_logger.Warn("EmailData is empty. Email will not be sent!")
Exit Sub
End If
@@ -222,8 +222,14 @@ Public Class ImportZUGFeRDFiles
Dim oCreatedWho = "ZUGFeRD Service"
Dim oFinalBodyText = String.Format(EMAIL_WRAPPING_TEXT, BodyText)
- Dim oEmailAddress = EmailData.From
- Dim oAttachment = EmailData.Attachment
+ Dim oEmailAddress = pEmailData.From
+ Dim oAttachment = pEmailData.Attachment
+ If oAttachment <> String.Empty Then
+ _logger.Debug($"Attachment_String [{oAttachment}]!")
+ If IO.File.Exists(oAttachment) = False Then
+ _logger.Info($"Attachment.File [{oAttachment}] is not existing!!!")
+ End If
+ End If
If IsNothing(oEmailAddress) OrElse String.IsNullOrWhiteSpace(oEmailAddress) Then
_logger.Warn("Could not find email-address for MessageId {0}", MessageId)
@@ -254,7 +260,8 @@ Public Class ImportZUGFeRDFiles
,[EMAIL_SUBJ]
,[EMAIL_BODY]
,[COMMENT]
- ,[ADDED_WHO])
+ ,[ADDED_WHO]
+ ,EMAIL_ATTMT1)
VALUES
(77
,{oAccountId}
@@ -265,7 +272,8 @@ Public Class ImportZUGFeRDFiles
,'{oSubject}'
,'{oFinalBodyText}'
,'{SourceProcedure}'
- ,'{oCreatedWho}')"
+ ,'{oCreatedWho}'
+ ,'{oAttachment}')"
_mssql.ExecuteNonQuery(oInsert)
Else
'If oDTResult.Rows.Count = 0 Then
@@ -433,7 +441,7 @@ Public Class ImportZUGFeRDFiles
End Try
If oRejected = False Then
HISTORY_ID = oMD5DT.Rows(0).Item("GUID")
- Throw New MD5HashException()
+ Throw New MD5HashException($"There is already an identical invoice! - HistoryID [{HISTORY_ID}]")
Else
_logger.Info("ZuGFeRDFile already has been worked, but formerly obviously was rejected!")
End If
diff --git a/Modules.Jobs/Exceptions.vb b/Modules.Jobs/Exceptions.vb
index d8be37c0..894ed27e 100644
--- a/Modules.Jobs/Exceptions.vb
+++ b/Modules.Jobs/Exceptions.vb
@@ -39,8 +39,8 @@ Public Class Exceptions
Public Class MD5HashException
Inherits ApplicationException
- Public Sub New()
- MyBase.New("There is already an identical invoice")
+ Public Sub New(pInfo As String)
+ MyBase.New(pInfo)
End Sub
End Class
End Class
diff --git a/Modules.Windream/My Project/AssemblyInfo.vb b/Modules.Windream/My Project/AssemblyInfo.vb
index 3d3e8589..3f210d4d 100644
--- a/Modules.Windream/My Project/AssemblyInfo.vb
+++ b/Modules.Windream/My Project/AssemblyInfo.vb
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
'
-
+
diff --git a/Modules.Windream/Windream.vb b/Modules.Windream/Windream.vb
index 9a21a654..deccea30 100644
--- a/Modules.Windream/Windream.vb
+++ b/Modules.Windream/Windream.vb
@@ -203,17 +203,18 @@ Public Class Windream
End Try
End Function
- Public Function GetFileByPath(Path As String) As WMObject
+ Public Function GetFileByPath(pPath As String) As WMObject
If TestSessionLoggedIn() = False Then
Return Nothing
End If
- Path = GetNormalizedPath(Path)
- Dim oWMObject As WMObject
+ pPath = GetNormalizedPath(pPath)
+ Dim oWMObject As WMObject
Try
- oWMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
+ oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
Return oWMObject
Catch ex As Exception
+ _logger.Error(ex)
Return Nothing
End Try
End Function
@@ -725,22 +726,29 @@ Public Class Windream
Public Function GetNormalizedPath(Path As String) As String
Dim oNormalizedPath = GetCleanedPath(Path)
+ Try
- If UsesDriveLetter Then
- ' Remove Driveletter eg. W:\
- If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
- oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter + 2)
+ If UsesDriveLetter Then
+ ' Remove Driveletter eg. W:\
+ If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
+ oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter + 2)
+ End If
+ Else
+ If oNormalizedPath.ToLower.StartsWith(ClientBasePath.ToLower) Then
+ ' Remove Windream Base Path eg. \\windream\objects\
+ oNormalizedPath = oNormalizedPath.Substring(ClientBasePath.Length - 1)
+ End If
End If
- Else
- If oNormalizedPath.ToLower.StartsWith(ClientBasePath.ToLower) Then
- ' Remove Windream Base Path eg. \\windream\objects\
- oNormalizedPath = oNormalizedPath.Substring(ClientBasePath.Length)
- End If
- End If
- oNormalizedPath = oNormalizedPath.Replace("\\", "\")
+ oNormalizedPath = oNormalizedPath.Replace("\\", "\")
+ _logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
+ Return oNormalizedPath
+ Catch ex As Exception
+ _logger.Warn($"Unexpected error in GetNormalizedPath - oNormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]")
+ Return ""
+ End Try
+
- Return oNormalizedPath
End Function
'''
@@ -993,6 +1001,7 @@ Public Class Windream
Public Function RemoveFile(Path As String) As Boolean
If TestSessionLoggedIn() = False Then
+ _logger.Warn("TestSession = False!")
Return Nothing
End If
@@ -1000,11 +1009,12 @@ Public Class Windream
Dim oWMObject As WMObject = GetFileByPath(Path)
If oWMObject Is Nothing Then
+ _logger.Warn("Error RemoveFile (oWMObject is nothing)")
Return False
End If
-
+ _logger.Info($"Deleting WMObject [{Path}]")
oWMObject.Delete()
- _logger.Warn($"file {Path} has been deleted!")
+ _logger.Info($"[RemoveFile] - File [{Path}] has been deleted!")
Return True
Catch ex As Exception
_logger.Error(ex)
@@ -1215,11 +1225,11 @@ Public Class Windream
Dim oWMObject As WMObject = GetFileByPath(WMPath)
- _logger.Debug("Working on file: " & oWMObject.aName)
+ _logger.Debug("(Export_WMFile)Working on file: " & oWMObject.aName)
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
- _logger.Debug("ExportFileIO created...")
+ _logger.Debug("(Export_WMFile)ExportFileIO created...")
' Stream Interface bereitstellen
oWMObject.LockFor(WMObjectEditModeFileSystem)
Try
@@ -1263,39 +1273,69 @@ Public Class Windream
End Function
Public Function Export_WMFile_DocID(WMPath As String, Exportpath As String, DocId As Integer)
Try
+
+
If Not Exportpath.EndsWith("\") Then
Exportpath &= "\"
End If
+ Dim Extension = WMPath.Substring(WMPath.LastIndexOf("."))
+ Dim oTempFilename As String = Exportpath & DocId & Extension
+ _logger.Info($"(Export_WMFile_DocID)Working on file [{WMPath}] ")
+
+ If IO.File.Exists(oTempFilename) Then
+ _logger.Info($"(Export_WMFile_DocID) DocID [{DocId}] already existing!! No action necessary!")
+ Return True
+ End If
+
+ Dim oWMObject As WMObject
+
+
- Dim oWMObject As WMObject = GetFileByPath(WMPath)
Try
- _logger.Info("Working on file: " & oWMObject.aName)
+ oWMObject = GetFileByPath(WMPath)
+
Catch ex As Exception
_logger.Error(ex)
_logger.Warn("No object created: " & WMPath)
Return False
End Try
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
- _logger.Debug("ExportFileIO created...")
+ _logger.Debug("(Export_WMFile_DocID)ExportFileIO created...")
Dim oWMStream = oWMObject.OpenStream("BinaryObject", 1)
'### VERSIONIERUNG ###
Dim version As Integer = 2
- Dim Extension = oWMObject.aName.Substring(oWMObject.aName.LastIndexOf("."))
- Dim tempFilename As String = Exportpath & DocId & Extension
+
+ _logger.Debug($"Checking (FileExists) on [{oTempFilename}]... ")
'Überprüfen ob File existiert
- Do While IO.File.Exists(tempFilename) = True
- tempFilename = Exportpath & DocId & "_" & version & Extension
+ Do While IO.File.Exists(oTempFilename) = True
+ oTempFilename = Exportpath & DocId & "_" & version & Extension
version = version + 1
Loop
- _logger.Debug("Exportfilename is: " & tempFilename)
+ _logger.Debug($"(Export_WMFile_DocID)Exportfilename is [{oTempFilename}] ")
' den Dateiinhalt der neuen Datei zuweisen
ExportFileIO.aWMStream = oWMStream
- ExportFileIO.bstrOriginalFileName = tempFilename
+ ExportFileIO.bstrOriginalFileName = oTempFilename
'Das eigentliche kopieren
ExportFileIO.ExportOriginal(True)
+
+ Dim oCounter = 0
+ Dim oError As Boolean = False
+ Do While IO.File.Exists(oTempFilename) = False
+ oCounter += 1
+ If oCounter = 30000 Then
+ _logger.Warn($"WMStream took too long...Check the file [{WMPath}]")
+ oError = True
+ Exit Do
+ End If
+ Loop
+ If oError = True Then
+ Return False
+ End If
+
+
'close the windream file stream
oWMStream.Close()
- _logger.Info($"WMFile DocID {DocId} has been exported to {tempFilename} ")
+ _logger.Info($"WMFile DocID [{DocId}] has been exported to [{oTempFilename}]")
Return True
Catch ex As Exception
_logger.Error(ex)