-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfigeditor.html
More file actions
1219 lines (1081 loc) · 55.3 KB
/
Copy pathconfigeditor.html
File metadata and controls
1219 lines (1081 loc) · 55.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ConfigEditor - Beep Data Management Engine Documentation</title>
<link rel="stylesheet" href="sphinx-style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
</head>
<body>
<!-- Mobile Menu Toggle -->
<button class="mobile-menu-toggle" onclick="toggleSidebar()">
<i class="bi bi-list"></i>
</button>
<!-- Theme Toggle -->
<button class="theme-toggle" onclick="toggleTheme()" title="Toggle theme">
<i class="bi bi-sun-fill" id="theme-icon"></i>
</button>
<div class="container">
<!-- Sidebar -->
<aside class="sidebar" id="sidebar">
<!-- Navigation will be loaded dynamically -->
</aside>
<!-- Main Content -->
<main class="content">
<div class="content-wrapper">
<!-- Breadcrumb -->
<nav class="breadcrumb-nav">
<a href="index.html">Home</a>
<span>></span>
<a href="#">Editor Classes</a>
<span>></span>
<span>ConfigEditor</span>
</nav>
<!-- Page Header -->
<div class="page-header">
<h1>ConfigEditor</h1>
<p class="page-subtitle">Centralized configuration management system for all Beep Data Management Engine components</p>
</div>
<!-- Table of Contents -->
<div class="toc">
<h3>Table of Contents</h3>
<ul>
<li><a href="#overview">Overview</a></li>
<li><a href="#architecture">Specialized Manager Architecture</a></li>
<li><a href="#initialization">Initialization & Setup</a></li>
<li><a href="#data-connections">Data Connection Management</a></li>
<li><a href="#component-configuration">Component Configuration</a></li>
<li><a href="#entity-mapping">Entity & Mapping Management</a></li>
<li><a href="#query-management">Query Management</a></li>
<li><a href="#configuration-persistence">Configuration Persistence</a></li>
<li><a href="#examples">Usage Examples</a></li>
<li><a href="#best-practices">Best Practices</a></li>
</ul>
</div>
<!-- Overview -->
<section id="overview" class="section">
<h2>Overview</h2>
<p>
The <code>ConfigEditor</code> class is the centralized configuration management system for the
Beep Data Management Engine. It provides a unified interface for managing data connections,
component configurations, entity mappings, queries, and application settings. The class has been
refactored to use specialized managers for different configuration responsibilities, improving
maintainability and separation of concerns.
</p>
<div class="success">
<strong>Core Purpose</strong>
<p>ConfigEditor serves as the single source of truth for all configuration data, ensuring consistency and providing a structured approach to configuration management across the entire engine.</p>
</div>
<div class="feature-grid">
<div class="feature-card">
<h3>Connection Management</h3>
<p>Comprehensive data source connection configuration and management</p>
</div>
<div class="feature-card">
<h3>Component Configuration</h3>
<p>Driver configurations, assembly definitions, and plugin management</p>
</div>
<div class="feature-card">
<h3>Entity & Mapping</h3>
<p>Entity structure definitions and field mapping configurations</p>
</div>
<div class="feature-card">
<h3>Query Repository</h3>
<p>Saved queries, SQL repositories, and database-specific query management</p>
</div>
</div>
</section>
<!-- Architecture -->
<section id="architecture" class="section">
<h2>Specialized Manager Architecture</h2>
<p>ConfigEditor uses a modular architecture with specialized managers that handle specific aspects of configuration:</p>
<div class="api-section">
<div class="api-header" onclick="toggleSection(this)">
<span class="toggle-icon">?</span>
<strong>Specialized Managers</strong>
</div>
<div class="api-content">
<table class="property-table">
<thead>
<tr><th>Manager</th><th>Responsibility</th><th>Key Operations</th></tr>
</thead>
<tbody>
<tr>
<td>ConfigPathManager</td>
<td>Path and directory management</td>
<td>Directory creation, path resolution, folder structure</td>
</tr>
<tr>
<td>DataConnectionManager</td>
<td>Data source connections</td>
<td>Connection CRUD, validation, persistence</td>
</tr>
<tr>
<td>QueryManager</td>
<td>SQL queries and repositories</td>
<td>Query storage, SQL generation, query templates</td>
</tr>
<tr>
<td>EntityMappingManager</td>
<td>Entity structures and mappings</td>
<td>Entity definitions, field mappings, schema management</td>
</tr>
<tr>
<td>ComponentConfigManager</td>
<td>Component and driver configurations</td>
<td>Driver configs, assembly definitions, workflows</td>
</tr>
<tr>
<td>MigrationHistoryManager</td>
<td>Migration history tracking</td>
<td>Load/save migration history, append migration records</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="code-example">
<h3>ConfigEditor Architecture</h3>
<pre><code class="language-csharp">public class ConfigEditor : IConfigEditor
{
// Specialized managers
private readonly ConfigPathManager _pathManager;
private readonly DataConnectionManager _connectionManager;
private readonly QueryManager _queryManager;
private readonly EntityMappingManager _entityManager;
private readonly ComponentConfigManager _componentManager;
private readonly MigrationHistoryManager _migrationHistoryManager;
// Core properties
public BeepConfigType ConfigType { get; set; }
public string ConfigPath { get; set; }
public ConfigandSettings Config { get; set; }
// Delegated properties
public List<ConnectionProperties> DataConnections { get; set; }
public List<ConnectionDriversConfig> DataDriversClasses { get; set; }
public List<QuerySqlRepo> QueryList { get; set; }
public List<WorkFlow> WorkFlows { get; set; }
}</code></pre>
</div>
</section>
<!-- Initialization -->
<section id="initialization" class="section">
<h2>Initialization & Setup</h2>
<div class="api-section">
<div class="api-header" onclick="toggleSection(this)">
<span class="toggle-icon">?</span>
<strong>Configuration Types</strong>
</div>
<div class="api-content">
<table class="property-table">
<thead>
<tr><th>Configuration Type</th><th>Purpose</th><th>Features Enabled</th></tr>
</thead>
<tbody>
<tr>
<td>BeepConfigType.Application</td>
<td>Full-featured application configuration</td>
<td>All folders, workflows, reports, AI scripts, addins</td>
</tr>
<tr>
<td>BeepConfigType.DataConnector</td>
<td>Minimal configuration for data operations only</td>
<td>Connections, drivers, basic config only</td>
</tr>
<tr>
<td>BeepConfigType.SingleApp</td>
<td>Single application instance</td>
<td>Application features with single instance support</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="code-example">
<h3>ConfigEditor Initialization</h3>
<pre><code class="language-csharp">// Full application configuration
var configEditor = new ConfigEditor(
logger, // IDMLogger instance
errorObject, // IErrorsInfo for error handling
jsonLoader, // IJsonLoader for serialization
folderPath: @"C:\MyApp\Data", // Base path (optional)
containerFolder: "MyContainer", // Container name (optional)
configType: BeepConfigType.Application
);
// Data connector only (minimal setup)
var dataConfigEditor = new ConfigEditor(
logger,
errorObject,
jsonLoader,
configType: BeepConfigType.DataConnector
);
// The ConfigEditor will automatically:
// 1. Create necessary directory structure
// 2. Initialize all specialized managers
// 3. Load existing configurations
// 4. Set up default values</code></pre>
</div>
<div class="tip">
<strong>Initialization Features</strong>
<ul>
<li><strong>Automatic Directory Creation:</strong> Creates all necessary folders based on configuration type</li>
<li><strong>Platform-Aware Paths:</strong> Uses appropriate system directories if no path specified</li>
<li><strong>Configuration Migration:</strong> Handles path changes and configuration updates</li>
<li><strong>Error Recovery:</strong> Graceful handling of missing or corrupted configuration files</li>
</ul>
</div>
</section>
<!-- Data Connections -->
<section id="data-connections" class="section">
<h2>Data Connection Management</h2>
<div class="api-section">
<div class="api-header" onclick="toggleSection(this)">
<span class="toggle-icon">?</span>
<strong>Connection Operations</strong>
</div>
<div class="api-content">
<div class="method-signature">
<code><span class="return-type">bool</span> AddDataConnection(<span class="parameter-type">ConnectionProperties</span> connection)</code>
</div>
<p>Adds a new data connection to the configuration with validation.</p>
<div class="method-signature">
<code><span class="return-type">bool</span> UpdateDataConnection(<span class="parameter-type">ConnectionProperties</span> source, <span class="parameter-type">string</span> targetGuidId)</code>
</div>
<p>Updates an existing connection using GUID identifier for safe updates.</p>
<div class="method-signature">
<code><span class="return-type">bool</span> DataConnectionExist(<span class="parameter-type">string</span> connectionName)</code>
</div>
<p>Checks if a connection with the specified name already exists.</p>
<div class="method-signature">
<code><span class="return-type">bool</span> RemoveDataConnection(<span class="parameter-type">string</span> connectionName)</code>
</div>
<p>Removes a connection by name with proper cleanup.</p>
<div class="method-signature">
<code><span class="return-type">void</span> SaveDataconnectionsValues()</code>
</div>
<p>Persists all connection configurations to storage.</p>
</div>
</div>
<div class="code-example">
<h3>Connection Management Examples</h3>
<pre><code class="language-csharp">// Create a new SQL Server connection
var sqlConnection = new ConnectionProperties
{
ConnectionName = "ProductionDB",
DatabaseType = DataSourceType.SqlServer,
ConnectionString = "Server=prod-server;Database=ProductionDB;Integrated Security=true;",
Category = DatasourceCategory.RDBMS,
GuidID = Guid.NewGuid().ToString(),
Host = "prod-server",
Database = "ProductionDB",
Port = 1433
};
// Add the connection
if (configEditor.AddDataConnection(sqlConnection))
{
Console.WriteLine("? Connection added successfully");
// Save to persistent storage
configEditor.SaveDataconnectionsValues();
}
// Check if a connection exists
if (configEditor.DataConnectionExist("ProductionDB"))
{
Console.WriteLine("Connection already exists");
}
// Load all existing connections
var allConnections = configEditor.LoadDataConnectionsValues();
foreach (var conn in allConnections)
{
Console.WriteLine($"Found connection: {conn.ConnectionName} ({conn.DatabaseType})");
}
// Update a connection
var updatedConnection = new ConnectionProperties
{
ConnectionName = "ProductionDB",
DatabaseType = DataSourceType.SqlServer,
ConnectionString = "Server=new-server;Database=ProductionDB;Integrated Security=true;",
Category = DatasourceCategory.RDBMS,
Host = "new-server",
Database = "ProductionDB",
Port = 1433
};
if (configEditor.UpdateDataConnection(updatedConnection, sqlConnection.GuidID))
{
Console.WriteLine("? Connection updated successfully");
configEditor.SaveDataconnectionsValues();
}
// Remove a connection
if (configEditor.RemoveDataConnection("ProductionDB"))
{
Console.WriteLine("? Connection removed successfully");
configEditor.SaveDataconnectionsValues();
}</code></pre>
</div>
</section>
<!-- Component Configuration -->
<section id="component-configuration" class="section">
<h2>Component Configuration</h2>
<div class="api-section">
<div class="api-header" onclick="toggleSection(this)">
<span class="toggle-icon">?</span>
<strong>Driver & Component Management</strong>
</div>
<div class="api-content">
<div class="method-signature">
<code><span class="return-type">int</span> AddDriver(<span class="parameter-type">ConnectionDriversConfig</span> driver)</code>
</div>
<p>Adds a new data source driver configuration.</p>
<div class="method-signature">
<code><span class="return-type">void</span> SaveConnectionDriversConfigValues()</code>
</div>
<p>Persists all driver configurations to storage.</p>
<div class="method-signature">
<code><span class="return-type">List<ConnectionDriversConfig></span> LoadConnectionDriversConfigValues()</code>
</div>
<p>Loads all driver configurations from storage.</p>
</div>
</div>
<div class="api-section">
<div class="api-header" onclick="toggleSection(this)">
<span class="toggle-icon">?</span>
<strong>Component Collections</strong>
</div>
<div class="api-content">
<table class="property-table">
<thead>
<tr><th>Collection</th><th>Type</th><th>Purpose</th></tr>
</thead>
<tbody>
<tr><td>DataDriversClasses</td><td>List<ConnectionDriversConfig></td><td>Database driver configurations</td></tr>
<tr><td>DataSourcesClasses</td><td>List<AssemblyClassDefinition></td><td>Data source implementation classes</td></tr>
<tr><td>WorkFlowActions</td><td>List<AssemblyClassDefinition></td><td>Workflow action components</td></tr>
<tr><td>Addins</td><td>List<AssemblyClassDefinition></td><td>Plugin and add-in definitions</td></tr>
<tr><td>ReportWritersClasses</td><td>List<AssemblyClassDefinition></td><td>Report generation components</td></tr>
<tr><td>AppComponents</td><td>List<AssemblyClassDefinition></td><td>Application-specific components</td></tr>
</tbody>
</table>
</div>
</div>
<div class="code-example">
<h3>Driver Configuration Example</h3>
<pre><code class="language-csharp">// Add a custom driver configuration
var customDriver = new ConnectionDriversConfig
{
GuidID = Guid.NewGuid().ToString(),
PackageName = "CustomPostgreSQLDriver",
DriverClass = "CustomPostgreSQLDataSource",
version = "1.0.0.0",
dllname = "MyCustomDrivers.dll",
classHandler = "MyCustomDrivers.CustomPostgreSQLDataSource",
DatasourceType = DataSourceType.Postgre,
DatasourceCategory = DatasourceCategory.RDBMS,
ConnectionString = "Host={Host};Port={Port};Database={Database};Username={UserID};Password={Password}",
ADOType = true,
CreateLocal = false,
InMemory = false
};
// Add the driver
int driverIndex = configEditor.AddDriver(customDriver);
if (driverIndex >= 0)
{
Console.WriteLine($"? Driver added at index {driverIndex}");
// Save driver configurations
configEditor.SaveConnectionDriversConfigValues();
}
// Register a data source class
var dataSourceClass = new AssemblyClassDefinition
{
className = "CustomPostgreSQLDataSource",
PackageName = "MyCustomDrivers",
type = "TheTechIdea.Beep.DataBase.IDataSource",
AddinType = "DataSource",
DllPath = "MyCustomDrivers.dll",
Order = 1,
version = "1.0.0.0"
};
configEditor.DataSourcesClasses.Add(dataSourceClass);
// Register workflow actions
var workflowAction = new AssemblyClassDefinition
{
className = "CustomDataValidationAction",
PackageName = "MyWorkflowActions",
type = "TheTechIdea.Beep.Workflow.IWorkFlowAction",
AddinType = "WorkFlowAction",
DllPath = "MyWorkflowActions.dll"
};
configEditor.WorkFlowActions.Add(workflowAction);</code></pre>
</div>
</section>
<!-- Entity Mapping -->
<section id="entity-mapping" class="section">
<h2>Entity & Mapping Management</h2>
<div class="api-section">
<div class="api-header" onclick="toggleSection(this)">
<span class="toggle-icon">?</span>
<strong>Entity Structure Operations</strong>
</div>
<div class="api-content">
<div class="method-signature">
<code><span class="return-type">void</span> SaveEntityStructure(<span class="parameter-type">string</span> filePath, <span class="parameter-type">EntityStructure</span> entity)</code>
</div>
<p>Saves an entity structure definition to a specific file path.</p>
<div class="method-signature">
<code><span class="return-type">EntityStructure</span> LoadEntityStructure(<span class="parameter-type">string</span> filePath, <span class="parameter-type">string</span> entityName, <span class="parameter-type">string</span> dataSourceId)</code>
</div>
<p>Loads an entity structure from storage with validation.</p>
<div class="method-signature">
<code><span class="return-type">bool</span> EntityStructureExist(<span class="parameter-type">string</span> filePath, <span class="parameter-type">string</span> entityName, <span class="parameter-type">string</span> dataSourceId)</code>
</div>
<p>Checks if an entity structure definition exists.</p>
</div>
</div>
<div class="api-section">
<div class="api-header" onclick="toggleSection(this)">
<span class="toggle-icon">?</span>
<strong>Mapping Operations</strong>
</div>
<div class="api-content">
<div class="method-signature">
<code><span class="return-type">void</span> SaveMappingValues(<span class="parameter-type">string</span> entityName, <span class="parameter-type">string</span> dataSource, <span class="parameter-type">EntityDataMap</span> mapping)</code>
</div>
<p>Saves entity data mapping configuration for field transformations.</p>
<div class="method-signature">
<code><span class="return-type">EntityDataMap</span> LoadMappingValues(<span class="parameter-type">string</span> entityName, <span class="parameter-type">string</span> dataSource)</code>
</div>
<p>Loads entity mapping configuration for data transformations.</p>
<div class="method-signature">
<code><span class="return-type">void</span> SaveMappingSchemaValue(<span class="parameter-type">string</span> schemaName, <span class="parameter-type">Map_Schema</span> mapping)</code>
</div>
<p>Saves complete schema mapping definitions.</p>
</div>
</div>
<div class="code-example">
<h3>Entity Structure Management</h3>
<pre><code class="language-csharp">// Create an entity structure
var customerEntity = new EntityStructure
{
EntityName = "Customers",
DatasourceEntityName = "Customers",
DataSourceID = "ProductionDB",
SchemaOrOwnerOrDatabase = "dbo",
Fields = new List<EntityField>
{
new EntityField
{
FieldName = "CustomerID",
Fieldtype = "System.Int32",
Size1 = 4,
AllowDBNull = false,
IsKey = true,
IsIdentity = true
},
new EntityField
{
FieldName = "CustomerName",
Fieldtype = "System.String",
Size1 = 100,
AllowDBNull = false
},
new EntityField
{
FieldName = "Email",
Fieldtype = "System.String",
Size1 = 255,
AllowDBNull = true
},
new EntityField
{
FieldName = "CreatedDate",
Fieldtype = "System.DateTime",
AllowDBNull = false,
DefaultValue = "GETDATE()"
}
}
};
// Save the entity structure
string entityPath = Path.Combine(configEditor.Config.EntitiesPath, "Customers.json");
configEditor.SaveEntityStructure(entityPath, customerEntity);
// Check if entity exists
if (configEditor.EntityStructureExist(entityPath, "Customers", "ProductionDB"))
{
// Load the entity structure
var loadedEntity = configEditor.LoadEntityStructure(entityPath, "Customers", "ProductionDB");
Console.WriteLine($"? Loaded entity with {loadedEntity.Fields.Count} fields");
}
// Create a field mapping for ETL operations
var entityMapping = new EntityDataMap
{
EntityName = "CustomerMapping",
SourceEntityName = "LegacyCustomers",
DestinationEntityName = "Customers",
FieldMapping = new List<EntityDataMap_DTL>
{
new EntityDataMap_DTL
{
SourceFieldName = "CUST_ID",
DestinationFieldName = "CustomerID",
DataType = "System.Int32",
MappingType = "Direct"
},
new EntityDataMap_DTL
{
SourceFieldName = "CUST_NAME",
DestinationFieldName = "CustomerName",
DataType = "System.String",
MappingType = "Direct"
},
new EntityDataMap_DTL
{
SourceFieldName = "EMAIL_ADDR",
DestinationFieldName = "Email",
DataType = "System.String",
MappingType = "Transform",
TransformRule = "LOWER(TRIM({value}))"
}
}
};
// Save the mapping
configEditor.SaveMappingValues("Customers", "ProductionDB", entityMapping);
// Load the mapping
var loadedMapping = configEditor.LoadMappingValues("Customers", "ProductionDB");
Console.WriteLine($"? Loaded mapping with {loadedMapping.FieldMapping.Count} field mappings");</code></pre>
</div>
</section>
<!-- Query Management -->
<section id="query-management" class="section">
<h2>Query Management</h2>
<div class="api-section">
<div class="api-header" onclick="toggleSection(this)">
<span class="toggle-icon">?</span>
<strong>Query Operations</strong>
</div>
<div class="api-content">
<div class="method-signature">
<code><span class="return-type">string</span> GetSql(<span class="parameter-type">Sqlcommandtype</span> cmdType, <span class="parameter-type">string</span> tableName, <span class="parameter-type">string</span> schemaName, <span class="parameter-type">string</span> filterParameters, <span class="parameter-type">DataSourceType</span> databaseType)</code>
</div>
<p>Generates SQL queries based on command type and database-specific syntax.</p>
<div class="method-signature">
<code><span class="return-type">List<string></span> GetSqlList(<span class="parameter-type">Sqlcommandtype</span> cmdType, <span class="parameter-type">string</span> tableName, <span class="parameter-type">string</span> schemaName, <span class="parameter-type">string</span> filterParameters, <span class="parameter-type">DataSourceType</span> databaseType)</code>
</div>
<p>Returns multiple SQL variations for complex operations.</p>
<div class="method-signature">
<code><span class="return-type">void</span> SaveQueryFile()</code>
</div>
<p>Persists all query configurations to storage.</p>
<div class="method-signature">
<code><span class="return-type">List<QuerySqlRepo></span> LoadQueryFile()</code>
</div>
<p>Loads saved query repository from storage.</p>
</div>
</div>
<div class="code-example">
<h3>Query Repository Management</h3>
<pre><code class="language-csharp">// Add custom queries to the repository
var customQueries = new List<QuerySqlRepo>
{
new QuerySqlRepo
{
ID = Guid.NewGuid().ToString(),
QueryName = "ActiveCustomers",
SqlQuery = "SELECT * FROM Customers WHERE IsActive = 1",
DatabaseType = DataSourceType.SqlServer,
CommandType = Sqlcommandtype.SELECT
},
new QuerySqlRepo
{
ID = Guid.NewGuid().ToString(),
QueryName = "CustomersByRegion",
SqlQuery = "SELECT * FROM Customers WHERE Region = @Region",
DatabaseType = DataSourceType.SqlServer,
CommandType = Sqlcommandtype.SELECT,
Parameters = "@Region"
},
new QuerySqlRepo
{
ID = Guid.NewGuid().ToString(),
QueryName = "InsertCustomer",
SqlQuery = "INSERT INTO Customers (CustomerName, Email, Region) VALUES (@Name, @Email, @Region)",
DatabaseType = DataSourceType.SqlServer,
CommandType = Sqlcommandtype.INSERT,
Parameters = "@Name,@Email,@Region"
}
};
// Add queries to the configuration
configEditor.QueryList.AddRange(customQueries);
// Save the query repository
configEditor.SaveQueryFile();
// Generate SQL using the repository
string selectSql = configEditor.GetSql(
Sqlcommandtype.SELECT,
"Customers",
"dbo",
"WHERE IsActive = 1",
DataSourceType.SqlServer
);
Console.WriteLine($"Generated SQL: {selectSql}");
// Get multiple SQL variations
var sqlVariations = configEditor.GetSqlList(
Sqlcommandtype.SELECT,
"Orders",
"dbo",
"WHERE OrderDate >= @StartDate",
DataSourceType.SqlServer
);
foreach (string sql in sqlVariations)
{
Console.WriteLine($"SQL Variation: {sql}");
}
// Load existing queries
var loadedQueries = configEditor.LoadQueryFile();
console.WriteLine($"? Loaded {loadedQueries.Count} saved queries");
// Use custom query with parameters
string customSql = configEditor.GetSqlFromCustomQuery(
Sqlcommandtype.SELECT,
"Customers",
"SELECT * FROM Customers WHERE Region = '{Region}' AND Status = 'Active'",
DataSourceType.SqlServer
);
Console.WriteLine($"Custom SQL: {customSql}");</code></pre>
</div>
</section>
<!-- Configuration Persistence -->
<section id="configuration-persistence" class="section">
<h2>Configuration Persistence</h2>
<div class="api-section">
<div class="api-header" onclick="toggleSection(this)">
<span class="toggle-icon">?</span>
<strong>Persistence Operations</strong>
</div>
<div class="api-content">
<div class="method-signature">
<code><span class="return-type">void</span> SaveConfigValues()</code>
</div>
<p>Saves the main configuration settings to Config.json.</p>
<div class="method-signature">
<code><span class="return-type">ConfigandSettings</span> LoadConfigValues()</code>
</div>
<p>Loads configuration settings from storage.</p>
<div class="method-signature">
<code><span class="return-type">void</span> SaveLocation()</code>
</div>
<p>Saves the configuration location to system registry for application discovery.</p>
<div class="method-signature">
<code><span class="return-type">bool</span> IsLocationSaved()</code>
</div>
<p>Checks if the configuration location has been properly saved.</p>
</div>
</div>
<div class="success">
<strong>? Configuration Files</strong>
<p>ConfigEditor manages multiple configuration files automatically:</p>
<ul>
<li><strong>Config.json:</strong> Main application configuration</li>
<li><strong>DataConnections.json:</strong> All data source connections</li>
<li><strong>ConnectionConfig.json:</strong> Driver configurations</li>
<li><strong>QueryList.json:</strong> Saved query repository</li>
<li><strong>CategoryFolders.json:</strong> Folder organization</li>
<li><strong>WorkFlow/DataWorkFlow.json:</strong> Workflow definitions</li>
<li><strong>Reportslist.json:</strong> Report list configuration</li>
<li><strong>reportsDefinition.json:</strong> Report template definitions</li>
</ul>
</div>
<div class="code-example">
<h3>Configuration Backup & Restore</h3>
<pre><code class="language-csharp">// Create a comprehensive configuration backup
public static class ConfigurationManager
{
public static void BackupConfiguration(IConfigEditor configEditor, string backupPath)
{
try
{
// Create backup directory
if (!Directory.Exists(backupPath))
{
Directory.CreateDirectory(backupPath);
}
// Backup main configuration
configEditor.SaveConfigValues();
File.Copy(
Path.Combine(configEditor.ConfigPath, "Config.json"),
Path.Combine(backupPath, $"Config_{DateTime.Now:yyyyMMdd_HHmmss}.json")
);
// Backup data connections
configEditor.SaveDataconnectionsValues();
File.Copy(
Path.Combine(configEditor.ConfigPath, "DataConnections.json"),
Path.Combine(backupPath, $"DataConnections_{DateTime.Now:yyyyMMdd_HHmmss}.json")
);
// Backup driver configurations
configEditor.SaveConnectionDriversConfigValues();
File.Copy(
Path.Combine(configEditor.ConfigPath, "ConnectionConfig.json"),
Path.Combine(backupPath, $"Drivers_{DateTime.Now:yyyyMMdd_HHmmss}.json")
);
// Backup query repository
configEditor.SaveQueryFile();
File.Copy(
Path.Combine(configEditor.ConfigPath, "QueryList.json"),
Path.Combine(backupPath, $"Queries_{DateTime.Now:yyyyMMdd_HHmmss}.json")
);
Console.WriteLine($"? Configuration backup completed: {backupPath}");
}
catch (Exception ex)
{
Console.WriteLine($"? Backup failed: {ex.Message}");
}
}
public static void RestoreConfiguration(IConfigEditor configEditor, string backupPath)
{
try
{
// Restore configurations from backup
var configFiles = Directory.GetFiles(backupPath, "*.json");
foreach (var file in configFiles)
{
var fileName = Path.GetFileName(file);
string targetPath = null;
if (fileName.StartsWith("Config_", StringComparison.OrdinalIgnoreCase))
targetPath = Path.Combine(configEditor.ConfigPath, "Config.json");
else if (fileName.StartsWith("DataConnections_", StringComparison.OrdinalIgnoreCase))
targetPath = Path.Combine(configEditor.ConfigPath, "DataConnections.json");
else if (fileName.StartsWith("Drivers_", StringComparison.OrdinalIgnoreCase))
targetPath = Path.Combine(configEditor.ConfigPath, "ConnectionConfig.json");
else if (fileName.StartsWith("Queries_", StringComparison.OrdinalIgnoreCase))
targetPath = Path.Combine(configEditor.ConfigPath, "QueryList.json");
if (targetPath == null)
continue;
File.Copy(file, targetPath, overwrite: true);
Console.WriteLine($"? Restored: {Path.GetFileName(targetPath)}");
}
// Reload configurations
configEditor.LoadConfigValues();
configEditor.LoadDataConnectionsValues();
configEditor.LoadConnectionDriversConfigValues();
configEditor.LoadQueryFile();
Console.WriteLine("? Configuration restore completed");
}
catch (Exception ex)
{
Console.WriteLine($"? Restore failed: {ex.Message}");
}
}
}</code></pre>
</div>
</section>
<!-- DMTypeBuilder: Dynamic Type Generation -->
<section id="dmtypebuilder" class="section">
<h2>DMTypeBuilder — Dynamic Type Generation</h2>
<p><code>DMTypeBuilder</code> creates runtime dynamic types from <code>EntityField</code> definitions using both <code>System.Reflection.Emit</code> and <code>RoslynCompiler</code>:</p>
<pre><code class="language-csharp">public static class DMTypeBuilder
{
public static IDMEEditor DMEEditor { get; set; }
public static Type MyType { get; set; }
public static object MyObject { get; set; }
public static Dictionary<string, string> DataSourceNameSpace { get; set; }
// Type cache for performance
public static readonly Dictionary<string, Type> typeCache;
// Primary: creates dynamic object from EntityField list
public static object CreateNewObject(IDMEEditor editor, string classNamespace,
string dataSourceName, string typeName, List<EntityField> fields);
// Overload without dataSourceName
public static object CreateNewObject(IDMEEditor editor, string classNamespace,
string typeName, List<EntityField> fields);
// Create dynamic type from an existing object (reflection-based)
public static Type CreateDynamicTypeFromObject(object sourceObject,
string typeName = "DynamicType");
}</code></pre>
<h3>How It Works</h3>
<ol>
<li>Converts <code>EntityField</code> list → <code>EntityStructure</code></li>
<li>Calls <code>ConvertPOCOClassToEntity</code> → generates C# code via <code>ClassCreator</code></li>
<li>Compiles via <code>RoslynCompiler.CompileClassTypeandAssembly()</code></li>
<li>Caches result in <code>typeCache</code> for subsequent calls</li>
<li>Returns <code>Activator.CreateInstance(type)</code></li>
</ol>
<h3>Usage</h3>
<pre><code class="language-csharp">var fields = new List<EntityField>
{
new EntityField { FieldName = "Id", FieldType = "System.Int32", IsKey = true },
new EntityField { FieldName = "Name", FieldType = "System.String", MaxLength = 100 },
new EntityField { FieldName = "Email", FieldType = "System.String" }
};
// Create dynamic object
var obj = DMTypeBuilder.CreateNewObject(editor, "MyApp.Models",
"MyDB", "DynamicCustomer", fields);
// Set properties via reflection
var type = obj.GetType();
type.GetProperty("Name").SetValue(obj, "John");
Console.WriteLine(type.GetProperty("Name").GetValue(obj));</code></pre>
<h3>CreateDynamicTypeFromObject</h3>
<p>Reflection-based type generation from an existing instance:</p>
<pre><code class="language-csharp">var source = new { Id = 1, Name = "Test", Date = DateTime.Now };
Type dynamicType = DMTypeBuilder.CreateDynamicTypeFromObject(source, "CustomType");
var instance = Activator.CreateInstance(dynamicType);
// Instance has matching Id, Name, Date properties</code></pre>
</section>
<!-- MigrationHistory -->
<section id="migration-history" class="section">
<h2>MigrationHistory — Schema Version Tracking</h2>
<pre><code class="language-csharp">public class MigrationHistory
{
public string DataSourceName { get; set; }
public DataSourceType DataSourceType { get; set; }
public List<MigrationRecord> Migrations { get; set; }
}
public class MigrationRecord
{
public string MigrationId { get; set; }
public string Name { get; set; }
public DateTime AppliedOnUtc { get; set; }
public bool Success { get; set; }
public string Notes { get; set; }
public List<MigrationStep> Steps { get; set; }
}
public class MigrationStep
{
public string Operation { get; set; } // Create, Alter, Drop, Rename
public string EntityName { get; set; }
public string ColumnName { get; set; }
public string Sql { get; set; }
public bool Success { get; set; }
public string Message { get; set; }
}</code></pre>
<p><code>MigrationHistoryManager</code> (in <code>Managers/MigrationHistoryManager.cs</code>) persists this data per datasource and provides query/export operations. Stored in <code>ConfigEditor._migrationHistory</code> and loaded via <code>ConfigEditor.LoadMigrationHistory()</code>.</p>
</section>
<!-- Examples -->
<section id="examples" class="section">
<h2>Usage Examples</h2>
<div class="code-example">
<h3>Complete Configuration Workflow</h3>
<pre><code class="language-csharp">// Initialize ConfigEditor for a data-intensive application
public static class DataApplicationConfigManager
{
private static IConfigEditor _configEditor;
public static void InitializeConfiguration()
{
// Create necessary services
var logger = new DMLogger();
var errorObject = new ErrorsInfo();
var jsonLoader = new JsonLoader();
// Initialize ConfigEditor for full application
_configEditor = new ConfigEditor(
logger,
errorObject,
jsonLoader,
folderPath: @"C:\MyDataApp\Config",
containerFolder: "Production",
configType: BeepConfigType.Application
);
Console.WriteLine("? ConfigEditor initialized");
// Setup data connections
SetupDataConnections();
// Configure drivers
SetupDrivers();
// Setup entity mappings
SetupEntityMappings();
// Create query repository
SetupQueryRepository();
// Save all configurations
PersistAllConfigurations();
}
private static void SetupDataConnections()