8
8
using System . Windows . Forms ;
9
9
using HandlebarsDotNet ;
10
10
using Newtonsoft . Json ;
11
- using TEAM ;
12
11
using DataWarehouseAutomation ;
13
12
using TEAM_Library ;
14
13
@@ -54,11 +53,16 @@ class CustomTabPage : TabPage
54
53
readonly RichTextBox localRichTextBoxGenerationOutput ;
55
54
56
55
readonly TabPage tabPageGenerationPattern ;
56
+ // Active pattern
57
57
readonly Label localLabelActivePattern ;
58
58
readonly Label localLabelFilePath ;
59
59
readonly Label localLabelFullFilePath ;
60
+ // Assigned connection
60
61
readonly Label localLabelActiveConnectionKey ;
61
62
readonly Label localLabelActiveConnectionKeyValue ;
63
+ // Output file pattern
64
+ readonly Label localLabelOutputFilePattern ;
65
+ readonly Label localLabelOutputFilePatternValue ;
62
66
63
67
readonly ComboBox localComboBoxGenerationPattern ;
64
68
readonly RichTextBox localRichTextBoxGenerationPattern ;
@@ -180,7 +184,7 @@ public CustomTabPage(string classification, string notes, Dictionary<string, VDW
180
184
_localRichTextBox . Size = new Size ( 393 , 120 ) ;
181
185
_localRichTextBox . BorderStyle = BorderStyle . None ;
182
186
_localRichTextBox . BackColor = SystemColors . Window ;
183
- _localRichTextBox . TextChanged += new EventHandler ( ScrollToCaret ) ;
187
+ _localRichTextBox . TextChanged += ScrollToCaret ;
184
188
185
189
// Add 'Filter' Group Box
186
190
var localGroupBoxFilter = new GroupBox ( ) ;
@@ -198,7 +202,7 @@ public CustomTabPage(string classification, string notes, Dictionary<string, VDW
198
202
_localTextBoxFilter . Location = new Point ( 6 , 15 ) ;
199
203
_localTextBoxFilter . Size = new Size ( 151 , 20 ) ;
200
204
_localTextBoxFilter . Name = $ "textBoxFilterCriterion{ _inputNiceName } ";
201
- _localTextBoxFilter . TextChanged += new EventHandler ( FilterItemList ) ;
205
+ _localTextBoxFilter . TextChanged += FilterItemList ;
202
206
203
207
#endregion
204
208
@@ -212,8 +216,7 @@ public CustomTabPage(string classification, string notes, Dictionary<string, VDW
212
216
localTabControl . Size = new Size ( 896 , 573 ) ;
213
217
localTabControl . Name = $ "tabControl{ classification } ";
214
218
localTabControl . BackColor = Color . White ;
215
- //localTabControl.SelectedIndexChanged += new EventHandler(SyntaxHighlightsHandlebars);
216
- localTabControl . SelectedIndexChanged += new EventHandler ( SubTabClick ) ;
219
+ localTabControl . SelectedIndexChanged += SubTabClick ;
217
220
218
221
// Add 'Generation Output' Tab Page on Sub Tab
219
222
tabPageGenerationOutput = new TabPage ( $ "{ _inputNiceName } Generation Output") ;
@@ -247,7 +250,7 @@ public CustomTabPage(string classification, string notes, Dictionary<string, VDW
247
250
localComboBoxGenerationPattern . Location = new Point ( 108 , 8 ) ;
248
251
localComboBoxGenerationPattern . Size = new Size ( 496 , 21 ) ;
249
252
localComboBoxGenerationPattern . Name = $ "comboBox{ classification } Pattern";
250
- localComboBoxGenerationPattern . SelectedIndexChanged += new EventHandler ( DisplayPattern ) ;
253
+ localComboBoxGenerationPattern . SelectedIndexChanged += DisplayPattern ;
251
254
252
255
// Add 'Active Pattern' Label
253
256
localLabelActivePattern = new Label ( ) ;
@@ -290,10 +293,28 @@ public CustomTabPage(string classification, string notes, Dictionary<string, VDW
290
293
tabPageGenerationPattern . Controls . Add ( localLabelActiveConnectionKeyValue ) ;
291
294
localLabelActiveConnectionKeyValue . Anchor = ( AnchorStyles . Top | AnchorStyles . Left ) ;
292
295
localLabelActiveConnectionKeyValue . Location = new Point ( 105 , 57 ) ;
293
- localLabelActiveConnectionKeyValue . Size = new Size ( 650 , 13 ) ;
296
+ localLabelActiveConnectionKeyValue . Size = new Size ( 240 , 13 ) ;
294
297
localLabelActiveConnectionKeyValue . Name = $ "label{ classification } ConnectionKeyValue";
295
298
localLabelActiveConnectionKeyValue . Text = @"<connection key>" ;
296
299
300
+ // Add 'Output File Pattern' Label
301
+ localLabelOutputFilePattern = new Label ( ) ;
302
+ tabPageGenerationPattern . Controls . Add ( localLabelOutputFilePattern ) ;
303
+ localLabelOutputFilePattern . Anchor = ( AnchorStyles . Top | AnchorStyles . Left ) ;
304
+ localLabelOutputFilePattern . Location = new Point ( 350 , 57 ) ;
305
+ localLabelOutputFilePattern . Size = new Size ( 100 , 13 ) ;
306
+ localLabelOutputFilePattern . Name = $ "label{ classification } OutputFilePattern";
307
+ localLabelOutputFilePattern . Text = @"Output file pattern:" ;
308
+
309
+ // Add 'Output File Pattern Value' Label
310
+ localLabelOutputFilePatternValue = new Label ( ) ;
311
+ tabPageGenerationPattern . Controls . Add ( localLabelOutputFilePatternValue ) ;
312
+ localLabelOutputFilePatternValue . Anchor = ( AnchorStyles . Top | AnchorStyles . Left ) ;
313
+ localLabelOutputFilePatternValue . Location = new Point ( 460 , 57 ) ;
314
+ localLabelOutputFilePatternValue . Size = new Size ( 250 , 13 ) ;
315
+ localLabelOutputFilePatternValue . Name = $ "label{ classification } OutputFilePatternValue";
316
+ localLabelOutputFilePatternValue . Text = @"<output file pattern>" ;
317
+
297
318
// Add 'Save Pattern' Button
298
319
localSavePattern = new Button ( ) ;
299
320
tabPageGenerationPattern . Controls . Add ( localSavePattern ) ;
@@ -302,7 +323,7 @@ public CustomTabPage(string classification, string notes, Dictionary<string, VDW
302
323
localSavePattern . Size = new Size ( 101 , 23 ) ;
303
324
localSavePattern . Text = $ "Save updates";
304
325
localSavePattern . Name = $ "Save{ classification } ";
305
- localSavePattern . Click += ( SavePattern ) ;
326
+ localSavePattern . Click += SavePattern ;
306
327
307
328
// Add 'Generation Pattern' RichTextBox to Pattern tab
308
329
localRichTextBoxGenerationPattern = new RichTextBox ( ) ;
@@ -311,7 +332,7 @@ public CustomTabPage(string classification, string notes, Dictionary<string, VDW
311
332
localRichTextBoxGenerationPattern . Location = new Point ( 3 , 82 ) ;
312
333
localRichTextBoxGenerationPattern . Size = new Size ( 195 , 30 ) ;
313
334
localRichTextBoxGenerationPattern . BorderStyle = BorderStyle . None ;
314
- localRichTextBoxGenerationPattern . TextChanged += new EventHandler ( CommitPatternToMemory ) ;
335
+ localRichTextBoxGenerationPattern . TextChanged += CommitPatternToMemory ;
315
336
#endregion
316
337
317
338
#region Constructor Methods
@@ -325,8 +346,7 @@ public CustomTabPage(string classification, string notes, Dictionary<string, VDW
325
346
// Report back to the user if there is not metadata available
326
347
if ( itemList == null || itemList . Count == 0 )
327
348
{
328
- _localRichTextBox . Text =
329
- $ "There was no metadata available to display { _inputNiceName } content. Please check the associated metadata schema (are there any { _inputNiceName } records available?) or the database connection.\r \n \r \n ";
349
+ _localRichTextBox . Text = $ "There was no metadata available to display { _inputNiceName } content. Please check the associated metadata schema (are there any { _inputNiceName } records available?) or the database connection.\r \n \r \n ";
330
350
}
331
351
332
352
// Initial documentation as per the definition notes
@@ -449,8 +469,7 @@ public void SetItemList(Dictionary<string, VDW_DataObjectMappingList> itemList)
449
469
// Report back to the user if there is not metadata available
450
470
if ( _localCheckedListBox . Items . Count == 0 )
451
471
{
452
- _localRichTextBox . Text =
453
- $ "There was no metadata available to display { _inputNiceName } content. Please check the associated metadata schema (are there any { _inputNiceName } records available?) or the database connection.";
472
+ _localRichTextBox . Text = $ "There was no metadata available to display { _inputNiceName } content. Please check the associated metadata schema (are there any { _inputNiceName } records available?) or the database connection.";
454
473
}
455
474
456
475
// Set all the Check Boxes to 'checked'
@@ -481,6 +500,16 @@ private void DisplayPattern(object o, EventArgs e)
481
500
localLabelFullFilePath . Text = localFullPath ;
482
501
localLabelActiveConnectionKeyValue . Text = loadPattern . LoadPatternConnectionKey ;
483
502
503
+ if ( ! string . IsNullOrEmpty ( loadPattern . LoadPatternOutputFilePattern ) )
504
+ {
505
+ localLabelOutputFilePatternValue . Text = loadPattern . LoadPatternOutputFilePattern ;
506
+ }
507
+ else
508
+ {
509
+ localLabelOutputFilePatternValue . Text = "Undefined" ;
510
+ }
511
+
512
+
484
513
// Read the file from the path
485
514
string loadPatternTemplate = "" ;
486
515
try
@@ -530,13 +559,13 @@ public void RaiseOnClearMainText()
530
559
void SavePattern ( object o , EventArgs e )
531
560
{
532
561
RaiseOnClearMainText ( ) ;
533
- string backupResponse = LoadPattern . BackupLoadPattern ( localLabelFullFilePath . Text ) ;
562
+ string backupResponse = LoadPatternFileHandling . BackupPatternCollection ( localLabelFullFilePath . Text ) ;
534
563
string saveResponse = "" ;
535
564
536
565
if ( backupResponse . StartsWith ( "A backup was created" ) )
537
566
{
538
567
RaiseOnChangeMainText ( backupResponse ) ;
539
- saveResponse = LoadPattern . SaveLoadPattern ( localLabelFullFilePath . Text , localRichTextBoxGenerationPattern . Text ) ;
568
+ saveResponse = LoadPatternFileHandling . SavePatternCollection ( localLabelFullFilePath . Text , localRichTextBoxGenerationPattern . Text ) ;
540
569
RaiseOnChangeMainText ( "\r \n \r \n " + saveResponse ) ;
541
570
}
542
571
else
@@ -570,7 +599,7 @@ private void GenerateFromPattern()
570
599
RaiseOnClearMainText ( ) ;
571
600
localTabControl . SelectedIndex = 0 ;
572
601
573
- // Loop through the checked items, select the right mapping and generate the pattern
602
+ // Loop through the checked items, select the right mapping and generate the pattern.
574
603
if ( _localCheckedListBox . CheckedItems . Count != 0 )
575
604
{
576
605
for ( int x = 0 ; x <= _localCheckedListBox . CheckedItems . Count - 1 ; x ++ )
@@ -584,11 +613,11 @@ private void GenerateFromPattern()
584
613
// Return the result to the user
585
614
try
586
615
{
587
- // Compile the template, and merge it with the metadata
616
+ // Compile the template, and merge it with the metadata.
588
617
var template = Handlebars . Compile ( localRichTextBoxGenerationPattern . Text ) ;
589
618
var result = template ( dataObjectMappingList ) ;
590
619
591
- // Check if the metadata needs to be displayed
620
+ // Check if the metadata needs to be displayed.
592
621
if ( DisplayJsonFlag )
593
622
{
594
623
try
@@ -602,16 +631,19 @@ private void GenerateFromPattern()
602
631
}
603
632
}
604
633
605
- // Display the output of the template to the user
634
+ // Display the output of the template to the user.
606
635
localRichTextBoxGenerationOutput . AppendText ( result ) ;
607
636
608
- // Spool the output to disk
637
+ // Spool the output to disk.
609
638
if ( SaveOutputFileFlag )
610
639
{
611
- VdwUtility . SaveOutputToDisk ( FormBase . VdwConfigurationSettings . VdwOutputPath + targetTableName + ".sql" , result ) ;
640
+ // Assert file output pattern.
641
+ var outputFile = localLabelOutputFilePatternValue . Text ;
642
+ outputFile = outputFile . Replace ( "{targetDataObject.name}" , targetTableName ) ;
643
+ VdwUtility . SaveOutputToDisk ( FormBase . VdwConfigurationSettings . VdwOutputPath + outputFile , result ) ;
612
644
}
613
645
614
- //Generate in database
646
+ //Generate in database.
615
647
if ( GenerateInDatabaseFlag )
616
648
{
617
649
// Find the right connection for the pattern connection key
@@ -659,6 +691,7 @@ private void GenerateFromPattern()
659
691
660
692
// Report back to the user
661
693
int errorCounter = 0 ;
694
+
662
695
foreach ( Event individualEvent in FormBase . VdwConfigurationSettings . VdwEventLog )
663
696
{
664
697
if ( individualEvent . eventCode == 1 && individualEvent . eventTime > currentTime )
0 commit comments