Advertisement
perjespersson

Old Class

Nov 6th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. //KLASSER//
  2. public class inData
  3. {
  4. //PUBLIC//
  5. public inData()
  6. {
  7. }
  8. public inData(string InData)
  9. {
  10.  
  11. InData = InData.Replace('.', ',');
  12. InData = InData.Replace('\r', ' ');
  13.  
  14. //Remove Time & Date
  15. if (InData.Length > 7)
  16. {
  17. if (InData[4] == '-' && InData[7] == '-' && InData.Contains(":"))
  18. {
  19. InData = InData.Remove(0, 20);
  20. }
  21.  
  22. //Date
  23. else if (InData[4] == '-' && InData[7] == '-')
  24. {
  25. InData = InData.Remove(0, 11);
  26. }
  27.  
  28. //Time
  29. else if (InData.Contains(":"))
  30. {
  31. InData = InData.Remove(0, 9);
  32. }
  33. }
  34.  
  35. Char[] split = { '\t' };
  36. String[] data = InData.Split(split);
  37.  
  38. //Measure - Location - Result
  39. if (data.Length == 3)
  40. {
  41. Data = data[0];
  42. Type = data[2];
  43. }
  44. //Measure - Result
  45. else if ((data.Length == 2) && (FindDecimal(data[0]) == 2) && ((data[1])[0] == 'A' || (data[1])[0] == 'R'))
  46. {
  47. Data = data[0];
  48. Type = data[1];
  49. }
  50. //Location - Result
  51. else if ((data.Length == 2) && (FindDecimal(data[0]) == 3) && ((data[1])[0] == 'A' || (data[1])[0] == 'R'))
  52. {
  53. Type = data[1];
  54. }
  55. //Measure - Location
  56. else if (data.Length == 2 && FindDecimal(data[0]) == 2 && FindDecimal(data[1]) == 3)
  57. {
  58. Data = data[0];
  59. }
  60. //Result
  61. else if (data.Length == 1 && data[0] != " " && data[0] != "" && ((data[0])[0] == 'A' || (data[0])[0] == 'R'))
  62. {
  63. Type = data[0];
  64. }
  65. //Measure
  66. else if (data.Length == 1 && data[0] != " " && data[0] != "" && FindDecimal(data[0]) == 2)
  67. {
  68. Data = data[0];
  69. }
  70. else if (data.Length == 0)
  71. {
  72. //Throw Error?
  73. }
  74. //Location
  75. else
  76. {
  77. //Throw Error?
  78. }
  79.  
  80.  
  81. Time = DateTime.Now.ToString("HH:mm:ss");
  82. Date = DateTime.Now.ToString("yyyy/MM/dd");
  83. }
  84.  
  85. public string Get_Type()
  86. {
  87. return Type;
  88. }
  89. public string Get_Data()
  90. {
  91. return Data;
  92. }
  93. public string Get_Time()
  94. {
  95. return Time;
  96. }
  97. public string Get_Date()
  98. {
  99. return Date;
  100. }
  101. public int FindDecimal(string input)
  102. {
  103.  
  104. input = input.Substring(input.IndexOf(',') + 1);
  105. if(input.Contains("E"))
  106. {
  107. input = input.Remove(input.IndexOf('E'));
  108. }
  109.  
  110. if (input.Contains(" "))
  111. {
  112. input = input.Remove(input.IndexOf(' '));
  113. }
  114.  
  115. return input.Length;
  116. }
  117. //PRIVATE//
  118. private string Type;
  119. private string Data;
  120. private string Time;
  121. private string Date;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement