Compare commits
7 Commits
32ac19cbd0
...
ffcfd017ce
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffcfd017ce | ||
|
|
b8040cff2b | ||
|
|
f3986bb8fa | ||
|
|
de2bb5e88d | ||
|
|
3d5315d032 | ||
|
|
ab83044664 | ||
|
|
267c90e287 |
15
GUIs.Test.JobTest/Form1.Designer.vb
generated
15
GUIs.Test.JobTest/Form1.Designer.vb
generated
@@ -23,28 +23,41 @@ Partial Class Form1
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Me.Button1 = New System.Windows.Forms.Button()
|
||||
Me.TextBox1 = New System.Windows.Forms.TextBox()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'Button1
|
||||
'
|
||||
Me.Button1.Location = New System.Drawing.Point(253, 101)
|
||||
Me.Button1.Location = New System.Drawing.Point(12, 25)
|
||||
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
|
||||
'
|
||||
'TextBox1
|
||||
'
|
||||
Me.TextBox1.Font = New System.Drawing.Font("Consolas", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
||||
Me.TextBox1.Location = New System.Drawing.Point(93, 25)
|
||||
Me.TextBox1.Multiline = True
|
||||
Me.TextBox1.Name = "TextBox1"
|
||||
Me.TextBox1.Size = New System.Drawing.Size(695, 413)
|
||||
Me.TextBox1.TabIndex = 1
|
||||
'
|
||||
'Form1
|
||||
'
|
||||
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.TextBox1)
|
||||
Me.Controls.Add(Me.Button1)
|
||||
Me.Name = "Form1"
|
||||
Me.Text = "Form1"
|
||||
Me.ResumeLayout(False)
|
||||
Me.PerformLayout()
|
||||
|
||||
End Sub
|
||||
|
||||
Friend WithEvents Button1 As Button
|
||||
Friend WithEvents TextBox1 As TextBox
|
||||
End Class
|
||||
|
||||
@@ -3,7 +3,8 @@ Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Form1
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
Dim oLogConfig As New LogConfig(LogConfig.PathType.Temp)
|
||||
Dim oLogConfig As New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath, Nothing, "Digital Data", "JobTest")
|
||||
oLogConfig.Debug = True
|
||||
Dim oJob As New GraphQLJob(oLogConfig)
|
||||
|
||||
Dim oArgs As New GraphQLArgs() With {
|
||||
@@ -12,5 +13,7 @@ Public Class Form1
|
||||
.QueryConfigPath = "E:\GraphQL"
|
||||
}
|
||||
oJob.Start(oArgs)
|
||||
|
||||
MsgBox("Finished!", MsgBoxStyle.Critical)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
@@ -86,8 +86,10 @@ Public Class ConfigManager(Of T)
|
||||
_UserDirectory = _File.CreateDirectory(UserConfigPath)
|
||||
_UserConfigPath = Path.Combine(_UserDirectory, USER_CONFIG_NAME)
|
||||
|
||||
_ComputerDirectory = _File.CreateDirectory(ComputerConfigPath)
|
||||
_ComputerConfigPath = Path.Combine(_ComputerDirectory, COMPUTER_CONFIG_NAME)
|
||||
If ComputerConfigPath <> String.Empty Then
|
||||
_ComputerDirectory = _File.CreateDirectory(ComputerConfigPath)
|
||||
_ComputerConfigPath = Path.Combine(_ComputerDirectory, COMPUTER_CONFIG_NAME)
|
||||
End If
|
||||
|
||||
If ApplicationStartupPath <> String.Empty Then
|
||||
_AppConfigPath = Path.Combine(ApplicationStartupPath, APP_CONFIG_NAME)
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("0.0.7.1")>
|
||||
<Assembly: AssemblyVersion("0.0.7.2")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
|
||||
@@ -64,21 +64,16 @@ Public Class MSSQLServer
|
||||
|
||||
Private Function GetSQLConnection() As SqlConnection
|
||||
Try
|
||||
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = CurrentSQLConnectionString}
|
||||
Dim oConnection As New SqlConnection(CurrentSQLConnectionString)
|
||||
oConnection.Open()
|
||||
Dim OMyConnection As New SqlClient.SqlConnection(CurrentSQLConnectionString) 'csb.ConnectionString)
|
||||
Dim csb As New SqlClient.SqlConnectionStringBuilder
|
||||
csb.ConnectionString = CurrentSQLConnectionString
|
||||
Dim constr = OMyConnection.ConnectionString
|
||||
Try
|
||||
constr = constr.Replace(csb.Password, "XXXXX")
|
||||
Catch ex As Exception
|
||||
|
||||
Try
|
||||
Dim oConnectionString = CurrentSQLConnectionString.Replace(oBuilder.Password, "XXXXX")
|
||||
_Logger.Debug($"Following Connectionstring is open: {oConnectionString}")
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
'If constr.Contains("Trusted_Connection=True") = False Then
|
||||
' constr = constr.Replace(csb.Password, "XXXXX")
|
||||
'End If
|
||||
_Logger.Debug($"Following Connectionstring is open: {constr}")
|
||||
|
||||
Return oConnection
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
|
||||
@@ -8,6 +8,7 @@ Public Class GraphQLConfig
|
||||
Public Property Queries As New List(Of Query)
|
||||
|
||||
Public Class Query
|
||||
Public Property Name As String
|
||||
Public Property ConnectionString As String = ""
|
||||
Public Property ClearBeforeFill As Boolean = False
|
||||
Public Property QueryString As String = ""
|
||||
|
||||
@@ -4,6 +4,9 @@ Imports DigitalData.Modules.Jobs
|
||||
Imports DigitalData.Modules.Config
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports Newtonsoft.Json.Linq
|
||||
Imports System.Collections.Generic
|
||||
Imports System.Linq
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
Public Class GraphQLJob
|
||||
Inherits JobBase
|
||||
@@ -25,16 +28,17 @@ Public Class GraphQLJob
|
||||
End With
|
||||
|
||||
' Login to get cookie
|
||||
_Logger.Info("Logging in..")
|
||||
_Logger.Debug("Logging in")
|
||||
Dim oLoginResponse = oInterface.Login()
|
||||
|
||||
' save cookie for future requests
|
||||
oInterface.SaveCookies(oLoginResponse.Cookies.Item(0))
|
||||
|
||||
_Logger.Info("Getting the data..")
|
||||
_Logger.Debug("Getting the data")
|
||||
|
||||
For Each oQuery As GraphQLConfig.Query In oConfigManager.Config.Queries
|
||||
Dim oCurrentQuery = oQuery
|
||||
Dim oDatabase As New Database.MSSQLServer(_LogConfig, oQuery.ConnectionString)
|
||||
|
||||
' get the data
|
||||
Dim oDataResponse = oInterface.GetData(oCurrentQuery.QueryString, oCurrentQuery.OperationName)
|
||||
@@ -47,11 +51,11 @@ Public Class GraphQLJob
|
||||
End Using
|
||||
End Using
|
||||
|
||||
oCurrentQuery = HandleResponse(oResult, oCurrentQuery)
|
||||
HandleResponse(oResult, oCurrentQuery, oDatabase)
|
||||
Next
|
||||
|
||||
' logout
|
||||
_Logger.Info("Logging out..")
|
||||
_Logger.Debug("Logging out")
|
||||
Dim oLogoutResponse = oInterface.Logout()
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
@@ -59,19 +63,47 @@ Public Class GraphQLJob
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function HandleResponse(JsonString As String, QueryData As GraphQLConfig.Query) As GraphQLConfig.Query
|
||||
Private Function HandleResponse(JsonString As String, QueryData As GraphQLConfig.Query, DB As Database.MSSQLServer)
|
||||
Dim oObj As JObject = JObject.Parse(JsonString)
|
||||
Dim oResultList = oObj.SelectToken(QueryData.MappingBasePath)
|
||||
Dim oMappings = QueryData.MappingFields
|
||||
|
||||
_Logger.Info("Processing Queue [{0}] with [{1}] Items", QueryData.Name, oResultList.Count)
|
||||
|
||||
If QueryData.ClearBeforeFill Then
|
||||
_Logger.Info("Clearing Table {0} before insert", QueryData.DestinationTable)
|
||||
Try
|
||||
DB.ExecuteNonQuery($"DELETE FROM {QueryData.DestinationTable}")
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End If
|
||||
|
||||
For Each oResultItem In oResultList
|
||||
For Each oMapping In oMappings
|
||||
Dim oValue = oResultItem.SelectToken(oMapping.SourcePath).ToString()
|
||||
Try
|
||||
Dim oValues As New List(Of String)
|
||||
Dim oKeys As New List(Of String)
|
||||
|
||||
' TODO: Build SQL
|
||||
Next
|
||||
For Each oMapping In oMappings
|
||||
Dim oValue = oResultItem.SelectToken(oMapping.SourcePath).ToString()
|
||||
|
||||
'TODO: Insert into db
|
||||
oValues.Add(oValue)
|
||||
oKeys.Add(oMapping.DestinationColumn)
|
||||
Next
|
||||
|
||||
Dim oColumnValues = oValues.
|
||||
Select(Function(Value) Regex.Replace(Value, "'", "''")).
|
||||
Select(Function(Value) $"'{Value}'").
|
||||
ToList()
|
||||
Dim oValueString = String.Join(",", oColumnValues)
|
||||
|
||||
Dim oColumns = String.Join(",", oKeys.ToArray)
|
||||
Dim oSQL As String = $"INSERT INTO {QueryData.DestinationTable} ({oColumns}) VALUES ({oValueString})"
|
||||
|
||||
DB.ExecuteNonQuery(oSQL)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
Return QueryData
|
||||
|
||||
@@ -56,7 +56,13 @@ Imports NLog.Targets
|
||||
''' </remarks>
|
||||
Public Class LogConfig
|
||||
#Region "Private Properties"
|
||||
Private Const OPEN_FILE_CACHE_TIMEOUT As Integer = 5
|
||||
Private Const OPEN_FILE_FLUSH_TIMEOUT As Integer = 5
|
||||
Private Const AUTO_FLUSH As Boolean = True
|
||||
|
||||
Private Const KEEP_FILES_OPEN As Boolean = False
|
||||
Private Const KEEP_FILES_OPEN_DEBUG As Boolean = True
|
||||
|
||||
' MAX_ARCHIVES_FILES works like this (in version 4.5.8):
|
||||
' 0 = keep ALL archives files
|
||||
' 1 = only keep latest logfile and NO archive files
|
||||
@@ -427,7 +433,10 @@ Public Class LogConfig
|
||||
.Layout = LOG_FORMAT_DEBUG,
|
||||
.MaxArchiveFiles = MAX_ARCHIVE_FILES_DEBUG_DETAIL,
|
||||
.ArchiveEvery = ARCHIVE_EVERY,
|
||||
.KeepFileOpen = KEEP_FILES_OPEN
|
||||
.KeepFileOpen = KEEP_FILES_OPEN_DEBUG,
|
||||
.OpenFileCacheTimeout = OPEN_FILE_CACHE_TIMEOUT,
|
||||
.AutoFlush = AUTO_FLUSH,
|
||||
.OpenFileFlushTimeout = OPEN_FILE_FLUSH_TIMEOUT
|
||||
}
|
||||
|
||||
Return debugLog
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("2.0.1.0")>
|
||||
<Assembly: AssemblyVersion("2.0.2.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
|
||||
Reference in New Issue
Block a user