Add MSSQL Functions to ZUGFeRD Service
This commit is contained in:
@@ -31,6 +31,12 @@
|
||||
<setting name="JOB_INTERVAL" serializeAs="String">
|
||||
<value>10</value>
|
||||
</setting>
|
||||
<setting name="MSSQL_CONNECTIONSTRING" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="MSSQL_ENABLED" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
</DDZUGFeRDService.My.MySettings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
18
DDZUGFeRDService/My Project/Settings.Designer.vb
generated
18
DDZUGFeRDService/My Project/Settings.Designer.vb
generated
@@ -116,6 +116,24 @@ Namespace My
|
||||
Return CType(Me("JOB_INTERVAL"),Integer)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property MSSQL_CONNECTIONSTRING() As String
|
||||
Get
|
||||
Return CType(Me("MSSQL_CONNECTIONSTRING"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("False")> _
|
||||
Public ReadOnly Property MSSQL_ENABLED() As Boolean
|
||||
Get
|
||||
Return CType(Me("MSSQL_ENABLED"),Boolean)
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
|
||||
@@ -23,5 +23,11 @@
|
||||
<Setting Name="JOB_INTERVAL" Type="System.Int32" Scope="Application">
|
||||
<Value Profile="(Default)">10</Value>
|
||||
</Setting>
|
||||
<Setting Name="MSSQL_CONNECTIONSTRING" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="MSSQL_ENABLED" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -22,18 +22,27 @@ Public Class ThreadRunner
|
||||
Private _originalEmailDirectory As String
|
||||
Private _zugferd As ZUGFeRDInterface
|
||||
Private _jobArguments As WorkerArgs
|
||||
Private _mssql As MSSQLServer
|
||||
|
||||
Private Const TIMER_INTERVAL_MS = 10_000
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Firebird As Firebird)
|
||||
Public Sub New(LogConfig As LogConfig, Firebird As Firebird, Optional MSSQL As MSSQLServer = Nothing)
|
||||
_logConfig = LogConfig
|
||||
_logger = _logConfig.GetLogger()
|
||||
_firebird = Firebird
|
||||
_zugferd = New ZUGFeRDInterface(_logConfig)
|
||||
_mssql = MSSQL
|
||||
|
||||
Dim args As New WorkerArgs()
|
||||
args = LoadFolderConfig(args)
|
||||
args = LoadPropertyMapFor(args, "DEFAULT")
|
||||
|
||||
' Use MSSQL Server if available
|
||||
If _mssql IsNot Nothing Then
|
||||
_logger.Debug("Data will be inserted into MSSQL Server.")
|
||||
args.InsertIntoSQLServer = True
|
||||
End If
|
||||
|
||||
_jobArguments = args
|
||||
|
||||
_logger.Debug("Checking SuccessDirectory {0}", args.SuccessDirectory)
|
||||
@@ -104,7 +113,7 @@ Public Class ThreadRunner
|
||||
|
||||
_logger.Debug("Background worker running..")
|
||||
|
||||
Dim job As New ImportZUGFeRDFiles(_logConfig, _firebird)
|
||||
Dim job As New ImportZUGFeRDFiles(_logConfig, _firebird, _mssql)
|
||||
job.Start(args)
|
||||
Catch ex As Exception
|
||||
_logger.Warn("Background worker failed!")
|
||||
|
||||
@@ -7,6 +7,7 @@ Public Class ZUGFeRDService
|
||||
Private _logConfig As LogConfig
|
||||
Private _logger As Logger
|
||||
Private _firebird As Firebird
|
||||
Private _mssql As MSSQLServer = Nothing
|
||||
|
||||
Private _threadRunner As ThreadRunner
|
||||
|
||||
@@ -21,14 +22,22 @@ Public Class ZUGFeRDService
|
||||
Dim oUser As String = My.Settings.DB_USER
|
||||
Dim oPassword As String = My.Settings.DB_PASSWORD
|
||||
Dim oJobInterval As Integer = My.Settings.JOB_INTERVAL
|
||||
|
||||
_logger.Debug("Datasource: {0}", oDataSource)
|
||||
_logger.Debug("Database: {0}", oDatabase)
|
||||
Dim oMSSQLConnectionString As String = My.Settings.MSSQL_CONNECTIONSTRING
|
||||
Dim oMSSQLEnabled As Boolean = My.Settings.MSSQL_ENABLED
|
||||
|
||||
_firebird = New Firebird(_logConfig, oDataSource, oDatabase, oUser, oPassword)
|
||||
|
||||
If oMSSQLEnabled = True Then
|
||||
_mssql = New MSSQLServer(_logConfig, oMSSQLConnectionString)
|
||||
|
||||
If _mssql.DBInitialized = False Then
|
||||
_logger.Warn("MSSQL Connection could not be initialized. Disabling MSSQL.")
|
||||
_mssql = Nothing
|
||||
End If
|
||||
End If
|
||||
|
||||
Try
|
||||
_threadRunner = New ThreadRunner(_logConfig, _firebird)
|
||||
_threadRunner = New ThreadRunner(_logConfig, _firebird, _mssql)
|
||||
_threadRunner.Start(oJobInterval)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
|
||||
Reference in New Issue
Block a user