Interfaces/GraphQL: Improve debugging
This commit is contained in:
@@ -16,6 +16,8 @@ Public Class GraphQLJob
|
||||
Inherits JobBase
|
||||
Implements IJob(Of GraphQLArgs)
|
||||
|
||||
Private _GraphQL As GraphQLInterface = Nothing
|
||||
|
||||
Private Const PLACEHOLDER_STATIC = "STATIC:"
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer)
|
||||
@@ -27,18 +29,16 @@ Public Class GraphQLJob
|
||||
Dim oConfigPath As String = Args.QueryConfigPath
|
||||
Dim oConfigManager As New ConfigManager(Of GraphQLConfig)(_LogConfig, oConfigPath)
|
||||
|
||||
Dim oInterface As GraphQLInterface
|
||||
|
||||
With oConfigManager.Config
|
||||
oInterface = New GraphQLInterface(_LogConfig, .BaseUrl, .Email, .Password, .CertificateFingerprint)
|
||||
_GraphQL = New GraphQLInterface(_LogConfig, .BaseUrl, .Email, .Password, .CertificateFingerprint)
|
||||
End With
|
||||
|
||||
' Login to get cookie
|
||||
_Logger.Debug("Logging in")
|
||||
Dim oLoginResponse = oInterface.Login()
|
||||
Dim oLoginResponse = _GraphQL.Login()
|
||||
|
||||
' save cookie for future requests
|
||||
oInterface.SaveCookies(oLoginResponse.Cookies.Item(0))
|
||||
_GraphQL.SaveCookies(oLoginResponse.Cookies.Item(0))
|
||||
|
||||
_Logger.Debug("Loading Queries")
|
||||
|
||||
@@ -85,7 +85,7 @@ Public Class GraphQLJob
|
||||
_Logger.Info("Getting data..", oQuery.Name)
|
||||
|
||||
' get the data from GraphQL
|
||||
Dim oDataResponse = oInterface.GetData(oQuery.QueryString, oQuery.OperationName)
|
||||
Dim oDataResponse = _GraphQL.GetData(oQuery.QueryString, oQuery.OperationName)
|
||||
Dim oResult As String
|
||||
|
||||
' write data to string
|
||||
@@ -144,7 +144,7 @@ Public Class GraphQLJob
|
||||
|
||||
' logout
|
||||
_Logger.Debug("Logging out")
|
||||
Dim oLogoutResponse = oInterface.Logout()
|
||||
Dim oLogoutResponse = _GraphQL.Logout()
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
@@ -153,24 +153,26 @@ Public Class GraphQLJob
|
||||
|
||||
Private Function HandleResponse(JsonString As String, QueryData As GraphQL.Query, DB As Database.MSSQLServer) As GraphQL.Query
|
||||
Dim oObj As JObject = JObject.Parse(JsonString)
|
||||
Dim oResultList As JToken = oObj.SelectToken(QueryData.MappingBasePath)
|
||||
Dim oResultList As JToken
|
||||
|
||||
If _GraphQL.ReadJSONPathFragmented(oObj, QueryData.MappingBasePath) = False Then
|
||||
_Logger.Warn("There is an error in the MappingBasePath [{1}] configuration of query [{0}]", QueryData.Name, QueryData.MappingBasePath)
|
||||
End If
|
||||
|
||||
Try
|
||||
oResultList = oObj.SelectToken(QueryData.MappingBasePath, errorWhenNoMatch:=True)
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("HandleResponse: Could not find BasePath: [{0}] for query [{1}]", QueryData.MappingBasePath, QueryData.Name)
|
||||
_Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
|
||||
If oResultList Is Nothing Then
|
||||
_Logger.Warn("HandleResponse: Could not find BasePath: [{0}] for query [{1}]", QueryData.MappingBasePath, QueryData.Name)
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
_Logger.Info("Processing Queue [{0}] with [{1}] Items", QueryData.Name, oResultList.Count)
|
||||
|
||||
'If QueryData.ClearBeforeFill Then
|
||||
' _Logger.Info("Clearing Table {0} before insert", QueryData.DestinationTable)
|
||||
' _Logger.Info("Clear Command: [{0}]", QueryData.ClearCommand)
|
||||
' Try
|
||||
' DB.ExecuteNonQuery(QueryData.ClearCommand)
|
||||
' Catch ex As Exception
|
||||
' _Logger.Error(ex)
|
||||
' End Try
|
||||
'End If
|
||||
_Logger.Info("HandleResponse: Processing Queue [{0}] with [{1}] Items", QueryData.Name, oResultList.Count)
|
||||
|
||||
For Each oResultItem As JToken In oResultList
|
||||
Try
|
||||
|
||||
Reference in New Issue
Block a user