using EInk.Dtos; namespace EInk.Dtos { public class ColourCastDto { public string id { get; set; } public string slidesNumber { get; set; } public string createTime { get; set; } public string topic { get; set; } public string pattern { get; set; } public string result { get; set; } public List values { get; set; } = new List(); public int NGCode { get; set; } //public List alarmLocation { get; set; } = new List(); //public string threshold { get; set; } 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(createTime) || String.IsNullOrEmpty(createTime.Trim())) { throw new Exception("Empty createTime"); } try { DateTime valid = Convert.ToDateTime(createTime); } catch { throw new Exception("Incorrect createTime"); } if (String.IsNullOrEmpty(topic) || String.IsNullOrEmpty(topic.Trim())) { throw new Exception("Empty topic"); } if (String.IsNullOrEmpty(pattern) || String.IsNullOrEmpty(pattern.Trim())) { throw new Exception("Empty pattern"); } if (String.IsNullOrEmpty(result) || (result != "NG" && result != "OK")) { throw new Exception("Incorrect result"); } if (values.Count != 15) { throw new Exception("Incorrect values length"); } try { foreach (var item in values) { Convert.ToDouble(item); } } catch { throw new Exception("Incorrect values"); } if (NGCode < 0 || NGCode > 32767) { throw new Exception("Incorrect NGCode"); } //if (alarmLocation.Count != 15) //{ // throw new Exception("Incorrect alarmLocation length"); //} //try //{ // foreach (var item in alarmLocation) // { // int judge = Convert.ToInt32(item); // if (judge != 0 && judge != 1) // { // throw new Exception("Incorrect alarmLocation"); // } // } //} //catch //{ // throw new Exception("Incorrect alarmLocation"); //} } } }