diff --git a/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs b/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs
index d243e05..f8e2b53 100644
--- a/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs
+++ b/BoerseDataConvert/BoerseDataConvert/Controller/RecordController.cs
@@ -20,6 +20,12 @@ namespace BoerseDataConvert
{
get { return count - 1; }
}
+ ///
+ /// It create XML writer,xml file, writes the first line in it
+ ///
+ /// output directoty
+ /// currnt file name
+ /// Locataion of tags,txt
public RecordController(string adr, string fileName, string tags)
{
count = 1;
@@ -36,6 +42,11 @@ namespace BoerseDataConvert
writer.WriteAttributeString("name", null, cur_fileName);
warning = new WarningStat(fileName);
}
+ ///
+ /// It writes the last line, closes the flie, and XMLwriter
+ /// and It creates new XML writer,new xml file, writes the first line in it
+ ///
+ /// name of the next file
public static void NextFile(string fileName)
{
writer.WriteEndElement();
@@ -54,13 +65,27 @@ namespace BoerseDataConvert
writer.WriteStartElement("table");
writer.WriteAttributeString("name", null, cur_fileName);
}
- public void WriteXmlRecord(Record record)
+ ///
+ /// It write the information in the record into the XML file
+ ///
+ /// Record that stores information about one record from the files
+ /// if true it makes a fastChech
+ public void WriteXmlRecord(Record record,bool fastCheck)
{
writer.WriteStartElement("record");
writer.WriteAttributeString("id", null, count.ToString());
foreach (var tagValue in record)
{
- string tag = CheckTagValue(tagValue.Key, tagValue.Value);
+ string tag = "";
+ if (fastCheck)
+ {
+ tag = FastChechTag(tagValue.Key);
+ }
+ else
+ {
+ tag = FullCheckTagValue(tagValue.Key, tagValue.Value);
+ }
+
if (tag != null)
{
writer.WriteStartElement(tag);
@@ -78,7 +103,30 @@ namespace BoerseDataConvert
writer.Close();
warning.PrintWarnigs();
}
- private string CheckTagValue(int tag, string value)
+ ///
+ /// It checks only if the tag is valid
+ ///
+ /// tag in the numeric form
+ /// return name of the tag
+ private string FastChechTag(int tag)
+ {
+ if (tagsTable.CheckInvalidTag(tag))
+ {
+ warning.Add(tag);
+ return null;
+ }
+ else
+ {
+ return tagsTable.GetTagName(tag);
+ }
+ }
+ ///
+ /// It make a full check on the value
+ ///
+ /// tag in the numeric form
+ ///
+ /// return name of the tag
+ private string FullCheckTagValue(int tag, string value)
{
if (tagsTable.CheckInvalidTag(tag))
{
diff --git a/BoerseDataConvert/BoerseDataConvert/Model/Record.cs b/BoerseDataConvert/BoerseDataConvert/Model/Record.cs
index 99732eb..e8e1b69 100644
--- a/BoerseDataConvert/BoerseDataConvert/Model/Record.cs
+++ b/BoerseDataConvert/BoerseDataConvert/Model/Record.cs
@@ -7,19 +7,30 @@ using System.Threading.Tasks;
namespace BoerseDataConvert
{
-
+ ///
+ /// Class Recorrd stores information about the tags and the values of every record
+ ///
public class Record : IEnumerable
{
+ //The tags and the values are stored in list from KeyValuePair where the tags are the keys
private List> TagsValues;
public Record()
{
TagsValues = new List>();
}
+ ///
+ /// This method adds a new TagValuePair in the TagsValues
+ ///
+ ///
+ ///
public void Add(int tag, string value)
{
TagsValues.Add(new KeyValuePair(tag, value));
}
+ ///
+ /// The iterator for class Record
+ ///
public IEnumerator> GetEnumerator()
{
foreach (var item in TagsValues)
diff --git a/BoerseDataConvert/BoerseDataConvert/Model/Tag.cs b/BoerseDataConvert/BoerseDataConvert/Model/Tag.cs
index 7741485..18528ed 100644
--- a/BoerseDataConvert/BoerseDataConvert/Model/Tag.cs
+++ b/BoerseDataConvert/BoerseDataConvert/Model/Tag.cs
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace BoerseDataConvert
{
+ ///
+ /// This class stores the name,the type and the value ranges for one tag
+ ///
public class Tag
{
private string name;
@@ -31,22 +34,37 @@ namespace BoerseDataConvert
}
else haveValueRanges = false;
}
+ ///
+ /// Returns the name of the tag
+ ///
public string Name
{
get { return name; }
}
+ ///
+ /// Returns true if the type of the tag is string
+ ///
public bool IsString
{
get { return isString; }
}
+ ///
+ /// Returns true if the tag has a value ranges
+ ///
public bool HaveValueRanges
{
get { return haveValueRanges; }
}
+ ///
+ /// Returns max length of the string value
+ ///
public int StringLength
{
get { return stringLength; }
}
+ ///
+ /// Returns true if the value is in the value ranges
+ ///
public bool ValidValue(string value)
{
foreach (string validValue in valueRanges)
diff --git a/BoerseDataConvert/BoerseDataConvert/Model/WarningStat.cs b/BoerseDataConvert/BoerseDataConvert/Model/WarningStat.cs
index 3d228a2..397f03f 100644
--- a/BoerseDataConvert/BoerseDataConvert/Model/WarningStat.cs
+++ b/BoerseDataConvert/BoerseDataConvert/Model/WarningStat.cs
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace BoerseDataConvert
{
+ ///
+ /// This class strores information about a invalid tags in a file
+ ///
public class WarningStat
{
private Dictionary tableWarnings;
@@ -15,7 +18,11 @@ namespace BoerseDataConvert
curFile = fileName;
tableWarnings = new Dictionary();
}
- public void Add(int tag)
+ ///
+ /// It increases count of encounters if the invalid tag or it sets it to 1 if the tag is new
+ ///
+ /// Invalid tag in numerical form
+ public void Add(int tag)
{
if (tableWarnings.ContainsKey(tag))
{
@@ -26,6 +33,9 @@ namespace BoerseDataConvert
tableWarnings.Add(tag, 1);
}
}
+ ///
+ /// It prints the count of encounters of every invalid tag in the file
+ ///
public void PrintWarnigs()
{
if (tableWarnings.Count == 0)
diff --git a/BoerseDataConvert/BoerseDataConvert/Views/Program.cs b/BoerseDataConvert/BoerseDataConvert/Views/Program.cs
index dd460a8..6747fd3 100644
--- a/BoerseDataConvert/BoerseDataConvert/Views/Program.cs
+++ b/BoerseDataConvert/BoerseDataConvert/Views/Program.cs
@@ -15,6 +15,7 @@ namespace BoerseDataConvert
static string outputDirectory;
static string tagsFile;
static bool helpMessage;
+ static bool fastCheck;
static void Main(string[] args)
{
/*
@@ -48,6 +49,7 @@ namespace BoerseDataConvert
"The working directory is cleared recursively if it isn't empty!",
{ "o|output=", "specify output directory", x => outputDirectory = x },
{ "t|tags=", "specify tag file", x => tagsFile = x },
+ { "f|fast|fastcheck=", "specify tag file", x => fastCheck = true },
{ "<>", v => throw new ArgumentException("ERROR: Invalid arguments") }, // default
"",
"Created by D. Delchev and D. Byalkov, 2021"
@@ -87,7 +89,7 @@ namespace BoerseDataConvert
try
{
Record record = reader.ReadLineRecord();
- a.WriteXmlRecord(record);
+ a.WriteXmlRecord(record,fastCheck);
}
catch (IndexOutOfRangeException)
{
diff --git a/BoerseDataConvert/BoerseDataConvert/Views/Reader.cs b/BoerseDataConvert/BoerseDataConvert/Views/Reader.cs
index b94d866..53d795f 100644
--- a/BoerseDataConvert/BoerseDataConvert/Views/Reader.cs
+++ b/BoerseDataConvert/BoerseDataConvert/Views/Reader.cs
@@ -16,6 +16,11 @@ namespace BoerseDataConvert
private static StreamReader reader;
private static int fileInd;
private string adr;
+ ///
+ /// it create a reader for first file, start the StopWatch and Checks the first line from the current file
+ ///
+ /// input directoty
+ /// array with the names of the every TXT file
public Reader(string adr, string[] _filesNames)
{
fileInd = 0;
@@ -26,6 +31,11 @@ namespace BoerseDataConvert
stopwatch.Start();
CheckFirstLine(date);
}
+ ///
+ /// It reads a line from the current file and return a Record with this information
+ /// and it goes to next file if it the current file ends
+ ///
+ /// Record with information from 1 line from current file
public Record ReadLineRecord()
{
string s = reader.ReadLine();
@@ -42,6 +52,12 @@ namespace BoerseDataConvert
}
return record;
}
+ ///
+ /// it checks the last line from the current file, closes the reader, create a new reader for he file
+ /// also it check first line from the next file and synchronizes a current file in RecordController with its current file
+ ///
+ ///
+ ///
private string NextFile(string s)
{
CheckFinalLine(s);
@@ -55,6 +71,10 @@ namespace BoerseDataConvert
s = reader.ReadLine();
return s;
}
+ ///
+ /// it checks if string date is in the correct format
+ ///
+ /// first line from a file
private void CheckFirstLine(string date)
{
try
@@ -68,6 +88,10 @@ namespace BoerseDataConvert
Console.WriteLine($"WARN: Invalid date in file {filesNames[fileInd]}");
}
}
+ ///
+ /// Checks if string s is in the correct format
+ ///
+ /// last line from a file
private void CheckFinalLine(string s)
{
if ("Datensaetze: " != s.Substring(0, 13))
@@ -93,6 +117,9 @@ namespace BoerseDataConvert
}
}
+ ///
+ /// Closes the reader, stops the stopwatch,print the its time, resets it and start it again
+ ///
internal static void EndFile()
{
reader.Close();