diff --git a/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs b/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs
index da44107..58a382e 100644
--- a/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs
+++ b/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs
@@ -9,7 +9,7 @@ namespace BoerseDataConvert
{
public class RecordController
{
- private static int count;
+ private static int count;
private static string cur_fileName;
public RecordController(string fileName)
@@ -30,7 +30,7 @@ namespace BoerseDataConvert
{
try
{
- string tag =CheckTagValue(tagValue.Key, tagValue.Value);
+ string tag = CheckTagValue(tagValue.Key, tagValue.Value);
xmlRecord.Append($" <{tag}>{tagValue.Value}{tag}>\n");
}
catch (ArgumentException e)
@@ -44,11 +44,11 @@ namespace BoerseDataConvert
}
private string CheckTagValue(string tag, string value)
{
- string tagname="";
+ string tagname = "";
StreamReader reader = new StreamReader(@"..\..\..\..\tags.txt");
using (reader)
{
- string[] tagLine= null ;
+ string[] tagLine = null;
while (!reader.EndOfStream)
{
string[] line = reader.ReadLine().Split('|').ToArray();
@@ -76,7 +76,7 @@ namespace BoerseDataConvert
}
}
- else
+ else
{
string[] valueRange = tagLine[3].Split('#').ToArray();
bool countain = false;
@@ -87,10 +87,10 @@ namespace BoerseDataConvert
{
countain = true;
break;
- }
+ }
}
- if(!countain) throw new ArgumentException("Value is not in value range!");
- }
+ if (!countain) throw new ArgumentException("Value is not in value range!");
+ }
}
return tagname;
}
diff --git a/BoerseDataConvert/BoerseDataConvert/Views/Program.cs b/BoerseDataConvert/BoerseDataConvert/Views/Program.cs
index 5a78b5b..d4733b6 100644
--- a/BoerseDataConvert/BoerseDataConvert/Views/Program.cs
+++ b/BoerseDataConvert/BoerseDataConvert/Views/Program.cs
@@ -15,29 +15,47 @@ namespace BoerseDataConvert
// -d directory or --dir directory
// -o directory or --output direcory
// -h - help
- // Console.OutputEncoding = System.Text.Encoding.UTF8;
+
+ // input handling
+ string zipFile = "", inputDir = "", outputDir = "";
Console.WriteLine();
if (args.Contains("-i") || args.Contains("--input"))
{
- string zipfile = args[Array.IndexOf(args, "-i") + 1];
+ zipFile = args[Array.IndexOf(args, "-i") + 1];
}
if (args.Contains("-d") || args.Contains("--directory"))
{
- string inputDir = args[Array.IndexOf(args, "-d" + 1)];
+ inputDir = args[Array.IndexOf(args, "-d") + 1];
}
if (args.Contains("-o") || args.Contains("--output"))
{
- string outputDir = args[Array.IndexOf(args, "-o" + 1)];
+ outputDir = args[Array.IndexOf(args, "-o") + 1];
}
if (args.Contains("-h") || args.Contains("--help"))
{
Help();
return;
}
- Reader reader = new Reader(@"E:\Downloads\TestData-2021_07_02", new string[1] { "subtype910.txt" });
- // Reader reader = new Reader(@"D:\Code\ИТ Кариера\Стаж\задача\TestData-2021_07_02", new string[1] { "subtype910.txt" });
- RecordController a = new RecordController("subtype910.txt");
- Writer writer = new Writer("subtype910.txt");
+ zipFile = @"D:\Code\ИТ Кариера\Стаж\задача\testdata.zip";
+ inputDir = @"D:\Code\ИТ Кариера\Стаж\задача\TestData";
+ outputDir = @"D:\Code\ИТ Кариера\Стаж\задача\outputdir";
+ if (zipFile == "" || inputDir == "" || outputDir == "")
+ {
+ throw new ArgumentException("Fields cannot be empty");
+ }
+
+ // TODO: clear matching files from inputDir
+ // TODO: check free disk space before file ops
+
+ ZipFile.ExtractToDirectory(zipFile, inputDir); // zip extract
+
+ // read files
+ string[] fileNames = Directory.GetFiles(inputDir).Select(x => x.Split('\\', '/').Last()).ToArray();
+
+ Reader reader = new Reader(inputDir, fileNames);
+ Writer writer = new Writer(outputDir, fileNames[0]);
+ RecordController a = new RecordController(fileNames[0]);
+
while (true)
{
try
@@ -48,20 +66,21 @@ namespace BoerseDataConvert
}
catch (IndexOutOfRangeException e)
{
+ Reader.EndFile();
Writer.EndFile();
break;
}
-
+ }
+ static void Help()
+ {
+ Console.WriteLine("BoerseDataConvert v1.0.0");
+ Console.WriteLine("D. Delchev and D. Byalkov, 2021");
+ Console.WriteLine("---");
+ Console.WriteLine("-i or --input ");
+ Console.WriteLine("-d or --directory ");
+ Console.WriteLine("-o