nonstatic WarningStat

This commit is contained in:
lastvoidtemplar
2021-07-12 13:24:34 +03:00
parent 9dd6d69241
commit d0a8c76ef9
2 changed files with 12 additions and 17 deletions

View File

@@ -15,6 +15,7 @@ namespace BoerseDataConvert
private TagsTable tagsTable; private TagsTable tagsTable;
private static string address; private static string address;
private static XmlWriter writer; private static XmlWriter writer;
private static WarningStat warning;
public RecordController(string adr,string fileName, string tags) public RecordController(string adr,string fileName, string tags)
{ {
count = 1; count = 1;
@@ -28,15 +29,15 @@ namespace BoerseDataConvert
writer.WriteStartDocument(); writer.WriteStartDocument();
writer.WriteStartElement("table"); writer.WriteStartElement("table");
writer.WriteAttributeString("name", null, cur_fileName); writer.WriteAttributeString("name", null, cur_fileName);
WarningStat.Refresh(fileName); warning= new WarningStat(fileName);
} }
public static void NextFile(string fileName) public static void NextFile(string fileName)
{ {
writer.WriteEndElement(); writer.WriteEndElement();
writer.WriteEndDocument(); writer.WriteEndDocument();
writer.Close(); writer.Close();
WarningStat.PrintWarnigs(); warning.PrintWarnigs();
WarningStat.Refresh(fileName); warning = new WarningStat(fileName);
cur_fileName = fileName.Split('.').First(); cur_fileName = fileName.Split('.').First();
count = 1; count = 1;
Console.WriteLine(cur_fileName + " start"); Console.WriteLine(cur_fileName + " start");
@@ -67,11 +68,11 @@ namespace BoerseDataConvert
writer.WriteEndElement(); writer.WriteEndElement();
writer.WriteEndDocument(); writer.WriteEndDocument();
writer.Close(); writer.Close();
WarningStat.PrintWarnigs(); warning.PrintWarnigs();
} }
private string CheckTagValue(int tag, string value) private string CheckTagValue(int tag, string value)
{ {
if (tagsTable.CheckInvalidTag(tag)) WarningStat.Add(tag); if (tagsTable.CheckInvalidTag(tag)) warning.Add(tag);
string tagname = tagsTable.GetTagName(tag); string tagname = tagsTable.GetTagName(tag);
if (value == "") return tagname; if (value == "") return tagname;
if (value != "NULL" && !tagsTable.HaveValueRanges(tag)) //Checks if the tag have not a value ranges if (value != "NULL" && !tagsTable.HaveValueRanges(tag)) //Checks if the tag have not a value ranges

View File

@@ -6,22 +6,16 @@ using System.Threading.Tasks;
namespace BoerseDataConvert namespace BoerseDataConvert
{ {
public static class WarningStat public class WarningStat
{ {
private static Dictionary<int, int> tableWarnings = tableWarnings = new Dictionary<int, int>(); private Dictionary<int, int> tableWarnings;
private static string curFile; private string curFile;
public static void Refresh(string fileName) public WarningStat(string fileName)
{ {
curFile = fileName; curFile = fileName;
tableWarnings = new Dictionary<int, int>(); tableWarnings = new Dictionary<int, int>();
} }
/* public void Add(int tag)
type "inv" - Ivalid tag
type "long" - too long string value
type "notnum" - is not in a valid format for number
type "range" - Value not in range
*/
public static void Add(int tag)//
{ {
if (tableWarnings.ContainsKey(tag)) if (tableWarnings.ContainsKey(tag))
{ {
@@ -32,7 +26,7 @@ namespace BoerseDataConvert
tableWarnings.Add(tag, 1); tableWarnings.Add(tag, 1);
} }
} }
public static void PrintWarnigs() public void PrintWarnigs()
{ {
if (tableWarnings.Count == 0) if (tableWarnings.Count == 0)
{ {