a
This commit is contained in:
64
ScanBox/ConfigTable.cs
Normal file
64
ScanBox/ConfigTable.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// *************************************
|
||||
// Angel Ivan 04/Nov/2024
|
||||
// *************************************
|
||||
|
||||
namespace ScaBox30
|
||||
{
|
||||
class ConfigTable
|
||||
{
|
||||
public String Code { get; set; }
|
||||
public String Box { get; set; }
|
||||
public String Program { get; set; }
|
||||
|
||||
|
||||
public static ConfigTable FromCsv(string csvLine, string[] opcs_on_program)
|
||||
{
|
||||
string[] csv_text_line = csvLine.Split(',');
|
||||
if (csv_text_line.Length > 1)
|
||||
{
|
||||
//If line on CSV file has more than 2 comma separated values
|
||||
// csv_text_line[2..n] will be ignored
|
||||
ConfigTable configtable = new ConfigTable();
|
||||
configtable.Code = new string(csv_text_line[0].ToCharArray().Where(c => !Char.IsWhiteSpace(c)).ToArray()); //removes spaces from csv_text_line[0]
|
||||
configtable.Box = new string(csv_text_line[1].ToCharArray().Where(c => !Char.IsWhiteSpace(c)).ToArray()); //removes spaces from csv_text_line[1]
|
||||
|
||||
|
||||
|
||||
if (configtable.Box == opcs_on_program[1])
|
||||
configtable.Program = "1";
|
||||
else if (configtable.Box == opcs_on_program[2])
|
||||
configtable.Program = "2";
|
||||
else if (configtable.Box == opcs_on_program[3])
|
||||
configtable.Program = "3";
|
||||
else if (configtable.Box == opcs_on_program[4])
|
||||
configtable.Program = "4";
|
||||
else if (configtable.Box == opcs_on_program[5])
|
||||
configtable.Program = "5";
|
||||
else if (configtable.Box == opcs_on_program[6])
|
||||
configtable.Program = "6";
|
||||
else if (configtable.Box == opcs_on_program[7])
|
||||
configtable.Program = "7";
|
||||
else if (configtable.Box == opcs_on_program[8])
|
||||
configtable.Program = "8";
|
||||
else
|
||||
configtable.Program = "1";
|
||||
|
||||
return configtable;
|
||||
}
|
||||
else
|
||||
{
|
||||
ConfigTable configtable = new ConfigTable();
|
||||
configtable.Code = null; // ignore lines with less than 1 comma separated value
|
||||
configtable.Box = null;
|
||||
configtable.Program = null;
|
||||
return configtable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user