First version of service
This commit is contained in:
parent
feb429f8f8
commit
49e6da3d79
@ -41,9 +41,6 @@ Namespace Jobs
|
||||
Logger.Info("Starting job {0}", JobId)
|
||||
|
||||
Try
|
||||
InitializeModels()
|
||||
InitializeServices()
|
||||
|
||||
Logger.Debug("Loading GdViewer..")
|
||||
GdViewer = New GdViewer()
|
||||
LicenseManager.RegisterKEY(oGdPictureKey)
|
||||
@ -54,9 +51,16 @@ Namespace Jobs
|
||||
Logger.Debug("Loading Database..")
|
||||
Database = GetDatabase(pContext, LogConfig)
|
||||
|
||||
Logger.Debug("Loading Models & Services")
|
||||
InitializeModels()
|
||||
InitializeServices()
|
||||
|
||||
Logger.Debug("Loading Configuration..")
|
||||
Config = ConfigModel.LoadConfiguration()
|
||||
|
||||
Logger.Debug("DocumentPath: [{0}]", Config.DocumentPath)
|
||||
Logger.Debug("ExportPath: [{0}]", Config.ExportPath)
|
||||
|
||||
Dim oCompleteStatus As Integer = Constants.EnvelopeStatus.EnvelopeCompletelySigned
|
||||
Dim oSql = $"SELECT * FROM TBSIG_ENVELOPE WHERE STATUS = {oCompleteStatus}"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
@ -155,35 +159,35 @@ Namespace Jobs
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Async Function GenerateReportPdf(pEnvelopeId As Integer) As Task(Of Byte())
|
||||
Dim oSql As String = $"SELECT * FROM VWSIG_ENVELOPE_REPORT WHERE ENVELOPE_ID = {pEnvelopeId}"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSql)
|
||||
Dim oItems = GetReportSource(oTable)
|
||||
'Private Async Function GenerateReportPdf(pEnvelopeId As Integer) As Task(Of Byte())
|
||||
' Dim oSql As String = $"SELECT * FROM VWSIG_ENVELOPE_REPORT WHERE ENVELOPE_ID = {pEnvelopeId}"
|
||||
' Dim oTable As DataTable = Database.GetDatatable(oSql)
|
||||
' Dim oItems = GetReportSource(oTable)
|
||||
|
||||
If oItems.Count = 0 Then
|
||||
Return Nothing
|
||||
End If
|
||||
' If oItems.Count = 0 Then
|
||||
' Return Nothing
|
||||
' End If
|
||||
|
||||
Dim oState As New State() With {
|
||||
.Database = Database,
|
||||
.LogConfig = LogConfig
|
||||
}
|
||||
EnvelopeModel = New EnvelopeModel(oState)
|
||||
Dim oEnvelope = EnvelopeModel.GetById(pEnvelopeId)
|
||||
' Dim oState As New State() With {
|
||||
' .Database = Database,
|
||||
' .LogConfig = LogConfig
|
||||
' }
|
||||
' EnvelopeModel = New EnvelopeModel(oState)
|
||||
' Dim oEnvelope = EnvelopeModel.GetById(pEnvelopeId)
|
||||
|
||||
Dim oCreator As New ReportCreator(oEnvelope)
|
||||
Dim oBuffer = Await oCreator.CreateReport(oItems)
|
||||
' Dim oCreator As New ReportCreator(oEnvelope)
|
||||
' Dim oBuffer = Await oCreator.CreateReport(oItems)
|
||||
|
||||
Return oBuffer
|
||||
End Function
|
||||
' Return oBuffer
|
||||
'End Function
|
||||
|
||||
Private Function GetReportSource(pDataTable As DataTable) As List(Of ReportItem)
|
||||
Return pDataTable.Rows.
|
||||
Cast(Of DataRow).
|
||||
Select(AddressOf ToReportItem).
|
||||
OrderByDescending(Function(r) r.ItemDate).
|
||||
ToList()
|
||||
End Function
|
||||
'Private Function GetReportSource(pDataTable As DataTable) As List(Of ReportItem)
|
||||
' Return pDataTable.Rows.
|
||||
' Cast(Of DataRow).
|
||||
' Select(AddressOf ToReportItem).
|
||||
' OrderByDescending(Function(r) r.ItemDate).
|
||||
' ToList()
|
||||
'End Function
|
||||
|
||||
Private Function GetEnvelopeData(pEnvelopeId As Integer) As EnvelopeData
|
||||
Dim oSql = $"SELECT T.GUID, T2.FILEPATH FROM [dbo].[TBSIG_ENVELOPE] T
|
||||
@ -202,6 +206,8 @@ Namespace Jobs
|
||||
.AnnotationData = oAnnotationData
|
||||
}
|
||||
|
||||
Logger.Debug("Document path: [{0}]", oData.DocumentPath)
|
||||
|
||||
Return oData
|
||||
End Function
|
||||
Private Function GetAnnotationData(pEnvelopeId As Integer) As List(Of String)
|
||||
@ -217,13 +223,13 @@ Namespace Jobs
|
||||
|
||||
Private Function ToReportItem(pRow As DataRow) As ReportItem
|
||||
Return New ReportItem() With {
|
||||
.EnvelopeId = pRow.Item("ENVELOPE_ID"),
|
||||
.EnvelopeTitle = pRow.ItemEx("HEAD_TITLE", String.Empty),
|
||||
.EnvelopeSubject = pRow.ItemEx("HEAD_SUBJECT", String.Empty),
|
||||
.ItemDate = pRow.ItemEx(Of Date)("POS_WHEN", Nothing),
|
||||
.ItemStatus = pRow.ItemEx("POS_STATUS", 0),
|
||||
.ItemUserReference = pRow.ItemEx("POS_WHO", "")
|
||||
}
|
||||
.EnvelopeId = pRow.Item("ENVELOPE_ID"),
|
||||
.EnvelopeTitle = pRow.ItemEx("HEAD_TITLE", String.Empty),
|
||||
.EnvelopeSubject = pRow.ItemEx("HEAD_SUBJECT", String.Empty),
|
||||
.ItemDate = pRow.ItemEx(Of Date)("POS_WHEN", Nothing),
|
||||
.ItemStatus = pRow.ItemEx("POS_STATUS", 0),
|
||||
.ItemUserReference = pRow.ItemEx("POS_WHO", "")
|
||||
}
|
||||
End Function
|
||||
|
||||
Private Sub InitializeServices()
|
||||
@ -245,9 +251,12 @@ Namespace Jobs
|
||||
End Function
|
||||
|
||||
Private Function GetState() As State
|
||||
Return New State() With {
|
||||
Return New State With {
|
||||
.LogConfig = LogConfig,
|
||||
.Database = Database
|
||||
.Database = Database,
|
||||
.UserId = 0,
|
||||
.Config = Nothing,
|
||||
.DbConfig = Nothing
|
||||
}
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@ -27,8 +27,11 @@ Namespace Jobs
|
||||
End Sub
|
||||
|
||||
Public Function BurnInstantJSONAnnotationsToPDF(pSourceFilePath As String, pInstantJSONList As List(Of String), pDestinationDirectoryPath As String) As Boolean
|
||||
If Manager.InitFromFile(pSourceFilePath) <> GdPictureStatus.OK Then
|
||||
Logger.Warn("Could not open file [{0}] for burning.", pSourceFilePath)
|
||||
Dim oResult As GdPictureStatus
|
||||
|
||||
oResult = Manager.InitFromFile(pSourceFilePath)
|
||||
If oResult <> GdPictureStatus.OK Then
|
||||
Logger.Warn("Could not open file [{0}] for burning: [{1}]", pSourceFilePath, oResult.ToString)
|
||||
Return False
|
||||
End If
|
||||
|
||||
@ -41,10 +44,21 @@ Namespace Jobs
|
||||
|
||||
Dim oFileInfo As New FileInfo(pSourceFilePath)
|
||||
Dim oDestinationFilePath As String = Path.Combine(pDestinationDirectoryPath, oFileInfo.Name)
|
||||
Try
|
||||
Logger.Debug("Export filepath: [{0}]", oDestinationFilePath)
|
||||
|
||||
Try
|
||||
oResult = Manager.BurnAnnotationsToPage(RemoveInitialAnnots:=True, VectorMode:=True)
|
||||
If oResult <> GdPictureStatus.OK Then
|
||||
Logger.Warn("Could not burn annotations to file file [{0}]: [{1}]", pSourceFilePath, oResult.ToString)
|
||||
Return False
|
||||
End If
|
||||
|
||||
oResult = Manager.SaveDocumentToPDF(oDestinationFilePath)
|
||||
If oResult <> GdPictureStatus.OK Then
|
||||
Logger.Warn("Could not save file [{0}] to path [{1}]: [{2}]", oFileInfo.Name, oDestinationFilePath, oResult.ToString)
|
||||
Return False
|
||||
End If
|
||||
|
||||
Manager.BurnAnnotationsToPage(RemoveInitialAnnots:=True, VectorMode:=True)
|
||||
Manager.SaveDocumentToPDF(oDestinationFilePath)
|
||||
Manager.Close()
|
||||
|
||||
Return True
|
||||
|
||||
@ -13,7 +13,7 @@ Public Class ConfigModel
|
||||
Try
|
||||
Dim oSql As String = "SELECT TOP 1 * FROM TBSIG_CONFIG"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSql)
|
||||
Dim oRow = oTable.Rows.Item(0)
|
||||
Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
|
||||
Return New DbConfig() With {
|
||||
.DocumentPath = oRow.ItemEx("DOCUMENT_PATH", ""),
|
||||
@ -23,6 +23,7 @@ Public Class ConfigModel
|
||||
.ExternalProgramName = oRow.ItemEx("EXTERNAL_PROGRAM_NAME", "")
|
||||
}
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return New DbConfig()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@ -10,12 +10,14 @@ Public Class Scheduler
|
||||
|
||||
Private Scheduler As IScheduler
|
||||
Private ConnectionString As String
|
||||
Private LicenseKey As String
|
||||
|
||||
Private Const JobName = "CertificateDocumentJob"
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pConnectionString As String)
|
||||
Public Sub New(pLogConfig As LogConfig, pConnectionString As String, pLicenseKey As String)
|
||||
MyBase.New(pLogConfig)
|
||||
ConnectionString = pConnectionString
|
||||
LicenseKey = pLicenseKey
|
||||
End Sub
|
||||
|
||||
Public Async Function Start(pInterval As Integer) As Task
|
||||
@ -29,6 +31,7 @@ Public Class Scheduler
|
||||
|
||||
Dim oJobKey = New JobKey(JobName)
|
||||
Dim oJobData = New JobDataMap() From {
|
||||
{Common.Constants.GDPICTURE, LicenseKey},
|
||||
{Common.Constants.LOGCONFIG, LogConfig},
|
||||
{Common.Constants.DATABASE, ConnectionString}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Messaging
|
||||
Imports DigitalData.Modules.Config
|
||||
Imports GdPicture.Internal.WPF
|
||||
|
||||
Public Class Service
|
||||
Private Logger As Logger
|
||||
@ -37,19 +38,27 @@ Public Class Service
|
||||
|
||||
Logger.Info("Inititalize Databases")
|
||||
|
||||
If Config.ConnectionString <> String.Empty Then
|
||||
Database = New MSSQLServer(LogConfig, Config.ConnectionString)
|
||||
If Config.ConnectionString = String.Empty Then
|
||||
Throw New ApplicationException("Connection String is empty!")
|
||||
End If
|
||||
|
||||
If Database.DBInitialized = False Then
|
||||
Logger.Warn("MSSQL Connection could not be established. Check the Error Log")
|
||||
End If
|
||||
Database = New MSSQLServer(LogConfig, Config.ConnectionString)
|
||||
|
||||
If Database.DBInitialized = False Then
|
||||
Throw New ApplicationException("Database connection could not be established!")
|
||||
End If
|
||||
|
||||
Dim oKey = Database.GetScalarValue("SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'")
|
||||
|
||||
If String.IsNullOrWhiteSpace(oKey) Then
|
||||
Throw New ApplicationException("GDPicture License could not be loaded!")
|
||||
End If
|
||||
|
||||
' === Initialize Queue ===
|
||||
|
||||
Logger.Debug("Inititalize Quartz")
|
||||
|
||||
Scheduler = New Scheduler(LogConfig, Config.ConnectionString)
|
||||
Scheduler = New Scheduler(LogConfig, Config.ConnectionString, oKey)
|
||||
Await Scheduler.Start(Config.IntervalInMin)
|
||||
|
||||
Logger.Info("Started [{0}] !", ServiceName)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user