ColourCastDto.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using EInk.Dtos;
  2. namespace EInk.Dtos
  3. {
  4. public class ColourCastDto
  5. {
  6. public string id { get; set; }
  7. public string slidesNumber { get; set; }
  8. public string createTime { get; set; }
  9. public string topic { get; set; }
  10. public string pattern { get; set; }
  11. public string result { get; set; }
  12. public List<int> values { get; set; } = new List<int>();
  13. public int alarmLocation { get; set; }
  14. public int threshold { get; set; }
  15. public void Valid()
  16. {
  17. if (String.IsNullOrEmpty(id) || String.IsNullOrEmpty(id.Trim()))
  18. {
  19. throw new Exception("Empty id");
  20. }
  21. if (String.IsNullOrEmpty(slidesNumber) || String.IsNullOrEmpty(slidesNumber.Trim()))
  22. {
  23. throw new Exception("Empty slidesNumber");
  24. }
  25. try
  26. {
  27. DateTime valid = Convert.ToDateTime(createTime);
  28. }
  29. catch
  30. {
  31. throw new Exception("Incorrect createTime");
  32. }
  33. if (String.IsNullOrEmpty(topic) || String.IsNullOrEmpty(topic.Trim()))
  34. {
  35. throw new Exception("Empty topic");
  36. }
  37. if (String.IsNullOrEmpty(pattern) || String.IsNullOrEmpty(pattern.Trim()))
  38. {
  39. throw new Exception("Empty pattern");
  40. }
  41. if (String.IsNullOrEmpty(result) || (result != "NG" && result != "OK"))
  42. {
  43. throw new Exception("Incorrect result");
  44. }
  45. try
  46. {
  47. int valid = Convert.ToInt32(alarmLocation);
  48. }
  49. catch
  50. {
  51. throw new Exception("Incorrect alarmLocation");
  52. }
  53. try
  54. {
  55. int valid = Convert.ToInt32(threshold);
  56. }
  57. catch
  58. {
  59. throw new Exception("Incorrect threshold");
  60. }
  61. }
  62. }
  63. }