diff --git a/GUIs.Test.GraphQLTest/App.config b/GUIs.Test.GraphQLTest/App.config index 9c1654e0..32746e5a 100644 --- a/GUIs.Test.GraphQLTest/App.config +++ b/GUIs.Test.GraphQLTest/App.config @@ -1,40 +1,44 @@ - + -
+
- + - + - + - + - + - + - + - - + + + + + + diff --git a/GUIs.Test.GraphQLTest/GUIs.Test.GraphQLTest.vbproj b/GUIs.Test.GraphQLTest/GUIs.Test.GraphQLTest.vbproj index 86e6f5ba..d33bfb27 100644 --- a/GUIs.Test.GraphQLTest/GUIs.Test.GraphQLTest.vbproj +++ b/GUIs.Test.GraphQLTest/GUIs.Test.GraphQLTest.vbproj @@ -48,6 +48,12 @@ On + + + + + + False ..\..\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll @@ -68,15 +74,17 @@ ..\..\DDModules\Patterns\bin\Debug\DigitalData.Modules.Patterns.dll - - ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - - ..\packages\NLog.4.7.0\lib\net45\NLog.dll + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll + + diff --git a/GUIs.Test.GraphQLTest/frmMain.Designer.vb b/GUIs.Test.GraphQLTest/frmMain.Designer.vb index 0567bb93..2ca31bcc 100644 --- a/GUIs.Test.GraphQLTest/frmMain.Designer.vb +++ b/GUIs.Test.GraphQLTest/frmMain.Designer.vb @@ -40,6 +40,8 @@ Partial Class frmMain Me.cmbQuery = New System.Windows.Forms.ComboBox() Me.Label7 = New System.Windows.Forms.Label() Me.TabControl1 = New System.Windows.Forms.TabControl() + Me.pageLog = New System.Windows.Forms.TabPage() + Me.lbLog = New DevExpress.XtraEditors.ListBoxControl() Me.pageRaw = New System.Windows.Forms.TabPage() Me.pageQuery = New System.Windows.Forms.TabPage() Me.txtQuery = New System.Windows.Forms.TextBox() @@ -57,12 +59,15 @@ Partial Class frmMain Me.txtCertFingerprint = New System.Windows.Forms.TextBox() Me.Label12 = New System.Windows.Forms.Label() Me.TabControl1.SuspendLayout() + Me.pageLog.SuspendLayout() + CType(Me.lbLog, System.ComponentModel.ISupportInitialize).BeginInit() Me.pageRaw.SuspendLayout() Me.pageQuery.SuspendLayout() Me.SuspendLayout() ' 'Button1 ' + Me.Button1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.Button1.Location = New System.Drawing.Point(826, 386) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(96, 31) @@ -203,6 +208,10 @@ Partial Class frmMain ' 'TabControl1 ' + Me.TabControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.TabControl1.Controls.Add(Me.pageLog) Me.TabControl1.Controls.Add(Me.pageRaw) Me.TabControl1.Controls.Add(Me.pageQuery) Me.TabControl1.Location = New System.Drawing.Point(450, 6) @@ -211,6 +220,25 @@ Partial Class frmMain Me.TabControl1.Size = New System.Drawing.Size(472, 374) Me.TabControl1.TabIndex = 5 ' + 'pageLog + ' + Me.pageLog.Controls.Add(Me.lbLog) + Me.pageLog.Location = New System.Drawing.Point(4, 22) + Me.pageLog.Name = "pageLog" + Me.pageLog.Padding = New System.Windows.Forms.Padding(3) + Me.pageLog.Size = New System.Drawing.Size(464, 348) + Me.pageLog.TabIndex = 2 + Me.pageLog.Text = "Log" + Me.pageLog.UseVisualStyleBackColor = True + ' + 'lbLog + ' + Me.lbLog.Dock = System.Windows.Forms.DockStyle.Fill + Me.lbLog.Location = New System.Drawing.Point(3, 3) + Me.lbLog.Name = "lbLog" + Me.lbLog.Size = New System.Drawing.Size(458, 342) + Me.lbLog.TabIndex = 0 + ' 'pageRaw ' Me.pageRaw.Controls.Add(Me.txtResult) @@ -255,6 +283,7 @@ Partial Class frmMain ' 'btnLogin ' + Me.btnLogin.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.btnLogin.Location = New System.Drawing.Point(724, 386) Me.btnLogin.Name = "btnLogin" Me.btnLogin.Size = New System.Drawing.Size(96, 31) @@ -264,7 +293,9 @@ Partial Class frmMain ' 'ProgressBar1 ' + Me.ProgressBar1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) Me.ProgressBar1.Location = New System.Drawing.Point(12, 394) + Me.ProgressBar1.MinimumSize = New System.Drawing.Size(432, 23) Me.ProgressBar1.Name = "ProgressBar1" Me.ProgressBar1.Size = New System.Drawing.Size(432, 23) Me.ProgressBar1.TabIndex = 6 @@ -386,6 +417,8 @@ Partial Class frmMain Me.Name = "frmMain" Me.Text = "GraphQL Interface" Me.TabControl1.ResumeLayout(False) + Me.pageLog.ResumeLayout(False) + CType(Me.lbLog, System.ComponentModel.ISupportInitialize).EndInit() Me.pageRaw.ResumeLayout(False) Me.pageRaw.PerformLayout() Me.pageQuery.ResumeLayout(False) @@ -428,4 +461,6 @@ Partial Class frmMain Friend WithEvents txtOperation As TextBox Friend WithEvents txtCertFingerprint As TextBox Friend WithEvents Label12 As Label + Friend WithEvents pageLog As TabPage + Friend WithEvents lbLog As DevExpress.XtraEditors.ListBoxControl End Class diff --git a/GUIs.Test.GraphQLTest/frmMain.vb b/GUIs.Test.GraphQLTest/frmMain.vb index 170aff8c..6447c3d8 100644 --- a/GUIs.Test.GraphQLTest/frmMain.vb +++ b/GUIs.Test.GraphQLTest/frmMain.vb @@ -9,9 +9,9 @@ Imports System.Net Imports System.Text.RegularExpressions Public Class frmMain + Private WithEvents _Interface As GraphQLInterface 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 { @@ -73,21 +73,36 @@ Public Class frmMain cmbQuery.SelectedIndex = oIndex _MSSQL = New MSSQLServer(_LogConfig, _Config.Config.ConnectionString) + + LogInfo("Initialization finished") + Catch ex As Exception - _Logger.Error(ex) + LogError(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 SaveConfig() + + lbLog.Items.Clear() + LogInfo("START OF REQUEST") + LogInfo("Looking up certificate by fingerprint..") + _Interface = New GraphQLInterface(_LogConfig, txtBaseUrl.Text, txtUsername.Text, txtPassword.Text, txtCertFingerprint.Text) + LogInfo("Certificate Subject: [{0}]", _Interface.Certificate.Subject) + LogInfo("Certificate Issuer: [{0}]", _Interface.Certificate.Issuer) + LogInfo("Certificate Fingerprint: [{0}]", _Interface.Certificate.Thumbprint) + If _Config.Config.HasProxySet() And _Config.Config.HasProxyCredentialsSet() Then Dim oURI As New Uri($"http://{_Config.Config.ProxyHost}:{_Config.Config.ProxyPort}") Dim oCredentials As New NetworkCredential(_Config.Config.ProxyUsername, _Config.Config.ProxyPassword) @@ -108,18 +123,21 @@ Public Class frmMain _Logger.Debug("Proxy not set.") End If + LogInfo("Starting login..") + Dim oResponse = _Interface.Login _Interface.SaveCookies(oResponse.Cookies.Item(0)) If oResponse.StatusCode = Net.HttpStatusCode.OK Then - MsgBox("Login Successful!", MsgBoxStyle.Information, Text) + LogInfo("Login Successful!") Else - MsgBox("Login failed! Check Certificate and User Credentials!", MsgBoxStyle.Critical, Text) + LogInfo("Login failed! Check Certificate and User Credentials!") End If Catch ex As Exception - _Logger.Error(ex) - MsgBox(ex.Message, MsgBoxStyle.Critical, Text) + LogError(ex) + End Try + LogInfo("END OF REQUEST") End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click @@ -246,8 +264,8 @@ Public Class frmMain Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing Try SaveConfig() - Dim oLogoutResponse = _Interface.Logout() - If oLogoutResponse.StatusCode = Net.HttpStatusCode.OK Then + Dim oLogoutResponse = _Interface?.Logout() + If oLogoutResponse?.StatusCode = Net.HttpStatusCode.OK Then _Logger.Info("Logout successful.") End If Catch ex As Exception @@ -267,4 +285,19 @@ Public Class frmMain _Config.Config.CurrentQuery = cmbQuery.Text _Config.Save() End Sub + + Private Sub LogInfo(pMessage As String, ParamArray pParams As String()) + Dim oMessage = String.Format(pMessage, pParams) + lbLog.Items.Add(oMessage) + _Logger.Info(oMessage) + End Sub + + Private Sub LogError(pException As Exception) + lbLog.Items.Add(pException.Message) + _Logger.Error(pException) + End Sub + + Private Sub _Interface_LogRequested(sender As Object, e As String) Handles _Interface.LogRequested + LogInfo(e) + End Sub End Class diff --git a/GUIs.Test.GraphQLTest/packages.config b/GUIs.Test.GraphQLTest/packages.config index 09a6f4d1..2eed0ec3 100644 --- a/GUIs.Test.GraphQLTest/packages.config +++ b/GUIs.Test.GraphQLTest/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file