Compare commits
3 Commits
39f4cc5152
...
737320d886
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
737320d886 | ||
|
|
9b47cb9ffb | ||
|
|
16193b08cf |
13
GUIs.Test.TestGUI/frmRelations.Designer.vb
generated
13
GUIs.Test.TestGUI/frmRelations.Designer.vb
generated
@@ -22,16 +22,29 @@ Partial Class frmRelations
|
||||
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Me.Button1 = New System.Windows.Forms.Button()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'Button1
|
||||
'
|
||||
Me.Button1.Location = New System.Drawing.Point(12, 12)
|
||||
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
|
||||
'
|
||||
'frmRelations
|
||||
'
|
||||
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.Button1)
|
||||
Me.Name = "frmRelations"
|
||||
Me.Text = "frmRelations"
|
||||
Me.ResumeLayout(False)
|
||||
|
||||
End Sub
|
||||
|
||||
Friend WithEvents Button1 As Button
|
||||
End Class
|
||||
|
||||
@@ -5,6 +5,9 @@ Imports DigitalData.Services.EDMIService
|
||||
Public Class frmRelations
|
||||
Private DB As MSSQLServer
|
||||
Private LogConfig As LogConfig
|
||||
Private JobResult As JobResult
|
||||
Private JobListener As JobListener
|
||||
Private DetailRow As DataRow
|
||||
|
||||
Private Sub frmRelations_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath)
|
||||
@@ -18,13 +21,18 @@ Public Class frmRelations
|
||||
oGroupUser.TableName = "TBDD_GROUPS_USER"
|
||||
|
||||
Dim oCronDetails As DataTable = DB.GetDatatable("SELECT * FROM TBAPPSERV_CRON_DETAIL WHERE DT_NAME = 'TBDD_USER'")
|
||||
JobListener = New JobListener(LogConfig, DB, oDataSet)
|
||||
|
||||
Dim oListener As New DigitalData.Services.EDMIService.JobListener(LogConfig, DB, oDataSet)
|
||||
oListener.SaveDataTables(New DigitalData.Services.EDMIService.JobResult() With {
|
||||
DetailRow = oCronDetails.Rows.Item(0)
|
||||
JobResult = New JobResult() With {
|
||||
.Table = oUsers,
|
||||
.TableRelationColumn = "GUID",
|
||||
.ChildTable = oGroupUser,
|
||||
.ChildRelationColumn = "USER_ID"
|
||||
}, oCronDetails.Rows.Item(0))
|
||||
}
|
||||
End Sub
|
||||
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
JobListener.SaveDataTables(JobResult, DetailRow)
|
||||
End Sub
|
||||
End Class
|
||||
@@ -17,8 +17,9 @@ Public Class ConfigManager(Of T)
|
||||
Private ReadOnly _UserConfigPath As String
|
||||
Private ReadOnly _ComputerDirectory As String
|
||||
Private ReadOnly _ComputerConfigPath As String
|
||||
Private ReadOnly _AppConfigPath As String
|
||||
Private ReadOnly _AppConfigDirectory As String
|
||||
Private ReadOnly _AppConfigPath As String
|
||||
|
||||
|
||||
Private ReadOnly _TestMode As Boolean = False
|
||||
|
||||
@@ -33,6 +34,19 @@ Public Class ConfigManager(Of T)
|
||||
GetType(GlobalSettingAttribute)
|
||||
}
|
||||
|
||||
''' <summary>
|
||||
''' Signals that all properties will be written to (and read from) the UserConfig.xml
|
||||
'''
|
||||
''' If Value is `True`:
|
||||
''' - AppConfig.xml does NOT exist
|
||||
''' - ComputerConfig.xml does NOT exist
|
||||
''' - ConnectionStrings will be saved to or read from UserConfig.xml
|
||||
'''
|
||||
''' If Value is `False`:
|
||||
''' - No ConnectionStrings will be saved to or read from UserConfig.xml
|
||||
'''
|
||||
''' Can be overwritten by optional parameter `ForceUserConfig`
|
||||
''' </summary>
|
||||
Private _WriteAllValuesToUserConfig As Boolean = False
|
||||
|
||||
''' <summary>
|
||||
@@ -93,7 +107,7 @@ Public Class ConfigManager(Of T)
|
||||
End If
|
||||
|
||||
If ApplicationStartupPath <> String.Empty Then
|
||||
_Logger.Debug($"Appconfig is being used: {ApplicationStartupPath}")
|
||||
_Logger.Debug($"AppConfig is being used: [{ApplicationStartupPath}]")
|
||||
_AppConfigPath = Path.Combine(ApplicationStartupPath, APP_CONFIG_NAME)
|
||||
End If
|
||||
|
||||
@@ -137,9 +151,7 @@ Public Class ConfigManager(Of T)
|
||||
Dim oType As Type = GetType(T)
|
||||
Dim oExcludedAttributeTypes = IIf(IsNothing(ExcludedAttributeTypes), New List(Of Type), ExcludedAttributeTypes)
|
||||
Dim oProperties = oType.GetProperties().
|
||||
Where(Function(p)
|
||||
Return p.CanRead And p.CanWrite
|
||||
End Function).
|
||||
Where(Function(p) p.CanRead And p.CanWrite).
|
||||
Where(Function(p)
|
||||
For Each oAttributeType As Type In oExcludedAttributeTypes
|
||||
If Attribute.IsDefined(p, oAttributeType) Then
|
||||
@@ -190,10 +202,13 @@ Public Class ConfigManager(Of T)
|
||||
Try
|
||||
Dim oAppConfig = ReadFromFile(_AppConfigPath)
|
||||
CopyValues(oAppConfig, Config)
|
||||
|
||||
_Logger.Info("AppConfig exists and will be used. [{0}]", _AppConfigPath)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("ApplicationConfig could not be loaded!")
|
||||
End Try
|
||||
|
||||
_WriteAllValuesToUserConfig = False
|
||||
Else
|
||||
_Logger.Debug("ApplicationConfig does not exist.")
|
||||
@@ -204,10 +219,14 @@ Public Class ConfigManager(Of T)
|
||||
End Function
|
||||
|
||||
Private Function LoadComputerConfig(ByVal Config As T) As T
|
||||
If File.Exists(_ComputerConfigPath) Then
|
||||
If _WriteAllValuesToUserConfig = False Then
|
||||
_Logger.Info("AppConfig exists. ComputerConfig will NOT be used")
|
||||
ElseIf File.Exists(_ComputerConfigPath) Then
|
||||
Try
|
||||
Dim oComputerConfig = ReadFromFile(_ComputerConfigPath)
|
||||
CopyValues(oComputerConfig, Config)
|
||||
|
||||
_Logger.Info("ComputerConfig exists and will be used. [{0}]", _ComputerConfigPath)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("Computer config could not be loaded!")
|
||||
@@ -237,6 +256,8 @@ Public Class ConfigManager(Of T)
|
||||
CopyValues(oUserConfig, Config, _ExcludedAttributes)
|
||||
End If
|
||||
End If
|
||||
|
||||
_Logger.Info("UserConfig exists and will be used. [{0}]", _UserConfigPath)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("User config could not be loaded!")
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.9.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.9.0")>
|
||||
<Assembly: AssemblyVersion("1.0.10.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.10.0")>
|
||||
|
||||
@@ -26,16 +26,35 @@ Public Class JobListener
|
||||
Dataset = ResultDataSet
|
||||
End Sub
|
||||
|
||||
Public Sub ReplaceExistingTable(Name As String, Table As DataTable, DataSet As DataSet)
|
||||
Public Sub ReplaceExistingTable(Name As String, Table As DataTable, DataSet As DataSet, Optional ChildTable As DataTable = Nothing)
|
||||
Dim oDatatableNameTemp As String = Name & "-TEMP"
|
||||
|
||||
_Logger.Debug("DataTable [{0}] exists, renaming and replacing in DataSet", Name)
|
||||
' Rename the new table, add TEMP suffix
|
||||
Table.TableName = oDatatableNameTemp
|
||||
|
||||
' If child table exists, remove all connections to it
|
||||
If ChildTable IsNot Nothing Then
|
||||
' Get name for relations and constraints
|
||||
Dim oRelationName = GetRelationName(Name, ChildTable.TableName)
|
||||
|
||||
' Remove the relation
|
||||
Dim oRelation As DataRelation = DataSet.Relations.Item(oRelationName)
|
||||
DataSet.Relations.Remove(oRelation)
|
||||
|
||||
' Remove the constraint
|
||||
Dim oConstraint As Constraint = ChildTable.Constraints.Item(oRelationName)
|
||||
ChildTable.Constraints.Remove(oConstraint)
|
||||
End If
|
||||
|
||||
' Remove the temp table if it exists
|
||||
If DataSet.Tables.Contains(oDatatableNameTemp) Then
|
||||
DataSet.Tables.Remove(Table)
|
||||
End If
|
||||
|
||||
' Add the new table to the dataset
|
||||
DataSet.Tables.Add(Table)
|
||||
' Remove the old table
|
||||
DataSet.Tables.Remove(Name)
|
||||
|
||||
' Rename the new table
|
||||
DataSet.Tables.Item(oDatatableNameTemp).TableName = Name
|
||||
End Sub
|
||||
@@ -46,11 +65,15 @@ Public Class JobListener
|
||||
DataSet.Tables.Add(Table)
|
||||
End Sub
|
||||
|
||||
Public Function GetRelationName(ParentTableName As String, ChildTableName As String) As String
|
||||
Return $"{ParentTableName}-{ChildTableName}"
|
||||
End Function
|
||||
|
||||
Public Sub AddRelation(ParentTableName As String, ParentColumnName As String, ChildTableName As String, ChildColumnName As String)
|
||||
Dim oChild As DataTable = Dataset.Tables.Item(ChildTableName)
|
||||
Dim oParent As DataTable = Dataset.Tables.Item(ParentTableName)
|
||||
|
||||
Dim oRelationName As String = $"{ParentTableName}-{ChildTableName}"
|
||||
Dim oRelationName As String = GetRelationName(ParentTableName, ChildTableName)
|
||||
Dim oParentColumn As DataColumn = oParent.Columns.Item(ParentColumnName)
|
||||
Dim oChildColumn As DataColumn = oChild.Columns.Item(ChildColumnName)
|
||||
|
||||
@@ -90,24 +113,18 @@ Public Class JobListener
|
||||
Public Sub SaveDataTables(Result As JobResult, DetailRow As DataRow)
|
||||
Try
|
||||
Dim oTable As DataTable = Result.Table
|
||||
|
||||
Dim oName As String = DetailRow.Item("DT_NAME")
|
||||
Dim oDetailId As Integer = DetailRow.Item("GUID")
|
||||
Dim oDatatableNameTemp As String = oName & "-TEMP"
|
||||
|
||||
If Dataset.Tables.Contains(oName) Then
|
||||
' Replace existing table
|
||||
If Result.ChildTable IsNot Nothing Then
|
||||
ReplaceExistingTable(Result.ChildTable.TableName, Result.ChildTable, Dataset)
|
||||
End If
|
||||
ReplaceExistingTable(oName, oTable, Dataset)
|
||||
|
||||
If Result.ChildTable IsNot Nothing Then
|
||||
Dim oRelation = Dataset.Relations.Item($"{oTable.TableName}-{Result.ChildTable.TableName}")
|
||||
|
||||
If oRelation IsNot Nothing Then
|
||||
Dataset.Relations.Remove(oRelation)
|
||||
End If
|
||||
|
||||
ReplaceExistingTable(oName, oTable, Dataset, Result.ChildTable)
|
||||
AddRelation(oName, Result.TableRelationColumn, Result.ChildTable.TableName, Result.ChildRelationColumn)
|
||||
Else
|
||||
ReplaceExistingTable(oName, oTable, Dataset)
|
||||
End If
|
||||
Else
|
||||
AddNewTable(oName, oTable, Dataset)
|
||||
|
||||
Reference in New Issue
Block a user