Jobs: Update to use Job Runner Table
This commit is contained in:
parent
36fe39ee66
commit
a8862709d8
@ -2,9 +2,9 @@
|
||||
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Interfaces
|
||||
Imports DigitalData.Modules.Jobs
|
||||
Imports DigitalData.Modules.Config
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports Newtonsoft.Json.Linq
|
||||
Imports System.Collections.Generic
|
||||
Imports System.Linq
|
||||
@ -43,7 +43,7 @@ Public Class GraphQLJob
|
||||
_Logger.Debug("Loading Queries")
|
||||
|
||||
' Load query data from TBCUST_JOBRUNNER_QUERY
|
||||
Dim oQueryTable As DataTable = _MSSQL.GetDatatable("SELECT * FROM TBCUST_JOBRUNNER_QUERY ORDER BY OPERATION_NAME, CLEAR_BEFORE_FILL ASC")
|
||||
Dim oQueryTable As DataTable = _MSSQL.GetDatatable("SELECT * FROM TBCUST_JOBRUNNER_QUERY ORDER BY SEQUENCE")
|
||||
Dim oQueryList As New List(Of GraphQL.Query)
|
||||
|
||||
' Save query data to business objects
|
||||
@ -51,14 +51,35 @@ Public Class GraphQLJob
|
||||
Dim oQuery As New GraphQL.Query With {
|
||||
.Id = oRow.Item("GUID"),
|
||||
.Name = oRow.Item("TITLE"),
|
||||
.ClearBeforeFill = oRow.Item("CLEAR_BEFORE_FILL"),
|
||||
.ConnectionId = oRow.Item("CON_ID"), ' TODO: Connection String?
|
||||
.DestinationTable = oRow.Item("DESTINATION_TABLE"),
|
||||
.OperationName = oRow.Item("OPERATION_NAME"),
|
||||
.MappingBasePath = oRow.Item("MAPPING_BASE_PATH"),
|
||||
.QueryString = oRow.Item("QUERY_STRING"),
|
||||
.QueryConstraint = oRow.Item("QUERY_CONSTRAINT")
|
||||
.ClearBeforeFill = oRow.ItemEx("CLEAR_BEFORE_FILL", False),
|
||||
.ConnectionId = oRow.ItemEx("CON_ID", 1), ' TODO: Connection String?
|
||||
.DestinationTable = oRow.ItemEx("DESTINATION_TABLE", String.Empty),
|
||||
.OperationName = oRow.ItemEx("OPERATION_NAME", String.Empty),
|
||||
.MappingBasePath = oRow.ItemEx("MAPPING_BASE_PATH", String.Empty),
|
||||
.QueryString = oRow.ItemEx("QUERY_STRING", String.Empty),
|
||||
.QueryConstraint = oRow.ItemEx("QUERY_CONSTRAINT", String.Empty)
|
||||
}
|
||||
|
||||
If oQuery.DestinationTable = String.Empty Then
|
||||
_Logger.Warn("Value [DestinationTable] could not be read. Configuration incomplete.")
|
||||
End If
|
||||
|
||||
If oQuery.OperationName = String.Empty Then
|
||||
_Logger.Warn("Value [OperationName] could not be read. Configuration incomplete.")
|
||||
End If
|
||||
|
||||
If oQuery.MappingBasePath = String.Empty Then
|
||||
_Logger.Warn("Value [MappingBasePath] could not be read. Configuration incomplete.")
|
||||
End If
|
||||
|
||||
If oQuery.QueryString = String.Empty Then
|
||||
_Logger.Warn("Value [QueryString] could not be read. Configuration incomplete.")
|
||||
End If
|
||||
|
||||
If oQuery.QueryConstraint = String.Empty Then
|
||||
_Logger.Warn("Value [QueryConstraint] could not be read. Configuration incomplete.")
|
||||
End If
|
||||
|
||||
oQueryList.Add(oQuery)
|
||||
Next
|
||||
|
||||
@ -71,6 +92,10 @@ Public Class GraphQLJob
|
||||
Dim oConnectionId As Integer = oQuery.ConnectionId
|
||||
Dim oConnectionString = _MSSQL.Get_ConnectionStringforID(oConnectionId)
|
||||
|
||||
If oConnectionString = String.Empty Then
|
||||
_Logger.Warn("Could not get Connection String for ConnectionId [{0}]", oConnectionId)
|
||||
End If
|
||||
|
||||
Dim oDatabase As New MSSQLServer(_LogConfig, oConnectionString)
|
||||
|
||||
' Reset all records to status = 0
|
||||
|
||||
@ -1,8 +1,17 @@
|
||||
Imports System.Collections.Generic
|
||||
|
||||
Public Class JobConfig
|
||||
Public Enabled As Boolean
|
||||
Public StartImmediately As Boolean
|
||||
Public CronExpression As String
|
||||
Public Arguments As Dictionary(Of String, String)
|
||||
Public Property Name As JobType
|
||||
Public Property Enabled As Boolean = False
|
||||
Public Property StartWithoutDelay As Boolean = False
|
||||
Public Property CronSchedule As String = ""
|
||||
|
||||
Public Property ArgsString As String = ""
|
||||
Public Property Args As New Dictionary(Of String, String)
|
||||
|
||||
Public Enum JobType
|
||||
ADSync
|
||||
GraphQL
|
||||
Test
|
||||
End Enum
|
||||
End Class
|
||||
@ -13,46 +13,17 @@ Public Class JobConfigParser
|
||||
''' </summary>
|
||||
''' <param name="ConfigString"></param>
|
||||
''' <returns>A populated JobConfig object</returns>
|
||||
Public Shared Function ParseConfig(ConfigString As String) As JobConfig
|
||||
If JobOptionsRegex.IsMatch(ConfigString) Then
|
||||
Dim oMatches = JobOptionsRegex.Matches(ConfigString)
|
||||
Dim oOptions As New JobConfig
|
||||
Public Shared Function ParseConfig(pJobConfig As JobConfig) As JobConfig
|
||||
|
||||
Dim oSplitOptions As String() = ConfigString.Split(ARGS_LIST_DELIMITER)
|
||||
' 24.11.2022: This only parses the optional Job arguments,
|
||||
' everything is comparmentalized in the Service config
|
||||
pJobConfig.Args = ParseOptionalArguments(pJobConfig.ArgsString)
|
||||
Return pJobConfig
|
||||
|
||||
If oSplitOptions.Length = 3 Then
|
||||
oOptions = ParseEnabled(oSplitOptions(0), oOptions)
|
||||
oOptions.CronExpression = oSplitOptions(1)
|
||||
oOptions.Arguments = ParseOptionalArguments(oSplitOptions(2))
|
||||
ElseIf oSplitOptions.Length = 2 Then
|
||||
oOptions = ParseEnabled(oSplitOptions(0), oOptions)
|
||||
oOptions.CronExpression = oSplitOptions(1)
|
||||
oOptions.Arguments = New Dictionary(Of String, String)
|
||||
Else
|
||||
Throw New ArgumentException("Config Malformed")
|
||||
End If
|
||||
|
||||
Return oOptions
|
||||
Else
|
||||
Throw New ArgumentException("Config Malformed")
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function ParseEnabled(EnabledValue As String, Options As JobConfig) As JobConfig
|
||||
Select Case EnabledValue
|
||||
Case "True"
|
||||
Options.Enabled = True
|
||||
Options.StartImmediately = False
|
||||
Case "Debug"
|
||||
Options.Enabled = True
|
||||
Options.StartImmediately = True
|
||||
Case Else
|
||||
Options.Enabled = False
|
||||
Options.StartImmediately = False
|
||||
End Select
|
||||
|
||||
Return Options
|
||||
End Function
|
||||
|
||||
Private Shared Function ParseOptionalArguments(ArgsString As String) As Dictionary(Of String, String)
|
||||
Dim oArgsDictionary As New Dictionary(Of String, String)
|
||||
|
||||
@ -116,6 +116,10 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DigitalData.Modules.Language, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Interfaces\bin\Debug\DigitalData.Modules.Language.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FirebirdSql.Data.FirebirdClient, Version=7.5.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FirebirdSql.Data.FirebirdClient.7.5.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user