81 lines
2.6 KiB
VB.net
81 lines
2.6 KiB
VB.net
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 |