Add message for successful coverting

This commit is contained in:
lastvoidtemplar
2021-07-09 10:19:41 +03:00
parent fd461fd99a
commit ae6699c2ff
2 changed files with 13 additions and 14 deletions

View File

@@ -46,48 +46,46 @@ namespace BoerseDataConvert
private string CheckTagValue(string tag, string value)
{
string[] tagLine;
try
try//Checks if the tag exists
{
tagLine = tagsTable.GetTagValue(tag);
}
catch (KeyNotFoundException)
{
throw new ArgumentException($"WARN: Invalid tag \"{tag}\", {cur_fileName} line {count + 1}");
}
string tagname = tagLine[0];
if (value != "NULL" && tagLine.Length == 2)
if (value != "NULL" && tagLine.Length == 2)//Checks if the tag have not a value ranges
{
string[] valueType = tagLine[1].Split('-').ToArray();
if (valueType.Length == 2)
if (valueType.Length == 2)//Checks if value type is string
{
if (value.Length > int.Parse(valueType[1]))
if (value.Length > int.Parse(valueType[1]))//Checks if the length of the value is bigger than permitted
{
throw new ArgumentException($"WARN: Too long value \"{tag}\", \"{value}\", max allowed \"{valueType[1]}\", {cur_fileName} line {count + 1}");
}
}
else
else//Checks if value type is decimal
{
if (value == "") return tagname;
try
try//Checks if the value is in the correct format
{
double.Parse(value);
double.Parse(value, new System.Globalization.CultureInfo("de-DE"));
}
catch (FormatException)
{
throw new ArgumentException($"WARN: Value is not in a valid format for number \"{tag}\", \"{value}\", {cur_fileName} line {count + 1}");
}
}
}
else
else//Checks if the tag have a value ranges
{
string[] valueRange = tagLine[2].Split('#').ToArray();
bool countain = false;
if (value == "") return tagname;
for (int i = 0; i < valueRange.Length; i++)
{
if (valueRange[i] == value)
if (valueRange[i] == value)//Checks if the value is in value ranges
{
countain = true;
break;

View File

@@ -26,6 +26,7 @@ namespace BoerseDataConvert
string s = reader.ReadLine();
if (s.Substring(0, 11) == "Datensaetze")
{
Console.WriteLine($"File{ filesNames[fileInd]}.xml was converted successfully");
fileInd++;
EndFile();
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}", CodePagesEncodingProvider.Instance.GetEncoding(1252));