EDMIService: Add Quartz Scheduler, Add Caching for Datatables
This commit is contained in:
40
Service.EDMIService/Scheduler/DatatableJob.vb
Normal file
40
Service.EDMIService/Scheduler/DatatableJob.vb
Normal file
@@ -0,0 +1,40 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports Quartz
|
||||
|
||||
Public Class DatatableJob
|
||||
Implements IJob
|
||||
|
||||
Public Function Execute(context As IJobExecutionContext) As Task Implements IJob.Execute
|
||||
Dim oJobData = context.MergedJobDataMap
|
||||
Dim oLogConfig As LogConfig = oJobData.Item("LogConfig")
|
||||
Dim oCronJobTitle As String = oJobData.Item("CronJobTitle")
|
||||
Dim oDetailRow As DataRow = oJobData.Item("CronJobDetails")
|
||||
Dim oMSSQL As MSSQLServer = oJobData.Item("MSSQL")
|
||||
|
||||
Dim oConnectionId As Integer = oDetailRow.Item("CON_ID")
|
||||
Dim oTitle As String = oDetailRow.Item("TITLE")
|
||||
Dim oDatatableName As String = oDetailRow.Item("DT_NAME")
|
||||
Dim oSQL As String = oDetailRow.Item("COMMAND")
|
||||
|
||||
Dim oLogger As Logger = oLogConfig.GetLogger()
|
||||
oLogger.Debug("Running Command-Job [{0}]", oTitle)
|
||||
oLogger.Debug("Datatable Name: {0}", oDatatableName)
|
||||
oLogger.Debug("Connection Id: {0}", oConnectionId)
|
||||
|
||||
Dim oConnectionString = oMSSQL.Get_ConnectionStringforID(oConnectionId)
|
||||
|
||||
Try
|
||||
Dim oResult = oMSSQL.GetDatatableWithConnection(oSQL, oConnectionString)
|
||||
oResult.TableName = oDatatableName
|
||||
oLogger.Debug("Result Datatable contains [{0}] rows", oResult.Rows.Count)
|
||||
|
||||
' Das Ergebnis speichern
|
||||
context.Result = oResult
|
||||
Catch ex As Exception
|
||||
oLogger.Warn("Unhandled exception while executing SQL for Datatable {}")
|
||||
End Try
|
||||
|
||||
Return Task.FromResult(True)
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user