Skip to content

Commit 419ad10

Browse files
committed
Separating saved files
1 parent 4caf579 commit 419ad10

9 files changed

+222
-132
lines changed

Virtual_EDW/CustomTabPage.cs

Lines changed: 143 additions & 90 deletions
Large diffs are not rendered by default.

Virtual_EDW/FodyWeavers.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
3-
<Costura />
4-
</Weavers>
1+
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd" />

Virtual_EDW/Form_Main.cs

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
using System.Drawing;
77
using System.IO;
88
using System.Linq;
9-
using System.Security.Permissions;
109
using System.Text;
1110
using System.Threading;
1211
using System.Windows.Forms;
1312
using DataWarehouseAutomation;
14-
using DataWarehouseAutomation.DwaModel;
15-
using DataWarehouseAutomation.Utils;
1613
using Newtonsoft.Json;
1714
using Newtonsoft.Json.Linq;
1815
using TEAM_Library;
@@ -43,7 +40,7 @@ public FormMain()
4340
InitializeComponent();
4441

4542
// Set the version of the build for everything
46-
const string versionNumberForApplication = "v1.6.14";
43+
const string versionNumberForApplication = "v1.7.0";
4744

4845
Text = $"Virtual Data Warehouse - {versionNumberForApplication}";
4946
labelWelcome.Text = $"{labelWelcome.Text} - {versionNumberForApplication}";
@@ -586,7 +583,7 @@ internal class LocalTemplate
586583
{
587584
internal string classification { get; set; }
588585
internal string notes { get; set; }
589-
internal Dictionary<string, VdwDataObjectMappingList> itemList { get; set; }
586+
internal Dictionary<string, VdwDataObjectMappingList> vdwDataObjectMappingList { get; set; }
590587
}
591588

592589

@@ -602,13 +599,12 @@ internal void InformUser(string text, EventTypes eventType)
602599
/// <returns></returns>
603600
internal List<LocalTemplate> GetMetadata()
604601
{
605-
606602
var hideDisabled = checkBoxHideDisabled.Checked;
607603

608604
#region Deserialisation
609605

610606
// Deserialise the Json files into a local List of Data Object Mappings (mappingList) for further use.
611-
List<VdwDataObjectMappingList> mappingList = new List<VdwDataObjectMappingList>();
607+
List<VdwDataObjectMappingList> vdwDataObjectMappigLists = new List<VdwDataObjectMappingList>();
612608

613609
if (Directory.Exists(VdwConfigurationSettings.VdwMetadatPath))
614610
{
@@ -632,6 +628,17 @@ internal List<LocalTemplate> GetMetadata()
632628
"Production_TEAM_Table_Mapping.json"
633629
};
634630

631+
var localConventions = new MetadataConfiguration();
632+
localConventions.recordSourceAttribute = TeamConfigurationSettings.RecordSourceAttribute;
633+
localConventions.recordChecksumAttribute = TeamConfigurationSettings.RecordChecksumAttribute;
634+
localConventions.changeDataCaptureAttribute = TeamConfigurationSettings.ChangeDataCaptureAttribute;
635+
localConventions.expiryDateTimeAttribute = TeamConfigurationSettings.ExpiryDateTimeAttribute;
636+
localConventions.eventDateTimeAttribute = TeamConfigurationSettings.EventDateTimeAttribute;
637+
localConventions.etlProcessAttribute = TeamConfigurationSettings.EtlProcessAttribute;
638+
localConventions.changeDataCaptureAttribute = TeamConfigurationSettings.ChangeDataCaptureAttribute;
639+
localConventions.loadDateTimeAttribute = TeamConfigurationSettings.LoadDateTimeAttribute;
640+
localConventions.sourceRowIdAttribute = TeamConfigurationSettings.RowIdAttribute;
641+
635642
if (fileEntries.Length > 0)
636643
{
637644
foreach (var fileName in fileEntries)
@@ -677,10 +684,13 @@ internal List<LocalTemplate> GetMetadata()
677684
}
678685
deserialisedMapping.DataObjectMappings = tempDOM;
679686

687+
688+
680689
if (deserialisedMapping != null)
681690
{
682691
deserialisedMapping.metadataFileName = fileName;
683-
mappingList.Add(deserialisedMapping);
692+
deserialisedMapping.metadataConfiguration = localConventions;
693+
vdwDataObjectMappigLists.Add(deserialisedMapping);
684694
}
685695
}
686696
catch (Exception exception)
@@ -716,23 +726,23 @@ internal List<LocalTemplate> GetMetadata()
716726
// In the Tuple, Item1 is the classification, Item2 is the mapping name and Item 3 is notes.
717727
Dictionary<VdwDataObjectMappingList, Tuple<string, string, string>> objectDictionary = new Dictionary<VdwDataObjectMappingList, Tuple<string, string, string>>();
718728

719-
if (mappingList.Any())
729+
if (vdwDataObjectMappigLists.Any())
720730
{
721-
foreach (VdwDataObjectMappingList dataObjectMappings in mappingList)
731+
foreach (VdwDataObjectMappingList dataObjectMappings in vdwDataObjectMappigLists)
722732
{
723733
if (dataObjectMappings.DataObjectMappings != null)
724734
{
725735
foreach (DataObjectMapping dataObjectMapping in dataObjectMappings.DataObjectMappings)
726736
{
727-
if (dataObjectMapping.Name == null)
737+
if (dataObjectMapping.MappingName == null)
728738
{
729-
dataObjectMapping.Name = dataObjectMapping.TargetDataObject.Name;
739+
dataObjectMapping.MappingName = dataObjectMapping.TargetDataObject.Name;
730740
InformUser($"The Data Object Mapping for target {dataObjectMapping.TargetDataObject.Name} does not have a mapping name, so the target name is used.", EventTypes.Warning);
731741
}
732742
// Check if there are classifications, as these are used to create the tabs.
733-
if (dataObjectMapping.Classifications != null)
743+
if (dataObjectMapping.MappingClassifications != null)
734744
{
735-
foreach (DataClassification classification in dataObjectMapping.Classifications)
745+
foreach (DataClassification classification in dataObjectMapping.MappingClassifications)
736746
{
737747
if (!objectDictionary.ContainsKey(dataObjectMappings))
738748
{
@@ -747,7 +757,7 @@ internal List<LocalTemplate> GetMetadata()
747757
objectDictionary.Add(dataObjectMappings, new Tuple<string, string, string>("Miscellaneous", dataObjectMapping.TargetDataObject.Name, ""));
748758
}
749759

750-
InformUser($"The Data Object Mapping {dataObjectMapping.Name} does not have a classification, and therefore will be placed under 'Miscellaneous'", EventTypes.Warning);
760+
InformUser($"The Data Object Mapping {dataObjectMapping.MappingName} does not have a classification, and therefore will be placed under 'Miscellaneous'", EventTypes.Warning);
751761
}
752762
}
753763
}
@@ -799,7 +809,7 @@ internal List<LocalTemplate> GetMetadata()
799809

800810
localTemplateMapping.classification = classification.Key;
801811
localTemplateMapping.notes = classification.Value;
802-
localTemplateMapping.itemList = itemList;
812+
localTemplateMapping.vdwDataObjectMappingList = itemList;
803813

804814
finalMappingList.Add(localTemplateMapping);
805815
}
@@ -839,6 +849,7 @@ internal void CreateCustomTabPages()
839849
Dictionary<string, LocalTemplate> sortedMappingList = new Dictionary<string, LocalTemplate>();
840850
foreach (var mapping in finalMappingList)
841851
{
852+
int counter = 1;
842853
string orderNumber = mapping.classification switch
843854
{
844855
"Source" => "0",
@@ -862,16 +873,25 @@ internal void CreateCustomTabPages()
862873
"NaturalBusinessRelationshipContextDrivingKey" => "71",
863874
"Link-Satellite Driving Key" => "72",
864875
"Presentation" => "80",
865-
_ => "900"
876+
"Helper" => "85",
877+
"Export" => "86",
878+
_ => $"{900+counter}" // To ensure uniquness for all unknowns
866879
};
867880

868-
sortedMappingList.Add(orderNumber, mapping);
881+
if (!sortedMappingList.ContainsKey(orderNumber))
882+
{
883+
sortedMappingList.Add(orderNumber, mapping);
884+
}
885+
else
886+
{
887+
// TODO
888+
}
869889
}
870890

871891
// Add the Custom Tab Pages
872892
foreach (var template in sortedMappingList.OrderBy(x => x.Key))
873893
{
874-
CustomTabPage localCustomTabPage = new CustomTabPage(template.Value.classification, template.Value.notes, template.Value.itemList);
894+
CustomTabPage localCustomTabPage = new CustomTabPage(template.Value.classification, template.Value.notes, template.Value.vdwDataObjectMappingList);
875895
localCustomTabPage.OnChangeMainText += UpdateMainInformationTextBox;
876896
localCustomTabPage.OnClearMainText += ClearMainInformationTextBox;
877897

@@ -998,7 +1018,7 @@ private void RefreshMetadata()
9981018
{
9991019
if (localTemplate.classification == tabName)
10001020
{
1001-
customTabPage.SetItemList(localTemplate.itemList);
1021+
customTabPage.SetItemList(localTemplate.vdwDataObjectMappingList);
10021022
}
10031023
}
10041024
}
@@ -1249,24 +1269,23 @@ private void SaveTemplateCollectionFileToolStripMenuItem_Click(object sender, Ev
12491269
TemplateType = singleRow[1].ToString(),
12501270
TemplateConnectionKey = singleRow[2].ToString(),
12511271
TemplateOutputFileConvention = singleRow[3].ToString(),
1252-
TemplateFilePath = singleRow[4].ToString(),
1253-
TemplateNotes = singleRow[5].ToString()
1272+
TemplateOutputFileSplit = singleRow[4].ToString(),
1273+
TemplateFilePath = singleRow[5].ToString(),
1274+
TemplateNotes = singleRow[6].ToString()
12541275
});
12551276
outputFileArray.Add(individualRow);
12561277
}
12571278

12581279
string json = JsonConvert.SerializeObject(outputFileArray, Formatting.Indented);
12591280

1260-
12611281
File.WriteAllText(chosenFile, json);
12621282

12631283
SetTextMain("The file " + chosenFile + " was updated.\r\n");
12641284

12651285
try
12661286
{
12671287
// Quick fix, in the file again to commit changes to memory.
1268-
VdwConfigurationSettings.templateList =
1269-
JsonConvert.DeserializeObject<List<TemplateHandling>>(File.ReadAllText(chosenFile));
1288+
VdwConfigurationSettings.templateList = JsonConvert.DeserializeObject<List<TemplateHandling>>(File.ReadAllText(chosenFile));
12701289
CreateCustomTabPages();
12711290
}
12721291
catch (Exception ex)

Virtual_EDW/GlobalSuppressions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
using System.Diagnostics.CodeAnalysis;
77

88
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>", Scope = "member", Target = "~M:Virtual_Data_Warehouse.FormMain.#ctor")]
9+
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>", Scope = "member", Target = "~M:Virtual_Data_Warehouse.FormMain.SaveTemplateCollectionFileToolStripMenuItem_Click(System.Object,System.EventArgs)")]
10+
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>", Scope = "member", Target = "~M:Virtual_Data_Warehouse.FormMain.PictureBoxUpdateTemplatePath_Click(System.Object,System.EventArgs)")]
11+
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>", Scope = "member", Target = "~M:Virtual_Data_Warehouse.FormMain.openTemplateCollectionFileToolStripMenuItem_Click(System.Object,System.EventArgs)")]
12+
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>", Scope = "member", Target = "~M:Virtual_Data_Warehouse.CustomTabPage.GenerateFromTemplate")]

Virtual_EDW/InterfaceObjectModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using DataWarehouseAutomation;
3-
using DataWarehouseAutomation.DwaModel;
43

54
namespace Virtual_Data_Warehouse
65
{
@@ -11,9 +10,11 @@ namespace Virtual_Data_Warehouse
1110
class VdwDataObjectMappingList : DataObjectMappingList
1211
{
1312
// TEAM and VDW specific details
14-
public MetadataConfiguration conventions { get; set; }
13+
public MetadataConfiguration metadataConfiguration { get; set; }
1514

1615
public string metadataFileName { get; set; }
16+
17+
public GenerationSpecificMetadata generationSpecificMetadata { get; set; }
1718
}
1819

1920

Virtual_EDW/LoadPatternGrid.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ public TemplateGridView(TeamConfiguration teamConfiguration)
9696
};
9797
Columns.Add(TemplateOutputFileConvention);
9898

99+
DataGridViewCheckBoxColumn TemplateOutputFileSplit= new DataGridViewCheckBoxColumn
100+
{
101+
Name = TemplateGridColumns.TemplateOutputFileSplit.ToString(),
102+
HeaderText = "Separate Files",
103+
DataPropertyName = TemplateGridColumns.TemplateOutputFileSplit.ToString(),
104+
MinimumWidth = 100
105+
};
106+
Columns.Add(TemplateOutputFileSplit);
107+
99108
DataGridViewTextBoxColumn TemplatePath = new DataGridViewTextBoxColumn
100109
{
101110
Name = TemplateGridColumns.TemplateFilePath.ToString(),
@@ -108,7 +117,8 @@ public TemplateGridView(TeamConfiguration teamConfiguration)
108117
{
109118
Name = TemplateGridColumns.TemplateNotes.ToString(),
110119
HeaderText = "Notes",
111-
DataPropertyName = TemplateGridColumns.TemplateNotes.ToString()
120+
DataPropertyName = TemplateGridColumns.TemplateNotes.ToString(),
121+
MinimumWidth = 100
112122
//Width = 400
113123
};
114124
Columns.Add(TemplateNotes);
@@ -208,8 +218,9 @@ public enum TemplateGridColumns
208218
TemplateType = 1,
209219
TemplateConnectionKey = 2,
210220
TemplateOutputFileConvention = 3,
211-
TemplateFilePath = 4,
212-
TemplateNotes = 5,
221+
TemplateOutputFileSplit = 4,
222+
TemplateFilePath = 5,
223+
TemplateNotes = 6,
213224
}
214225

215226

Virtual_EDW/TemplateHandling.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class TemplateHandling
1919
public string TemplateType { get; set; }
2020
public string TemplateConnectionKey { get; set; }
2121
public string TemplateOutputFileConvention { get; set; }
22+
public bool TemplateOutputFileSplit { get; set; } = false;
2223
public string TemplateFilePath { get; set; }
2324
public string TemplateNotes { get; set; }
2425

Virtual_EDW/VdwUtility.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using Microsoft.Data.SqlClient;
32
using System.IO;
43
using System.Reflection;
54
using System.Text;
@@ -8,11 +7,8 @@
87
using Microsoft.SqlServer.Management.Smo;
98
using Microsoft.Win32;
109
using TEAM_Library;
11-
using System.Data.SqlClient;
12-
using Microsoft.SqlServer.Management.Sdk.Sfc;
1310
using System.Data;
1411
using Snowflake.Data.Client;
15-
using System.Linq;
1612

1713

1814
namespace Virtual_Data_Warehouse

Virtual_EDW/Virtual_Data_Warehouse.csproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
<None Remove="Templates\template_test_SAT_StagingMappingCheck.Handlebars" />
140140
</ItemGroup>
141141
<ItemGroup>
142+
<Reference Include="Snowflake.Data">
143+
<HintPath>Libraries\Snowflake.Data.dll</HintPath>
144+
</Reference>
142145
<Reference Include="TEAM_Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
143146
<SpecificVersion>False</SpecificVersion>
144147
<HintPath>Libraries\TEAM_Library.dll</HintPath>
@@ -589,22 +592,26 @@
589592
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
590593
</ItemGroup>
591594
<ItemGroup>
595+
<PackageReference Include="Costura.Fody" Version="5.7.0">
596+
<PrivateAssets>all</PrivateAssets>
597+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
598+
</PackageReference>
592599
<PackageReference Include="DataWarehouseAutomation">
593600
<Version>1.3.4</Version>
594601
</PackageReference>
595-
<PackageReference Include="Fody" Version="6.8.1">
602+
<PackageReference Include="Fody" Version="6.8.2">
596603
<PrivateAssets>all</PrivateAssets>
597-
<IncludeAssets>runtime; compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
604+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
598605
</PackageReference>
599606
<PackageReference Include="Handlebars.Net">
600607
<Version>2.1.6</Version>
601608
</PackageReference>
602-
<PackageReference Include="log4net" Version="2.0.17" />
609+
<PackageReference Include="log4net" Version="3.0.1" />
603610
<PackageReference Include="Microsoft.Data.SqlClient">
604611
<Version>5.2.2</Version>
605612
</PackageReference>
606613
<PackageReference Include="Microsoft.Identity.Client">
607-
<Version>4.64.0</Version>
614+
<Version>4.65.0</Version>
608615
</PackageReference>
609616
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects">
610617
<Version>171.30.0</Version>
@@ -616,5 +623,6 @@
616623
<PrivateAssets>all</PrivateAssets>
617624
</PackageReference>
618625
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.8" />
626+
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
619627
</ItemGroup>
620628
</Project>

0 commit comments

Comments
 (0)