14 Commits

Author SHA1 Message Date
6ed636bca0 Merge branch 'master' of http://git.dd:3000/AppStd/Modules 2022-11-17 17:09:16 +01:00
5f8e1a8608 MS windream Mod 2022-11-17 17:09:07 +01:00
Jonathan Jenne
e424402d63 Interfaces: Version 1.8.0.0 2022-11-16 16:34:46 +01:00
Jonathan Jenne
9d6dd695e4 Jobs: 1.9.0.0 2022-11-16 16:34:10 +01:00
Jonathan Jenne
0410e11b59 ZUGFeRD: WIP Allow blocking factur-x and xrechnung invoice files with config flags 2022-11-16 16:33:35 +01:00
Jonathan Jenne
f4adba98eb Interfaces: Version 1.7.5.0 2022-11-14 11:46:08 +01:00
Jonathan Jenne
1dba028deb Interfaces: Add errortype unknownerror 2022-11-14 11:45:20 +01:00
Jonathan Jenne
3a26343083 Merge branch 'Database_SqlConnection' 2022-11-02 16:20:43 +01:00
Jonathan Jenne
1e732a036a Revert all modules to .NET 4.6.1 2022-11-02 14:35:43 +01:00
Jonathan Jenne
41165a470d Language: Version 1.6.1.0 2022-11-02 13:36:52 +01:00
Jonathan Jenne
8128987be4 Language: Add EscapeForSQL string extension method 2022-11-02 13:36:29 +01:00
Jonathan Jenne
6ebd3b82b6 Messaging: Improve logging 2022-11-02 13:36:00 +01:00
Jonathan Jenne
d18ebfe912 Jobs: 1.8.7.0 2022-11-02 13:35:04 +01:00
Jonathan Jenne
b614b3f140 Jobs: escape attachment paths 2022-11-02 13:34:33 +01:00
25 changed files with 268 additions and 98 deletions

View File

@@ -10,7 +10,7 @@
<AssemblyName>DigitalData.Modules.Interfaces</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>Windows</MyType>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Interfaces")>
<Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("1.7.4.0")>
<Assembly: AssemblyTrademark("1.8.0.0")>
<Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.7.4.0")>
<Assembly: AssemblyFileVersion("1.7.4.0")>
<Assembly: AssemblyVersion("1.8.0.0")>
<Assembly: AssemblyFileVersion("1.8.0.0")>

View File

@@ -8,41 +8,87 @@ Imports DigitalData.Modules.Logging
Imports GdPicture14
Public Class ZUGFeRDInterface
Private _logConfig As LogConfig
Private _logger As Logger
Private ReadOnly _logConfig As LogConfig
Private ReadOnly _logger As Logger
Private ReadOnly _Options As ZugferdOptions
Private ReadOnly ValidFilenames As New List(Of String) From {
PDFEmbeds.ZUGFERD_XML_FILENAME.ToUpper,
PDFEmbeds.FACTUR_X_XML_FILENAME_DE.ToUpper,
PDFEmbeds.FACTUR_X_XML_FILENAME_FR.ToUpper
}
Private AllowedFilenames As New List(Of String)
Public Enum ErrorType
NoValidFile
NoZugferd
NoValidZugferd
MissingProperties
UnsupportedFormat
UnknownError
End Enum
Public ReadOnly Property FileGroup As FileGroups
Public ReadOnly Property PropertyValues As PropertyValues
Public Sub New(LogConfig As LogConfig, GDPictureKey As String)
_logConfig = LogConfig
Public Class ZugferdOptions
Public Property AllowFacturX_Filename As Boolean = True
Public Property AllowXRechnung_Filename As Boolean = True
End Class
''' <summary>
''' Create a new instance of ZUGFeRDInterface
''' </summary>
''' <param name="pLogConfig">A LogConfig object</param>
''' <param name="pGDPictureKey">A valid GDPicture License</param>
''' <param name="pOptions">Optional parameters to control various settings</param>
Public Sub New(pLogConfig As LogConfig, pGDPictureKey As String, Optional pOptions As ZugferdOptions = Nothing)
_logConfig = pLogConfig
_logger = _logConfig.GetLogger()
If pOptions Is Nothing Then
_Options = New ZugferdOptions()
Else
_Options = pOptions
End If
ApplyFilenameOptions(_Options)
FileGroup = New FileGroups(_logConfig)
PropertyValues = New PropertyValues(_logConfig)
Try
Dim oLicenseManager As New LicenseManager
oLicenseManager.RegisterKEY(GDPictureKey)
oLicenseManager.RegisterKEY(pGDPictureKey)
Catch ex As Exception
_logger.Warn("GDPicture License could not be registered!")
_logger.Error(ex)
End Try
End Sub
Private Sub ApplyFilenameOptions(pOptions As ZugferdOptions)
Dim oAllowedFilenames As List(Of String) = ValidFilenames
If pOptions.AllowFacturX_Filename = False Then
oAllowedFilenames = oAllowedFilenames.
Except(New List(Of String) From {PDFEmbeds.FACTUR_X_XML_FILENAME_FR}).ToList()
End If
If pOptions.AllowXRechnung_Filename = False Then
oAllowedFilenames = oAllowedFilenames.
Except(New List(Of String) From {PDFEmbeds.FACTUR_X_XML_FILENAME_DE}).ToList()
End If
AllowedFilenames = oAllowedFilenames
End Sub
''' <summary>
''' Validates a ZUGFeRD File and extracts the XML Document from it
''' </summary>
''' <param name="Path"></param>
''' <exception cref="ZUGFeRDExecption"></exception>
''' <returns></returns>
Public Function ExtractZUGFeRDFileWithGDPicture(Path As String) As Object
Dim oXmlDocument = ValidateZUGFeRDFileWithGDPicture(Path)
@@ -58,7 +104,6 @@ Public Class ZUGFeRDInterface
''' </summary>
''' <param name="Stream"></param>
''' <exception cref="ZUGFeRDExecption"></exception>
''' <returns></returns>
Public Function ExtractZUGFeRDFileWithGDPicture(Stream As Stream) As Object
Dim oXmlDocument = ValidateZUGFeRDFileWithGDPicture(Stream)
@@ -72,15 +117,15 @@ Public Class ZUGFeRDInterface
''' <summary>
''' Validates a ZUGFeRD File and extracts the XML Document from it
''' </summary>
''' <param name="Stream"></param>
''' <param name="pStream"></param>
''' <exception cref="ZUGFeRDExecption"></exception>
''' <returns></returns>
Public Function ValidateZUGFeRDFileWithGDPicture(Stream As Stream) As XPathDocument
''' <returns>The embedded xml data as an XPath document</returns>
Public Function ValidateZUGFeRDFileWithGDPicture(pStream As Stream) As XPathDocument
Dim oEmbedExtractor = New PDFEmbeds(_logConfig)
Dim oAllowedExtensions = New List(Of String) From {"xml"}
Try
Dim oFiles = oEmbedExtractor.Extract(Stream, oAllowedExtensions)
' Extract XML attachments only!
Dim oFiles = oEmbedExtractor.Extract(pStream, New List(Of String) From {"xml"})
' Attachments are in this case the files that are embedded into a pdf file,
' like for example the zugferd-invoice.xml file
@@ -97,12 +142,18 @@ Public Class ZUGFeRDInterface
End Try
End Function
Public Function ValidateZUGFeRDFileWithGDPicture(Path As String) As XPathDocument
''' <summary>
''' Validates a ZUGFeRD File and extracts the XML Document from it
''' </summary>
''' <param name="pPath"></param>
''' <exception cref="ZUGFeRDExecption"></exception>
''' <returns>The embedded xml data as an XPath document</returns>
Public Function ValidateZUGFeRDFileWithGDPicture(pPath As String) As XPathDocument
Dim oEmbedExtractor = New PDFEmbeds(_logConfig)
Dim oAllowedExtensions = New List(Of String) From {"xml"}
Try
Dim oFiles = oEmbedExtractor.Extract(Path, oAllowedExtensions)
' Extract XML attachments only!
Dim oFiles = oEmbedExtractor.Extract(pPath, New List(Of String) From {"xml"})
' Attachments are in this case the files that are embedded into a pdf file,
' like for example the zugferd-invoice.xml file
@@ -119,34 +170,38 @@ Public Class ZUGFeRDInterface
End Try
End Function
Private Function HandleEmbeddedFiles(Results As List(Of PDFEmbeds.EmbeddedFile)) As XPathDocument
Private Function HandleEmbeddedFiles(pResults As List(Of PDFEmbeds.EmbeddedFile)) As XPathDocument
Dim oXmlDocument As XPathDocument
If Results Is Nothing Then
If pResults Is Nothing Then
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil die Attachments nicht gelesen werden konnten.")
End If
If Results.Count = 0 Then
If pResults.Count = 0 Then
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil sie keine Attachments enthält.")
End If
Dim oValidFilenames As New List(Of String) From {
PDFEmbeds.ZUGFERD_XML_FILENAME.ToUpper,
PDFEmbeds.FACTUR_X_XML_FILENAME_DE.ToUpper,
PDFEmbeds.FACTUR_X_XML_FILENAME_FR.ToUpper
}
' Find the first file which filename matches the valid filenames for embedded invoice files
Dim oFoundResult As PDFEmbeds.EmbeddedFile = Results.
Where(Function(result) oValidFilenames.Contains(result.FileName.ToUpper)).
Dim oValidResult As PDFEmbeds.EmbeddedFile = pResults.
Where(Function(result) ValidFilenames.Contains(result.FileName.ToUpper)).
FirstOrDefault()
If oFoundResult Is Nothing Then
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil die zugferd-invoice.xml nicht gefunden wurde.")
If oValidResult Is Nothing Then
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil keine entsprechende XML-Datei gefunden wurde.")
End If
' Search the embedded files for the ones which are allowed as per the configuration.
' The config might say, allow ZUGFeRD but not Factur-X.
Dim oAllowedResult As PDFEmbeds.EmbeddedFile = pResults.
Where(Function(result) AllowedFilenames.Contains(result.FileName.ToUpper)).
FirstOrDefault()
If oAllowedResult Is Nothing Then
Throw New ZUGFeRDExecption(ErrorType.UnsupportedFormat, "Datei ist eine ZUGFeRD Datei, aber das Format wird nicht unterstützt.")
End If
Try
Using oStream As New MemoryStream(oFoundResult.FileContents)
Using oStream As New MemoryStream(oAllowedResult.FileContents)
oXmlDocument = New XPathDocument(oStream)
End Using
@@ -162,9 +217,9 @@ Public Class ZUGFeRDInterface
End Try
End Function
Public Function SerializeZUGFeRDDocument(Document As XPathDocument) As Object
Public Function SerializeZUGFeRDDocument(pDocument As XPathDocument) As Object
Try
Dim oNavigator As XPathNavigator = Document.CreateNavigator()
Dim oNavigator As XPathNavigator = pDocument.CreateNavigator()
Dim oReader As XmlReader
Dim oResult = Nothing

View File

@@ -28,7 +28,7 @@ Public Class PDFEmbeds
Public Function Extract(FilePath As String, AllowedExtensions As List(Of String)) As List(Of EmbeddedFile)
Dim oFile As New List(Of EmbeddedFile)
Dim oFileInfo As FileInfo
Dim oExtensions = AllowedExtensions.ConvertAll(New Converter(Of String, String)(Function(ext) ext.ToUpper))
Dim oExtensions = AllowedExtensions.Select(Function(ext) ext.ToUpper).ToList()
Logger.Debug("Extracting embedded files from [{0}]", FilePath)
@@ -69,7 +69,7 @@ Public Class PDFEmbeds
''' <param name="AllowedExtensions">List of allowed extensions to be extracted</param>
Public Function Extract(Stream As Stream, AllowedExtensions As List(Of String)) As List(Of EmbeddedFile)
Dim oResults As New List(Of EmbeddedFile)
Dim oExtensions = AllowedExtensions.ConvertAll(New Converter(Of String, String)(Function(ext) ext.ToUpper))
Dim oExtensions = AllowedExtensions.Select(Function(ext) ext.ToUpper).ToList()
Logger.Debug("Extracting embedded files from stream")

View File

@@ -8,4 +8,4 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

View File

@@ -40,6 +40,14 @@ Public Class Exceptions
End Sub
End Class
Public Class UnsupportedFerdException
Inherits ApplicationException
Public Sub New()
MyBase.New("ZUGFeRD document found but is not supported!")
End Sub
End Class
Public Class NoFerdsException
Inherits ApplicationException

View File

@@ -10,7 +10,7 @@
<AssemblyName>DigitalData.Modules.Jobs</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>Empty</MyType>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
@@ -91,17 +91,17 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="EDMI\ADSync\ADSyncArgs.vb" />
<Compile Include="EDMI\ADSync\ADSyncJob.vb" />
<Compile Include="EDMI\GraphQL\GraphQLArgs.vb" />
<Compile Include="EDMI\GraphQL\GraphQLConfig.vb" />
<Compile Include="EDMI\GraphQL\GraphQLJob.vb" />
<Compile Include="EDMI\GraphQL\GraphQLQuery.vb" />
<Compile Include="EDMI\ZUGFeRD\EmailData.vb" />
<Compile Include="EDMI\ZUGFeRD\EmailFunctions.vb" />
<Compile Include="EDMI\ZUGFeRD\EmailStrings.vb" />
<Compile Include="EDMI\ZUGFeRD\ImportZUGFeRDFiles.vb" />
<Compile Include="EDMI\ZUGFeRD\WorkerArgs.vb" />
<Compile Include="ADSync\ADSyncArgs.vb" />
<Compile Include="ADSync\ADSyncJob.vb" />
<Compile Include="GraphQL\GraphQLArgs.vb" />
<Compile Include="GraphQL\GraphQLConfig.vb" />
<Compile Include="GraphQL\GraphQLJob.vb" />
<Compile Include="GraphQL\GraphQLQuery.vb" />
<Compile Include="ZUGFeRD\EmailData.vb" />
<Compile Include="ZUGFeRD\EmailFunctions.vb" />
<Compile Include="ZUGFeRD\EmailStrings.vb" />
<Compile Include="ZUGFeRD\ImportZUGFeRDFiles.vb" />
<Compile Include="ZUGFeRD\WorkerArgs.vb" />
<Compile Include="Exceptions.vb" />
<Compile Include="JobInterface.vb" />
<Compile Include="JobBase.vb" />

View File

@@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Jobs")>
<Assembly: AssemblyCopyright("Copyright © 2021")>
<Assembly: AssemblyTrademark("")>
<Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("1.9.0.0")>
<Assembly: ComVisible(False)>
@@ -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.8.6.0")>
<Assembly: AssemblyFileVersion("1.8.6.0")>
<Assembly: AssemblyVersion("1.9.0.0")>
<Assembly: AssemblyFileVersion("1.9.0.0")>

View File

@@ -83,13 +83,14 @@ Public Class EmailFunctions
Dim oFinalBodyText = String.Format(EmailStrings.EMAIL_WRAPPING_TEXT.Replace(EmailStrings.constNAME_ZUGFERD_PORTAL, NamePortal), oCompleteBodyText)
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!!!")
Dim oAttachmentPath = pEmailData.Attachment
If oAttachmentPath <> String.Empty Then
_logger.Debug($"Attachment_String [{oAttachmentPath}]!")
If IO.File.Exists(oAttachmentPath) = False Then
_logger.Info($"Attachment.File [{oAttachmentPath}] is not existing!!!")
End If
End If
Dim oAttachmentPathEscaped = oAttachmentPath.Replace("'", "''")
If IsNothing(oEmailAddress) OrElse String.IsNullOrWhiteSpace(oEmailAddress) Then
_logger.Warn("Could not find email-address for MessageId {0}", MessageId)
@@ -133,7 +134,7 @@ Public Class EmailFunctions
,'{oFinalBodyText}'
,'{SourceProcedure}'
,'{oCreatedWho}'
,'{oAttachment}')"
,'{oAttachmentPathEscaped}')"
_mssql.ExecuteNonQuery(oInsert)
Else
'If oDTResult.Rows.Count = 0 Then

View File

@@ -37,4 +37,8 @@
<li>Betrags-Werte weisen ungültiges Format auf (25,01 anstatt 25.01)</li>
</ul></p>
"
Public Const EMAIL_UNSUPPORTED_DOCUMENT = "
<p>Ihre Email enthielt ein ZUGFeRD Dokument, welches aber zur Zeit noch nicht unsterstützt wird.</p>
"
End Class

View File

@@ -26,35 +26,33 @@ Public Class ImportZUGFeRDFiles
Private Const DIRECTORY_DONT_MOVE = "DIRECTORY_DONT_MOVE"
' List of allowed extensions for PDF/A Attachments
' This list should not contain xml so the zugferd xml file will be filtered out
Private ReadOnly AllowedExtensions As List(Of String) = New List(Of String) From {"docx", "doc", "pdf", "xls", "xlsx", "ppt", "pptx", "txt"}
Private ReadOnly AllowedExtensions As New List(Of String) From {"docx", "doc", "pdf", "xls", "xlsx", "ppt", "pptx", "txt"}
Private ReadOnly _logger As Logger
Private ReadOnly _logConfig As LogConfig
Private ReadOnly _zugferd As ZUGFeRDInterface
Private ReadOnly _firebird As Firebird
Private ReadOnly _filesystem As Filesystem.File
Private ReadOnly _EmailOutAccountId As Integer
Private ReadOnly _mssql As MSSQLServer
Private ReadOnly _email As EmailFunctions
Private ReadOnly _gdpictureLicenseKey As String
Private _zugferd As ZUGFeRDInterface
Private _EmailOutAccountId As Integer
Public Sub New(LogConfig As LogConfig, Firebird As Firebird, pEmailOutAccount As Integer, pPortalName As String, Optional MSSQL As MSSQLServer = Nothing)
Public Sub New(LogConfig As LogConfig, Firebird As Firebird, Optional MSSQL As MSSQLServer = Nothing)
_logConfig = LogConfig
_logger = LogConfig.GetLogger()
_firebird = Firebird
_filesystem = New Filesystem.File(_logConfig)
_mssql = MSSQL
_EmailOutAccountId = pEmailOutAccount
_email = New EmailFunctions(LogConfig, _mssql, _firebird)
_logger.Debug("Registering GDPicture License")
If _mssql IsNot Nothing Then
Dim oSQL = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"
Dim oLicenseKey As String = _mssql.GetScalarValue(oSQL)
_zugferd = New ZUGFeRDInterface(_logConfig, oLicenseKey)
_gdpictureLicenseKey = _mssql.GetScalarValue(oSQL)
Else
_logger.Warn("GDPicture License could not be registered! MSSQL is not enabled!")
Throw New ArgumentNullException("MSSQL")
@@ -125,6 +123,14 @@ Public Class ImportZUGFeRDFiles
Dim oPropertyExtractor = New PropertyValues(_logConfig)
Dim oAttachmentExtractor = New PDFEmbeds(_logConfig)
_EmailOutAccountId = oArgs.EmailOutProfileId
Dim oOptions As New ZUGFeRDInterface.ZugferdOptions() With {
.AllowFacturX_Filename = oArgs.AllowFacturX,
.AllowXRechnung_Filename = oArgs.AllowXRechnung
}
_zugferd = New ZUGFeRDInterface(_logConfig, _gdpictureLicenseKey, oOptions)
_logger.Debug("Starting Job {0}", [GetType].Name)
Try
@@ -238,6 +244,10 @@ Public Class ImportZUGFeRDFiles
oEmailAttachmentFiles.Add(oFile)
Continue For
Case ZUGFeRDInterface.ErrorType.UnsupportedFormat
_logger.Info("File [{0}] is an unsupported ZUFeRD document format!")
Throw New UnsupportedFerdException()
Case ZUGFeRDInterface.ErrorType.NoValidZugferd
_logger.Warn("File [{0}] is an Incorrectly formatted ZUGFeRD document!", oFile.Name)
Throw New InvalidFerdException()
@@ -380,6 +390,18 @@ Public Class ImportZUGFeRDFiles
_email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "MD5HashException", _EmailOutAccountId, oArgs.NamePortal)
AddRejectedState(oMessageId, "MD5HashException", "Die gesendete Rechnung wurde bereits verarbeitet!", "", oSQLTransaction)
Catch ex As UnsupportedFerdException
_logger.Error(ex)
' When UnsupportedFerdException is thrown, we don't have a MD5Hash yet.
' That 's why we set it to String.Empty here.
Create_HistoryEntry(oMessageId, String.Empty, "REJECTED - ZUGFeRD yes but unsupported format", oFBTransaction)
Dim oBody = EmailStrings.EMAIL_UNSUPPORTED_DOCUMENT
Dim oEmailData = MoveAndRenameEmailToRejected(oArgs, oMessageId)
_email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "UnsupportedFerdException", _EmailOutAccountId, oArgs.NamePortal)
AddRejectedState(oMessageId, "UnsupportedFerdException", "Nicht unterstütztes Datenformat", "", oSQLTransaction)
Catch ex As InvalidFerdException
_logger.Error(ex)

View File

@@ -14,10 +14,16 @@ Public Class WorkerArgs
' Property Parameter
Public PropertyMap As New Dictionary(Of String, XmlItemProperty)
' Email Parameter
Public EmailOutProfileId As Integer = 0
' Misc Flag Parameters
Public InsertIntoSQLServer As Boolean = False
Public ExceptionEmailAddress As String = Nothing
Public IgnoreRejectionStatus As Boolean = False
Public MaxAttachmentSizeInMegaBytes As Integer = -1
Public NamePortal As String = "NO PORTAL_NAME IN CONFIG"
Public AllowFacturX As Boolean = True
Public AllowXRechnung As Boolean = True
End Class

View File

@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("Language")>
<Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("")>
<Assembly: AssemblyTrademark("1.6.1.0")>
<Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.6.0.0")>
<Assembly: AssemblyFileVersion("1.6.0.0")>
<Assembly: AssemblyVersion("1.6.1.0")>
<Assembly: AssemblyFileVersion("1.6.1.0")>

View File

@@ -12,4 +12,15 @@ Public Module StringEx
If String.IsNullOrEmpty(pString) Then Return pString
Return pString.Substring(0, Math.Min(pLength, pString.Length))
End Function
''' <summary>
''' Replaces single quotes in text for SQL Commands.
''' </summary>
''' <param name="pString">The string</param>
''' <returns>The escaped string.</returns>
<Extension()>
Public Function EscapeForSQL(pString As String) As String
If String.IsNullOrEmpty(pString) Then Return pString
Return pString.Replace("'", "''")
End Function
End Module

View File

@@ -113,17 +113,21 @@ Public Class Limilab
End Try
End Function
Public Function IMAPGetMessageIDs_AllMails() As List(Of Long)
Dim oListuids As New List(Of Long)
Logger.Debug("Starting IMAPGetMessageIDs ...")
If Initialized = False Then
Return Nothing
End If
Try
Dim oConnect As Boolean = ImapConnect()
Dim oConnectionSuccessful As Boolean = ImapConnect()
Dim oListuids As List(Of Long)
If oConnect = True Then
If oConnectionSuccessful = True Then
Logger.Debug("Checking for new messages..")
oListuids = ImapGetMessageIDs_All()
CURR_ListUIDs = oListuids
Else
Logger.Warn("Connection was NOT successful. Returning Nothing.")
Return Nothing
End If
Return oListuids
Catch ex As Exception
@@ -223,10 +227,13 @@ Public Class Limilab
Private Function ImapGetMessageIDs_All() As List(Of Long)
Dim oListuids As New List(Of Long)
Try
Logger.Debug("Opening Inbox..")
CurrentImapObject.SelectInbox()
Logger.Debug("Searching messages..")
oListuids = CurrentImapObject.Search(Flag.All)
Logger.Debug("[{0}] messages found.", oListuids.Count)
Return oListuids
Catch ex As Exception
Logger.Error(ex)

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.3.0.0")>
<Assembly: AssemblyFileVersion("1.3.0.0")>
<Assembly: AssemblyVersion("1.6.0.0")>
<Assembly: AssemblyFileVersion("1.6.0.0")>

View File

@@ -114,6 +114,7 @@ Public Class Windream
Public ReadOnly Property SessionServername As String
Public ReadOnly Property UsesDriveLetter As Boolean = True
Public Property NewDocumentID As Int32 = 0
''' <returns>A list of object types that are available</returns>
Public ReadOnly Property ObjectTypes As List(Of String)
@@ -243,14 +244,45 @@ Public Class Windream
Return oItems
End Try
End Function
Public Function CheckFileExistsinWM(pPath As String) As Boolean
If TestSessionLoggedIn() = False Then
Return Nothing
End If
pPath = GetNormalizedPath(pPath, False)
_logger.Info($"CheckFileExistsinWM: {pPath} ...")
Dim oWMObject As WMObject
Try
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
Return True
Catch ex As Exception
_logger.Info($"Unexpected Error in windream.GetFileByPath: {ex.Message}")
_logger.Error(ex)
Return False
End Try
End Function
Public Function GetFileByPath(pPath As String) As WMObject
If TestSessionLoggedIn() = False Then
Return Nothing
End If
pPath = GetNormalizedPath(pPath)
pPath = GetNormalizedPath(pPath, False)
Dim oWMObject As WMObject
Try
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
Return oWMObject
Catch ex As Exception
_logger.Info($"Unexpected Error in windream.GetFileByPath: {ex.Message}")
_logger.Error(ex)
Return Nothing
End Try
End Function
Public Function GetFileByPathObj6(pPath As String) As IWMObject6
If TestSessionLoggedIn() = False Then
Return Nothing
End If
pPath = GetNormalizedPath(pPath, False)
Dim oWMObject As IWMObject6
Try
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
Return oWMObject
@@ -283,7 +315,7 @@ Public Class Windream
End If
Try
Path = GetNormalizedPath(Path)
Path = GetNormalizedPath(Path, False)
Dim oWMObject As WMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
If oWMObject Is Nothing Then
@@ -628,7 +660,7 @@ Public Class Windream
End If
Try
Path = GetNormalizedPath(Path)
Path = GetNormalizedPath(Path, True)
Dim oFolders As List(Of String) = Path.Split("\").ToList()
Dim oFolderObject As WMObject
Dim oCurrentPath As String = String.Empty
@@ -637,6 +669,8 @@ Public Class Windream
For Each oFolder In oFolders
If oFolder.ToString.EndsWith(pExtension) Then
Exit For
ElseIf oFolder = String.Empty Then
Continue For
End If
oCurrentPath = Combine(oCurrentPath, oFolder)
@@ -659,7 +693,7 @@ Public Class Windream
End If
Try
Path = GetNormalizedPath(Path)
Path = GetNormalizedPath(Path, False)
Dim oFileObject As IWMObject6
oFileObject = GetObjectByPath(Path, WMEntityDocument)
oFileObject.CreateVersion2(False, Constants.HISTORY_NEW_FROM_VERSION, Comment)
@@ -671,6 +705,7 @@ Public Class Windream
End Function
Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String) As Boolean
NewDocumentID = 0
Dim oExtension As String = Path.GetExtension(FilenameSource)
If Not TestSessionLoggedIn() Then
@@ -678,7 +713,7 @@ Public Class Windream
End If
Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget)
FilenameTarget = GetNormalizedPath(FilenameTarget)
FilenameTarget = GetNormalizedPath(FilenameTarget, True)
_logger.NewBlock("File Stream")
_logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}")
@@ -687,6 +722,8 @@ Public Class Windream
Dim oFileIO As WMFileIO
Dim oWMStream As WMStream
NewFolder(FilenameTarget, oExtension)
'Indexierungsdialog der Session unterdrücken
Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False)
@@ -749,6 +786,11 @@ Public Class Windream
End Try
_logger.Info($"File '{FilenameTarget}' was streamed.")
Dim oDocid = GetIndexValue(FilenameTarget, "Dokument-ID")
If Not IsNothing(oDocid) Then
NewDocumentID = oDocid(0)
End If
_logger.EndBlock()
Return True
@@ -774,11 +816,13 @@ Public Class Windream
End Try
End Function
Public Function GetNormalizedPath(Path As String) As String
'Dim oNormalizedPath = GetCleanedPath(Path)
Dim oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path)
_logger.Debug("Normalizing Path: [{0}]", oNormalizedPath)
Public Function GetNormalizedPath(Path As String, pCleanPath As Boolean) As String
_logger.Debug("Normalizing Path: [{0}]", Path)
Dim oNormalizedPath As String = Path
If pCleanPath = True Then
oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path)
_logger.Debug("path after RemoveInvalidCharacters: [{0}]", oNormalizedPath)
End If
Try
' Convert any forward slashes / and double slashes \\ into backslashes \
' See: https://stackoverflow.com/questions/3144492/how-do-i-get-nets-path-combine-to-convert-forward-slashes-to-backslashes
@@ -788,8 +832,8 @@ Public Class Windream
' Remove Driveletter, eg. W:\
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
_logger.Debug($"Replacing ClientDriveLetter: [{ClientDriveLetter}]")
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
_logger.Debug($"path after replaced ClientDriveLetter: [{oNormalizedPath}]")
End If
' Remove Windream Base Path, eg. \\windream\objects\
@@ -804,7 +848,9 @@ Public Class Windream
_logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]")
oNormalizedPath = oNormalizedPath.Substring(3)
End If
If oNormalizedPath.StartsWith("\") = False Then
oNormalizedPath = $"\{oNormalizedPath}"
End If
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
Return oNormalizedPath
@@ -1041,7 +1087,7 @@ Public Class Windream
End If
Try
FolderPath = GetNormalizedPath(FolderPath)
FolderPath = GetNormalizedPath(FolderPath, False)
If TestFolderExists(FolderPath) = False Then
_logger.Warn("Folder {0} does not exist!", FolderPath)
@@ -1312,13 +1358,22 @@ Public Class Windream
Exportpath &= "\"
End If
Dim oWMObject As WMObject = GetFileByPath(WMPath)
Dim oWMObject As Object = GetFileByPath(WMPath)
If IsNothing(oWMObject) Then
Return False
'_logger.Debug("GetFileByPath failed - Trying GetFileByPathObj6...")
'oWMObject = GetFileByPathObj6(WMPath)
'If IsNothing(oWMObject) Then
' Return False
'End If
_logger.Debug("(Export_WMFile)Working on file: " & oWMObject.aName)
End If
_logger.Debug("(Export_WMFile) Working on file: " & oWMObject.aName)
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
_logger.Debug("(Export_WMFile)ExportFileIO created...")
_logger.Debug("(Export_WMFile) ExportFileIO created...")
' Stream Interface bereitstellen
oWMObject.LockFor(WMObjectEditModeFileSystem)
Try
@@ -1354,12 +1409,13 @@ Public Class Windream
oWMObject.unlock()
_logger.Info($"WMFile has been exported to {tempFilename} ")
Return True
Return tempFilename
Catch ex As Exception
_logger.Error(ex)
Return False
End Try
End Function
Public Function Export_WMFile_DocID(WMPath As String, Exportpath As String, DocId As Integer)
Try
@@ -1454,11 +1510,11 @@ Public Class Windream
'Return rNewFilepath
End Function
Public Function TestFolderExists(Path As String) As Boolean
Return TestObjectExists(GetNormalizedPath(Path), WMEntityFolder)
Return TestObjectExists(GetNormalizedPath(Path, False), WMEntityFolder)
End Function
Public Function TestFileExists(Path As String) As Boolean
Return TestObjectExists(GetNormalizedPath(Path), WMEntityDocument)
Return TestObjectExists(GetNormalizedPath(Path, False), WMEntityDocument)
End Function
Public Function TestUserExists(Username As String) As Boolean
@@ -1530,7 +1586,7 @@ Public Class Windream
End If
Try
Dim oNormalizedPath = GetNormalizedPath(ObjectPath)
Dim oNormalizedPath = GetNormalizedPath(ObjectPath, False)
Dim oWMObject As WMObject = Session.GetWMObjectByPath(ObjectType, oNormalizedPath)
Return oWMObject
Catch ex As Exception