Add message for successful coverting
This commit is contained in:
@@ -46,48 +46,46 @@ namespace BoerseDataConvert
|
|||||||
private string CheckTagValue(string tag, string value)
|
private string CheckTagValue(string tag, string value)
|
||||||
{
|
{
|
||||||
string[] tagLine;
|
string[] tagLine;
|
||||||
try
|
try//Checks if the tag exists
|
||||||
{
|
{
|
||||||
tagLine = tagsTable.GetTagValue(tag);
|
tagLine = tagsTable.GetTagValue(tag);
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException)
|
catch (KeyNotFoundException)
|
||||||
{
|
{
|
||||||
|
|
||||||
throw new ArgumentException($"WARN: Invalid tag \"{tag}\", {cur_fileName} line {count + 1}");
|
throw new ArgumentException($"WARN: Invalid tag \"{tag}\", {cur_fileName} line {count + 1}");
|
||||||
}
|
}
|
||||||
string tagname = tagLine[0];
|
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();
|
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}");
|
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;
|
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)
|
catch (FormatException)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"WARN: Value is not in a valid format for number \"{tag}\", \"{value}\", {cur_fileName} line {count + 1}");
|
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();
|
string[] valueRange = tagLine[2].Split('#').ToArray();
|
||||||
bool countain = false;
|
bool countain = false;
|
||||||
if (value == "") return tagname;
|
if (value == "") return tagname;
|
||||||
for (int i = 0; i < valueRange.Length; i++)
|
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;
|
countain = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ namespace BoerseDataConvert
|
|||||||
string s = reader.ReadLine();
|
string s = reader.ReadLine();
|
||||||
if (s.Substring(0, 11) == "Datensaetze")
|
if (s.Substring(0, 11) == "Datensaetze")
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"File{ filesNames[fileInd]}.xml was converted successfully");
|
||||||
fileInd++;
|
fileInd++;
|
||||||
EndFile();
|
EndFile();
|
||||||
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}", CodePagesEncodingProvider.Instance.GetEncoding(1252));
|
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}", CodePagesEncodingProvider.Instance.GetEncoding(1252));
|
||||||
RecordController.NextFile(filesNames[fileInd]);
|
RecordController.NextFile(filesNames[fileInd]);
|
||||||
Writer.NextFile(filesNames[fileInd]);
|
Writer.NextFile(filesNames[fileInd]);
|
||||||
|
|||||||
Reference in New Issue
Block a user