diff --git a/Jobs/ZUGFeRD/XRechnungViewDocument.vb b/Jobs/ZUGFeRD/XRechnungViewDocument.vb index 688ecabd..971db15b 100644 --- a/Jobs/ZUGFeRD/XRechnungViewDocument.vb +++ b/Jobs/ZUGFeRD/XRechnungViewDocument.vb @@ -7,6 +7,7 @@ Imports DigitalData.Modules.Logging Imports GdPicture14 Imports System.Drawing Imports System.Linq +Imports System.Text.RegularExpressions Public Class XRechnungViewDocument Private ReadOnly _logger As Logger Private ReadOnly _logConfig As LogConfig @@ -25,28 +26,35 @@ Public Class XRechnungViewDocument _file = New ZUGFeRD.FileFunctions(LogConfig, MSSQL) _gdpictureLicenseKey = GDPictureLicenseKey End Sub - Public Function Create_PDFfromXML(oxmlFile As FileInfo, pDTItemValues As DataTable) As FileInfo + Public Function Create_PDFfromXML(pXmlFile As FileInfo, pDTItemValues As DataTable) As FileInfo _logger.Debug("Create_PDFfromXML() Start") Try - Dim oXRechnungFile = oxmlFile.FullName + Dim oXRechnungFile = pXmlFile.FullName Dim oNewFileinfo As FileInfo - Dim oxmlFilePath = oxmlFile.FullName - Dim oViewRecieptFilename = oxmlFile.Name - Dim oTempFilePath = Path.GetDirectoryName(oxmlFilePath) + "\Temp" + Dim oXmlFilePath = pXmlFile.FullName + Dim oViewRecieptFilename = pXmlFile.Name + Dim oTempFilePath = Path.Combine(Path.GetDirectoryName(oXmlFilePath), "temp") If Not Directory.Exists(oTempFilePath) Then Directory.CreateDirectory(oTempFilePath) End If - oTempFilePath = oTempFilePath + "\xrechnung.xml" + oTempFilePath = Path.Combine(oTempFilePath, "xrechnung.xml") If File.Exists(oTempFilePath) Then File.Delete(oTempFilePath) End If - File.Move(oxmlFilePath, oTempFilePath) - oxmlFile = New FileInfo(oTempFilePath) - oViewRecieptFilename = oViewRecieptFilename.Replace("xml", "pdf") - Dim oOutputPath = Path.GetDirectoryName(oxmlFilePath) + "\" + oViewRecieptFilename + + _logger.Debug("Vor MOVE... oxmlFilePath: [{0}] / oTempFilePath: [{1}]", oXmlFilePath, oTempFilePath) + + File.Move(oXmlFilePath, oTempFilePath) + pXmlFile = New FileInfo(oTempFilePath) + + 'oViewRecieptFilename = oViewRecieptFilename.Replace(".xml", ".pdf") + oViewRecieptFilename = Regex.Replace(oViewRecieptFilename, ".xml", ".pdf", RegexOptions.IgnoreCase) + + Dim oOutputPath = Path.Combine(Path.GetDirectoryName(oXmlFilePath), oViewRecieptFilename) + _logger.Debug("Create_PDFfromXML() Resulting PDF Filepath: [{0}]", oOutputPath) If File.Exists(oOutputPath) Then File.Delete(oOutputPath) End If @@ -417,7 +425,7 @@ Public Class XRechnungViewDocument File.Delete(oXRechnungFile) oNewFileinfo = New FileInfo(oOutputPath) - _logger.Debug("Create_PDFfromXML() End successfully") + _logger.Debug("Create_PDFfromXML() End successfully. File [{0}] written.", oNewFileinfo.FullName) Return oNewFileinfo Else _logger.Debug("Create_PDFfromXML() Ends with nothing")