ColourCastDto.cs 1.7 KB

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