Compare commits
3 Commits
3e795a1a6d
...
73c5255bd5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73c5255bd5 | ||
|
|
0c8a4fb8e3 | ||
|
|
204151b78c |
@@ -37,6 +37,9 @@
|
||||
<setting name="MSSQL_ENABLED" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="GDPICTURE_KEY" serializeAs="String">
|
||||
<value>1234567890_EXAMPLE_KEY</value>
|
||||
</setting>
|
||||
</DDZUGFeRDService.My.MySettings>
|
||||
</applicationSettings>
|
||||
<system.data>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyVersion("1.1.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
|
||||
11
DDZUGFeRDService/My Project/Settings.Designer.vb
generated
11
DDZUGFeRDService/My Project/Settings.Designer.vb
generated
@@ -15,7 +15,7 @@ Option Explicit On
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0"), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
@@ -134,6 +134,15 @@ Namespace My
|
||||
Return CType(Me("MSSQL_ENABLED"),Boolean)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("1234567890_EXAMPLE_KEY")> _
|
||||
Public ReadOnly Property GDPICTURE_KEY() As String
|
||||
Get
|
||||
Return CType(Me("GDPICTURE_KEY"),String)
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
|
||||
@@ -29,5 +29,8 @@
|
||||
<Setting Name="MSSQL_ENABLED" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="GDPICTURE_KEY" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">1234567890_EXAMPLE_KEY</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -27,7 +27,7 @@ Public Class ThreadRunner
|
||||
|
||||
Private Const TIMER_INTERVAL_MS = 10_000
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Firebird As Firebird, Optional MSSQL As MSSQLServer = Nothing)
|
||||
Public Sub New(LogConfig As LogConfig, GDPictureKey As String, Firebird As Firebird, Optional MSSQL As MSSQLServer = Nothing)
|
||||
_logConfig = LogConfig
|
||||
_logger = _logConfig.GetLogger()
|
||||
_firebird = Firebird
|
||||
@@ -37,6 +37,7 @@ Public Class ThreadRunner
|
||||
Dim args As New WorkerArgs()
|
||||
args = LoadFolderConfig(args)
|
||||
args = LoadPropertyMapFor(args, "DEFAULT")
|
||||
args.GDPictureKey = GDPictureKey
|
||||
|
||||
' Use MSSQL Server if available
|
||||
If Not IsNothing(_mssql) Then
|
||||
|
||||
@@ -24,6 +24,7 @@ Public Class ZUGFeRDService
|
||||
Dim oJobInterval As Integer = My.Settings.JOB_INTERVAL
|
||||
Dim oMSSQLConnectionString As String = My.Settings.MSSQL_CONNECTIONSTRING
|
||||
Dim oMSSQLEnabled As Boolean = My.Settings.MSSQL_ENABLED
|
||||
Dim oGDPictureKey As String = My.Settings.GDPICTURE_KEY
|
||||
|
||||
_firebird = New Firebird(_logConfig, oDataSource, oDatabase, oUser, oPassword)
|
||||
|
||||
@@ -37,7 +38,7 @@ Public Class ZUGFeRDService
|
||||
End If
|
||||
|
||||
Try
|
||||
_threadRunner = New ThreadRunner(_logConfig, _firebird, _mssql)
|
||||
_threadRunner = New ThreadRunner(_logConfig, oGDPictureKey, _firebird, _mssql)
|
||||
_threadRunner.Start(oJobInterval)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
|
||||
@@ -161,11 +161,13 @@ Public Class File
|
||||
Return True
|
||||
End Function
|
||||
|
||||
<DebuggerStepThrough>
|
||||
Public Sub MoveTo(FilePath As String, Directory As String)
|
||||
Dim oFileInfo As New FileInfo(FilePath)
|
||||
IO.File.Move(FilePath, Path.Combine(Directory, oFileInfo.Name))
|
||||
End Sub
|
||||
|
||||
<DebuggerStepThrough>
|
||||
Public Sub MoveTo(FilePath As String, NewFileName As String, Directory As String)
|
||||
Dim oFileInfo As New FileInfo(FilePath)
|
||||
IO.File.Move(FilePath, Path.Combine(Directory, NewFileName))
|
||||
|
||||
@@ -13,6 +13,7 @@ Imports DigitalData.Modules.Interfaces.Exceptions
|
||||
Imports DigitalData.Modules.Jobs.Exceptions
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports FirebirdSql.Data.FirebirdClient
|
||||
Imports GdPicture14
|
||||
|
||||
Public Class ImportZUGFeRDFiles
|
||||
Implements IJob
|
||||
@@ -333,6 +334,10 @@ Public Class ImportZUGFeRDFiles
|
||||
|
||||
_logger.Debug("Starting Job {0}", [GetType].Name)
|
||||
|
||||
_logger.Debug("Registering GDPicture License")
|
||||
Dim oLicenseManager As New LicenseManager
|
||||
oLicenseManager.RegisterKEY(oArgs.GDPictureKey)
|
||||
|
||||
Try
|
||||
For Each oPath As String In oArgs.WatchDirectories
|
||||
Dim oDirInfo As New DirectoryInfo(oPath)
|
||||
@@ -418,11 +423,14 @@ Public Class ImportZUGFeRDFiles
|
||||
End Select
|
||||
End Try
|
||||
|
||||
' Extract all attachments other than the zugferd-invoice.xml
|
||||
Dim oAttachments = oAttachmentExtractor.Extract(oFile.FullName, AllowedExtensions)
|
||||
If oAttachments Is Nothing Then
|
||||
_logger.Warn("Attachments for file [{0}] could not be extracted", oFile.FullName)
|
||||
Else
|
||||
oFileAttachmentFiles.AddRange(oFileGroupFiles)
|
||||
'oFileAttachmentFiles.AddRange(oFileGroupFiles)
|
||||
'oFileAttachmentFiles.AddRange(oAttachments)
|
||||
|
||||
oFileAttachmentFiles.AddRange(oAttachments)
|
||||
End If
|
||||
|
||||
@@ -741,18 +749,27 @@ Public Class ImportZUGFeRDFiles
|
||||
End Sub
|
||||
|
||||
Private Sub MoveFiles(Args As WorkerArgs, Files As List(Of FileInfo), AttachmentFiles As List(Of FileInfo), MoveDirectory As String)
|
||||
Dim oFinalMoveDirectory As String = MoveDirectory
|
||||
Dim oAttachmentDirectory As String = Path.Combine(MoveDirectory, Args.AttachmentsSubDirectory)
|
||||
|
||||
If Not Directory.Exists(oFinalMoveDirectory) Then
|
||||
Try
|
||||
Directory.CreateDirectory(oFinalMoveDirectory)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
End If
|
||||
|
||||
If Not Directory.Exists(oAttachmentDirectory) And AttachmentFiles.Count > 0 Then
|
||||
Try
|
||||
Directory.CreateDirectory(oAttachmentDirectory)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
End If
|
||||
|
||||
For Each oFile In Files
|
||||
Try
|
||||
Dim oFinalMoveDirectory As String = MoveDirectory
|
||||
|
||||
If AttachmentFiles.Contains(oFile) Then
|
||||
oFinalMoveDirectory = Path.Combine(MoveDirectory, Args.AttachmentsSubDirectory)
|
||||
|
||||
If Not Directory.Exists(oFinalMoveDirectory) Then
|
||||
Directory.CreateDirectory(oFinalMoveDirectory)
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim oFileName = _filesystem.GetVersionedFilename(Path.Combine(oFinalMoveDirectory, oFile.Name))
|
||||
|
||||
_filesystem.MoveTo(oFile.FullName, oFileName, oFinalMoveDirectory)
|
||||
@@ -764,6 +781,20 @@ Public Class ImportZUGFeRDFiles
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
For Each oFile In AttachmentFiles
|
||||
Try
|
||||
Dim oFileName = _filesystem.GetVersionedFilename(Path.Combine(oAttachmentDirectory, oFile.Name))
|
||||
|
||||
_filesystem.MoveTo(oFile.FullName, oFileName, oAttachmentDirectory)
|
||||
|
||||
_logger.Info("Finished processing file {0}", oFile.Name)
|
||||
_logger.Info("Attachment moved to {0}", oFileName)
|
||||
Catch ex As Exception
|
||||
_logger.Warn("Could not move attachment {0}", oFile.FullName)
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
@@ -5,11 +5,13 @@ Imports GdPicture14
|
||||
|
||||
Public Class PDFAttachments
|
||||
Private Logger As Logger
|
||||
Private Filesystem As Filesystem.File
|
||||
|
||||
Private Const ZUGFERD_XML_FILENAME = "ZUGFeRD-invoice.xml"
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, GdPictureKey As String)
|
||||
Logger = LogConfig.GetLogger
|
||||
Filesystem = New Filesystem.File(LogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Extract(FileName As String, AllowedExtensions As List(Of String)) As List(Of FileInfo)
|
||||
@@ -36,7 +38,8 @@ Public Class PDFAttachments
|
||||
Dim status As GdPictureStatus = oGDPicturePDF.ExtractEmbeddedFile(index, FileData)
|
||||
|
||||
If status = GdPictureStatus.OK Then
|
||||
Dim oTempName As String = Path.Combine(Path.GetTempPath(), oFileName)
|
||||
Dim oVersionedName = Filesystem.GetVersionedFilename(oFileName)
|
||||
Dim oTempName As String = Path.Combine(Path.GetTempPath(), oVersionedName)
|
||||
Using oFileStream As New FileStream(oTempName, FileMode.OpenOrCreate)
|
||||
oFileStream.Write(FileData, 0, FileData.Length)
|
||||
End Using
|
||||
|
||||
@@ -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.0.0.0")>
|
||||
<Assembly: AssemblyVersion("1.1.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
|
||||
Reference in New Issue
Block a user