Compare commits
14 Commits
Database_S
...
6ed636bca0
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ed636bca0 | |||
| 5f8e1a8608 | |||
|
|
e424402d63 | ||
|
|
9d6dd695e4 | ||
|
|
0410e11b59 | ||
|
|
f4adba98eb | ||
|
|
1dba028deb | ||
|
|
3a26343083 | ||
|
|
1e732a036a | ||
|
|
41165a470d | ||
|
|
8128987be4 | ||
|
|
6ebd3b82b6 | ||
|
|
d18ebfe912 | ||
|
|
b614b3f140 |
@@ -10,7 +10,7 @@
|
|||||||
<AssemblyName>DigitalData.Modules.Interfaces</AssemblyName>
|
<AssemblyName>DigitalData.Modules.Interfaces</AssemblyName>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<MyType>Windows</MyType>
|
<MyType>Windows</MyType>
|
||||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
|
|||||||
<Assembly: AssemblyCompany("Digital Data")>
|
<Assembly: AssemblyCompany("Digital Data")>
|
||||||
<Assembly: AssemblyProduct("Modules.Interfaces")>
|
<Assembly: AssemblyProduct("Modules.Interfaces")>
|
||||||
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||||
<Assembly: AssemblyTrademark("1.7.4.0")>
|
<Assembly: AssemblyTrademark("1.8.0.0")>
|
||||||
|
|
||||||
<Assembly: ComVisible(False)>
|
<Assembly: ComVisible(False)>
|
||||||
|
|
||||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
|||||||
' übernehmen, indem Sie "*" eingeben:
|
' übernehmen, indem Sie "*" eingeben:
|
||||||
' <Assembly: AssemblyVersion("1.0.*")>
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("1.7.4.0")>
|
<Assembly: AssemblyVersion("1.8.0.0")>
|
||||||
<Assembly: AssemblyFileVersion("1.7.4.0")>
|
<Assembly: AssemblyFileVersion("1.8.0.0")>
|
||||||
|
|||||||
@@ -8,41 +8,87 @@ Imports DigitalData.Modules.Logging
|
|||||||
Imports GdPicture14
|
Imports GdPicture14
|
||||||
|
|
||||||
Public Class ZUGFeRDInterface
|
Public Class ZUGFeRDInterface
|
||||||
Private _logConfig As LogConfig
|
Private ReadOnly _logConfig As LogConfig
|
||||||
Private _logger As Logger
|
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
|
Public Enum ErrorType
|
||||||
NoValidFile
|
NoValidFile
|
||||||
NoZugferd
|
NoZugferd
|
||||||
NoValidZugferd
|
NoValidZugferd
|
||||||
MissingProperties
|
MissingProperties
|
||||||
|
UnsupportedFormat
|
||||||
|
UnknownError
|
||||||
End Enum
|
End Enum
|
||||||
|
|
||||||
Public ReadOnly Property FileGroup As FileGroups
|
Public ReadOnly Property FileGroup As FileGroups
|
||||||
Public ReadOnly Property PropertyValues As PropertyValues
|
Public ReadOnly Property PropertyValues As PropertyValues
|
||||||
|
|
||||||
Public Sub New(LogConfig As LogConfig, GDPictureKey As String)
|
Public Class ZugferdOptions
|
||||||
_logConfig = LogConfig
|
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()
|
_logger = _logConfig.GetLogger()
|
||||||
|
|
||||||
|
If pOptions Is Nothing Then
|
||||||
|
_Options = New ZugferdOptions()
|
||||||
|
Else
|
||||||
|
_Options = pOptions
|
||||||
|
End If
|
||||||
|
|
||||||
|
ApplyFilenameOptions(_Options)
|
||||||
|
|
||||||
FileGroup = New FileGroups(_logConfig)
|
FileGroup = New FileGroups(_logConfig)
|
||||||
PropertyValues = New PropertyValues(_logConfig)
|
PropertyValues = New PropertyValues(_logConfig)
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Dim oLicenseManager As New LicenseManager
|
Dim oLicenseManager As New LicenseManager
|
||||||
oLicenseManager.RegisterKEY(GDPictureKey)
|
oLicenseManager.RegisterKEY(pGDPictureKey)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_logger.Warn("GDPicture License could not be registered!")
|
_logger.Warn("GDPicture License could not be registered!")
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
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>
|
''' <summary>
|
||||||
''' Validates a ZUGFeRD File and extracts the XML Document from it
|
''' Validates a ZUGFeRD File and extracts the XML Document from it
|
||||||
''' </summary>
|
''' </summary>
|
||||||
''' <param name="Path"></param>
|
''' <param name="Path"></param>
|
||||||
''' <exception cref="ZUGFeRDExecption"></exception>
|
''' <exception cref="ZUGFeRDExecption"></exception>
|
||||||
''' <returns></returns>
|
|
||||||
Public Function ExtractZUGFeRDFileWithGDPicture(Path As String) As Object
|
Public Function ExtractZUGFeRDFileWithGDPicture(Path As String) As Object
|
||||||
Dim oXmlDocument = ValidateZUGFeRDFileWithGDPicture(Path)
|
Dim oXmlDocument = ValidateZUGFeRDFileWithGDPicture(Path)
|
||||||
|
|
||||||
@@ -58,7 +104,6 @@ Public Class ZUGFeRDInterface
|
|||||||
''' </summary>
|
''' </summary>
|
||||||
''' <param name="Stream"></param>
|
''' <param name="Stream"></param>
|
||||||
''' <exception cref="ZUGFeRDExecption"></exception>
|
''' <exception cref="ZUGFeRDExecption"></exception>
|
||||||
''' <returns></returns>
|
|
||||||
Public Function ExtractZUGFeRDFileWithGDPicture(Stream As Stream) As Object
|
Public Function ExtractZUGFeRDFileWithGDPicture(Stream As Stream) As Object
|
||||||
Dim oXmlDocument = ValidateZUGFeRDFileWithGDPicture(Stream)
|
Dim oXmlDocument = ValidateZUGFeRDFileWithGDPicture(Stream)
|
||||||
|
|
||||||
@@ -72,15 +117,15 @@ Public Class ZUGFeRDInterface
|
|||||||
''' <summary>
|
''' <summary>
|
||||||
''' Validates a ZUGFeRD File and extracts the XML Document from it
|
''' Validates a ZUGFeRD File and extracts the XML Document from it
|
||||||
''' </summary>
|
''' </summary>
|
||||||
''' <param name="Stream"></param>
|
''' <param name="pStream"></param>
|
||||||
''' <exception cref="ZUGFeRDExecption"></exception>
|
''' <exception cref="ZUGFeRDExecption"></exception>
|
||||||
''' <returns></returns>
|
''' <returns>The embedded xml data as an XPath document</returns>
|
||||||
Public Function ValidateZUGFeRDFileWithGDPicture(Stream As Stream) As XPathDocument
|
Public Function ValidateZUGFeRDFileWithGDPicture(pStream As Stream) As XPathDocument
|
||||||
Dim oEmbedExtractor = New PDFEmbeds(_logConfig)
|
Dim oEmbedExtractor = New PDFEmbeds(_logConfig)
|
||||||
Dim oAllowedExtensions = New List(Of String) From {"xml"}
|
|
||||||
|
|
||||||
Try
|
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,
|
' Attachments are in this case the files that are embedded into a pdf file,
|
||||||
' like for example the zugferd-invoice.xml file
|
' like for example the zugferd-invoice.xml file
|
||||||
@@ -97,12 +142,18 @@ Public Class ZUGFeRDInterface
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
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 oEmbedExtractor = New PDFEmbeds(_logConfig)
|
||||||
Dim oAllowedExtensions = New List(Of String) From {"xml"}
|
|
||||||
|
|
||||||
Try
|
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,
|
' Attachments are in this case the files that are embedded into a pdf file,
|
||||||
' like for example the zugferd-invoice.xml file
|
' like for example the zugferd-invoice.xml file
|
||||||
@@ -119,34 +170,38 @@ Public Class ZUGFeRDInterface
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
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
|
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.")
|
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil die Attachments nicht gelesen werden konnten.")
|
||||||
End If
|
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.")
|
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil sie keine Attachments enthält.")
|
||||||
End If
|
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
|
' Find the first file which filename matches the valid filenames for embedded invoice files
|
||||||
Dim oFoundResult As PDFEmbeds.EmbeddedFile = Results.
|
Dim oValidResult As PDFEmbeds.EmbeddedFile = pResults.
|
||||||
Where(Function(result) oValidFilenames.Contains(result.FileName.ToUpper)).
|
Where(Function(result) ValidFilenames.Contains(result.FileName.ToUpper)).
|
||||||
FirstOrDefault()
|
FirstOrDefault()
|
||||||
|
|
||||||
If oFoundResult Is Nothing Then
|
If oValidResult Is Nothing Then
|
||||||
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil die zugferd-invoice.xml nicht gefunden wurde.")
|
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
|
End If
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Using oStream As New MemoryStream(oFoundResult.FileContents)
|
Using oStream As New MemoryStream(oAllowedResult.FileContents)
|
||||||
oXmlDocument = New XPathDocument(oStream)
|
oXmlDocument = New XPathDocument(oStream)
|
||||||
End Using
|
End Using
|
||||||
|
|
||||||
@@ -162,9 +217,9 @@ Public Class ZUGFeRDInterface
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function SerializeZUGFeRDDocument(Document As XPathDocument) As Object
|
Public Function SerializeZUGFeRDDocument(pDocument As XPathDocument) As Object
|
||||||
Try
|
Try
|
||||||
Dim oNavigator As XPathNavigator = Document.CreateNavigator()
|
Dim oNavigator As XPathNavigator = pDocument.CreateNavigator()
|
||||||
Dim oReader As XmlReader
|
Dim oReader As XmlReader
|
||||||
Dim oResult = Nothing
|
Dim oResult = Nothing
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Public Class PDFEmbeds
|
|||||||
Public Function Extract(FilePath As String, AllowedExtensions As List(Of String)) As List(Of EmbeddedFile)
|
Public Function Extract(FilePath As String, AllowedExtensions As List(Of String)) As List(Of EmbeddedFile)
|
||||||
Dim oFile As New List(Of EmbeddedFile)
|
Dim oFile As New List(Of EmbeddedFile)
|
||||||
Dim oFileInfo As FileInfo
|
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)
|
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>
|
''' <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)
|
Public Function Extract(Stream As Stream, AllowedExtensions As List(Of String)) As List(Of EmbeddedFile)
|
||||||
Dim oResults As New 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")
|
Logger.Debug("Extracting embedded files from stream")
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,4 @@
|
|||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</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>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||||
</startup>
|
</startup>
|
||||||
<runtime>
|
<runtime>
|
||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ Public Class Exceptions
|
|||||||
End Sub
|
End Sub
|
||||||
End Class
|
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
|
Public Class NoFerdsException
|
||||||
Inherits ApplicationException
|
Inherits ApplicationException
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<AssemblyName>DigitalData.Modules.Jobs</AssemblyName>
|
<AssemblyName>DigitalData.Modules.Jobs</AssemblyName>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<MyType>Empty</MyType>
|
<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>
|
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
@@ -91,17 +91,17 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="EDMI\ADSync\ADSyncArgs.vb" />
|
<Compile Include="ADSync\ADSyncArgs.vb" />
|
||||||
<Compile Include="EDMI\ADSync\ADSyncJob.vb" />
|
<Compile Include="ADSync\ADSyncJob.vb" />
|
||||||
<Compile Include="EDMI\GraphQL\GraphQLArgs.vb" />
|
<Compile Include="GraphQL\GraphQLArgs.vb" />
|
||||||
<Compile Include="EDMI\GraphQL\GraphQLConfig.vb" />
|
<Compile Include="GraphQL\GraphQLConfig.vb" />
|
||||||
<Compile Include="EDMI\GraphQL\GraphQLJob.vb" />
|
<Compile Include="GraphQL\GraphQLJob.vb" />
|
||||||
<Compile Include="EDMI\GraphQL\GraphQLQuery.vb" />
|
<Compile Include="GraphQL\GraphQLQuery.vb" />
|
||||||
<Compile Include="EDMI\ZUGFeRD\EmailData.vb" />
|
<Compile Include="ZUGFeRD\EmailData.vb" />
|
||||||
<Compile Include="EDMI\ZUGFeRD\EmailFunctions.vb" />
|
<Compile Include="ZUGFeRD\EmailFunctions.vb" />
|
||||||
<Compile Include="EDMI\ZUGFeRD\EmailStrings.vb" />
|
<Compile Include="ZUGFeRD\EmailStrings.vb" />
|
||||||
<Compile Include="EDMI\ZUGFeRD\ImportZUGFeRDFiles.vb" />
|
<Compile Include="ZUGFeRD\ImportZUGFeRDFiles.vb" />
|
||||||
<Compile Include="EDMI\ZUGFeRD\WorkerArgs.vb" />
|
<Compile Include="ZUGFeRD\WorkerArgs.vb" />
|
||||||
<Compile Include="Exceptions.vb" />
|
<Compile Include="Exceptions.vb" />
|
||||||
<Compile Include="JobInterface.vb" />
|
<Compile Include="JobInterface.vb" />
|
||||||
<Compile Include="JobBase.vb" />
|
<Compile Include="JobBase.vb" />
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices
|
|||||||
<Assembly: AssemblyDescription("")>
|
<Assembly: AssemblyDescription("")>
|
||||||
<Assembly: AssemblyCompany("Digital Data")>
|
<Assembly: AssemblyCompany("Digital Data")>
|
||||||
<Assembly: AssemblyProduct("Modules.Jobs")>
|
<Assembly: AssemblyProduct("Modules.Jobs")>
|
||||||
<Assembly: AssemblyCopyright("Copyright © 2021")>
|
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||||
<Assembly: AssemblyTrademark("")>
|
<Assembly: AssemblyTrademark("1.9.0.0")>
|
||||||
|
|
||||||
<Assembly: ComVisible(False)>
|
<Assembly: ComVisible(False)>
|
||||||
|
|
||||||
@@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
|
|||||||
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
' übernehmen, indem Sie "*" eingeben:
|
' übernehmen, indem Sie "*" eingeben:
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("1.8.6.0")>
|
<Assembly: AssemblyVersion("1.9.0.0")>
|
||||||
<Assembly: AssemblyFileVersion("1.8.6.0")>
|
<Assembly: AssemblyFileVersion("1.9.0.0")>
|
||||||
|
|||||||
@@ -83,13 +83,14 @@ Public Class EmailFunctions
|
|||||||
Dim oFinalBodyText = String.Format(EmailStrings.EMAIL_WRAPPING_TEXT.Replace(EmailStrings.constNAME_ZUGFERD_PORTAL, NamePortal), oCompleteBodyText)
|
Dim oFinalBodyText = String.Format(EmailStrings.EMAIL_WRAPPING_TEXT.Replace(EmailStrings.constNAME_ZUGFERD_PORTAL, NamePortal), oCompleteBodyText)
|
||||||
|
|
||||||
Dim oEmailAddress = pEmailData.From
|
Dim oEmailAddress = pEmailData.From
|
||||||
Dim oAttachment = pEmailData.Attachment
|
Dim oAttachmentPath = pEmailData.Attachment
|
||||||
If oAttachment <> String.Empty Then
|
If oAttachmentPath <> String.Empty Then
|
||||||
_logger.Debug($"Attachment_String [{oAttachment}]!")
|
_logger.Debug($"Attachment_String [{oAttachmentPath}]!")
|
||||||
If IO.File.Exists(oAttachment) = False Then
|
If IO.File.Exists(oAttachmentPath) = False Then
|
||||||
_logger.Info($"Attachment.File [{oAttachment}] is not existing!!!")
|
_logger.Info($"Attachment.File [{oAttachmentPath}] is not existing!!!")
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
Dim oAttachmentPathEscaped = oAttachmentPath.Replace("'", "''")
|
||||||
|
|
||||||
If IsNothing(oEmailAddress) OrElse String.IsNullOrWhiteSpace(oEmailAddress) Then
|
If IsNothing(oEmailAddress) OrElse String.IsNullOrWhiteSpace(oEmailAddress) Then
|
||||||
_logger.Warn("Could not find email-address for MessageId {0}", MessageId)
|
_logger.Warn("Could not find email-address for MessageId {0}", MessageId)
|
||||||
@@ -133,7 +134,7 @@ Public Class EmailFunctions
|
|||||||
,'{oFinalBodyText}'
|
,'{oFinalBodyText}'
|
||||||
,'{SourceProcedure}'
|
,'{SourceProcedure}'
|
||||||
,'{oCreatedWho}'
|
,'{oCreatedWho}'
|
||||||
,'{oAttachment}')"
|
,'{oAttachmentPathEscaped}')"
|
||||||
_mssql.ExecuteNonQuery(oInsert)
|
_mssql.ExecuteNonQuery(oInsert)
|
||||||
Else
|
Else
|
||||||
'If oDTResult.Rows.Count = 0 Then
|
'If oDTResult.Rows.Count = 0 Then
|
||||||
@@ -37,4 +37,8 @@
|
|||||||
<li>Betrags-Werte weisen ungültiges Format auf (25,01 anstatt 25.01)</li>
|
<li>Betrags-Werte weisen ungültiges Format auf (25,01 anstatt 25.01)</li>
|
||||||
</ul></p>
|
</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
|
End Class
|
||||||
@@ -26,35 +26,33 @@ Public Class ImportZUGFeRDFiles
|
|||||||
|
|
||||||
Private Const DIRECTORY_DONT_MOVE = "DIRECTORY_DONT_MOVE"
|
Private Const DIRECTORY_DONT_MOVE = "DIRECTORY_DONT_MOVE"
|
||||||
|
|
||||||
|
|
||||||
' List of allowed extensions for PDF/A Attachments
|
' List of allowed extensions for PDF/A Attachments
|
||||||
' This list should not contain xml so the zugferd xml file will be filtered out
|
' 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 _logger As Logger
|
||||||
Private ReadOnly _logConfig As LogConfig
|
Private ReadOnly _logConfig As LogConfig
|
||||||
Private ReadOnly _zugferd As ZUGFeRDInterface
|
|
||||||
Private ReadOnly _firebird As Firebird
|
Private ReadOnly _firebird As Firebird
|
||||||
Private ReadOnly _filesystem As Filesystem.File
|
Private ReadOnly _filesystem As Filesystem.File
|
||||||
Private ReadOnly _EmailOutAccountId As Integer
|
|
||||||
Private ReadOnly _mssql As MSSQLServer
|
Private ReadOnly _mssql As MSSQLServer
|
||||||
Private ReadOnly _email As EmailFunctions
|
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
|
_logConfig = LogConfig
|
||||||
_logger = LogConfig.GetLogger()
|
_logger = LogConfig.GetLogger()
|
||||||
_firebird = Firebird
|
_firebird = Firebird
|
||||||
_filesystem = New Filesystem.File(_logConfig)
|
_filesystem = New Filesystem.File(_logConfig)
|
||||||
_mssql = MSSQL
|
_mssql = MSSQL
|
||||||
_EmailOutAccountId = pEmailOutAccount
|
|
||||||
_email = New EmailFunctions(LogConfig, _mssql, _firebird)
|
_email = New EmailFunctions(LogConfig, _mssql, _firebird)
|
||||||
|
|
||||||
_logger.Debug("Registering GDPicture License")
|
_logger.Debug("Registering GDPicture License")
|
||||||
If _mssql IsNot Nothing Then
|
If _mssql IsNot Nothing Then
|
||||||
Dim oSQL = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"
|
Dim oSQL = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"
|
||||||
Dim oLicenseKey As String = _mssql.GetScalarValue(oSQL)
|
_gdpictureLicenseKey = _mssql.GetScalarValue(oSQL)
|
||||||
_zugferd = New ZUGFeRDInterface(_logConfig, oLicenseKey)
|
|
||||||
Else
|
Else
|
||||||
_logger.Warn("GDPicture License could not be registered! MSSQL is not enabled!")
|
_logger.Warn("GDPicture License could not be registered! MSSQL is not enabled!")
|
||||||
Throw New ArgumentNullException("MSSQL")
|
Throw New ArgumentNullException("MSSQL")
|
||||||
@@ -125,6 +123,14 @@ Public Class ImportZUGFeRDFiles
|
|||||||
Dim oPropertyExtractor = New PropertyValues(_logConfig)
|
Dim oPropertyExtractor = New PropertyValues(_logConfig)
|
||||||
Dim oAttachmentExtractor = New PDFEmbeds(_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)
|
_logger.Debug("Starting Job {0}", [GetType].Name)
|
||||||
|
|
||||||
Try
|
Try
|
||||||
@@ -238,6 +244,10 @@ Public Class ImportZUGFeRDFiles
|
|||||||
oEmailAttachmentFiles.Add(oFile)
|
oEmailAttachmentFiles.Add(oFile)
|
||||||
Continue For
|
Continue For
|
||||||
|
|
||||||
|
Case ZUGFeRDInterface.ErrorType.UnsupportedFormat
|
||||||
|
_logger.Info("File [{0}] is an unsupported ZUFeRD document format!")
|
||||||
|
Throw New UnsupportedFerdException()
|
||||||
|
|
||||||
Case ZUGFeRDInterface.ErrorType.NoValidZugferd
|
Case ZUGFeRDInterface.ErrorType.NoValidZugferd
|
||||||
_logger.Warn("File [{0}] is an Incorrectly formatted ZUGFeRD document!", oFile.Name)
|
_logger.Warn("File [{0}] is an Incorrectly formatted ZUGFeRD document!", oFile.Name)
|
||||||
Throw New InvalidFerdException()
|
Throw New InvalidFerdException()
|
||||||
@@ -380,6 +390,18 @@ Public Class ImportZUGFeRDFiles
|
|||||||
_email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "MD5HashException", _EmailOutAccountId, oArgs.NamePortal)
|
_email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "MD5HashException", _EmailOutAccountId, oArgs.NamePortal)
|
||||||
AddRejectedState(oMessageId, "MD5HashException", "Die gesendete Rechnung wurde bereits verarbeitet!", "", oSQLTransaction)
|
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
|
Catch ex As InvalidFerdException
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|
||||||
@@ -14,10 +14,16 @@ Public Class WorkerArgs
|
|||||||
' Property Parameter
|
' Property Parameter
|
||||||
Public PropertyMap As New Dictionary(Of String, XmlItemProperty)
|
Public PropertyMap As New Dictionary(Of String, XmlItemProperty)
|
||||||
|
|
||||||
|
' Email Parameter
|
||||||
|
Public EmailOutProfileId As Integer = 0
|
||||||
|
|
||||||
' Misc Flag Parameters
|
' Misc Flag Parameters
|
||||||
Public InsertIntoSQLServer As Boolean = False
|
Public InsertIntoSQLServer As Boolean = False
|
||||||
Public ExceptionEmailAddress As String = Nothing
|
Public ExceptionEmailAddress As String = Nothing
|
||||||
Public IgnoreRejectionStatus As Boolean = False
|
Public IgnoreRejectionStatus As Boolean = False
|
||||||
Public MaxAttachmentSizeInMegaBytes As Integer = -1
|
Public MaxAttachmentSizeInMegaBytes As Integer = -1
|
||||||
Public NamePortal As String = "NO PORTAL_NAME IN CONFIG"
|
Public NamePortal As String = "NO PORTAL_NAME IN CONFIG"
|
||||||
|
|
||||||
|
Public AllowFacturX As Boolean = True
|
||||||
|
Public AllowXRechnung As Boolean = True
|
||||||
End Class
|
End Class
|
||||||
@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
|
|||||||
<Assembly: AssemblyCompany("")>
|
<Assembly: AssemblyCompany("")>
|
||||||
<Assembly: AssemblyProduct("Language")>
|
<Assembly: AssemblyProduct("Language")>
|
||||||
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||||
<Assembly: AssemblyTrademark("")>
|
<Assembly: AssemblyTrademark("1.6.1.0")>
|
||||||
|
|
||||||
<Assembly: ComVisible(False)>
|
<Assembly: ComVisible(False)>
|
||||||
|
|
||||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
|||||||
' übernehmen, indem Sie "*" eingeben:
|
' übernehmen, indem Sie "*" eingeben:
|
||||||
' <Assembly: AssemblyVersion("1.0.*")>
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("1.6.0.0")>
|
<Assembly: AssemblyVersion("1.6.1.0")>
|
||||||
<Assembly: AssemblyFileVersion("1.6.0.0")>
|
<Assembly: AssemblyFileVersion("1.6.1.0")>
|
||||||
|
|||||||
@@ -12,4 +12,15 @@ Public Module StringEx
|
|||||||
If String.IsNullOrEmpty(pString) Then Return pString
|
If String.IsNullOrEmpty(pString) Then Return pString
|
||||||
Return pString.Substring(0, Math.Min(pLength, pString.Length))
|
Return pString.Substring(0, Math.Min(pLength, pString.Length))
|
||||||
End Function
|
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
|
End Module
|
||||||
|
|||||||
@@ -113,17 +113,21 @@ Public Class Limilab
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
Public Function IMAPGetMessageIDs_AllMails() As List(Of Long)
|
Public Function IMAPGetMessageIDs_AllMails() As List(Of Long)
|
||||||
Dim oListuids As New List(Of Long)
|
|
||||||
Logger.Debug("Starting IMAPGetMessageIDs ...")
|
Logger.Debug("Starting IMAPGetMessageIDs ...")
|
||||||
If Initialized = False Then
|
If Initialized = False Then
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End If
|
End If
|
||||||
Try
|
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()
|
oListuids = ImapGetMessageIDs_All()
|
||||||
CURR_ListUIDs = oListuids
|
CURR_ListUIDs = oListuids
|
||||||
|
Else
|
||||||
|
Logger.Warn("Connection was NOT successful. Returning Nothing.")
|
||||||
|
Return Nothing
|
||||||
End If
|
End If
|
||||||
Return oListuids
|
Return oListuids
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
@@ -223,10 +227,13 @@ Public Class Limilab
|
|||||||
Private Function ImapGetMessageIDs_All() As List(Of Long)
|
Private Function ImapGetMessageIDs_All() As List(Of Long)
|
||||||
Dim oListuids As New List(Of Long)
|
Dim oListuids As New List(Of Long)
|
||||||
Try
|
Try
|
||||||
|
Logger.Debug("Opening Inbox..")
|
||||||
CurrentImapObject.SelectInbox()
|
CurrentImapObject.SelectInbox()
|
||||||
|
|
||||||
|
Logger.Debug("Searching messages..")
|
||||||
oListuids = CurrentImapObject.Search(Flag.All)
|
oListuids = CurrentImapObject.Search(Flag.All)
|
||||||
|
|
||||||
|
Logger.Debug("[{0}] messages found.", oListuids.Count)
|
||||||
Return oListuids
|
Return oListuids
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Logger.Error(ex)
|
Logger.Error(ex)
|
||||||
|
|||||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
|||||||
' übernehmen, indem Sie "*" eingeben:
|
' übernehmen, indem Sie "*" eingeben:
|
||||||
' <Assembly: AssemblyVersion("1.0.*")>
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("1.3.0.0")>
|
<Assembly: AssemblyVersion("1.6.0.0")>
|
||||||
<Assembly: AssemblyFileVersion("1.3.0.0")>
|
<Assembly: AssemblyFileVersion("1.6.0.0")>
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ Public Class Windream
|
|||||||
Public ReadOnly Property SessionServername As String
|
Public ReadOnly Property SessionServername As String
|
||||||
|
|
||||||
Public ReadOnly Property UsesDriveLetter As Boolean = True
|
Public ReadOnly Property UsesDriveLetter As Boolean = True
|
||||||
|
Public Property NewDocumentID As Int32 = 0
|
||||||
|
|
||||||
''' <returns>A list of object types that are available</returns>
|
''' <returns>A list of object types that are available</returns>
|
||||||
Public ReadOnly Property ObjectTypes As List(Of String)
|
Public ReadOnly Property ObjectTypes As List(Of String)
|
||||||
@@ -243,14 +244,45 @@ Public Class Windream
|
|||||||
Return oItems
|
Return oItems
|
||||||
End Try
|
End Try
|
||||||
End Function
|
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
|
Public Function GetFileByPath(pPath As String) As WMObject
|
||||||
If TestSessionLoggedIn() = False Then
|
If TestSessionLoggedIn() = False Then
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End If
|
End If
|
||||||
pPath = GetNormalizedPath(pPath)
|
pPath = GetNormalizedPath(pPath, False)
|
||||||
|
|
||||||
Dim oWMObject As WMObject
|
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
|
Try
|
||||||
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
|
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
|
||||||
Return oWMObject
|
Return oWMObject
|
||||||
@@ -283,7 +315,7 @@ Public Class Windream
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Path = GetNormalizedPath(Path)
|
Path = GetNormalizedPath(Path, False)
|
||||||
Dim oWMObject As WMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
|
Dim oWMObject As WMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
|
||||||
|
|
||||||
If oWMObject Is Nothing Then
|
If oWMObject Is Nothing Then
|
||||||
@@ -628,7 +660,7 @@ Public Class Windream
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Path = GetNormalizedPath(Path)
|
Path = GetNormalizedPath(Path, True)
|
||||||
Dim oFolders As List(Of String) = Path.Split("\").ToList()
|
Dim oFolders As List(Of String) = Path.Split("\").ToList()
|
||||||
Dim oFolderObject As WMObject
|
Dim oFolderObject As WMObject
|
||||||
Dim oCurrentPath As String = String.Empty
|
Dim oCurrentPath As String = String.Empty
|
||||||
@@ -637,6 +669,8 @@ Public Class Windream
|
|||||||
For Each oFolder In oFolders
|
For Each oFolder In oFolders
|
||||||
If oFolder.ToString.EndsWith(pExtension) Then
|
If oFolder.ToString.EndsWith(pExtension) Then
|
||||||
Exit For
|
Exit For
|
||||||
|
ElseIf oFolder = String.Empty Then
|
||||||
|
Continue For
|
||||||
End If
|
End If
|
||||||
oCurrentPath = Combine(oCurrentPath, oFolder)
|
oCurrentPath = Combine(oCurrentPath, oFolder)
|
||||||
|
|
||||||
@@ -659,7 +693,7 @@ Public Class Windream
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Path = GetNormalizedPath(Path)
|
Path = GetNormalizedPath(Path, False)
|
||||||
Dim oFileObject As IWMObject6
|
Dim oFileObject As IWMObject6
|
||||||
oFileObject = GetObjectByPath(Path, WMEntityDocument)
|
oFileObject = GetObjectByPath(Path, WMEntityDocument)
|
||||||
oFileObject.CreateVersion2(False, Constants.HISTORY_NEW_FROM_VERSION, Comment)
|
oFileObject.CreateVersion2(False, Constants.HISTORY_NEW_FROM_VERSION, Comment)
|
||||||
@@ -671,6 +705,7 @@ Public Class Windream
|
|||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String) As Boolean
|
Public Function NewFileStream(ByVal FilenameSource As String, ByVal FilenameTarget As String) As Boolean
|
||||||
|
NewDocumentID = 0
|
||||||
Dim oExtension As String = Path.GetExtension(FilenameSource)
|
Dim oExtension As String = Path.GetExtension(FilenameSource)
|
||||||
|
|
||||||
If Not TestSessionLoggedIn() Then
|
If Not TestSessionLoggedIn() Then
|
||||||
@@ -678,7 +713,7 @@ Public Class Windream
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget)
|
Dim oTargetDrive As String = Path.GetDirectoryName(FilenameTarget)
|
||||||
FilenameTarget = GetNormalizedPath(FilenameTarget)
|
FilenameTarget = GetNormalizedPath(FilenameTarget, True)
|
||||||
|
|
||||||
_logger.NewBlock("File Stream")
|
_logger.NewBlock("File Stream")
|
||||||
_logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}")
|
_logger.Debug($"Preparing to stream file from {FilenameSource} to {FilenameTarget}")
|
||||||
@@ -687,6 +722,8 @@ Public Class Windream
|
|||||||
Dim oFileIO As WMFileIO
|
Dim oFileIO As WMFileIO
|
||||||
Dim oWMStream As WMStream
|
Dim oWMStream As WMStream
|
||||||
|
|
||||||
|
NewFolder(FilenameTarget, oExtension)
|
||||||
|
|
||||||
'Indexierungsdialog der Session unterdrücken
|
'Indexierungsdialog der Session unterdrücken
|
||||||
Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False)
|
Session.SwitchEvents(Constants.COM_EVENT_SESSION_NEED_INDEX, False)
|
||||||
|
|
||||||
@@ -749,6 +786,11 @@ Public Class Windream
|
|||||||
End Try
|
End Try
|
||||||
|
|
||||||
_logger.Info($"File '{FilenameTarget}' was streamed.")
|
_logger.Info($"File '{FilenameTarget}' was streamed.")
|
||||||
|
Dim oDocid = GetIndexValue(FilenameTarget, "Dokument-ID")
|
||||||
|
If Not IsNothing(oDocid) Then
|
||||||
|
NewDocumentID = oDocid(0)
|
||||||
|
End If
|
||||||
|
|
||||||
_logger.EndBlock()
|
_logger.EndBlock()
|
||||||
|
|
||||||
Return True
|
Return True
|
||||||
@@ -774,11 +816,13 @@ Public Class Windream
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function GetNormalizedPath(Path As String) As String
|
Public Function GetNormalizedPath(Path As String, pCleanPath As Boolean) As String
|
||||||
'Dim oNormalizedPath = GetCleanedPath(Path)
|
_logger.Debug("Normalizing Path: [{0}]", Path)
|
||||||
Dim oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path)
|
Dim oNormalizedPath As String = Path
|
||||||
_logger.Debug("Normalizing Path: [{0}]", oNormalizedPath)
|
If pCleanPath = True Then
|
||||||
|
oNormalizedPath = Language.Utils.RemoveInvalidCharacters(Path)
|
||||||
|
_logger.Debug("path after RemoveInvalidCharacters: [{0}]", oNormalizedPath)
|
||||||
|
End If
|
||||||
Try
|
Try
|
||||||
' Convert any forward slashes / and double slashes \\ into backslashes \
|
' 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
|
' 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:\
|
' Remove Driveletter, eg. W:\
|
||||||
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
|
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
|
||||||
_logger.Debug($"Replacing ClientDriveLetter: [{ClientDriveLetter}]")
|
|
||||||
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
|
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter.Length + 2)
|
||||||
|
_logger.Debug($"path after replaced ClientDriveLetter: [{oNormalizedPath}]")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Remove Windream Base Path, eg. \\windream\objects\
|
' Remove Windream Base Path, eg. \\windream\objects\
|
||||||
@@ -804,7 +848,9 @@ Public Class Windream
|
|||||||
_logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]")
|
_logger.Warn($"Check Your config ClientDriveLetter [{ClientDriveLetter}] // ClientBasePath [{ClientBasePath}]")
|
||||||
oNormalizedPath = oNormalizedPath.Substring(3)
|
oNormalizedPath = oNormalizedPath.Substring(3)
|
||||||
End If
|
End If
|
||||||
|
If oNormalizedPath.StartsWith("\") = False Then
|
||||||
|
oNormalizedPath = $"\{oNormalizedPath}"
|
||||||
|
End If
|
||||||
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
|
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
|
||||||
|
|
||||||
Return oNormalizedPath
|
Return oNormalizedPath
|
||||||
@@ -1041,7 +1087,7 @@ Public Class Windream
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Try
|
Try
|
||||||
FolderPath = GetNormalizedPath(FolderPath)
|
FolderPath = GetNormalizedPath(FolderPath, False)
|
||||||
|
|
||||||
If TestFolderExists(FolderPath) = False Then
|
If TestFolderExists(FolderPath) = False Then
|
||||||
_logger.Warn("Folder {0} does not exist!", FolderPath)
|
_logger.Warn("Folder {0} does not exist!", FolderPath)
|
||||||
@@ -1312,13 +1358,22 @@ Public Class Windream
|
|||||||
Exportpath &= "\"
|
Exportpath &= "\"
|
||||||
End If
|
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
|
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
|
' Stream Interface bereitstellen
|
||||||
oWMObject.LockFor(WMObjectEditModeFileSystem)
|
oWMObject.LockFor(WMObjectEditModeFileSystem)
|
||||||
Try
|
Try
|
||||||
@@ -1354,12 +1409,13 @@ Public Class Windream
|
|||||||
oWMObject.unlock()
|
oWMObject.unlock()
|
||||||
_logger.Info($"WMFile has been exported to {tempFilename} ")
|
_logger.Info($"WMFile has been exported to {tempFilename} ")
|
||||||
|
|
||||||
Return True
|
Return tempFilename
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
Return False
|
Return False
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function Export_WMFile_DocID(WMPath As String, Exportpath As String, DocId As Integer)
|
Public Function Export_WMFile_DocID(WMPath As String, Exportpath As String, DocId As Integer)
|
||||||
Try
|
Try
|
||||||
|
|
||||||
@@ -1454,11 +1510,11 @@ Public Class Windream
|
|||||||
'Return rNewFilepath
|
'Return rNewFilepath
|
||||||
End Function
|
End Function
|
||||||
Public Function TestFolderExists(Path As String) As Boolean
|
Public Function TestFolderExists(Path As String) As Boolean
|
||||||
Return TestObjectExists(GetNormalizedPath(Path), WMEntityFolder)
|
Return TestObjectExists(GetNormalizedPath(Path, False), WMEntityFolder)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function TestFileExists(Path As String) As Boolean
|
Public Function TestFileExists(Path As String) As Boolean
|
||||||
Return TestObjectExists(GetNormalizedPath(Path), WMEntityDocument)
|
Return TestObjectExists(GetNormalizedPath(Path, False), WMEntityDocument)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function TestUserExists(Username As String) As Boolean
|
Public Function TestUserExists(Username As String) As Boolean
|
||||||
@@ -1530,7 +1586,7 @@ Public Class Windream
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Dim oNormalizedPath = GetNormalizedPath(ObjectPath)
|
Dim oNormalizedPath = GetNormalizedPath(ObjectPath, False)
|
||||||
Dim oWMObject As WMObject = Session.GetWMObjectByPath(ObjectType, oNormalizedPath)
|
Dim oWMObject As WMObject = Session.GetWMObjectByPath(ObjectType, oNormalizedPath)
|
||||||
Return oWMObject
|
Return oWMObject
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
|||||||
Reference in New Issue
Block a user