-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainForm.cs
2757 lines (2624 loc) · 134 KB
/
mainForm.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Threading;
using System.Xml;
using System.Reflection;
namespace Script_Builder
{
public partial class mainForm : Form
{
DataTable tblExcel2WinData;
public string CurrentPath = Application.StartupPath;
public options programOptions { get; private set; }
public Strings programmStrings { get; private set; }
private TreeNode selectedNode;
private bool importTemplateMode;
private Dictionary<TreeNode, VorlagenType> nodeTypen;
private Dictionary<TreeNode, RichTextBox> nodeTextBoxes;
private Dictionary<TreeNode, OutputFile> nodeOutputFile;
private bool checkingText = false;
private int checkingStartSelection;
private String debuggingFileName = "C:\\ScriptBuilder_Debug_" + DateTime.Now.ToString("yyyyMMdd") + ".log";
private String currentTemplatePath;
List<string> outputLog;
public mainForm(string[] args)
{
programOptions = new options(Path.Combine(Application.StartupPath, "options.xml"), this);
programOptions.ReadOptions();
Thread.CurrentThread.CurrentCulture = programOptions.GetCulture();
Thread.CurrentThread.CurrentUICulture = programOptions.GetCulture();
programmStrings = new Strings(programOptions.GetCulture(), Application.StartupPath);
InitializeComponent();
importTemplateMode = false;
programOptions.CreateMakroMenu();
this.splitContainer1.Panel2MinSize = 427;
tblExcel2WinData = new DataTable();
dgrExcelContents.DataSource = tblExcel2WinData.DefaultView;
if (programOptions.GetOptions("DokuPath") != null && File.Exists(programOptions.GetOptions("DokuPath").Value))
this.openScriptingDoku.Enabled = true;
else
this.openScriptingDoku.Enabled = false;
this.cboNodeFileFormat.Items.AddRange(new object[] {
programmStrings.GetString("NodeFileFormatUTF"),
programmStrings.GetString("NodeFileFormatUnicode"),
programmStrings.GetString("NodeFileFormatASCII"),
programmStrings.GetString("NodeFileFormatANSI")});
if (args.Length > 0)
loadVorlage(args[0]);
else
{
newDocument();
addTemplate(null, VorlagenType.File);
addTemplate(trvVorlageSelect.Nodes[0], VorlagenType.Header);
addTemplate(trvVorlageSelect.Nodes[0], VorlagenType.Body);
}
showTextBox(null);
selectedNode = null;
if (nodeSelectionChanged(trvVorlageSelect.Nodes[0])) {
trvVorlageSelect.SelectedNode = selectedNode;
}
#region Shortcuts Localisiert setzen
beenden.ShortcutKeys = Keys.Control | Keys.End;
createOutputFile.ShortcutKeys = Keys.Control | Keys.S;
options.ShortcutKeys = Keys.Control | Keys.O;
clearAll.ShortcutKeys = Keys.Control | Keys.N;
checkTemplate.ShortcutKeys = Keys.Control | Keys.P;
spalteHinzu.ShortcutKeys = Keys.Control | Keys.Insert;
clearTable.ShortcutKeys = Keys.Control | Keys.L;
openScriptingDoku.ShortcutKeys = Keys.Control | Keys.D;
infoPageShow.ShortcutKeys = Keys.Control | Keys.I;
beenden.ShortcutKeyDisplayString = programmStrings.GetString("ShortcutCtrlEnd");
createOutputFile.ShortcutKeyDisplayString = programmStrings.GetString("ShortcutCtrlS");
options.ShortcutKeyDisplayString = programmStrings.GetString("ShortcutCtrlO");
clearAll.ShortcutKeyDisplayString = programmStrings.GetString("ShortcutCtrlN");
checkTemplate.ShortcutKeyDisplayString = programmStrings.GetString("ShortcutCtrlP");
spalteHinzu.ShortcutKeyDisplayString = programmStrings.GetString("ShortcutCtrlIns");
clearTable.ShortcutKeyDisplayString = programmStrings.GetString("ShortcutCtrlL");
openScriptingDoku.ShortcutKeyDisplayString = programmStrings.GetString("ShortcutCtrlD");
infoPageShow.ShortcutKeyDisplayString = programmStrings.GetString("ShortcutCtrlI");
tsmOrderUp.ShortcutKeyDisplayString = "+";
tsmOrderDown.ShortcutKeyDisplayString = "-";
tsmEditName.ShortcutKeyDisplayString = "F2";
tsmRemove.ShortcutKeyDisplayString = programmStrings.GetString("ShortcutDel"); ;
#endregion
/*mnuChangeNodeName.Enabled = false;
mnuRemoveNode.Enabled = false;
mnuAddFile.Enabled = true;
mnuAddBlock.Enabled = false;
mnuChangeOrder.Enabled = false;*/
//cxmTextBox = new ContextMenuStrip(this.components);
outputLog = new List<string>();
trvVorlageSelect.Select();
}
private void dgrExcelContents_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
changeTableHeader(this, tblExcel2WinData, e.ColumnIndex);
}
}
public static void changeTableHeader(mainForm mainForm, DataTable InputTable, int ColumnIndex)
{
string value = InputTable.Columns[ColumnIndex].ColumnName.ToString();
if (InputBox.InputBox2(mainForm.programmStrings.GetString("textChangeHeader"), mainForm.programmStrings.GetString("textNewHeader1"), ref value) == DialogResult.OK && value.Length > 0)
{
try
{
InputTable.Columns[ColumnIndex].ColumnName = value;
}
catch (DuplicateNameException)
{
MessageBox.Show(mainForm.programmStrings.GetString("textErrorHeaderUsed1") + " \"" + value + "\" " + mainForm.programmStrings.GetString("textErrorHeaderUsed2"), mainForm.programmStrings.GetString("textNewHeader2"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
private void dgrExcelContents_KeyPress(object sender, KeyPressEventArgs e)
{
if ((int)e.KeyChar == 22)
{
PasteExcelData(tblExcel2WinData);
e.Handled = true;
}
/*
else
{
MessageBox.Show(((int)e.KeyChar).ToString());
}
*/
}
public static void PasteExcelData(DataTable InputTable)
{
IDataObject objPresumablyExcel = Clipboard.GetDataObject();
if (objPresumablyExcel.GetDataPresent(DataFormats.CommaSeparatedValue))
{
using (StreamReader srReadExcel = new StreamReader(objPresumablyExcel.GetData(DataFormats.CommaSeparatedValue) as Stream,Encoding.Default))
{
readClipboardInput(srReadExcel, InputTable, new Char[] { ';' });
}
}
else if (objPresumablyExcel.GetDataPresent(DataFormats.Text))
{
using(StringReader srReadText = new StringReader((string)objPresumablyExcel.GetData(DataFormats.Text)))
{
readClipboardInput(srReadText, InputTable, new Char[] { '\t' });
}
}
}
private void loadHeaderFormat_Click(object sender, EventArgs e)
{
TreeNode fileNode;
if (selectedNode == null)
{
DialogResult result = MessageBox.Show(this.programmStrings.GetString("textErrorNoOutputFile"), this.programmStrings.GetString("textImportText"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
return;
}
if (selectedNode != null && nodeTypen.ContainsKey(selectedNode))
{
if (nodeTypen[selectedNode] != VorlagenType.File)
fileNode = selectedNode.Parent;
else
fileNode = selectedNode;
}
else
fileNode = addTemplate(null, VorlagenType.File);
TreeNode newNode = addTemplate(fileNode, VorlagenType.Header);
if(nodeTextBoxes.ContainsKey(newNode))
if(sender == headerNewFormat)
{
nodeTextBoxes[newNode].Text = "FILE VERSION:11.00.01:MP2\r\n";
}
else if (sender == headerOldFormat)
{
nodeTextBoxes[newNode].Text = "FILE VERSION:10.01.01\r\n";
}
fileNode.Expand();
selectedNode = newNode;
trvVorlageSelect.SelectedNode = selectedNode;
}
private void activateControlls(bool activate)
{
if (activate)
progressBar.Maximum = 100;
progressBar.Visible = !activate;
mainMenuStrip.Enabled = activate;
dgrExcelContents.Enabled = activate;
trvVorlageSelect.Enabled = activate;
pnlFileProperties.Enabled = activate;
foreach (KeyValuePair<TreeNode, RichTextBox> thisTextBoxPair in nodeTextBoxes)
thisTextBoxPair.Value.ReadOnly = !activate;
}
private void createOutputFile_Click(object sender, EventArgs e)
{
activateControlls(false);
if (selectedNode != null && nodeTypen.ContainsKey(selectedNode) && (nodeTypen[selectedNode] == VorlagenType.File || nodeTypen[selectedNode] == VorlagenType.Serial) && nodeChanged())
{
DialogResult declineChanges = MessageBox.Show(this.programmStrings.GetString("textUnsavedChanges1"), this.programmStrings.GetString("textUnsavedChanges2"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
if (declineChanges == DialogResult.Yes)
{
declineNodeChanges();
}
else if (declineChanges == DialogResult.No)
{
acceptNodeChanges();
}
else
{
activateControlls(true);
return;
}
}
bool Debugging = false;
if (programOptions.GetOptions("Debugging") != null && programOptions.GetOptions("Debugging").Value == "On")
{
Debugging = true;
writeDebugging("Start OutputFile Creation");
}
#region Überprüfen ob Dateinamen und Speicherpfad korrekt und existiert
foreach (KeyValuePair<TreeNode, OutputFile> thisOutputFilePair in nodeOutputFile)
{
if (Directory.Exists(thisOutputFilePair.Value.FullFileName))
{
MessageBox.Show(this.programmStrings.GetString("textErrorPathIsDir1") + " \"" + thisOutputFilePair.Value.FullFileName + "\" " + this.programmStrings.GetString("textErrorPathIsDir2"), this.programmStrings.GetString("textCreateOutputFile"), MessageBoxButtons.OK, MessageBoxIcon.Error);
if (Debugging)
writeDebugging("Die Outputdatei \"" + thisOutputFilePair.Value.FullFileName + "\" ist ein Verzeichnis.");
activateControlls(true);
return;
}
if (!Directory.Exists(thisOutputFilePair.Value.FilePath))
{
MessageBox.Show(this.programmStrings.GetString("textErrorPathDoentExist1") + " \"" + thisOutputFilePair.Value.FilePath + "\" " + this.programmStrings.GetString("textErrorPathDoentExist2"), this.programmStrings.GetString("textCreateOutputFile"), MessageBoxButtons.OK, MessageBoxIcon.Error);
if (Debugging)
writeDebugging("Das Verzeichnis \"" + thisOutputFilePair.Value.FilePath + "\" existiert nicht.");
activateControlls(true);
return;
}
if (thisOutputFilePair.Value.Exists)
{
DialogResult result = MessageBox.Show(this.programmStrings.GetString("textErrorReplaceOutputFile1") + " \"" + thisOutputFilePair.Value.FileName + "\" " + this.programmStrings.GetString("textErrorReplaceOutputFile2"), this.programmStrings.GetString("textCreateOutputFile"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (Debugging)
writeDebugging("Die Outputdatei \"" + thisOutputFilePair.Value.FileName + "\" existiert bereits in dem ausgewählten Verzeichnis.\r\nSoll sie überschrieben werden?");
if (result == DialogResult.Cancel)
{
activateControlls(true);
return;
}
else if (result == DialogResult.No)
{
thisOutputFilePair.Value.Overwrite = false;
}
else
thisOutputFilePair.Value.Overwrite = true;
}
}
#endregion
dgrExcelContents.EndEdit();
dgrExcelContents.Refresh();
#region ProgressBar Maximum setzen
int barMaximum = 0;
int multiplikator;
foreach(TreeNode thisNode in trvVorlageSelect.Nodes)
{
if(nodeOutputFile.ContainsKey(thisNode) && (!nodeOutputFile[thisNode].Exists || nodeOutputFile[thisNode].Overwrite))
{
foreach(TreeNode thisChildNode in thisNode.Nodes)
{
if(nodeTypen.ContainsKey(thisChildNode) && nodeTypen.ContainsKey(thisNode))
{
if (nodeTypen[thisNode] == VorlagenType.Serial && nodeOutputFile.ContainsKey(thisNode) && nodeOutputFile[thisNode].SerialInputTable != null)
multiplikator = nodeOutputFile[thisNode].SerialInputTable.Rows.Count;
else
multiplikator = 1;
if (nodeTypen[thisChildNode] == VorlagenType.Body)
barMaximum += tblExcel2WinData.Rows.Count * multiplikator;
else if (nodeTypen[thisChildNode] == VorlagenType.Header || nodeTypen[thisChildNode] == VorlagenType.SerialHeader)
barMaximum += multiplikator;
}
}
}
}
progressBar.Maximum = barMaximum;
progressBar.Value = 0;
if (Debugging)
{
writeDebugging("progressBar.Maximum = " + progressBar.Maximum);
writeDebugging("progressBar.Value = " + progressBar.Value);
writeDebugging("tblExcel2WinData.Rows = " + tblExcel2WinData.Rows.Count);
}
#endregion
int iSpalten;
int CounterOK = 0;
int matchFieldA = -1;
int matchFieldB = -1;
DateTime startTime = DateTime.Now;;
DateTime endTime;
outputLog.Add(this.programmStrings.GetString("logCreateScript1"));
outputLog.Add(this.programmStrings.GetString("logStart") + startTime.ToString(this.programmStrings.GetString("logTimeCode")));
outputLog.Add("");
List<OutputFile> warnFileFormat = new List<OutputFile>();
string variabelMarker;
if (programOptions.GetOptions("VariableMarker") != null)
variabelMarker = programOptions.GetOptions("VariableMarker").Value;
else
variabelMarker = "%";
string[] columns = new string[tblExcel2WinData.Columns.Count];
for (iSpalten = 0; iSpalten < tblExcel2WinData.Columns.Count; iSpalten++)
{
columns[iSpalten] = tblExcel2WinData.Columns[iSpalten].ColumnName;
}
Dictionary<TreeNode,vorlage> nodeVorlagen = new Dictionary<TreeNode,vorlage>();
foreach(KeyValuePair<TreeNode,VorlagenType> thisNodePair in nodeTypen)
{
if(thisNodePair.Value == VorlagenType.Body && nodeTextBoxes.ContainsKey(thisNodePair.Key))
nodeVorlagen.Add(thisNodePair.Key, new vorlage(nodeTextBoxes[thisNodePair.Key].Lines,columns,variabelMarker));
else if (thisNodePair.Value == VorlagenType.SerialHeader && nodeTextBoxes.ContainsKey(thisNodePair.Key) && thisNodePair.Key.Parent != null && nodeOutputFile.ContainsKey(thisNodePair.Key.Parent))
{
string[] tempColumns = new string[nodeOutputFile[thisNodePair.Key.Parent].SerialInputTable.Columns.Count];
for (iSpalten = 0; iSpalten < nodeOutputFile[thisNodePair.Key.Parent].SerialInputTable.Columns.Count; iSpalten++)
tempColumns[iSpalten] = nodeOutputFile[thisNodePair.Key.Parent].SerialInputTable.Columns[iSpalten].ColumnName;
nodeVorlagen.Add(thisNodePair.Key, new vorlage(nodeTextBoxes[thisNodePair.Key].Lines, tempColumns, variabelMarker));
}
}
foreach(TreeNode thisNode in trvVorlageSelect.Nodes)
{
if(nodeOutputFile.ContainsKey(thisNode))
{
if (nodeOutputFile[thisNode].SerialFile)
{
if (nodeOutputFile[thisNode].SerialInputTable != null)
{
string OutputFileName;
int iZeilen;
matchFieldA = nodeOutputFile[thisNode].SerialFieldLinkID();
matchFieldB = nodeOutputFile[thisNode].SerialFieldLinkID(tblExcel2WinData);
for (iZeilen = 0; iZeilen < nodeOutputFile[thisNode].SerialInputTable.Rows.Count; iZeilen++)
{
string[] thisRow = new string[nodeOutputFile[thisNode].SerialInputTable.Columns.Count];
for (iSpalten = 0; iSpalten < nodeOutputFile[thisNode].SerialInputTable.Columns.Count; iSpalten++)
{
if (nodeOutputFile[thisNode].SerialInputTable.Rows[iZeilen].Field<string>(iSpalten) != null)
thisRow[iSpalten] = nodeOutputFile[thisNode].SerialInputTable.Rows[iZeilen].Field<string>(iSpalten).Trim();
else
thisRow[iSpalten] = "";
}
OutputFileName = nodeOutputFile[thisNode].FullFileName;
string TempFileName = OutputFileName;
for (iSpalten = 0; iSpalten < thisRow.Length; iSpalten++)
OutputFileName = vorlage.patternSearch(OutputFileName, variabelMarker, nodeOutputFile[thisNode].SerialInputTable.Columns[iSpalten].Caption, thisRow[iSpalten]);
if (TempFileName == OutputFileName)
OutputFileName = numberingFileName(OutputFileName, (iZeilen + 1).ToString());
if(matchFieldA != -1)
CounterOK += createNodeOutput(thisNode, nodeVorlagen, warnFileFormat, Debugging, OutputFileName, thisRow, matchFieldB, thisRow[matchFieldA]);
else
CounterOK += createNodeOutput(thisNode, nodeVorlagen, warnFileFormat, Debugging, OutputFileName, thisRow, matchFieldB, null);
}
}
}
else
{
CounterOK += createNodeOutput(thisNode, nodeVorlagen, warnFileFormat, Debugging);
}
}
}
endTime = DateTime.Now;
outputLog.Add(this.programmStrings.GetString("logEnde") + endTime.ToString(this.programmStrings.GetString("logTimeCode")));
if (Debugging)
writeDebugging("End of creation");
TimeSpan createDuration = endTime.Subtract(startTime);
outputLog.Add(this.programmStrings.GetString("logFinishedScriptCreation1") + (createDuration.Days > 0 ? createDuration.Days + "t" : "") + (createDuration.Hours > 0 ? createDuration.Hours + "h" : "") + createDuration.Minutes + "m" + createDuration.Seconds + "s" + createDuration.Milliseconds + "ms" + this.programmStrings.GetString("logFinishedScriptCreation2") + CounterOK + this.programmStrings.GetString("logFinishedScriptCreation3"));
string resultText = this.programmStrings.GetString("logFinishedScriptCreation4") + "\r\n" + this.programmStrings.GetString("logFinishedScriptCreation1") + (createDuration.Days > 0 ? createDuration.Days + "t" : "") + (createDuration.Hours > 0 ? createDuration.Hours + "h" : "") + createDuration.Minutes + "m" + createDuration.Seconds + "s" + createDuration.Milliseconds + "ms " + this.programmStrings.GetString("logFinishedScriptCreation2") + CounterOK + this.programmStrings.GetString("logFinishedScriptCreation3");
if (warnFileFormat.Count > 0)
{
outputLog.Add(this.programmStrings.GetString("logFinishWarning1"));
resultText += "\r\n\r\n" + this.programmStrings.GetString("logFinishWarning1") + "\r\n" + this.programmStrings.GetString("logFinishWarning2");
outputLog.Add(this.programmStrings.GetString("logFinishWarning3"));
foreach(OutputFile thisOutputFile in warnFileFormat)
outputLog.Add(" - " + thisOutputFile.FileName);
}
outputLog.Add(this.programmStrings.GetString("logFinishedScriptCreation4"));
outputLog.Add("");
MessageBox.Show(resultText, this.programmStrings.GetString("logCreateScript2"), MessageBoxButtons.OK, MessageBoxIcon.Information);
activateControlls(true);
}
private int createNodeOutput(TreeNode thisNode, Dictionary<TreeNode, vorlage> nodeVorlagen, List<OutputFile> warnFileFormat, Boolean Debugging)
{
return createNodeOutput(thisNode, nodeVorlagen, warnFileFormat, Debugging, null , null, -1, null);
}
private int createNodeOutput(TreeNode thisNode, Dictionary<TreeNode,vorlage> nodeVorlagen, List<OutputFile> warnFileFormat, Boolean Debugging, String FullFileName, String[] SerialHeaders, int matchField, string matchWith)
{
int iZeilen;
int iSpalten;
int ZeilenCounterPart = 0;
int CounterOK = 0;
string CreateFileName;
if(!nodeTypen.ContainsKey(thisNode) || !nodeOutputFile.ContainsKey(thisNode))
return 0;
if (nodeTypen[thisNode] == VorlagenType.File && nodeOutputFile[thisNode].Exists && !nodeOutputFile[thisNode].Overwrite)
return 0; //Standard File existiert bereits und overwrite ist nicht erlaubt
else if (nodeTypen[thisNode] == VorlagenType.Serial && (FullFileName == null || SerialHeaders == null))
return 0; //Vorlage ist Serien-Datei aber die Werte für den FileName und die Serien-Tabellen Felder sind nicht übergeben.
else if (nodeTypen[thisNode] == VorlagenType.Serial && File.Exists(FullFileName) && nodeOutputFile[thisNode].Overwrite)
return 0; //Vorlage ist Serien-Datei aber der aktuelle Filename existiert bereits oder overwrite ist nicht erlaubt
else if (matchField == -1 ^ matchWith == null)
return 0; //Es müssen entweder beide null sein, oder beide gesetzt sein
if (nodeTypen[thisNode] == VorlagenType.File)
CreateFileName = nodeOutputFile[thisNode].FullFileName;
else
CreateFileName = FullFileName;
outputLog.Add(this.programmStrings.GetString("logOutputFile") + " \"" + CreateFileName + "\"");
if (Debugging)
writeDebugging("Output Datei: \"" + CreateFileName + "\"");
if(nodeOutputFile[thisNode].Encoding is ASCIIEncoding)
warnFileFormat.Add(nodeOutputFile[thisNode]);
using (FileStream sw = new FileStream(CreateFileName, FileMode.Create))
{
if (nodeOutputFile[thisNode].Encoding is UnicodeEncoding)
{
sw.WriteByte((byte)255);
sw.WriteByte((byte)254);
}
foreach(TreeNode thisChildNode in thisNode.Nodes)
{
if(nodeTypen.ContainsKey(thisChildNode) && nodeTextBoxes.ContainsKey(thisChildNode))
{
outputLog.Add(this.programmStrings.GetString("logBlock") + " \"" + thisChildNode.Text + "\" (" + DateTime.Now.ToString("HH:mm:ss") + ")");
if (Debugging)
writeDebugging("Block \"" + thisChildNode.Text);
if (nodeTypen[thisChildNode] == VorlagenType.Header)
{
ZeilenCounterPart = 0;
foreach (string lineText in nodeTextBoxes[thisChildNode].Lines)
{
writeLines(lineText, sw, nodeOutputFile[thisNode].Encoding);
ZeilenCounterPart++;
}
outputLog.Add(this.programmStrings.GetString("logSingleBlockWith1") + (ZeilenCounterPart > 1 ? ZeilenCounterPart + this.programmStrings.GetString("logBlockWith2") : this.programmStrings.GetString("logBlockWith3")));
if (progressBar.Value < progressBar.Maximum)
progressBar.Value++;
if (Debugging)
{
writeDebugging("Einzelblock mit " + (ZeilenCounterPart > 1 ? ZeilenCounterPart + " Zeilen." : "einer Zeile."));
writeDebugging("progressBar.Value = " + progressBar.Value);
}
Application.DoEvents();
}
else if (nodeTypen[thisChildNode] == VorlagenType.Body && nodeVorlagen.ContainsKey(thisChildNode))
{
ZeilenCounterPart = 0;
for (iZeilen = 0; iZeilen < tblExcel2WinData.Rows.Count; iZeilen++)
{
string[] thisRow = new string[tblExcel2WinData.Columns.Count];
for (iSpalten = 0; iSpalten < tblExcel2WinData.Columns.Count; iSpalten++)
{
if (tblExcel2WinData.Rows[iZeilen].Field<string>(iSpalten) != null)
thisRow[iSpalten] = tblExcel2WinData.Rows[iZeilen].Field<string>(iSpalten).Trim();
else
thisRow[iSpalten] = "";
}
/*string[] tempOutput = nodeVorlagen[thisChildNode].CreateOutput(thisRow);
foreach (string lineOutput in tempOutput)
{
writeLines(lineOutput, sw, nodeOutputFile[thisNode].Encoding);
ZeilenCounterPart++;
}
CounterOK++;
*/
if ((matchField == -1 && matchWith == null) || (matchField != -1 && matchWith != null && thisRow[matchField] == matchWith))
{
ZeilenCounterPart += createVorlageOutput(nodeVorlagen[thisChildNode], thisRow, sw, nodeOutputFile[thisNode].Encoding, Debugging);
CounterOK++;
}
if (progressBar.Value < progressBar.Maximum)
progressBar.Value++;
if (Debugging)
writeDebugging("progressBar.Value = " + progressBar.Value);
Application.DoEvents();
}
outputLog.Add(this.programmStrings.GetString("logMultiBlockWith1") + (ZeilenCounterPart > 1 ? ZeilenCounterPart + this.programmStrings.GetString("logBlockWith2") : this.programmStrings.GetString("logBlockWith3")) + this.programmStrings.GetString("logMultiBlockWith2") + (tblExcel2WinData.Rows.Count > 1 ? tblExcel2WinData.Rows.Count + this.programmStrings.GetString("logMultiBlockWith3") : this.programmStrings.GetString("logMultiBlockWith4")));
if (Debugging)
writeDebugging("Wiederholungsblock mit " + (ZeilenCounterPart > 1 ? ZeilenCounterPart + " Zeilen" : "einer Zeile") + " für " + (tblExcel2WinData.Rows.Count > 1 ? tblExcel2WinData.Rows.Count + " Datensätze" : "einen Datensatz"));
}
else if (nodeTypen[thisChildNode] == VorlagenType.SerialHeader && nodeVorlagen.ContainsKey(thisChildNode))
{
ZeilenCounterPart = 0;
ZeilenCounterPart = createVorlageOutput(nodeVorlagen[thisChildNode], SerialHeaders, sw, nodeOutputFile[thisNode].Encoding, Debugging);
if (progressBar.Value < progressBar.Maximum)
progressBar.Value++;
if (Debugging)
{
writeDebugging("Serienfeldblock mit " + (ZeilenCounterPart > 1 ? ZeilenCounterPart + " Zeilen." : "einer Zeile."));
writeDebugging("progressBar.Value = " + progressBar.Value);
}
Application.DoEvents();
}
outputLog.Add("");
}
}
}
return CounterOK;
}
private int createVorlageOutput(vorlage nodeVorlage, string[] datenReihe, FileStream sw, Encoding fileEncoding, Boolean Debugging)
{
int ZeilenCounterPart = 0;
string[] tempOutput = nodeVorlage.CreateOutput(datenReihe);
foreach (string lineOutput in tempOutput)
{
writeLines(lineOutput, sw, fileEncoding);
ZeilenCounterPart++;
}
return ZeilenCounterPart;
}
private void excelTableImport_Click(object sender, EventArgs e)
{
PasteExcelData(tblExcel2WinData);
dgrExcelContents.DataSource = tblExcel2WinData.DefaultView;
}
private void clearTable_Click(object sender, EventArgs e)
{
tblExcel2WinData.Clear();
tblExcel2WinData.Columns.Clear();
dgrExcelContents.DataSource = tblExcel2WinData.DefaultView;
}
private void openScriptingDoku_Click(object sender, EventArgs e)
{
try
{
Process.Start(programOptions.GetOptions("DokuPath").Value);
MessageBox.Show(this.programmStrings.GetString("textErrorOpenDokument1"), this.programmStrings.GetString("textErrorOpenDokument3"), MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch
{
MessageBox.Show(this.programmStrings.GetString("textErrorOpenDokument2"), this.programmStrings.GetString("textErrorOpenDokument3"), MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void beenden_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void spalteHinzuToolStripMenuItem_Click(object sender, EventArgs e)
{
tblExcel2WinData.Columns.Add();
dgrExcelContents.DataSource = tblExcel2WinData.DefaultView;
}
private void infoPageShow_Click(object sender, EventArgs e)
{
AboutBox1 AboutBox = new AboutBox1(programOptions.GetCulture(), programmStrings.GetString("InfoBoxHeader"),programmStrings.GetString("InfoBoxDescription"));
AboutBox.ShowDialog();
}
private static void writeLines(string inputText, FileStream fs, Encoding encoder)
{
writeLines(inputText, fs, encoder, false);
}
public static void writeLines(string inputText, FileStream fs, Encoding encoder, bool windowsFormat)
{
byte[] encodedBytes = encoder.GetBytes(inputText);
foreach (Byte b in encodedBytes)
{
fs.WriteByte(b);
}
if (windowsFormat)
{
fs.WriteByte((byte)13);
if (encoder is UnicodeEncoding)
fs.WriteByte((byte)0);
}
fs.WriteByte((byte)10);
if (encoder is UnicodeEncoding)
fs.WriteByte((byte)0);
}
public static void readClipboardInput(TextReader text, DataTable table, Char[] splitChar)
{
string sFormattedData;
int iLoopCounter;
DataRow rowNew;
string[] arrSplitData;
string lastRow;
while (text.Peek() > 0)
{
sFormattedData = text.ReadLine();
lastRow = sFormattedData;
if (!sFormattedData.StartsWith("#") && sFormattedData.Length > 0)
{
arrSplitData = sFormattedData.Split(splitChar);
if (table.Columns.Count < arrSplitData.Count())
{
int moreColumns = arrSplitData.Count() - table.Columns.Count;
for (iLoopCounter = 0; iLoopCounter < moreColumns; iLoopCounter++)
{
table.Columns.Add();
}
}
rowNew = table.NewRow();
for (iLoopCounter = 0; iLoopCounter <= arrSplitData.GetUpperBound(0); iLoopCounter++)
{
rowNew[iLoopCounter] = arrSplitData.GetValue(iLoopCounter);
}
table.Rows.Add(rowNew);
}
}
}
private void fileTableImport_Click(object sender, EventArgs e)
{
importTableFromFile(this, tblExcel2WinData);
dgrExcelContents.DataSource = tblExcel2WinData.DefaultView;
}
public static void importTableFromFile(mainForm mainForm, DataTable InputTable)
{
importForm importForm1 = new importForm(mainForm);
DialogResult result = importForm1.ShowDialog();
if (result == DialogResult.Cancel) return;
result = MessageBox.Show(mainForm.programmStrings.GetString("textImportTable1"), mainForm.programmStrings.GetString("textImportTable2"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
return;
InputTable.Clear();
InputTable.Columns.Clear();
try
{
if(importForm1.ImportType == ImportType.File) {
using (StreamReader srImportFile = new StreamReader(importForm1.importFilePath,importForm1.ImportEncoding))
{
readClipboardInput(srImportFile, InputTable, importForm1.SeparatorChar);
}
}
else
{
IDataObject objClipboard = Clipboard.GetDataObject();
if (objClipboard.GetDataPresent(DataFormats.Text))
{
using (StreamReader srImportData = new StreamReader(objClipboard.GetData(DataFormats.CommaSeparatedValue) as Stream, importForm1.ImportEncoding))
{
readClipboardInput(srImportData, InputTable, importForm1.SeparatorChar);
}
}
}
if (importForm1.firstRowHeader)
headerInFirstRow(InputTable);
}
catch (Exception ex)
{
MessageBox.Show(mainForm.programmStrings.GetString("textErrorUnexpected") + "\r\n" + ex.Message, mainForm.programmStrings.GetString("textImportTable2"), MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public void createMakroMenu(List<makroKeys> makroKeys)
{
if(makrosMenu == null) {
return;
}
makrosMenu.DropDownItems.Clear();
makrosMenu.DropDownItems.AddRange(new ToolStripItem[] {
this.groupDefaultHeader,
this.toolStripSeparator6 });
foreach (makroKeys thisKey in makroKeys)
{
ToolStripItem newKey = new ToolStripMenuItem();
newKey.Name = thisKey.KeyName.Replace(" ","");
newKey.Size = new System.Drawing.Size(237, 22);
newKey.Text = thisKey.KeyName;
newKey.Click += new EventHandler(this.MakroKey_Click);
makrosMenu.DropDownItems.Add(newKey);
}
}
private void dgrExcelContents_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
statusLabel.Text = this.programmStrings.GetString("textEntities") + tblExcel2WinData.Rows.Count.ToString();
}
private void MakroKey_Click(object sender, EventArgs e)
{
if (!(sender is ToolStripMenuItem)) return;
ToolStripMenuItem thisItem = sender as ToolStripMenuItem;
makroKeys thisKey = programOptions.GetMakroKey(thisItem.Text);
if (thisKey == null)
return;
if (thisKey.TargetTextBox == "Define")
{
DialogResult result = MessageBox.Show(this.programmStrings.GetString("textImportTemplate1"), this.programmStrings.GetString("textImportTemplate2"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
return;
loadVorlage(thisKey.KeyTarget, "DEFINE");
}
else if (thisKey.TargetTextBox == "Table")
{
DialogResult result = MessageBox.Show(this.programmStrings.GetString("textImportTable1"), this.programmStrings.GetString("textImportTable2"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
return;
loadVorlage(thisKey.KeyTarget, "TABLE");
}
else
{
if (selectedNode == null)
{
DialogResult result = MessageBox.Show(this.programmStrings.GetString("textErrorNoOutputMakro1"), this.programmStrings.GetString("textErrorNoOutputMakro2"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
return;
}
loadVorlage(thisKey.KeyTarget, thisKey.TargetTextBox.ToUpper());
}
}
private void options_Click(object sender, EventArgs e)
{
optionsForm optionsForm = new optionsForm(this);
if (optionsForm.ShowDialog() != DialogResult.OK) return;
this.programOptions.WriteOptions();
}
private void clearAll_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show(this.programmStrings.GetString("textImportTemplate1"), this.programmStrings.GetString("textImportTemplate2"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
return;
newDocument();
}
private void newDocument() {
tblExcel2WinData = new DataTable();
dgrExcelContents.DataSource = tblExcel2WinData.DefaultView;
trvVorlageSelect.Nodes.Clear();
nodeTypen = new Dictionary<TreeNode, VorlagenType>();
if (nodeTextBoxes != null)
{
foreach (KeyValuePair<TreeNode, RichTextBox> thisPair in nodeTextBoxes)
{
splitContainer1.Panel2.Controls.Remove(thisPair.Value);
}
}
nodeTextBoxes = new Dictionary<TreeNode, RichTextBox>();
nodeOutputFile = new Dictionary<TreeNode, OutputFile>();
pnlFileProperties.Visible = false;
this.Text = "Script Builder - " + this.programmStrings.GetString("textNewTemplate");
currentTemplatePath = "";
Application.DoEvents();
}
private void docConvert_Click(object sender, EventArgs e)
{
string convertedText = "";
if (activeTextBox == null)
return;
foreach (string textLine in activeTextBox.Lines)
{
if (convertedText != "")
convertedText += "\r\n";
convertedText += textLine;
}
activeTextBox.Text = convertedText;
}
private RichTextBox activeTextBox
{
get {
if(selectedNode != null && nodeTextBoxes.ContainsKey(selectedNode))
return nodeTextBoxes[selectedNode];
else
return null;
}
}
private void wrongDotNetVersion()
{
this.Dispose();
Application.Exit();
}
public static void headerInFirstRow(DataTable InputTable)
{
if (InputTable.Rows.Count > 0 && InputTable.Columns.Count > 0)
{
for (int i = 0; i < InputTable.Columns.Count; i++)
{
if (InputTable.Rows[0].Field<string>(i) != null && InputTable.Rows[0].Field<string>(i).Trim() != "" && !InputTable.Columns.Contains(InputTable.Rows[0].Field<string>(i).Trim().Replace(" ", "_")))
InputTable.Columns[i].ColumnName = InputTable.Rows[0].Field<string>(i).Trim().Replace(" ", "_");
}
InputTable.Rows[0].Delete();
}
}
private void firstRowHeader_Click(object sender, EventArgs e)
{
headerInFirstRow(tblExcel2WinData);
}
private void vorlagenExport_Click(object sender, EventArgs e)
{
activateControlls(false);
string Ausgabedateiname = "";
string workLineText;
string startPath;
string caption;
DialogResult result;
SaveFileDialog saveOutput = new SaveFileDialog();
switch (programOptions.GetOptions("StartPathType").Value)
{
case "GroupsLast":
startPath = "StartPathTemplate";
break;
default:
startPath = "StartPath";
break;
}
saveOutput.InitialDirectory = programOptions.GetOptions(startPath).Value;
saveOutput.OverwritePrompt = true;
saveOutput.ValidateNames = true;
saveOutput.SupportMultiDottedExtensions = true;
saveOutput.AddExtension = true;
saveOutput.Filter = this.programmStrings.GetString("filterTemplateXml");
//saveOutput.Filter += "|" + this.programmStrings.GetString("filterTemplate");
saveOutput.DefaultExt = "stx";
saveOutput.FilterIndex = 1;
saveOutput.Title = this.programmStrings.GetString("textExportTemplate1");
if (currentTemplatePath != "")
saveOutput.FileName = Path.GetFileNameWithoutExtension(currentTemplatePath) + ".stx";
result = saveOutput.ShowDialog();
if (result == DialogResult.Cancel || result == DialogResult.Abort)
{
activateControlls(true);
return;
}
Ausgabedateiname = saveOutput.FileName.ToString();
CurrentPath = Path.GetDirectoryName(Ausgabedateiname);
if (programOptions.GetOptions("StartPathType").Value != "AlwaysSame")
programOptions.SetOptions(startPath, CurrentPath);
if (Path.GetExtension(saveOutput.FileName) == ".txt")
{
Encoding encoderOutput = Encoding.Default;
try
{
using (FileStream sw = new FileStream(Ausgabedateiname, FileMode.Create))
{
if (tblExcel2WinData.Columns.Count > 0)
{
writeLines("# Table", sw, encoderOutput, true);
createCSVValues(sw, encoderOutput, tblExcel2WinData);
}
foreach (TreeNode thisFile in trvVorlageSelect.Nodes)
{
OutputFile thisOutputFile;
if (nodeOutputFile.ContainsKey(thisFile))
thisOutputFile = nodeOutputFile[thisFile];
else
thisOutputFile = new OutputFile(thisFile.Name, startPath, 3);
if (!thisOutputFile.SerialFile)
writeLines("# File " + Path.Combine(thisOutputFile.FilePath, thisOutputFile.FileName).ToString(), sw, encoderOutput, true);
else
writeLines("# Serial " + Path.Combine(thisOutputFile.FilePath, thisOutputFile.FileName).ToString(), sw, encoderOutput, true);
writeLines("FileType=" + thisOutputFile.FileType.ToString(), sw, encoderOutput, true);
if (thisOutputFile.SerialFile)
{
if (thisOutputFile.SerialFieldLinkA != null && thisOutputFile.SerialFieldLinkA != "")
writeLines("LinkTableA=" + thisOutputFile.SerialFieldLinkA, sw, encoderOutput, true);
if (thisOutputFile.SerialFieldLinkB != null && thisOutputFile.SerialFieldLinkB != "")
writeLines("LinkTableB=" + thisOutputFile.SerialFieldLinkB, sw, encoderOutput, true);
if (thisOutputFile.SerialInputTable.Columns.Count > 0)
{
writeLines("SerialSourceTable", sw, encoderOutput, true);
createCSVValues(sw, encoderOutput, thisOutputFile.SerialInputTable);
}
}
foreach (TreeNode thisTemplate in thisFile.Nodes)
{
if (nodeTypen.ContainsKey(thisTemplate) && nodeTextBoxes.ContainsKey(thisTemplate))
{
if (nodeTypen[thisTemplate] == VorlagenType.Header)
caption = "# Simple " + thisTemplate.Text;
else if (nodeTypen[thisTemplate] == VorlagenType.Body)
//caption = "# Multi " + thisTemplate.Text;
caption = "# Repeated " + thisTemplate.Text;
else if (nodeTypen[thisTemplate] == VorlagenType.SerialHeader)
caption = "# SerialHeader " + thisTemplate.Text;
else
caption = "# Unknown " + thisTemplate.Text;
writeLines(caption, sw, encoderOutput, true);
foreach (string lineText in nodeTextBoxes[thisTemplate].Lines)
{
workLineText = lineText;
if (workLineText.StartsWith("#") || workLineText.StartsWith("\\"))
workLineText = "\\" + lineText;
writeLines(workLineText, sw, encoderOutput, true);
}
}
}
}
}
currentTemplatePath = Ausgabedateiname;
this.Text = "Script Builder - [" + Path.GetFileName(currentTemplatePath) + "]";
}
catch (Exception ex)
{
MessageBox.Show(this.programmStrings.GetString("textErrorUnexpected") + "\r\n" + ex.Message, this.programmStrings.GetString("textExportTemplate2"), MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else if (Path.GetExtension(saveOutput.FileName) == ".stx")
{
try
{
using (XmlTextWriter stxWriter = new XmlTextWriter(saveOutput.FileName , System.Text.Encoding.UTF8))
{
stxWriter.WriteStartDocument();
stxWriter.Formatting = Formatting.Indented;
stxWriter.WriteComment("Script Builder Template File");
//Begin Template Element
stxWriter.WriteStartElement("Template");
stxWriter.WriteAttributeString("Build", Assembly.GetExecutingAssembly().GetName().Version.ToString());
//Begin Table Element
stxWriter.WriteStartElement("Table");
if (tblExcel2WinData.Columns.Count > 0)
createXMLTable(stxWriter, tblExcel2WinData); //Create Table in XML Format
//End Table Element
stxWriter.WriteEndElement();
foreach (TreeNode thisFile in trvVorlageSelect.Nodes)
{
OutputFile thisOutputFile;
if (nodeOutputFile.ContainsKey(thisFile))
thisOutputFile = nodeOutputFile[thisFile];
else
thisOutputFile = new OutputFile(thisFile.Name, startPath, 3);
if (!thisOutputFile.SerialFile)
stxWriter.WriteStartElement("File"); //Write File Element
else
stxWriter.WriteStartElement("Serial"); //Write Serial File Element
//Write Attribute FileName
stxWriter.WriteAttributeString("FileName", Path.Combine(thisOutputFile.FilePath, thisOutputFile.FileName).ToString());
//Write Attribute FileType
stxWriter.WriteAttributeString("FileType",thisOutputFile.FileType.ToString());
//Write Serial Table when Serial File
if (thisOutputFile.SerialFile)
{
//Begin SerialSourceTable Element
stxWriter.WriteStartElement("SerialSourceTable");
//When LinkTableA is set write Attribute LinkTableA
if (thisOutputFile.SerialFieldLinkA != null && thisOutputFile.SerialFieldLinkA != "")
stxWriter.WriteAttributeString("LinkTableA", thisOutputFile.SerialFieldLinkA);
//When LinkTableA is set write Attribute LinkTableA
if (thisOutputFile.SerialFieldLinkB != null && thisOutputFile.SerialFieldLinkB != "")
stxWriter.WriteAttributeString("LinkTableB", thisOutputFile.SerialFieldLinkB);
if (thisOutputFile.SerialInputTable.Columns.Count > 0)
createXMLTable(stxWriter, thisOutputFile.SerialInputTable); //Create Table in XML Format
//End SerialSourceTable Element
stxWriter.WriteEndElement();
}
//Write Contents
foreach (TreeNode thisTemplate in thisFile.Nodes)
{
if (nodeTypen.ContainsKey(thisTemplate) && nodeTextBoxes.ContainsKey(thisTemplate))
{
if (nodeTypen[thisTemplate] == VorlagenType.Header)
stxWriter.WriteStartElement("Simple"); //Begin Simple Content Element
else if (nodeTypen[thisTemplate] == VorlagenType.Body)
stxWriter.WriteStartElement("Repeated"); //Begin Repeated Content Element
else if (nodeTypen[thisTemplate] == VorlagenType.SerialHeader)
stxWriter.WriteStartElement("SerialHeader"); //Begin SerialHeader Content Element