Prepare Cert Document job

This commit is contained in:
Jonathan Jenne 2023-12-04 16:29:33 +01:00
parent 3d20a9b401
commit 5d210350e7
3 changed files with 50 additions and 10 deletions

View File

@ -62,6 +62,7 @@
Public Const DATABASE = "DATABASE" Public Const DATABASE = "DATABASE"
Public Const LOGCONFIG = "LOGCONFIG" Public Const LOGCONFIG = "LOGCONFIG"
Public Const GDPICTURE = "GDPICTURE"
#End Region #End Region
End Class End Class

View File

@ -74,6 +74,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath> <HintPath>..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
</Reference> </Reference>
<Reference Include="GdPicture.NET.14">
<HintPath>D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET (.NET Framework 4.5)\GdPicture.NET.14.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> <Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath> <HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>

View File

@ -1,36 +1,72 @@
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports GdPicture14
Imports Quartz Imports Quartz
Imports Quartz.Util
Public Class CertificateDocumentJob Public Class CertificateDocumentJob
Implements IJob Implements IJob
Private LicenseManager As New LicenseManager()
Private GdViewer As GdViewer
Private LogConfig As LogConfig
Private Logger As Logger
Private Database As MSSQLServer
Private Config As DbConfig
Public Function Execute(pContext As IJobExecutionContext) As Task Implements IJob.Execute Public Function Execute(pContext As IJobExecutionContext) As Task Implements IJob.Execute
Dim oLogConfig As LogConfig = pContext.MergedJobDataMap.Item(Constants.LOGCONFIG) Dim oGdPictureKey As String = pContext.MergedJobDataMap.Item(Constants.GDPICTURE)
Dim oConnectionString As String = pContext.MergedJobDataMap.Item(Constants.DATABASE) LogConfig = pContext.MergedJobDataMap.Item(Constants.LOGCONFIG)
Dim oLogger As Logger = oLogConfig.GetLogger() Logger = LogConfig.GetLogger()
Try Try
Dim oDatabase As New MSSQLServer(oLogConfig, MSSQLServer.DecryptConnectionString(oConnectionString)) Logger.Info("Loading GdViewer..")
GdViewer = New GdViewer()
LicenseManager.RegisterKEY(oGdPictureKey)
Logger.Info("Loading Database..")
Database = GetDatabase(pContext, LogConfig)
Logger.Info("Loading Configuration..")
Config = GetDbConfig(Database)
Dim JobId = pContext.JobDetail.Key Dim JobId = pContext.JobDetail.Key
oLogger.Info("Starting job {0}", JobId) Logger.Info("Starting job {0}", JobId)
Dim oCompleteStatus As Integer = Constants.EnvelopeStatus.EnvelopeCompletelySigned Dim oCompleteStatus As Integer = Constants.EnvelopeStatus.EnvelopeCompletelySigned
Dim oSql = $"SELECT * FROM TBSIG_ENVELOPE WHERE STATUS = {oCompleteStatus}" Dim oSql = $"SELECT * FROM TBSIG_ENVELOPE WHERE STATUS = {oCompleteStatus}"
Dim oTable = oDatabase.GetDatatable(oSql) Dim oTable = Database.GetDatatable(oSql)
oLogger.Info("Found [{0}] completed envelopes.", oTable.Rows.Count) Logger.Info("Found [{0}] completed envelopes.", oTable.Rows.Count)
' Do important work... ' Do important work...
oLogger.Info("Completed job {0}", JobId) Logger.Info("Completed job {0}", JobId)
Return Task.FromResult(True) Return Task.FromResult(True)
Catch ex As Exception Catch ex As Exception
oLogger.Warn("Certificate Document job failed!") Logger.Warn("Certificate Document job failed!")
oLogger.Error(ex) Logger.Error(ex)
Return Task.FromException(ex) Return Task.FromException(ex)
End Try End Try
End Function End Function
Private Function GetDbConfig(pDatabase) As DbConfig
Dim oState As New State With {.Database = pDatabase}
Dim oConfigModel = New ConfigModel(oState)
Return oConfigModel.LoadConfiguration()
End Function
Private Function GetDatabase(pContext As IJobExecutionContext, pLogConfig As LogConfig) As MSSQLServer
Dim oConnectionString As String = pContext.MergedJobDataMap.Item(Constants.DATABASE)
Dim Database = New MSSQLServer(pLogConfig, MSSQLServer.DecryptConnectionString(oConnectionString))
Return Database
End Function
End Class End Class