5 Commits

Author SHA1 Message Date
Jonathan Jenne
e6b9bc30df EDMI.API: Version 1.2.3 2021-09-30 13:18:07 +02:00
Jonathan Jenne
0b7c83626a EDMI.API: Better parsing of Service address 2021-09-30 13:17:44 +02:00
Jonathan Jenne
6c9e459bf7 Jobs: Version 1.8.1 2021-09-30 13:16:45 +02:00
Jonathan Jenne
98a3cf1286 Interfaces: Version 1.5.9 2021-09-30 13:16:30 +02:00
Jonathan Jenne
d73e3e2f28 Interfaces/GraphQL: Improve debugging 2021-09-30 13:15:23 +02:00
8 changed files with 74 additions and 29 deletions

View File

@@ -251,6 +251,7 @@ Partial Class frmMain
Me.txtOperation.Name = "txtOperation" Me.txtOperation.Name = "txtOperation"
Me.txtOperation.Size = New System.Drawing.Size(458, 20) Me.txtOperation.Size = New System.Drawing.Size(458, 20)
Me.txtOperation.TabIndex = 1 Me.txtOperation.TabIndex = 1
Me.txtOperation.Text = "Auftraege"
' '
'btnLogin 'btnLogin
' '

View File

@@ -153,7 +153,9 @@ Public Class frmMain
End Using End Using
End Using End Using
Dim oObj As JObject = JsonConvert.DeserializeObject(oResult) 'Dim oObj As JObject = JsonConvert.DeserializeObject(oResult)
Dim oObj As JObject = JObject.Parse(oResult)
Dim oData As SAPData = ConvertResponse(oResult) Dim oData As SAPData = ConvertResponse(oResult)
_Logger.Debug("Inserting [{0}] items for datapool [{1}]", oData.sapdaten.Count, oDatapool) _Logger.Debug("Inserting [{0}] items for datapool [{1}]", oData.sapdaten.Count, oDatapool)
@@ -203,7 +205,13 @@ Public Class frmMain
End Using End Using
End Using End Using
Dim oObj As JObject = JsonConvert.DeserializeObject(oResult) Dim oPath = "data.auftraege.auftraege"
Dim oObj As JObject = JObject.Parse(oResult)
If _Interface.ReadJSONPathFragmented(oObj, oPath) = False Then
MsgBox($"JSONPath [{oPath}] was not successfully read", MsgBoxStyle.Critical, Text)
End If
'Dim oObj As JObject = JsonConvert.DeserializeObject(oResult)
Dim oIndentedJson As String = JsonConvert.SerializeObject(oObj, Formatting.Indented) Dim oIndentedJson As String = JsonConvert.SerializeObject(oObj, Formatting.Indented)
txtResult.Text = oIndentedJson txtResult.Text = oIndentedJson
@@ -217,6 +225,7 @@ Public Class frmMain
MsgBox(ex.Message, MsgBoxStyle.Critical) MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try End Try
End Sub End Sub
Sub SaveConfig() Sub SaveConfig()
_Config.Config.ConnectionString = txtConnectionString.Text _Config.Config.ConnectionString = txtConnectionString.Text
_Config.Config.BaseUrl = txtBaseUrl.Text _Config.Config.BaseUrl = txtBaseUrl.Text

View File

@@ -44,13 +44,22 @@ Public Class Client
''' Creates a new EDMI Client object ''' Creates a new EDMI Client object
''' </summary> ''' </summary>
''' <param name="LogConfig">LogConfig object</param> ''' <param name="LogConfig">LogConfig object</param>
''' <param name="ServiceAdress">The full service url to connect to, for example: net.tcp://1.1.1.1:1111/some/path</param> ''' <param name="ServiceAdress">The IP address/hostname and port, separated by semicolon or colon, ex localhost:9000</param>
Public Sub New(LogConfig As LogConfig, ServiceAdress As String) Public Sub New(LogConfig As LogConfig, ServiceAdress As String)
_logger = LogConfig.GetLogger() _logger = LogConfig.GetLogger()
Dim oServiceAddress As String = ServiceAdress
Dim oAddressArray() As String
If oServiceAddress.Contains(";") Then
oAddressArray = oServiceAddress.Split(";")
Else
oAddressArray = oServiceAddress.Split(":")
End If
Try Try
Dim oBinding = Channel.GetBinding() Dim oBinding = Channel.GetBinding()
Dim oAddress = New EndpointAddress(ServiceAdress) Dim oAddress = New EndpointAddress($"net.tcp://{oAddressArray(0)}:{oAddressArray(1)}/DigitalData/Services/Main")
Dim oFactory = New ChannelFactory(Of IEDMIServiceChannel)(oBinding, oAddress) Dim oFactory = New ChannelFactory(Of IEDMIServiceChannel)(oBinding, oAddress)
_channelFactory = oFactory _channelFactory = oFactory

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.2.2.0")> <Assembly: AssemblyVersion("1.2.3.0")>
<Assembly: AssemblyFileVersion("1.2.2.0")> <Assembly: AssemblyFileVersion("1.2.3.0")>

View File

@@ -118,6 +118,30 @@ Public Class GraphQLInterface
End Try End Try
End Function End Function
Public Function ReadJSONPathFragmented(pObject As Linq.JObject, pJsonPath As String)
Dim oSplitPath As List(Of String) = pJsonPath.Split(".").ToList()
Dim oCurrentPath As String = String.Empty
For Each oPart In oSplitPath
If oCurrentPath = String.Empty Then
oCurrentPath = oPart
Else
oCurrentPath &= "." & oPart
End If
_logger.Debug("Selecting Path Fragment [{0}]", oCurrentPath)
Try
pObject.SelectToken(oCurrentPath, errorWhenNoMatch:=True)
Catch ex As Exception
_logger.Warn("Path Fragment [{0}] did not return a valid token", oCurrentPath)
Return False
End Try
Next
Return True
End Function
Private Function GetRequest(Url As String, PostData As Byte()) As HttpWebRequest Private Function GetRequest(Url As String, PostData As Byte()) As HttpWebRequest
Try Try
Dim oRequest As HttpWebRequest = WebRequest.Create($"{_baseUrl}{Url}") Dim oRequest As HttpWebRequest = WebRequest.Create($"{_baseUrl}{Url}")

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.5.8.0")> <Assembly: AssemblyVersion("1.5.9.0")>
<Assembly: AssemblyFileVersion("1.5.8.0")> <Assembly: AssemblyFileVersion("1.5.9.0")>

View File

@@ -16,6 +16,8 @@ Public Class GraphQLJob
Inherits JobBase Inherits JobBase
Implements IJob(Of GraphQLArgs) Implements IJob(Of GraphQLArgs)
Private _GraphQL As GraphQLInterface = Nothing
Private Const PLACEHOLDER_STATIC = "STATIC:" Private Const PLACEHOLDER_STATIC = "STATIC:"
Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer) Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer)
@@ -27,18 +29,16 @@ Public Class GraphQLJob
Dim oConfigPath As String = Args.QueryConfigPath Dim oConfigPath As String = Args.QueryConfigPath
Dim oConfigManager As New ConfigManager(Of GraphQLConfig)(_LogConfig, oConfigPath) Dim oConfigManager As New ConfigManager(Of GraphQLConfig)(_LogConfig, oConfigPath)
Dim oInterface As GraphQLInterface
With oConfigManager.Config With oConfigManager.Config
oInterface = New GraphQLInterface(_LogConfig, .BaseUrl, .Email, .Password, .CertificateFingerprint) _GraphQL = New GraphQLInterface(_LogConfig, .BaseUrl, .Email, .Password, .CertificateFingerprint)
End With End With
' Login to get cookie ' Login to get cookie
_Logger.Debug("Logging in") _Logger.Debug("Logging in")
Dim oLoginResponse = oInterface.Login() Dim oLoginResponse = _GraphQL.Login()
' save cookie for future requests ' save cookie for future requests
oInterface.SaveCookies(oLoginResponse.Cookies.Item(0)) _GraphQL.SaveCookies(oLoginResponse.Cookies.Item(0))
_Logger.Debug("Loading Queries") _Logger.Debug("Loading Queries")
@@ -85,7 +85,7 @@ Public Class GraphQLJob
_Logger.Info("Getting data..", oQuery.Name) _Logger.Info("Getting data..", oQuery.Name)
' get the data from GraphQL ' 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 Dim oResult As String
' write data to string ' write data to string
@@ -144,7 +144,7 @@ Public Class GraphQLJob
' logout ' logout
_Logger.Debug("Logging out") _Logger.Debug("Logging out")
Dim oLogoutResponse = oInterface.Logout() Dim oLogoutResponse = _GraphQL.Logout()
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)
Throw 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 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 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 If oResultList Is Nothing Then
_Logger.Warn("HandleResponse: Could not find BasePath: [{0}] for query [{1}]", QueryData.MappingBasePath, QueryData.Name) _Logger.Warn("HandleResponse: Could not find BasePath: [{0}] for query [{1}]", QueryData.MappingBasePath, QueryData.Name)
Return Nothing Return Nothing
End If End If
_Logger.Info("Processing Queue [{0}] with [{1}] Items", QueryData.Name, oResultList.Count) _Logger.Info("HandleResponse: 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
For Each oResultItem As JToken In oResultList For Each oResultItem As JToken In oResultList
Try Try

View File

@@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern ' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
<Assembly: AssemblyVersion("1.8.0.0")> <Assembly: AssemblyVersion("1.8.1.0")>
<Assembly: AssemblyFileVersion("1.8.0.0")> <Assembly: AssemblyFileVersion("1.8.1.0")>