jj appserv
This commit is contained in:
@@ -8,23 +8,24 @@ Public Class DatatableJob
|
||||
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 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)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Imports System.Threading
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports Quartz
|
||||
Imports Quartz.Listener
|
||||
@@ -10,12 +11,14 @@ Public Class JobListener
|
||||
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly _LogConfig As LogConfig
|
||||
Private ReadOnly _MSSQL As MSSQLServer
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, ResultDataSet As DataSet)
|
||||
Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer, ResultDataSet As DataSet)
|
||||
MyBase.New()
|
||||
|
||||
_LogConfig = LogConfig
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_MSSQL = MSSQL
|
||||
Dataset = ResultDataSet
|
||||
End Sub
|
||||
|
||||
@@ -24,10 +27,11 @@ Public Class JobListener
|
||||
Dim oDataTable As DataTable = context.Result
|
||||
Dim oDetailRow As DataRow = context.MergedJobDataMap.Item("CronJobDetails")
|
||||
Dim oDatatableName As String = oDetailRow.Item("DT_NAME")
|
||||
Dim oDetailId As Integer = oDetailRow.Item("GUID")
|
||||
Dim oDatatableNameTemp As String = oDatatableName & "-TEMP"
|
||||
|
||||
If Dataset.Tables.Contains(oDatatableName) Then
|
||||
_Logger.Debug("DataTable exists, renaming and replacing")
|
||||
_Logger.Debug("DataTable [{0}] exists, renaming and replacing", oDatatableName)
|
||||
' Rename the new table, add TEMP suffix
|
||||
oDataTable.TableName = oDatatableNameTemp
|
||||
' Add the new table to the dataset
|
||||
@@ -37,10 +41,13 @@ Public Class JobListener
|
||||
' Rename the new table
|
||||
Dataset.Tables.Item(oDatatableNameTemp).TableName = oDatatableName
|
||||
Else
|
||||
_Logger.Debug("DataTable does not exist, adding")
|
||||
_Logger.Debug("DataTable [{0}] does not exist, adding", oDatatableName)
|
||||
Dataset.Tables.Add(oDataTable)
|
||||
End If
|
||||
|
||||
_MSSQL.ExecuteNonQuery($"INSERT INTO TBAPPSERV_CRON_DETAIL_HISTORY (DETAIL_ID) VALUES ({oDetailId})")
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Unexpected error in JobListener: {0}", ex.Message)
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
|
||||
Reference in New Issue
Block a user