diff --git a/GUIs.Test.GraphQLTest/frmMain.Designer.vb b/GUIs.Test.GraphQLTest/frmMain.Designer.vb
index 2ca31bcc..e068ef32 100644
--- a/GUIs.Test.GraphQLTest/frmMain.Designer.vb
+++ b/GUIs.Test.GraphQLTest/frmMain.Designer.vb
@@ -191,7 +191,7 @@ Partial Class frmMain
'cmbQuery
'
Me.cmbQuery.FormattingEnabled = True
- Me.cmbQuery.Items.AddRange(New Object() {"SAPDaten", "Custom"})
+ Me.cmbQuery.Items.AddRange(New Object() {"SAPDaten", "SAPAufträge", "Custom"})
Me.cmbQuery.Location = New System.Drawing.Point(106, 352)
Me.cmbQuery.Name = "cmbQuery"
Me.cmbQuery.Size = New System.Drawing.Size(338, 21)
diff --git a/GUIs.Test.GraphQLTest/frmMain.vb b/GUIs.Test.GraphQLTest/frmMain.vb
index 6447c3d8..aeb215bb 100644
--- a/GUIs.Test.GraphQLTest/frmMain.vb
+++ b/GUIs.Test.GraphQLTest/frmMain.vb
@@ -31,6 +31,18 @@ Public Class frmMain
Public gueltig_bis As String
End Class
+ Public Class AuftragData
+ Public auftraege As List(Of AuftragDataItem)
+ End Class
+
+ Public Class AuftragDataItem
+ Public auftragsnr As String
+ Public kdnr As String
+ Public mdnr As String
+ Public name As String
+ Public objektnummer As String
+ End Class
+
Const GRAPHQL_QUERY_SAP_DATA = "
query SAPDaten {
sapdaten(datenpool: __DATA_POOL__) {
@@ -44,6 +56,21 @@ Public Class frmMain
}
"
+ Const GRAPHQL_QUERY_SAP_AUFTRAEGE = "
+ query Auftraege{
+ auftraege(offset: 0, limit: 0){
+ auftraege {
+ auftragsnr
+ kdnr
+ mdnr
+ name
+ kontaktName
+ kontaktMail
+ }
+ }
+ }
+ "
+
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim oStartupPath As String = AppDomain.CurrentDomain.BaseDirectory
@@ -153,6 +180,62 @@ Public Class frmMain
Exit Sub
End If
+ If cmbQuery.Text = "SAPAufträge" Then
+ _MSSQL.ExecuteNonQuery("DELETE FROM TBCUST_SYNC_API_AUFTRAEGE")
+
+ txtResult.Text = String.Empty
+
+ Dim oTotalTotal As Integer = 0
+
+
+ Dim oQuery As String = GRAPHQL_QUERY_SAP_AUFTRAEGE.Trim
+ Dim oDataResponse = _Interface.GetData(oQuery, "Auftraege")
+ 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 oObj As JObject = JObject.Parse(oResult)
+
+ Dim oData As AuftragData = ConvertAuftraegeResponse(oResult)
+
+ Dim oCounter As Integer = 0
+ Dim oTotal As Integer = oData.auftraege.Count
+ ProgressBar1.Maximum = oTotal
+ ProgressBar1.Value = oCounter
+
+ 'For Each oItem As AuftragDataItem In oData.auftraege
+ ' Dim oBeschreibung = Regex.Replace(oItem.name, "'", "''", RegexOptions.IgnoreCase)
+
+ ' Dim oSQL = $"INSERT INTO TBCUST_SYNC_API_AUFTRAEGE (AUFTRAGSNR, KDNR, MDNR, NAME) VALUES ('{oItem.auftragsnr}', '{oItem.kdnr}', '{oItem.mdnr}', '{oItem.name}')"
+ ' Dim oSuccess = _MSSQL.ExecuteNonQuery(oSQL)
+
+ ' If oSuccess Then
+ ' _Logger.Debug("Record [{0}] inserted!", oItem.name)
+ ' End If
+
+ ' oCounter += 1
+ ' ProgressBar1.Value = oCounter
+ 'Next
+
+ Dim oQueryResult = JsonConvert.SerializeObject(oObj, Formatting.None)
+
+ txtResult.Text &= "--------------------------------------------" & vbNewLine
+ txtResult.Text &= oQueryResult & vbNewLine
+
+ Application.DoEvents()
+ File.WriteAllText("E:\graphql.txt", oQueryResult)
+
+ oTotalTotal += oTotal
+
+
+ MsgBox($"Query finished! Lines inserted: [{oTotalTotal}]", MsgBoxStyle.Information, Text)
+ End If
+
If cmbQuery.Text = "SAPDaten" Then
_MSSQL.ExecuteNonQuery("DELETE FROM TBCUST_SYNC_API_SAPDATEN")
@@ -174,7 +257,7 @@ Public Class frmMain
'Dim oObj As JObject = JsonConvert.DeserializeObject(oResult)
Dim oObj As JObject = JObject.Parse(oResult)
- Dim oData As SAPData = ConvertResponse(oResult)
+ Dim oData As SAPData = ConvertSAPDatenResponse(oResult)
_Logger.Debug("Inserting [{0}] items for datapool [{1}]", oData.sapdaten.Count, oDatapool)
@@ -207,12 +290,15 @@ Public Class frmMain
Next
MsgBox($"Query finished! Lines inserted: [{oTotalTotal}]", MsgBoxStyle.Information, Text)
- ElseIf cmbQuery.Text = "Custom" Then
+ End If
+
+ If cmbQuery.Text = "Custom" Then
If txtOperation.Text = String.Empty Then
MsgBox("Please select an operation!", MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
+
Dim oDataResponse = _Interface.GetData(txtQuery.Text, txtOperation.Text)
Dim oResult As String
@@ -223,7 +309,7 @@ Public Class frmMain
End Using
End Using
- Dim oPath = "data.auftraege.auftraege"
+ Dim oPath = "data"
Dim oObj As JObject = JObject.Parse(oResult)
If _Interface.ReadJSONPathFragmented(oObj, oPath) = False Then
MsgBox($"JSONPath [{oPath}] was not successfully read", MsgBoxStyle.Critical, Text)
@@ -234,10 +320,8 @@ Public Class frmMain
txtResult.Text = oIndentedJson
TabControl1.SelectedTab = pageRaw
- Else
- MsgBox("Unknown query!", MsgBoxStyle.Exclamation, Text)
- Exit Sub
End If
+
Catch ex As Exception
_Logger.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical)
@@ -273,7 +357,7 @@ Public Class frmMain
End Try
End Sub
- Public Function ConvertResponse(JsonString As String) As SAPData
+ Public Function ConvertSAPDatenResponse(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)
@@ -281,6 +365,14 @@ Public Class frmMain
Return oSAPData
End Function
+ Public Function ConvertAuftraegeResponse(JsonString As String) As AuftragData
+ Dim oObj As JObject = JObject.Parse(JsonString)("data")("auftraege")
+ Dim oString As String = JsonConvert.SerializeObject(oObj, Formatting.None)
+ Dim oAuftragData As AuftragData = JsonConvert.DeserializeObject(Of AuftragData)(oString)
+
+ Return oAuftragData
+ End Function
+
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbQuery.SelectedIndexChanged
_Config.Config.CurrentQuery = cmbQuery.Text
_Config.Save()
diff --git a/GUIs.Test.TestGUI/TestGUI.vbproj b/GUIs.Test.TestGUI/TestGUI.vbproj
index 3b46931b..f1f66ff0 100644
--- a/GUIs.Test.TestGUI/TestGUI.vbproj
+++ b/GUIs.Test.TestGUI/TestGUI.vbproj
@@ -86,6 +86,10 @@
False
..\..\DDModules\Interfaces\bin\Debug\DigitalData.Modules.Interfaces.dll
+
+ False
+ ..\..\DDModules\Jobs\bin\Debug\DigitalData.Modules.Jobs.dll
+
..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll
@@ -163,6 +167,12 @@
+
+ frmBulkInsert.vb
+
+
+ Form
+
frmChecksum.vb
@@ -266,6 +276,9 @@
+
+ frmBulkInsert.vb
+
frmChecksum.vb
diff --git a/GUIs.Test.TestGUI/frmBulkInsert.Designer.vb b/GUIs.Test.TestGUI/frmBulkInsert.Designer.vb
new file mode 100644
index 00000000..65cc43cc
--- /dev/null
+++ b/GUIs.Test.TestGUI/frmBulkInsert.Designer.vb
@@ -0,0 +1,97 @@
+ _
+Partial Class frmBulkInsert
+ Inherits System.Windows.Forms.Form
+
+ 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
+ _
+ 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.
+ _
+ 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
diff --git a/GUIs.Test.TestGUI/frmBulkInsert.resx b/GUIs.Test.TestGUI/frmBulkInsert.resx
new file mode 100644
index 00000000..1af7de15
--- /dev/null
+++ b/GUIs.Test.TestGUI/frmBulkInsert.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/GUIs.Test.TestGUI/frmBulkInsert.vb b/GUIs.Test.TestGUI/frmBulkInsert.vb
new file mode 100644
index 00000000..dd20e0f1
--- /dev/null
+++ b/GUIs.Test.TestGUI/frmBulkInsert.vb
@@ -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
\ No newline at end of file
diff --git a/GUIs.Test.TestGUI/frmStart.Designer.vb b/GUIs.Test.TestGUI/frmStart.Designer.vb
index 673304ef..5267e2e7 100644
--- a/GUIs.Test.TestGUI/frmStart.Designer.vb
+++ b/GUIs.Test.TestGUI/frmStart.Designer.vb
@@ -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
diff --git a/GUIs.Test.TestGUI/frmStart.vb b/GUIs.Test.TestGUI/frmStart.vb
index 3f7bc298..f0f0587b 100644
--- a/GUIs.Test.TestGUI/frmStart.vb
+++ b/GUIs.Test.TestGUI/frmStart.vb
@@ -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
\ No newline at end of file