Get GDPicture Key from Database

This commit is contained in:
Jonathan Jenne 2020-03-10 15:38:03 +01:00
parent 1e02757b22
commit 1c2fb43f6a
9 changed files with 41 additions and 33 deletions

View File

@ -32,7 +32,7 @@
<value>10</value>
</setting>
<setting name="MSSQL_CONNECTIONSTRING" serializeAs="String">
<value />
<value/>
</setting>
<setting name="MSSQL_ENABLED" serializeAs="String">
<value>False</value>

View File

@ -37,7 +37,6 @@ 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
@ -114,25 +113,6 @@ Public Class ThreadRunner
Dim args As WorkerArgs = e.Argument
_logger.Debug("Background worker running..")
' Use MSSQL Server if available
If Not IsNothing(_mssql) Then
'Checking if documents have bee´n rejected
Dim oSQL As String = "Select * from TBEDMI_DOC_REJECTED WHERE MD5_UPDATE = 0"
'Dim oDT As DataTable = _mssql.GetDatatable(oSQL)
'If Not IsNothing(oDT) Then
' For Each oRow As DataRow In oDT.Rows
' oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET REJECTED = TRUE WHERE MESSAGE_ID = '{oRow.Item("MESSAGE_ID")}'"
' If _firebird.ExecuteNonQuery(oSQL) = True Then
' oSQL = $"UPDATE TBEDMI_DOC_REJECTED SET MD5_UPDATE = 1 WHERE GUID = '{oRow.Item("GUID")}'"
' If _mssql.ExecuteNonQuery(oSQL) = True Then
' _logger.Debug($"Refreshed the Rejected Info for messageid [{oRow.Item("MESSAGE_ID")}]")
' End If
' End If
' Next
'Else
' _logger.Warn("oDTTBEDMI_DOC_REJECTED is nothing...")
'End If
End If
Dim job As New ImportZUGFeRDFiles(_logConfig, _firebird, _mssql)
job.Start(args)
Catch ex As Exception

View File

@ -32,6 +32,9 @@
<setting name="MD5Cheksum" serializeAs="String">
<value />
</setting>
<setting name="MSSQL_CONNECTIONSTRING" serializeAs="String">
<value>Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM_TEST;User Id=sa;Password=dd</value>
</setting>
</ZUGFeRDTest.My.MySettings>
</userSettings>
<runtime>

View File

@ -13,6 +13,7 @@ Imports DigitalData.Modules.Logging
Public Class Form1
Private _logConfig As LogConfig
Private _firebird As Firebird
Private _mssql As MSSQLServer
Private _zugferd As ZUGFeRDInterface
Private PropertyMap As New Dictionary(Of String, XmlItemProperty)
@ -22,6 +23,7 @@ Public Class Form1
_logConfig = New LogConfig(LogConfig.PathType.CurrentDirectory)
_logConfig.Debug = True
_firebird = New Firebird(_logConfig, My.Settings.FB_DATASOURCE, My.Settings.FB_DATABASE, My.Settings.FB_USER, My.Settings.FB_PASS)
_mssql = New MSSQLServer(_logConfig, My.Settings.MSSQL_CONNECTIONSTRING)
_zugferd = New ZUGFeRDInterface(_logConfig)
End Sub
@ -85,9 +87,8 @@ Public Class Form1
Dim args As New WorkerArgs()
args = LoadFolderConfig(args)
args = LoadPropertyMapFor(args, "DEFAULT")
args.GDPictureKey = "21182889975216572111813147150675976632"
Dim job As New Jobs.ImportZUGFeRDFiles(_logConfig, _firebird)
Dim job As New Jobs.ImportZUGFeRDFiles(_logConfig, _firebird, _mssql)
job.Start(args)
End Sub
@ -163,13 +164,11 @@ Public Class Form1
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim oExtractor = New Jobs.PDFAttachments(_logConfig, "21182889975216572111813147150675976632")
Dim oExtractor = New Jobs.PDFAttachments(_logConfig)
Dim oResult = OpenFileDialog1.ShowDialog()
If oResult = DialogResult.OK Then
oExtractor.Extract(OpenFileDialog1.FileName, AllowedExtensions:=New List(Of String) From {"docx", "doc", "pdf", "xls", "xlsx", "ppt", "pptx", "txt"})
End If
End Sub
End Class

View File

@ -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
@ -107,6 +107,18 @@ Namespace My
Me("MD5Cheksum") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM_TEST;User Id=sa;Password=dd")> _
Public Property MSSQL_CONNECTIONSTRING() As String
Get
Return CType(Me("MSSQL_CONNECTIONSTRING"),String)
End Get
Set
Me("MSSQL_CONNECTIONSTRING") = value
End Set
End Property
End Class
End Namespace

View File

@ -17,5 +17,8 @@
<Setting Name="MD5Cheksum" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="MSSQL_CONNECTIONSTRING" Type="System.String" Scope="User">
<Value Profile="(Default)">Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM_TEST;User Id=sa;Password=dd</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -330,13 +330,26 @@ Public Class ImportZUGFeRDFiles
Public Sub Start(Arguments As Object) Implements IJob.Start
Dim oArgs As WorkerArgs = Arguments
Dim oPropertyExtractor = New PropertyValues(_logConfig)
Dim oAttachmentExtractor = New PDFAttachments(_logConfig, oArgs.GDPictureKey)
Dim oAttachmentExtractor = New PDFAttachments(_logConfig)
_logger.Debug("Starting Job {0}", [GetType].Name)
_logger.Debug("Registering GDPicture License")
Dim oLicenseManager As New LicenseManager
oLicenseManager.RegisterKEY(oArgs.GDPictureKey)
If _mssql IsNot Nothing Then
Try
Dim oSQL = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"
Dim oLicenseKey As String = _mssql.GetScalarValue(oSQL)
Dim oLicenseManager As New LicenseManager
oLicenseManager.RegisterKEY(oLicenseKey)
Catch ex As Exception
_logger.Error(ex)
_logger.Warn("GDPicture License could not be retrieved! Query failed! Exiting job.")
Exit Sub
End Try
Else
_logger.Warn("GDPicture License could not be retrieved! MSSQL is not enabled! Exiting job.")
Exit Sub
End If
Try
For Each oPath As String In oArgs.WatchDirectories

View File

@ -13,7 +13,7 @@ Public Class PDFAttachments
Public FileContents As Byte()
End Class
Public Sub New(LogConfig As LogConfig, GdPictureKey As String)
Public Sub New(LogConfig As LogConfig)
Logger = LogConfig.GetLogger
End Sub

View File

@ -9,7 +9,6 @@ Public Class WorkerArgs
Public AttachmentsSubDirectory As String
Public PropertyMap As Dictionary(Of String, XmlItemProperty)
Public InsertIntoSQLServer As Boolean
Public GDPictureKey As String
Public Sub New()
WatchDirectories = New List(Of String)
@ -20,6 +19,5 @@ Public Class WorkerArgs
AttachmentsSubDirectory = Nothing
PropertyMap = New Dictionary(Of String, XmlItemProperty)
InsertIntoSQLServer = False
GDPictureKey = String.Empty
End Sub
End Class