Lot2Lot3Dto.cs 5.7 KB

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