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..e068ef32 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) @@ -186,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) @@ -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..aeb215bb 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 { @@ -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 @@ -73,21 +100,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 +150,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 @@ -135,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") @@ -156,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) @@ -189,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 @@ -205,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) @@ -216,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) @@ -246,8 +348,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 @@ -255,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) @@ -263,8 +365,31 @@ 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() 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 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 diff --git a/Service.JobRunner/Config.vb b/Service.JobRunner/Config.vb index c1836561..f5acd6e9 100644 --- a/Service.JobRunner/Config.vb +++ b/Service.JobRunner/Config.vb @@ -2,24 +2,6 @@ Public Class Config Public Property Debug As Boolean = False - Public Property SQLConnectionString As String = "" - - Public Property Firebird As New FirebirdConfig Public Property Jobs As New List(Of JobConfig) - - 'Public Enum JobType - ' ADSync - ' GraphQL - ' Test - 'End Enum - - - - Public Class FirebirdConfig - Public Property DataSource As String = "172.24.12.41" - Public Property Database As String = "172.24.12.41:E:\DB\Firebird\Databases\EDMI_TEMPLATE\EDMI_MASTER.FDB" - Public Property User As String = "sysdba" - Public Property Password As String = "dd" - End Class End Class diff --git a/Service.JobRunner/JobRunner.vb b/Service.JobRunner/JobRunner.vb index 72cfd780..c5783a3f 100644 --- a/Service.JobRunner/JobRunner.vb +++ b/Service.JobRunner/JobRunner.vb @@ -11,17 +11,15 @@ Imports Quartz.Logging Public Class JobRunner Private ReadOnly _LogConfig As LogConfig Private ReadOnly _Logger As DigitalData.Modules.Logging.Logger - Private ReadOnly _firebird As Firebird Private ReadOnly _mssql As MSSQLServer Private ReadOnly _config As Config Private _factory As StdSchedulerFactory Private _scheduler As IScheduler - Public Sub New(pLogConfig As LogConfig, pConfig As Config, pMSSQL As MSSQLServer, pFirebird As Firebird) + Public Sub New(pLogConfig As LogConfig, pConfig As Config, pMSSQL As MSSQLServer) _LogConfig = pLogConfig _Logger = pLogConfig.GetLogger() - _firebird = pFirebird _mssql = pMSSQL _config = pConfig End Sub @@ -64,7 +62,7 @@ Public Class JobRunner Dim oJobConfig As JobConfig = JobConfigParser.ParseConfig(pJobConfig) Dim oJobData As New JobDataMap From { {"LogConfig", _LogConfig}, - {"Firebird", _firebird}, + {"Firebird", Nothing}, {"MSSQL", _mssql}, {"Args", oJobConfig.Args} } diff --git a/Service.JobRunner/JobRunnerService.vb b/Service.JobRunner/JobRunnerService.vb index a4d770b8..849f9087 100644 --- a/Service.JobRunner/JobRunnerService.vb +++ b/Service.JobRunner/JobRunnerService.vb @@ -9,7 +9,6 @@ Public Class JobRunnerService Private _logger As Logger Private _config As ConfigManager(Of Config) Private _mssql As MSSQLServer - Private _firebird As Firebird Private _jobrunner As JobRunner Protected Overrides Sub OnStart(ByVal args() As String) @@ -22,16 +21,13 @@ Public Class JobRunnerService _config = New ConfigManager(Of Config)(_logConfig, My.Application.Info.DirectoryPath) _logConfig.Debug = _config.Config.Debug - Dim oFirebird = _config.Config.Firebird - _logger.Debug("Connecting to Database..") _mssql = New MSSQLServer(_logConfig, _config.Config.SQLConnectionString) - _firebird = New Firebird(_logConfig, oFirebird.DataSource, oFirebird.Database, oFirebird.User, oFirebird.Password) _logger.Debug("Starting Jobrunner..") - _jobrunner = New JobRunner(_logConfig, _config.Config, _mssql, _firebird) + _jobrunner = New JobRunner(_logConfig, _config.Config, _mssql) _jobrunner.Start() Catch ex As Exception _logger.Error(ex) diff --git a/Service.JobRunner/Jobs/ADJob.vb b/Service.JobRunner/Jobs/ADJob.vb index f85ca378..5a31c2e8 100644 --- a/Service.JobRunner/Jobs/ADJob.vb +++ b/Service.JobRunner/Jobs/ADJob.vb @@ -9,7 +9,6 @@ Public Class ADJob Public Function Execute(context As IJobExecutionContext) As Task Implements Quartz.IJob.Execute Dim oJobData = context.MergedJobDataMap Dim oLogConfig As LogConfig = oJobData.Item("LogConfig") - Dim oFirebird As Firebird = oJobData.Item("Firebird") Dim oArgs As Dictionary(Of String, String) = oJobData.Item("Args") Dim oADJobArgs = New ADSyncArgs() @@ -25,16 +24,14 @@ Public Class ADJob oADJobArgs.GroupFilter = oArgs.Item("GroupFilter") End If - If oArgs.ContainsKey("DisableFirebird") AndAlso oArgs.Item("DisableFirebird") = "True" Then - oFirebird = Nothing - End If + Dim oFirebird = Nothing Dim oMSSQL As MSSQLServer = oJobData.Item("MSSQL") If oArgs.ContainsKey("DisableMSSQL") AndAlso oArgs.Item("DisableMSSQL") = "True" Then oMSSQL = Nothing End If - Dim oADSyncJob As New ADSyncJob(oLogConfig, oFirebird, oMSSQL) + Dim oADSyncJob As New ADSyncJob(oLogConfig, oMSSQL) oADSyncJob.Start(oADJobArgs) Return Task.FromResult(True) diff --git a/Service.JobRunner/My Project/AssemblyInfo.vb b/Service.JobRunner/My Project/AssemblyInfo.vb index 6f4dd46c..87d37dcf 100644 --- a/Service.JobRunner/My Project/AssemblyInfo.vb +++ b/Service.JobRunner/My Project/AssemblyInfo.vb @@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices - - + + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - +