From 879eb3766b04ec3c5d158b1294e2eced1dc74b62 Mon Sep 17 00:00:00 2001 From: Dimitar Byalkov Date: Thu, 8 Jul 2021 20:06:45 +0300 Subject: [PATCH] Tag parameter --- .../Controller/RecordController.cs | 4 +- .../BoerseDataConvert/Model/TagsTable.cs | 4 +- .../BoerseDataConvert/Views/Program.cs | 41 +++++++++++++++---- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs b/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs index 891bda5..08020c4 100644 --- a/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs +++ b/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs @@ -12,11 +12,11 @@ namespace BoerseDataConvert private static int count; private static string cur_fileName; private TagsTable tagsTable; - public RecordController(string fileName) + public RecordController(string fileName, string tags) { count = 1; cur_fileName = fileName; - tagsTable = new TagsTable(); + tagsTable = new TagsTable(tags); } public static void NextFile(string fileName) { diff --git a/BoerseDataConvert/BoerseDataConvert/Model/TagsTable.cs b/BoerseDataConvert/BoerseDataConvert/Model/TagsTable.cs index 9b40e96..6ab7658 100644 --- a/BoerseDataConvert/BoerseDataConvert/Model/TagsTable.cs +++ b/BoerseDataConvert/BoerseDataConvert/Model/TagsTable.cs @@ -11,9 +11,9 @@ namespace BoerseDataConvert { StreamReader reader ; Dictionary table; - public TagsTable() + public TagsTable(string tags) { - reader = new StreamReader(@"..\..\..\..\tags.txt"); + reader = new StreamReader(tags); table = new Dictionary(); LoadInfo(); } diff --git a/BoerseDataConvert/BoerseDataConvert/Views/Program.cs b/BoerseDataConvert/BoerseDataConvert/Views/Program.cs index d5d8d1f..01a7bbc 100644 --- a/BoerseDataConvert/BoerseDataConvert/Views/Program.cs +++ b/BoerseDataConvert/BoerseDataConvert/Views/Program.cs @@ -15,7 +15,7 @@ namespace BoerseDataConvert // -d directory or --dir directory // -o directory or --output direcory // -h - help - /* + FileStream ostrm; StreamWriter writer1; TextWriter oldOut = Console.Out; @@ -30,11 +30,11 @@ namespace BoerseDataConvert return; } Console.SetOut(writer1); - */ + // input handling string[] input = InputValidate(args); - string zipFile = input[0], inputDir = input[1], outputDir = input[2]; + string zipFile = input[0], inputDir = input[1], outputDir = input[2], tags = input[3]; CheckFreeDisk(outputDir); ZipExtract(zipFile, inputDir); @@ -44,7 +44,7 @@ namespace BoerseDataConvert Reader reader = new Reader(inputDir, fileNames); Writer writer = new Writer(outputDir, fileNames[0]); - RecordController a = new RecordController(fileNames[0]); + RecordController a = new RecordController(fileNames[0], tags); while (true) { @@ -72,6 +72,7 @@ namespace BoerseDataConvert Console.WriteLine("-i or --input "); Console.WriteLine("-d or --directory "); Console.WriteLine("-o or --output "); + Console.WriteLine("-t or --tags "); Console.WriteLine("-h or --help - Prints this message"); Environment.Exit(0); } @@ -89,22 +90,46 @@ namespace BoerseDataConvert } static string[] InputValidate(string[] args) { - string[] output = new string[3]; + string[] output = new string[4]; // check input zipfile parameter - if (args.Contains("-i") || args.Contains("--input")) + if (args.Contains("-i")) { output[0] = args[Array.IndexOf(args, "-i") + 1]; } + if (args.Contains("--input")) + { + output[0] = args[Array.IndexOf(args, "--input") + 1]; + } // check input directory parameter - if (args.Contains("-d") || args.Contains("--directory")) + if (args.Contains("-d")) { output[1] = args[Array.IndexOf(args, "-d") + 1]; } + if (args.Contains("--directory")) + { + output[1] = args[Array.IndexOf(args, "--directory") + 1]; + } // check output directory parameter - if (args.Contains("-o") || args.Contains("--output")) + if (args.Contains("-o")) { output[2] = args[Array.IndexOf(args, "-o") + 1]; } + if (args.Contains("--output")) + { + output[2] = args[Array.IndexOf(args, "-output") + 1]; + } + if (args.Contains("-t")) + { + output[3] = args[Array.IndexOf(args, "-t") + 1]; + } + if (args.Contains("--tags")) + { + output[3] = args[Array.IndexOf(args, "--tags") + 1]; + } + if (!args.Contains("-t") || !args.Contains("--tags")) + { + output[3] = "tags.txt"; + } // check help parameter if (args.Contains("-h") || args.Contains("--help")) {