Lot2Lot3Dto.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using Microsoft.Extensions.FileSystemGlobbing.Internal;
  2. using System.ComponentModel;
  3. using static System.Collections.Specialized.BitVector32;
  4. namespace EInk.Dtos
  5. {
  6. public class Lot2Lot3Dto
  7. {
  8. public string id { get; set; }
  9. public string slidesNumber { get; set; }
  10. public string topic { get; set; }
  11. public string createTime { get; set; }
  12. public string result { get; set; }
  13. public List<itemCheckData> itemCheckDatas { get; set; } = new List<itemCheckData>();
  14. public void Valid()
  15. {
  16. if (String.IsNullOrEmpty(id.Trim()))
  17. {
  18. throw new Exception("Empty id");
  19. }
  20. if (String.IsNullOrEmpty(slidesNumber.Trim()))
  21. {
  22. throw new Exception("Empty slidesNumber");
  23. }
  24. if (String.IsNullOrEmpty(result.Trim()))
  25. {
  26. throw new Exception("Empty result");
  27. }
  28. if (result!="NG"&&result!="OK")
  29. {
  30. throw new Exception("Incorrect result");
  31. }
  32. try
  33. {
  34. DateTime valid = Convert.ToDateTime(createTime);
  35. }
  36. catch
  37. {
  38. throw new Exception("Incorrect createTime");
  39. }
  40. foreach (var itemCheckData in itemCheckDatas)
  41. {
  42. itemCheckData.Valid();
  43. }
  44. }
  45. }
  46. public class itemCheckData
  47. {
  48. public string station { get; set; }
  49. public string method { get; set; }
  50. public string pattern { get; set; }
  51. public string result { get; set; }
  52. public string imagePath { get; set; }
  53. public string detailImagePath { get; set; }
  54. public List<detail> details { get; set; } = new List<detail>();
  55. public void Valid()
  56. {
  57. if (String.IsNullOrEmpty(station.Trim()))
  58. {
  59. throw new Exception("Empty station");
  60. }
  61. if (String.IsNullOrEmpty(method.Trim()))
  62. {
  63. throw new Exception("Empty method");
  64. }
  65. if (String.IsNullOrEmpty(pattern.Trim()))
  66. {
  67. throw new Exception("Empty pattern");
  68. }
  69. if (String.IsNullOrEmpty(result.Trim()))
  70. {
  71. throw new Exception("Empty result");
  72. }
  73. if (result != "NG" && result != "OK")
  74. {
  75. throw new Exception("Incorrect result");
  76. }
  77. foreach (var itemdetail in details)
  78. {
  79. itemdetail.Valid();
  80. }
  81. }
  82. }
  83. public class detail
  84. {
  85. public string defectCode { get; set; }
  86. public string defectName { get; set; }
  87. public string x { get; set; }
  88. public string y { get; set; }
  89. public string width { get; set; }
  90. public string height { get; set; }
  91. public string area { get; set; }
  92. public void Valid()
  93. {
  94. if (String.IsNullOrEmpty(defectCode.Trim()))
  95. {
  96. throw new Exception("Empty defectCode");
  97. }
  98. if (String.IsNullOrEmpty(defectName.Trim()))
  99. {
  100. throw new Exception("Empty defectName");
  101. }
  102. if (String.IsNullOrEmpty(x.Trim()))
  103. {
  104. throw new Exception("Empty x");
  105. }
  106. if (String.IsNullOrEmpty(y.Trim()))
  107. {
  108. throw new Exception("Empty y");
  109. }
  110. if (String.IsNullOrEmpty(width.Trim()))
  111. {
  112. throw new Exception("Empty width");
  113. }
  114. if (String.IsNullOrEmpty(height.Trim()))
  115. {
  116. throw new Exception("Empty height");
  117. }
  118. if (String.IsNullOrEmpty(area.Trim()))
  119. {
  120. throw new Exception("Empty area");
  121. }
  122. //try
  123. //{
  124. // double valid = Convert.ToDouble(x);
  125. //}
  126. //catch
  127. //{
  128. // throw new Exception("Incorrect x");
  129. //}
  130. //try
  131. //{
  132. // double valid = Convert.ToDouble(y);
  133. //}
  134. //catch
  135. //{
  136. // throw new Exception("Incorrect y");
  137. //}
  138. //try
  139. //{
  140. // double valid = Convert.ToDouble(width);
  141. //}
  142. //catch
  143. //{
  144. // throw new Exception("Incorrect width");
  145. //}
  146. //try
  147. //{
  148. // double valid = Convert.ToDouble(height);
  149. //}
  150. //catch
  151. //{
  152. // throw new Exception("Incorrect height");
  153. //}
  154. //try
  155. //{
  156. // double valid = Convert.ToDouble(area);
  157. //}
  158. //catch
  159. //{
  160. // throw new Exception("Incorrect area");
  161. //}
  162. }
  163. }
  164. }