using EInk.Models; using Microsoft.Extensions.FileSystemGlobbing.Internal; using System.ComponentModel; using static System.Collections.Specialized.BitVector32; namespace EInk.Dtos { public class Lot2Lot3Dto { 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? itemCheckDatas { get; set; } = new List(); 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 (String.IsNullOrEmpty(createTime) || String.IsNullOrEmpty(createTime.Trim())) { throw new Exception("Empty createTime"); } if (result!="NG"&&result!="OK") { throw new Exception("Incorrect result"); } 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? details { get; set; } = new List(); 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 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"); //} } } }