Lot2Lot3Dto.cs 6.7 KB

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