GraphQLTest: Prepare for test

This commit is contained in:
Jonathan Jenne 2020-05-04 14:48:01 +02:00
parent 857f1b1f9f
commit 729b4d8195
12 changed files with 498 additions and 154 deletions

View File

@ -1,6 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="GUIs.Test.GraphQLTest.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<userSettings>
<GUIs.Test.GraphQLTest.My.MySettings>
<setting name="ConnectionString" serializeAs="String">
<value />
</setting>
<setting name="CertificateFile" serializeAs="String">
<value />
</setting>
<setting name="CertificatePass" serializeAs="String">
<value />
</setting>
<setting name="Email" serializeAs="String">
<value />
</setting>
<setting name="Password" serializeAs="String">
<value />
</setting>
<setting name="BaseUrl" serializeAs="String">
<value />
</setting>
</GUIs.Test.GraphQLTest.My.MySettings>
</userSettings>
</configuration>

View File

@ -0,0 +1,8 @@
Public Class Config
Public Property ConnectionString As String = "Server=SERVER;Database=DATABASE;User Id=sa;Password=dd"
Public Property CertificateFile As String = "C:\Path\To\Cert.pfx"
Public Property CertificatePass As String = "CertificatePassword"
Public Property Email As String = "foo.bar@wisag.de"
Public Property Password As String = "Password"
Public Property BaseUrl As String = "https://data.api.wisag.de:8443"
End Class

View File

@ -1,46 +0,0 @@
Imports System.IO
Imports DigitalData.Modules.Interfaces
Imports DigitalData.Modules.Logging
Public Class Form1
Private _LogConfig As LogConfig
Private _Interface As GraphQLInterface
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
_LogConfig = New LogConfig(LogConfig.PathType.CurrentDirectory)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
_Interface = New GraphQLInterface(_LogConfig,
txtBaseUrl.Text,
txtUsername.Text,
txtPassword.Text,
txtCertFile.Text,
txtCertPass.Text)
Dim oLoginResponse = _Interface.Login()
_Interface.SaveCookies(oLoginResponse.Cookies.Item(0))
Dim oDataResponse = _Interface.GetData(txtQuery.Text, "Nls")
Dim oResult As String
Using oStream = oDataResponse.GetResponseStream()
Using oReader As New StreamReader(oStream)
oResult = oReader.ReadToEnd()
End Using
End Using
File.WriteAllText("E:\JenneJ\WISAG\results.json", oResult)
Dim oObj = Newtonsoft.Json.JsonConvert.DeserializeObject(oResult)
Dim oJson = Newtonsoft.Json.JsonConvert.SerializeObject(oObj, Newtonsoft.Json.Formatting.Indented)
txtResults.Text = oJson
Dim oLogoutResponse = _Interface.Logout()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
End Class

View File

@ -84,11 +84,12 @@
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.vb">
<Compile Include="Config.vb" />
<Compile Include="frmMain.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.vb">
<DependentUpon>Form1.vb</DependentUpon>
<Compile Include="frmMain.Designer.vb">
<DependentUpon>frmMain.vb</DependentUpon>
<SubType>Form</SubType>
</Compile>
<Compile Include="My Project\AssemblyInfo.vb" />
@ -108,8 +109,8 @@
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.vb</DependentUpon>
<EmbeddedResource Include="frmMain.resx">
<DependentUpon>frmMain.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
@ -132,6 +133,14 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Modules.Config\Config.vbproj">
<Project>{44982f9b-6116-44e2-85d0-f39650b1ef99}</Project>
<Name>Config</Name>
</ProjectReference>
<ProjectReference Include="..\Modules.Database\Database.vbproj">
<Project>{EAF0EA75-5FA7-485D-89C7-B2D843B03A96}</Project>
<Name>Database</Name>
</ProjectReference>
<ProjectReference Include="..\Modules.Interfaces\Interfaces.vbproj">
<Project>{AB6F09BF-E794-4F6A-94BB-C97C0BA84D64}</Project>
<Name>Interfaces</Name>
@ -141,5 +150,8 @@
<Name>Logging</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="My Project\DataSources\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project>

View File

@ -32,7 +32,7 @@ Namespace My
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.GUIs.Test.GraphQLTest.Form1
Me.MainForm = Global.GUIs.Test.GraphQLTest.frmMain
End Sub
End Class
End Namespace

View File

@ -1,10 +1,10 @@
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.42000
' Dieser Code wurde von einem Tool generiert.
' Laufzeitversion:4.0.30319.42000
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
' der Code erneut generiert wird.
' </auto-generated>
'------------------------------------------------------------------------------
@ -13,57 +13,129 @@ Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
#Region "My.Settings Auto-Save Functionality"
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
#Region "Automatische My.Settings-Speicherfunktion"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property ConnectionString() As String
Get
Return CType(Me("ConnectionString"),String)
End Get
Set
Me("ConnectionString") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property CertificateFile() As String
Get
Return CType(Me("CertificateFile"),String)
End Get
Set
Me("CertificateFile") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property CertificatePass() As String
Get
Return CType(Me("CertificatePass"),String)
End Get
Set
Me("CertificatePass") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property Email() As String
Get
Return CType(Me("Email"),String)
End Get
Set
Me("Email") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property Password() As String
Get
Return CType(Me("Password"),String)
End Get
Set
Me("Password") = value
End Set
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property BaseUrl() As String
Get
Return CType(Me("BaseUrl"),String)
End Get
Set
Me("BaseUrl") = value
End Set
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.GUIs.Test.GraphQLTest.My.MySettings
Get
Return Global.GUIs.Test.GraphQLTest.My.MySettings.Default

View File

@ -1,7 +1,24 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="My" GeneratedClassName="MySettings" UseMySettingsClassName="true">
<Profiles />
<Settings>
<Setting Name="ConnectionString" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="CertificateFile" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="CertificatePass" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="Email" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="Password" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="BaseUrl" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@ -1,5 +1,5 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Partial Class frmMain
Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
@ -22,7 +22,6 @@ Partial Class Form1
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.Button1 = New System.Windows.Forms.Button()
Me.txtBaseUrl = New System.Windows.Forms.TextBox()
Me.txtUsername = New System.Windows.Forms.TextBox()
@ -35,55 +34,64 @@ Partial Class Form1
Me.Label4 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.txtResults = New System.Windows.Forms.TextBox()
Me.txtQuery = New System.Windows.Forms.TextBox()
Me.txtConnectionString = New System.Windows.Forms.TextBox()
Me.Label6 = New System.Windows.Forms.Label()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.Label7 = New System.Windows.Forms.Label()
Me.TabControl1 = New System.Windows.Forms.TabControl()
Me.TabPage1 = New System.Windows.Forms.TabPage()
Me.btnLogin = New System.Windows.Forms.Button()
Me.ProgressBar1 = New System.Windows.Forms.ProgressBar()
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(15, 407)
Me.Button1.Location = New System.Drawing.Point(826, 300)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(318, 31)
Me.Button1.Size = New System.Drawing.Size(96, 31)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Run!"
Me.Button1.UseVisualStyleBackColor = True
'
'txtBaseUrl
'
Me.txtBaseUrl.Location = New System.Drawing.Point(86, 6)
Me.txtBaseUrl.Location = New System.Drawing.Point(106, 6)
Me.txtBaseUrl.Name = "txtBaseUrl"
Me.txtBaseUrl.Size = New System.Drawing.Size(247, 20)
Me.txtBaseUrl.Size = New System.Drawing.Size(338, 20)
Me.txtBaseUrl.TabIndex = 1
Me.txtBaseUrl.Text = "https://data.api.wisag.de:8090"
Me.txtBaseUrl.Text = "https://data.api.wisag.de:8443"
'
'txtUsername
'
Me.txtUsername.Location = New System.Drawing.Point(86, 32)
Me.txtUsername.Location = New System.Drawing.Point(106, 32)
Me.txtUsername.Name = "txtUsername"
Me.txtUsername.Size = New System.Drawing.Size(247, 20)
Me.txtUsername.Size = New System.Drawing.Size(338, 20)
Me.txtUsername.TabIndex = 1
Me.txtUsername.Text = "j.jenne@digitaldata.works"
'
'txtPassword
'
Me.txtPassword.Location = New System.Drawing.Point(86, 58)
Me.txtPassword.Location = New System.Drawing.Point(106, 58)
Me.txtPassword.Name = "txtPassword"
Me.txtPassword.Size = New System.Drawing.Size(247, 20)
Me.txtPassword.Size = New System.Drawing.Size(338, 20)
Me.txtPassword.TabIndex = 1
Me.txtPassword.Text = "DigitalData01!"
'
'txtCertFile
'
Me.txtCertFile.Location = New System.Drawing.Point(86, 84)
Me.txtCertFile.Location = New System.Drawing.Point(106, 84)
Me.txtCertFile.Name = "txtCertFile"
Me.txtCertFile.Size = New System.Drawing.Size(247, 20)
Me.txtCertFile.Size = New System.Drawing.Size(338, 20)
Me.txtCertFile.TabIndex = 1
Me.txtCertFile.Text = "E:\JenneJ\WISAG\jonathanjenne.pfx"
'
'txtCertPass
'
Me.txtCertPass.Location = New System.Drawing.Point(86, 110)
Me.txtCertPass.Location = New System.Drawing.Point(106, 110)
Me.txtCertPass.Name = "txtCertPass"
Me.txtCertPass.Size = New System.Drawing.Size(247, 20)
Me.txtCertPass.Size = New System.Drawing.Size(338, 20)
Me.txtCertPass.TabIndex = 1
Me.txtCertPass.Text = "jonathanjenne"
'
@ -134,44 +142,114 @@ Partial Class Form1
'
'txtResults
'
Me.txtResults.Dock = System.Windows.Forms.DockStyle.Fill
Me.txtResults.Font = New System.Drawing.Font("Consolas", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtResults.Location = New System.Drawing.Point(339, 6)
Me.txtResults.Location = New System.Drawing.Point(3, 3)
Me.txtResults.Multiline = True
Me.txtResults.Name = "txtResults"
Me.txtResults.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.txtResults.Size = New System.Drawing.Size(881, 432)
Me.txtResults.Size = New System.Drawing.Size(458, 260)
Me.txtResults.TabIndex = 3
'
'txtQuery
'txtConnectionString
'
Me.txtQuery.Font = New System.Drawing.Font("Consolas", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtQuery.Location = New System.Drawing.Point(15, 136)
Me.txtQuery.Multiline = True
Me.txtQuery.Name = "txtQuery"
Me.txtQuery.Size = New System.Drawing.Size(318, 265)
Me.txtQuery.TabIndex = 4
Me.txtQuery.Text = resources.GetString("txtQuery.Text")
Me.txtConnectionString.Location = New System.Drawing.Point(106, 136)
Me.txtConnectionString.Multiline = True
Me.txtConnectionString.Name = "txtConnectionString"
Me.txtConnectionString.Size = New System.Drawing.Size(338, 98)
Me.txtConnectionString.TabIndex = 1
'
'Form1
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(12, 139)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(88, 13)
Me.Label6.TabIndex = 2
Me.Label6.Text = "ConnectionString"
'
'ComboBox1
'
Me.ComboBox1.FormattingEnabled = True
Me.ComboBox1.Items.AddRange(New Object() {"SAPDaten"})
Me.ComboBox1.Location = New System.Drawing.Point(106, 240)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(338, 21)
Me.ComboBox1.TabIndex = 4
'
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Location = New System.Drawing.Point(12, 243)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(35, 13)
Me.Label7.TabIndex = 2
Me.Label7.Text = "Query"
'
'TabControl1
'
Me.TabControl1.Controls.Add(Me.TabPage1)
Me.TabControl1.Location = New System.Drawing.Point(450, 6)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size(472, 292)
Me.TabControl1.TabIndex = 5
'
'TabPage1
'
Me.TabPage1.Controls.Add(Me.txtResults)
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Padding = New System.Windows.Forms.Padding(3)
Me.TabPage1.Size = New System.Drawing.Size(464, 266)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "Raw GraphQL Result"
Me.TabPage1.UseVisualStyleBackColor = True
'
'btnLogin
'
Me.btnLogin.Location = New System.Drawing.Point(724, 300)
Me.btnLogin.Name = "btnLogin"
Me.btnLogin.Size = New System.Drawing.Size(96, 31)
Me.btnLogin.TabIndex = 0
Me.btnLogin.Text = "Login"
Me.btnLogin.UseVisualStyleBackColor = True
'
'ProgressBar1
'
Me.ProgressBar1.Location = New System.Drawing.Point(12, 311)
Me.ProgressBar1.Name = "ProgressBar1"
Me.ProgressBar1.Size = New System.Drawing.Size(432, 23)
Me.ProgressBar1.TabIndex = 6
'
'frmMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1232, 450)
Me.Controls.Add(Me.txtQuery)
Me.Controls.Add(Me.txtResults)
Me.ClientSize = New System.Drawing.Size(934, 346)
Me.Controls.Add(Me.ProgressBar1)
Me.Controls.Add(Me.TabControl1)
Me.Controls.Add(Me.ComboBox1)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.txtConnectionString)
Me.Controls.Add(Me.txtCertPass)
Me.Controls.Add(Me.txtCertFile)
Me.Controls.Add(Me.txtPassword)
Me.Controls.Add(Me.txtUsername)
Me.Controls.Add(Me.txtBaseUrl)
Me.Controls.Add(Me.btnLogin)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "GraphQL Interface Test"
Me.Name = "frmMain"
Me.Text = "GraphQL Interface"
Me.TabControl1.ResumeLayout(False)
Me.TabPage1.ResumeLayout(False)
Me.TabPage1.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
@ -189,5 +267,12 @@ Partial Class Form1
Friend WithEvents Label4 As Label
Friend WithEvents Label5 As Label
Friend WithEvents txtResults As TextBox
Friend WithEvents txtQuery As TextBox
Friend WithEvents txtConnectionString As TextBox
Friend WithEvents Label6 As Label
Friend WithEvents ComboBox1 As ComboBox
Friend WithEvents Label7 As Label
Friend WithEvents TabControl1 As TabControl
Friend WithEvents TabPage1 As TabPage
Friend WithEvents btnLogin As Button
Friend WithEvents ProgressBar1 As ProgressBar
End Class

View File

@ -117,22 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="txtQuery.Text" xml:space="preserve">
<value>query Nls{
niederlassungen {
niederlassungen {
mdnr
mdkurzbezeichnung
bezeichnung
sparte {
id
name
__typename
}
__typename
}
__typename
}
}</value>
</data>
</root>

View File

@ -0,0 +1,186 @@
Imports System.IO
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Interfaces
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Config
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Public Class frmMain
Private _LogConfig As LogConfig
Private _Logger As Logger
Private _Interface As GraphQLInterface
Private _MSSQL As MSSQLServer
Private _Config As ConfigManager(Of Config)
Private _Datapools As New List(Of String) From {
"sap_aviation",
"sap_facility",
"sap_holding"
}
Public Class SAPData
Public sapdaten As List(Of SAPDataItem)
End Class
Public Class SAPDataItem
Public buchungskreis As String
Public kostenstelle As String
Public beschreibung As String
Public gueltig_bis As String
End Class
Const GRAPHQL_QUERY_SAP_DATA = "
query SAPDaten {
sapdaten(datenpool: __DATA_POOL__) {
sapdaten {
buchungskreis
kostenstelle
beschreibung
gueltig_bis
}
}
}
"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim oStartupPath As String = AppDomain.CurrentDomain.BaseDirectory
_LogConfig = New LogConfig(LogConfig.PathType.CustomPath, oStartupPath) With {
.Debug = True
}
_Logger = _LogConfig.GetLogger()
_Config = New ConfigManager(Of Config)(_LogConfig, oStartupPath)
txtBaseUrl.Text = _Config.Config.BaseUrl
txtUsername.Text = _Config.Config.Email
txtPassword.Text = _Config.Config.Password
txtCertFile.Text = _Config.Config.CertificateFile
txtCertPass.Text = _Config.Config.CertificatePass
txtConnectionString.Text = _Config.Config.ConnectionString
ComboBox1.SelectedIndex = 0
_MSSQL = New MSSQLServer(_LogConfig, _Config.Config.ConnectionString)
Catch ex As Exception
_Logger.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
End Try
End Sub
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
Try
_Interface = New GraphQLInterface(_LogConfig,
txtBaseUrl.Text,
txtUsername.Text,
txtPassword.Text,
txtCertFile.Text,
txtCertPass.Text)
Dim oResponse = _Interface.Login
_Interface.SaveCookies(oResponse.Cookies.Item(0))
If oResponse.StatusCode = Net.HttpStatusCode.OK Then
MsgBox("Login Successful!", MsgBoxStyle.Information, Text)
Else
MsgBox("Login failed! Check Certificate and User Credentials!", MsgBoxStyle.Critical, Text)
End If
Catch ex As Exception
_Logger.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
If _Interface Is Nothing Then
MsgBox("Please login first!", MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
If ComboBox1.SelectedIndex = -1 Then
MsgBox("Please select a query!", MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
If ComboBox1.Text = "SAPDaten" Then
_MSSQL.ExecuteNonQuery("DELETE FROM TBCUST_SYNC_API_SAPDATEN")
txtResults.Text = String.Empty
For Each oDatapool In _Datapools
Dim oQuery As String = GRAPHQL_QUERY_SAP_DATA.Trim.Replace("__DATA_POOL__", oDatapool)
Dim oDataResponse = _Interface.GetData(oQuery, "SAPDaten")
Dim oResult As String
Using oStream = oDataResponse.GetResponseStream()
Using oReader As New StreamReader(oStream)
oResult = oReader.ReadToEnd()
End Using
End Using
Dim oObj As JObject = JsonConvert.DeserializeObject(oResult)
Dim oData As SAPData = ConvertResponse(oResult)
_Logger.Debug("Inserting [{0}] items for datapool [{1}]", oData.sapdaten.Count, oDatapool)
Dim oCounter As Integer = 0
Dim oTotal As Integer = oData.sapdaten.Count
ProgressBar1.Maximum = oTotal
ProgressBar1.Value = oCounter
For Each oItem As SAPDataItem In oData.sapdaten
Dim oSQL = $"INSERT INTO TBCUST_SYNC_API_SAPDATEN (BESCHREIBUNG, BUCHUNGSKREIS, KOSTENSTELLE, GUELTIG_BIS) VALUES ('{oItem.beschreibung}', '{oItem.buchungskreis}', '{oItem.kostenstelle}', '{oItem.gueltig_bis}')"
Dim oSuccess = _MSSQL.ExecuteNonQuery(oSQL)
If oSuccess Then
_Logger.Debug("Record [{0}] inserted!", oItem.beschreibung)
End If
Next
txtResults.Text &= "--------------------------------------------" & vbNewLine
txtResults.Text &= $"--- Datapool: {oDatapool}" & vbNewLine
txtResults.Text &= JsonConvert.SerializeObject(oObj, Formatting.Indented) & vbNewLine
oCounter += 1
ProgressBar1.Value = oCounter
Next
Else
MsgBox("Unknown query!", MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
Catch ex As Exception
_Logger.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Try
Dim oLogoutResponse = _Interface.Logout()
If oLogoutResponse.StatusCode = Net.HttpStatusCode.OK Then
_Logger.Info("Logout successful.")
End If
_Config.Config.ConnectionString = txtConnectionString.Text
_Config.Config.BaseUrl = txtBaseUrl.Text
_Config.Config.CertificateFile = txtCertFile.Text
_Config.Config.CertificatePass = txtCertPass.Text
_Config.Config.Email = txtUsername.Text
_Config.Config.Password = txtPassword.Text
_Config.Save()
Catch ex As Exception
_Logger.Error(ex)
End Try
End Sub
Public Function ConvertResponse(JsonString As String) As SAPData
Dim oObj As JObject = JObject.Parse(JsonString)("data")("sapdaten")
Dim oString As String = JsonConvert.SerializeObject(oObj, Formatting.None)
Dim oSAPData As SAPData = JsonConvert.DeserializeObject(Of SAPData)(oString)
Return oSAPData
End Function
End Class

View File

@ -1,5 +1,5 @@
Public Class QueryData
Public Query As String
Public OperationName As String
Public Variables As New Object
Public query As String
Public operationName As String
Public variables As New Object
End Class

View File

@ -71,11 +71,12 @@ Public Class GraphQLInterface
Public Function GetData(Query As String, OperationName As String) As HttpWebResponse
Try
Dim oQueryData As New QueryData() With {
.OperationName = OperationName,
.Query = Query,
.Variables = New Object
}
Dim oBytes = ToBytes(JsonConvert.SerializeObject(oQueryData))
.operationName = OperationName,
.query = Query,
.variables = New Object
}
Dim oJson = JsonConvert.SerializeObject(oQueryData)
Dim oBytes = ToBytes(oJson)
Dim oRequest = GetRequest("/graphql", oBytes)
Using stream = oRequest.GetRequestStream()
@ -107,7 +108,7 @@ Public Class GraphQLInterface
Private Function GetCookies() As CookieContainer
If _cookieJar Is Nothing Then
_cookieJar = New CookieContainer()
_cookieJar = New CookieContainer(300, 20, 8192)
End If
Return _cookieJar