Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //KLASSER//
- public class inData
- {
- //PUBLIC//
- public inData()
- {
- }
- public inData(string InData)
- {
- InData = InData.Replace('.', ',');
- InData = InData.Replace('\r', ' ');
- //Remove Time & Date
- if (InData.Length > 7)
- {
- if (InData[4] == '-' && InData[7] == '-' && InData.Contains(":"))
- {
- InData = InData.Remove(0, 20);
- }
- //Date
- else if (InData[4] == '-' && InData[7] == '-')
- {
- InData = InData.Remove(0, 11);
- }
- //Time
- else if (InData.Contains(":"))
- {
- InData = InData.Remove(0, 9);
- }
- }
- Char[] split = { '\t' };
- String[] data = InData.Split(split);
- //Measure - Location - Result
- if (data.Length == 3)
- {
- Data = data[0];
- Type = data[2];
- }
- //Measure - Result
- else if ((data.Length == 2) && (FindDecimal(data[0]) == 2) && ((data[1])[0] == 'A' || (data[1])[0] == 'R'))
- {
- Data = data[0];
- Type = data[1];
- }
- //Location - Result
- else if ((data.Length == 2) && (FindDecimal(data[0]) == 3) && ((data[1])[0] == 'A' || (data[1])[0] == 'R'))
- {
- Type = data[1];
- }
- //Measure - Location
- else if (data.Length == 2 && FindDecimal(data[0]) == 2 && FindDecimal(data[1]) == 3)
- {
- Data = data[0];
- }
- //Result
- else if (data.Length == 1 && data[0] != " " && data[0] != "" && ((data[0])[0] == 'A' || (data[0])[0] == 'R'))
- {
- Type = data[0];
- }
- //Measure
- else if (data.Length == 1 && data[0] != " " && data[0] != "" && FindDecimal(data[0]) == 2)
- {
- Data = data[0];
- }
- else if (data.Length == 0)
- {
- //Throw Error?
- }
- //Location
- else
- {
- //Throw Error?
- }
- Time = DateTime.Now.ToString("HH:mm:ss");
- Date = DateTime.Now.ToString("yyyy/MM/dd");
- }
- public string Get_Type()
- {
- return Type;
- }
- public string Get_Data()
- {
- return Data;
- }
- public string Get_Time()
- {
- return Time;
- }
- public string Get_Date()
- {
- return Date;
- }
- public int FindDecimal(string input)
- {
- input = input.Substring(input.IndexOf(',') + 1);
- if(input.Contains("E"))
- {
- input = input.Remove(input.IndexOf('E'));
- }
- if (input.Contains(" "))
- {
- input = input.Remove(input.IndexOf(' '));
- }
- return input.Length;
- }
- //PRIVATE//
- private string Type;
- private string Data;
- private string Time;
- private string Date;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement