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) 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;

View File

@@ -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]);