GUIs.Test: Rewrite graphql test tool, add BulkInsert form

This commit is contained in:
Jonathan Jenne
2024-01-23 13:50:04 +01:00
parent e4ce86dd3c
commit 6573ab3e7c
8 changed files with 429 additions and 9 deletions

View File

@@ -86,6 +86,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\DDModules\Interfaces\bin\Debug\DigitalData.Modules.Interfaces.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Modules.Jobs, Version=2.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\DDModules\Jobs\bin\Debug\DigitalData.Modules.Jobs.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Modules.Logging">
<HintPath>..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
</Reference>
@@ -163,6 +167,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ApplicationEvents.vb" />
<Compile Include="frmBulkInsert.Designer.vb">
<DependentUpon>frmBulkInsert.vb</DependentUpon>
</Compile>
<Compile Include="frmBulkInsert.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmChecksum.Designer.vb">
<DependentUpon>frmChecksum.vb</DependentUpon>
</Compile>
@@ -266,6 +276,9 @@
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="frmBulkInsert.resx">
<DependentUpon>frmBulkInsert.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmChecksum.resx">
<DependentUpon>frmChecksum.vb</DependentUpon>
</EmbeddedResource>

View File

@@ -0,0 +1,97 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmBulkInsert
Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Wird vom Windows Form-Designer benötigt.
Private components As System.ComponentModel.IContainer
'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.txtQueryId = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.txtQueryFile = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(22, 155)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
Me.Button1.UseVisualStyleBackColor = True
'
'txtQueryId
'
Me.txtQueryId.Location = New System.Drawing.Point(22, 40)
Me.txtQueryId.Name = "txtQueryId"
Me.txtQueryId.Size = New System.Drawing.Size(276, 20)
Me.txtQueryId.TabIndex = 1
Me.txtQueryId.Text = "16"
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(19, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(47, 13)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Query Id"
'
'txtQueryFile
'
Me.txtQueryFile.Location = New System.Drawing.Point(22, 96)
Me.txtQueryFile.Name = "txtQueryFile"
Me.txtQueryFile.Size = New System.Drawing.Size(276, 20)
Me.txtQueryFile.TabIndex = 3
Me.txtQueryFile.Text = "E:\graphql.txt"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(19, 73)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(54, 13)
Me.Label2.TabIndex = 2
Me.Label2.Text = "Query File"
'
'frmBulkInsert
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(800, 450)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.txtQueryFile)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.txtQueryId)
Me.Controls.Add(Me.Button1)
Me.Name = "frmBulkInsert"
Me.Text = "frmBulkInsert"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Button1 As Button
Friend WithEvents txtQueryId As TextBox
Friend WithEvents Label1 As Label
Friend WithEvents txtQueryFile As TextBox
Friend WithEvents Label2 As Label
End Class

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,81 @@
Imports System.Data.SqlClient
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Filesystem
Imports DigitalData.Modules.Jobs
Imports DigitalData.Modules.Logging
Public Class frmBulkInsert
Private LogConfig As LogConfig
Private Logger As Logger
Private Database As MSSQLServer
Private Writer As GraphQLWriter
Private Model As GraphQLModel
Private Const TABLE_NAME = "TBTEST_BULKINSERT"
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer)
' Dieser Aufruf ist für den Designer erforderlich.
InitializeComponent()
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
LogConfig = pLogConfig
Logger = LogConfig.GetLogger()
Database = pDatabase
Writer = New GraphQLWriter(LogConfig, Database)
Model = New GraphQLModel(LogConfig, Database)
End Sub
Private Sub frmBulkInsert_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim oSW As New Stopwatch()
oSW.Start()
Dim oQueryId As Integer = Integer.Parse(txtQueryId.Text)
Dim oJsonString = IO.File.ReadAllText(txtQueryFile.Text)
Dim oQueries = Model.GetQueryList()
Dim oQuery = oQueries.Where(Function(q) q.Id = oQueryId).FirstOrDefault()
Writer.WriteNewQueryData(oJsonString, oQuery, "Test GraphQL")
oSW.Stop()
MsgBox("Time: " & oSW.ElapsedMilliseconds / 1000 & "s")
End Sub
Private Function BulkInsert()
Dim oSQL As String = "SELECT AUFTRAGSNR, name, MDNR, KDNR FROM TBCUST_SYNC_API_AUFTRAEGE"
Dim oTable = Database.GetDatatable(oSQL)
Dim oSw As New Stopwatch()
oSw.Start()
Using oConnection = Database.GetConnection()
Using oBulkCopy = New SqlBulkCopy(oConnection)
oBulkCopy.DestinationTableName = "TBCUST_SYNC_API_AUFTRAEGE_COPY"
oBulkCopy.ColumnMappings.Add(New SqlBulkCopyColumnMapping("AUFTRAGSNR", "AUFTRAGSNR"))
oBulkCopy.ColumnMappings.Add(New SqlBulkCopyColumnMapping("name", "name"))
oBulkCopy.ColumnMappings.Add(New SqlBulkCopyColumnMapping("MDNR", "MDNR"))
oBulkCopy.ColumnMappings.Add(New SqlBulkCopyColumnMapping("KDNR", "KDNR"))
Try
oBulkCopy.WriteToServer(oTable)
Catch ex As Exception
Logger.Error(ex)
End Try
End Using
End Using
End Function
End Class

View File

@@ -33,6 +33,7 @@ Partial Class frmStart
Me.Button9 = New System.Windows.Forms.Button()
Me.Button10 = New System.Windows.Forms.Button()
Me.btnObjectProperties = New System.Windows.Forms.Button()
Me.Button11 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Button1
@@ -134,6 +135,15 @@ Partial Class frmStart
Me.btnObjectProperties.Text = "Object Properties"
Me.btnObjectProperties.UseVisualStyleBackColor = True
'
'Button11
'
Me.Button11.Location = New System.Drawing.Point(254, 326)
Me.Button11.Name = "Button11"
Me.Button11.Size = New System.Drawing.Size(236, 60)
Me.Button11.TabIndex = 2
Me.Button11.Text = "Bulk Insert"
Me.Button11.UseVisualStyleBackColor = True
'
'frmStart
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -142,6 +152,7 @@ Partial Class frmStart
Me.Controls.Add(Me.Button10)
Me.Controls.Add(Me.Button9)
Me.Controls.Add(Me.Button6)
Me.Controls.Add(Me.Button11)
Me.Controls.Add(Me.btnObjectProperties)
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.Button4)
@@ -167,4 +178,5 @@ Partial Class frmStart
Friend WithEvents Button9 As Button
Friend WithEvents Button10 As Button
Friend WithEvents btnObjectProperties As Button
Friend WithEvents Button11 As Button
End Class

View File

@@ -12,7 +12,7 @@ Public Class frmStart
.ProductName = "TestGUI",
.CompanyName = "Digital Data"
})
Database = New MSSQLServer(LogConfig, "Data Source=SDD-VMP04-SQL17\DD_DEVELOP01;Initial Catalog=DD_ECM;Persist Security Info=True;User ID=sa;Password=dd")
Database = New MSSQLServer(LogConfig, "Data Source=SDD-VMP04-SQL17\WISAG;Initial Catalog=DD_ECM;Persist Security Info=True;User ID=sa;Password=dd")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
@@ -65,4 +65,9 @@ Public Class frmStart
Dim oForm As New frmObjectProperties(LogConfig, Database)
oForm.ShowDialog()
End Sub
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
Dim oForm As New frmBulkInsert(LogConfig, Database)
oForm.ShowDialog()
End Sub
End Class