42 lines
1.6 KiB
VB.net
42 lines
1.6 KiB
VB.net
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 oLogger As Logger = oLogConfig.GetLogger()
|
|
|
|
Try
|
|
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")
|
|
|
|
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)
|
|
|
|
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
|