Lot2Lot3Dto.cs 5.3 KB

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