123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- 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<double> values { get; set; } = new List<double>();
- public int NGCode { get; set; }
- //public List<int> alarmLocation { get; set; } = new List<int>();
- //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");
- //}
- }
- }
- }
|