123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- using EInk.Models;
- using Microsoft.Extensions.FileSystemGlobbing.Internal;
- using System.ComponentModel;
- using static System.Collections.Specialized.BitVector32;
- namespace EInk.Dtos
- {
- public class Lot2Lot3Dto
- {
- public Lot2Lot3Dto() { }
- public Lot2Lot3Dto(Lot3Dto lot3Data)
- {
- id = lot3Data.id;
- slidesNumber = lot3Data.slidesNumber;
- topic= lot3Data.topic;
- createTime = lot3Data.createTime;
- result = lot3Data.result;
- itemCheckDatas = lot3Data.itemCheckDatas;
- }
- public string id { get; set; }
- public string slidesNumber { get; set; }
- public string topic { get; set; }
- public string createTime { get; set; }
- public string result { get; set; }
- public List<itemCheckData>? itemCheckDatas { get; set; } = new List<itemCheckData>();
- public void Valid()
- {
- if (String.IsNullOrEmpty(id) || String.IsNullOrEmpty(id.Trim()))
- {
- throw new Exception("Empty id");
- }
- if (String.IsNullOrEmpty(slidesNumber) || String.IsNullOrEmpty(slidesNumber.Trim()))
- {
- throw new Exception("Empty slidesNumber");
- }
- if (String.IsNullOrEmpty(topic) || String.IsNullOrEmpty(topic.Trim()))
- {
- throw new Exception("Empty topic");
- }
- if (String.IsNullOrEmpty(result)||String.IsNullOrEmpty(result.Trim()))
- {
- throw new Exception("Empty result");
- }
- if (result != "NG" && result != "OK")
- {
- throw new Exception("Incorrect result");
- }
- if (String.IsNullOrEmpty(createTime) || String.IsNullOrEmpty(createTime.Trim()))
- {
- throw new Exception("Empty createTime");
- }
- try
- {
- DateTime valid = Convert.ToDateTime(createTime);
- }
- catch
- {
- throw new Exception("Incorrect createTime");
- }
- foreach (var itemCheckData in itemCheckDatas)
- {
- itemCheckData.Valid();
- }
- }
- }
- public class itemCheckData
- {
- public string station { get; set; }
- public string method { get; set; }
- public string pattern { get; set; }
- public string result { get; set; }
- public string? imagePath { get; set; }
- public string? detailImagePath { get; set; }
- public List<detail>? details { get; set; } = new List<detail>();
- public void Valid()
- {
- if (String.IsNullOrEmpty(station) || String.IsNullOrEmpty(station.Trim()))
- {
- throw new Exception("Empty station");
- }
- if (String.IsNullOrEmpty(method) || String.IsNullOrEmpty(method.Trim()))
- {
- throw new Exception("Empty method");
- }
- if (String.IsNullOrEmpty(pattern) || String.IsNullOrEmpty(pattern.Trim()))
- {
- throw new Exception("Empty pattern");
- }
- if (String.IsNullOrEmpty(result) || String.IsNullOrEmpty(result.Trim()))
- {
- throw new Exception("Empty result");
- }
- if (result != "NG" && result != "OK")
- {
- throw new Exception("Incorrect result");
- }
- foreach (var itemdetail in details)
- {
- itemdetail.Valid();
- }
- }
- }
- public class detail
- {
- public string defectCode { get; set; }
- public string defectName { get; set; }
- public string? x { get; set; }
- public string? y { get; set; }
- public string? width { get; set; }
- public string? height { get; set; }
- public string? area { get; set; }
- public string? rotation { get; set; } = "0";
- public void Valid()
- {
- if (String.IsNullOrEmpty(defectCode) || String.IsNullOrEmpty(defectCode.Trim()))
- {
- throw new Exception("Empty defectCode");
- }
- if (String.IsNullOrEmpty(defectName) || String.IsNullOrEmpty(defectName.Trim()))
- {
- throw new Exception("Empty defectName");
- }
- //if (x == null || String.IsNullOrEmpty(x.Trim()))
- //{
- // throw new Exception("Empty x");
- //}
- //if (y == null || String.IsNullOrEmpty(y.Trim()))
- //{
- // throw new Exception("Empty y");
- //}
- //if (width == null || String.IsNullOrEmpty(width.Trim()))
- //{
- // throw new Exception("Empty width");
- //}
- //if (height == null || String.IsNullOrEmpty(height.Trim()))
- //{
- // throw new Exception("Empty height");
- //}
- //if (area == null || String.IsNullOrEmpty(area.Trim()))
- //{
- // throw new Exception("Empty area");
- //}
- //try
- //{
- // double valid = Convert.ToDouble(x);
- //}
- //catch
- //{
- // throw new Exception("Incorrect x");
- //}
- //try
- //{
- // double valid = Convert.ToDouble(y);
- //}
- //catch
- //{
- // throw new Exception("Incorrect y");
- //}
- //try
- //{
- // double valid = Convert.ToDouble(width);
- //}
- //catch
- //{
- // throw new Exception("Incorrect width");
- //}
- //try
- //{
- // double valid = Convert.ToDouble(height);
- //}
- //catch
- //{
- // throw new Exception("Incorrect height");
- //}
- //try
- //{
- // double valid = Convert.ToDouble(area);
- //}
- //catch
- //{
- // throw new Exception("Incorrect area");
- //}
- }
- public (bool,double,double) Valid_HeightWidth()
- {
- if (width == null || String.IsNullOrEmpty(width.Trim())|| height == null || String.IsNullOrEmpty(height.Trim()))
- {
- return (false, 0, 0);
- }
- double valid_width;
- double valid_height;
- try
- {
- valid_width = Convert.ToDouble(width);
- valid_height = Convert.ToDouble(height);
- }
- catch
- {
- return (false, 0, 0);
- }
- return (true, valid_height, valid_width);
- }
- }
- }
|