From 35bd65fcc20d3296997f4fdf1fd45d1f721bfd48 Mon Sep 17 00:00:00 2001 From: Simon Martens Date: Thu, 14 Sep 2023 18:47:54 +0200 Subject: [PATCH] Intoduced project --- Transformation-2023-9-15/.vscode/launch.json | 7 ++++ Transformation-2023-9-15/Program.cs | 40 +++++++++++++++++++ .../Transformation-2023-9-15.csproj | 11 +++++ 3 files changed, 58 insertions(+) create mode 100644 Transformation-2023-9-15/.vscode/launch.json create mode 100644 Transformation-2023-9-15/Program.cs create mode 100644 Transformation-2023-9-15/Transformation-2023-9-15.csproj diff --git a/Transformation-2023-9-15/.vscode/launch.json b/Transformation-2023-9-15/.vscode/launch.json new file mode 100644 index 0000000..5c7247b --- /dev/null +++ b/Transformation-2023-9-15/.vscode/launch.json @@ -0,0 +1,7 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [] +} \ No newline at end of file diff --git a/Transformation-2023-9-15/Program.cs b/Transformation-2023-9-15/Program.cs new file mode 100644 index 0000000..3251f3c --- /dev/null +++ b/Transformation-2023-9-15/Program.cs @@ -0,0 +1,40 @@ +using System.IO; +using System.Xml.Linq; +// See https://aka.ms/new-console-template for more information +const string XML_PATH = "D:/Simon/source/hamann-xml/transformations_2023-9-14_test/"; +const string GIT_PATH = "../../hamann-xml/"; +const string BRANCH_NAME = "testdata"; + +if (File.Exists(GIT_PATH + ".git/HEAD") || !Directory.Exists(XML_PATH)) { + var text = File.ReadAllText(GIT_PATH + ".git/HEAD").Trim(); + if (!text.EndsWith(BRANCH_NAME)) { + throw new("Not it the Branch " + BRANCH_NAME); + } +} else { + throw new("Specified Paths do not exist"); +} + +var xmls = Directory.GetFiles(XML_PATH, "*.xml"); + +if (xmls == null || !xmls.Any()) { + throw new("No XML Data fonund!"); +} + +List<(string, XDocument)> Documents = new(); + +foreach (var f in xmls) { + Documents.Add((f, XDocument.Load(f, LoadOptions.PreserveWhitespace))); + Console.WriteLine("" + f); +} + + +void SaveHamannFile(XElement element, string basefilepath, string oldfile) { + var filename = "hamann_" + ".xml"; + var path = Path.Combine(basefilepath, filename); + + if (!Directory.Exists(basefilepath)) + Directory.CreateDirectory(basefilepath); + using (var targetStream = System.IO.File.Create(path)) + element.Save(targetStream, SaveOptions.DisableFormatting); + + } \ No newline at end of file diff --git a/Transformation-2023-9-15/Transformation-2023-9-15.csproj b/Transformation-2023-9-15/Transformation-2023-9-15.csproj new file mode 100644 index 0000000..0fef654 --- /dev/null +++ b/Transformation-2023-9-15/Transformation-2023-9-15.csproj @@ -0,0 +1,11 @@ + + + + Exe + net6.0 + Transformation_2023_9_15 + enable + enable + + +