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 static string address;
private static XmlWriter writer;
private static WarningStat warning;
public RecordController(string adr,string fileName, string tags)
{
count = 1;
@@ -28,15 +29,15 @@ namespace BoerseDataConvert
writer.WriteStartDocument();
writer.WriteStartElement("table");
writer.WriteAttributeString("name", null, cur_fileName);
WarningStat.Refresh(fileName);
warning= new WarningStat(fileName);
}
public static void NextFile(string fileName)
{
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
WarningStat.PrintWarnigs();
WarningStat.Refresh(fileName);
warning.PrintWarnigs();
warning = new WarningStat(fileName);
cur_fileName = fileName.Split('.').First();
count = 1;
Console.WriteLine(cur_fileName + " start");
@@ -67,11 +68,11 @@ namespace BoerseDataConvert
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
WarningStat.PrintWarnigs();
warning.PrintWarnigs();
}
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);
if (value == "") return tagname;
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
{
public static class WarningStat
public class WarningStat
{
private static Dictionary<int, int> tableWarnings = tableWarnings = new Dictionary<int, int>();
private static string curFile;
public static void Refresh(string fileName)
private Dictionary<int, int> tableWarnings;
private string curFile;
public WarningStat(string fileName)
{
curFile = fileName;
tableWarnings = new Dictionary<int, int>();
}
/*
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)//
public void Add(int tag)
{
if (tableWarnings.ContainsKey(tag))
{
@@ -32,7 +26,7 @@ namespace BoerseDataConvert
tableWarnings.Add(tag, 1);
}
}
public static void PrintWarnigs()
public void PrintWarnigs()
{
if (tableWarnings.Count == 0)
{