This commit is contained in:
PitzM 2024-01-26 11:42:35 +01:00
commit cc38211924
16 changed files with 542 additions and 69 deletions

View File

@ -1,40 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<?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"/>
<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.8"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<userSettings>
<GUIs.Test.GraphQLTest.My.MySettings>
<setting name="ConnectionString" serializeAs="String">
<value/>
<value />
</setting>
<setting name="CertificateFile" serializeAs="String">
<value/>
<value />
</setting>
<setting name="CertificatePass" serializeAs="String">
<value/>
<value />
</setting>
<setting name="Email" serializeAs="String">
<value/>
<value />
</setting>
<setting name="Password" serializeAs="String">
<value/>
<value />
</setting>
<setting name="BaseUrl" serializeAs="String">
<value/>
<value />
</setting>
</GUIs.Test.GraphQLTest.My.MySettings>
</userSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-7.5.0.0" newVersion="7.5.0.0"/>
<assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.5.0.0" newVersion="7.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

View File

@ -48,6 +48,12 @@
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="DevExpress.Data.Desktop.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Printing.v21.2.Core, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Sparkline.v21.2.Core, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Utils.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.XtraEditors.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DigitalData.Modules.Config, Version=1.1.4.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
@ -68,15 +74,17 @@
<HintPath>..\..\DDModules\Patterns\bin\Debug\DigitalData.Modules.Patterns.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.0\lib\net45\NLog.dll</HintPath>
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.0.5\lib\net46\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Data.Linq" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />

View File

@ -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

View File

@ -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

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net461" />
<package id="NLog" version="4.7.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="NLog" version="5.0.5" targetFramework="net48" />
</packages>

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

View File

@ -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

View File

@ -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}
}

View File

@ -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)

View File

@ -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)

View File

@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("Service.JobRunner")>
<Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("2.1.0.0")>
<Assembly: AssemblyCopyright("Copyright © 2024")>
<Assembly: AssemblyTrademark("2.3.0.0")>
<Assembly: ComVisible(False)>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.1.0.0")>
<Assembly: AssemblyVersion("2.3.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>