3 Commits

Author SHA1 Message Date
Jonathan Jenne
73c5255bd5 add debuggerstepthrough attribute to MoveFile 2020-03-10 11:44:49 +01:00
Jonathan Jenne
0c8a4fb8e3 DDZUGFeRDSErvice: Version 1.1.0.0 2020-03-10 11:44:21 +01:00
Jonathan Jenne
204151b78c Modules.Jobs: Version 1.1.0.0 2020-03-10 11:43:55 +01:00
10 changed files with 70 additions and 17 deletions

View File

@@ -37,6 +37,9 @@
<setting name="MSSQL_ENABLED" serializeAs="String"> <setting name="MSSQL_ENABLED" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="GDPICTURE_KEY" serializeAs="String">
<value>1234567890_EXAMPLE_KEY</value>
</setting>
</DDZUGFeRDService.My.MySettings> </DDZUGFeRDService.My.MySettings>
</applicationSettings> </applicationSettings>
<system.data> <system.data>

View File

@@ -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.0.0.0")> <Assembly: AssemblyVersion("1.1.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")> <Assembly: AssemblyFileVersion("1.0.0.0")>

View File

@@ -15,7 +15,7 @@ Option Explicit On
Namespace My Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ <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)> _ Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase Inherits Global.System.Configuration.ApplicationSettingsBase
@@ -134,6 +134,15 @@ Namespace My
Return CType(Me("MSSQL_ENABLED"),Boolean) Return CType(Me("MSSQL_ENABLED"),Boolean)
End Get End Get
End Property 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 Class
End Namespace End Namespace

View File

@@ -29,5 +29,8 @@
<Setting Name="MSSQL_ENABLED" Type="System.Boolean" Scope="Application"> <Setting Name="MSSQL_ENABLED" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="GDPICTURE_KEY" Type="System.String" Scope="Application">
<Value Profile="(Default)">1234567890_EXAMPLE_KEY</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@@ -27,7 +27,7 @@ Public Class ThreadRunner
Private Const TIMER_INTERVAL_MS = 10_000 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 _logConfig = LogConfig
_logger = _logConfig.GetLogger() _logger = _logConfig.GetLogger()
_firebird = Firebird _firebird = Firebird
@@ -37,6 +37,7 @@ Public Class ThreadRunner
Dim args As New WorkerArgs() Dim args As New WorkerArgs()
args = LoadFolderConfig(args) args = LoadFolderConfig(args)
args = LoadPropertyMapFor(args, "DEFAULT") args = LoadPropertyMapFor(args, "DEFAULT")
args.GDPictureKey = GDPictureKey
' Use MSSQL Server if available ' Use MSSQL Server if available
If Not IsNothing(_mssql) Then If Not IsNothing(_mssql) Then

View File

@@ -24,6 +24,7 @@ Public Class ZUGFeRDService
Dim oJobInterval As Integer = My.Settings.JOB_INTERVAL Dim oJobInterval As Integer = My.Settings.JOB_INTERVAL
Dim oMSSQLConnectionString As String = My.Settings.MSSQL_CONNECTIONSTRING Dim oMSSQLConnectionString As String = My.Settings.MSSQL_CONNECTIONSTRING
Dim oMSSQLEnabled As Boolean = My.Settings.MSSQL_ENABLED Dim oMSSQLEnabled As Boolean = My.Settings.MSSQL_ENABLED
Dim oGDPictureKey As String = My.Settings.GDPICTURE_KEY
_firebird = New Firebird(_logConfig, oDataSource, oDatabase, oUser, oPassword) _firebird = New Firebird(_logConfig, oDataSource, oDatabase, oUser, oPassword)
@@ -37,7 +38,7 @@ Public Class ZUGFeRDService
End If End If
Try Try
_threadRunner = New ThreadRunner(_logConfig, _firebird, _mssql) _threadRunner = New ThreadRunner(_logConfig, oGDPictureKey, _firebird, _mssql)
_threadRunner.Start(oJobInterval) _threadRunner.Start(oJobInterval)
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)

View File

@@ -161,11 +161,13 @@ Public Class File
Return True Return True
End Function End Function
<DebuggerStepThrough>
Public Sub MoveTo(FilePath As String, Directory As String) Public Sub MoveTo(FilePath As String, Directory As String)
Dim oFileInfo As New FileInfo(FilePath) Dim oFileInfo As New FileInfo(FilePath)
IO.File.Move(FilePath, Path.Combine(Directory, oFileInfo.Name)) IO.File.Move(FilePath, Path.Combine(Directory, oFileInfo.Name))
End Sub End Sub
<DebuggerStepThrough>
Public Sub MoveTo(FilePath As String, NewFileName As String, Directory As String) Public Sub MoveTo(FilePath As String, NewFileName As String, Directory As String)
Dim oFileInfo As New FileInfo(FilePath) Dim oFileInfo As New FileInfo(FilePath)
IO.File.Move(FilePath, Path.Combine(Directory, NewFileName)) IO.File.Move(FilePath, Path.Combine(Directory, NewFileName))

View File

@@ -13,6 +13,7 @@ Imports DigitalData.Modules.Interfaces.Exceptions
Imports DigitalData.Modules.Jobs.Exceptions Imports DigitalData.Modules.Jobs.Exceptions
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports FirebirdSql.Data.FirebirdClient Imports FirebirdSql.Data.FirebirdClient
Imports GdPicture14
Public Class ImportZUGFeRDFiles Public Class ImportZUGFeRDFiles
Implements IJob Implements IJob
@@ -333,6 +334,10 @@ Public Class ImportZUGFeRDFiles
_logger.Debug("Starting Job {0}", [GetType].Name) _logger.Debug("Starting Job {0}", [GetType].Name)
_logger.Debug("Registering GDPicture License")
Dim oLicenseManager As New LicenseManager
oLicenseManager.RegisterKEY(oArgs.GDPictureKey)
Try Try
For Each oPath As String In oArgs.WatchDirectories For Each oPath As String In oArgs.WatchDirectories
Dim oDirInfo As New DirectoryInfo(oPath) Dim oDirInfo As New DirectoryInfo(oPath)
@@ -418,11 +423,14 @@ Public Class ImportZUGFeRDFiles
End Select End Select
End Try End Try
' Extract all attachments other than the zugferd-invoice.xml
Dim oAttachments = oAttachmentExtractor.Extract(oFile.FullName, AllowedExtensions) Dim oAttachments = oAttachmentExtractor.Extract(oFile.FullName, AllowedExtensions)
If oAttachments Is Nothing Then If oAttachments Is Nothing Then
_logger.Warn("Attachments for file [{0}] could not be extracted", oFile.FullName) _logger.Warn("Attachments for file [{0}] could not be extracted", oFile.FullName)
Else Else
oFileAttachmentFiles.AddRange(oFileGroupFiles) 'oFileAttachmentFiles.AddRange(oFileGroupFiles)
'oFileAttachmentFiles.AddRange(oAttachments)
oFileAttachmentFiles.AddRange(oAttachments) oFileAttachmentFiles.AddRange(oAttachments)
End If End If
@@ -741,18 +749,27 @@ Public Class ImportZUGFeRDFiles
End Sub End Sub
Private Sub MoveFiles(Args As WorkerArgs, Files As List(Of FileInfo), AttachmentFiles As List(Of FileInfo), MoveDirectory As String) 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 For Each oFile In Files
Try 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)) Dim oFileName = _filesystem.GetVersionedFilename(Path.Combine(oFinalMoveDirectory, oFile.Name))
_filesystem.MoveTo(oFile.FullName, oFileName, oFinalMoveDirectory) _filesystem.MoveTo(oFile.FullName, oFileName, oFinalMoveDirectory)
@@ -764,6 +781,20 @@ Public Class ImportZUGFeRDFiles
_logger.Error(ex) _logger.Error(ex)
End Try End Try
Next 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 End Sub

View File

@@ -5,11 +5,13 @@ Imports GdPicture14
Public Class PDFAttachments Public Class PDFAttachments
Private Logger As Logger Private Logger As Logger
Private Filesystem As Filesystem.File
Private Const ZUGFERD_XML_FILENAME = "ZUGFeRD-invoice.xml" Private Const ZUGFERD_XML_FILENAME = "ZUGFeRD-invoice.xml"
Public Sub New(LogConfig As LogConfig, GdPictureKey As String) Public Sub New(LogConfig As LogConfig, GdPictureKey As String)
Logger = LogConfig.GetLogger Logger = LogConfig.GetLogger
Filesystem = New Filesystem.File(LogConfig)
End Sub End Sub
Public Function Extract(FileName As String, AllowedExtensions As List(Of String)) As List(Of FileInfo) 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) Dim status As GdPictureStatus = oGDPicturePDF.ExtractEmbeddedFile(index, FileData)
If status = GdPictureStatus.OK Then 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) Using oFileStream As New FileStream(oTempName, FileMode.OpenOrCreate)
oFileStream.Write(FileData, 0, FileData.Length) oFileStream.Write(FileData, 0, FileData.Length)
End Using End Using

View File

@@ -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.0.0.0")> <Assembly: AssemblyVersion("1.1.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")> <Assembly: AssemblyFileVersion("1.0.0.0")>