ColourCastDto.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. if (String.IsNullOrEmpty(createTime) || String.IsNullOrEmpty(createTime.Trim()))
  26. {
  27. throw new Exception("Empty createTime");
  28. }
  29. try
  30. {
  31. DateTime valid = Convert.ToDateTime(createTime);
  32. }
  33. catch
  34. {
  35. throw new Exception("Incorrect createTime");
  36. }
  37. if (String.IsNullOrEmpty(topic) || String.IsNullOrEmpty(topic.Trim()))
  38. {
  39. throw new Exception("Empty topic");
  40. }
  41. if (String.IsNullOrEmpty(pattern) || String.IsNullOrEmpty(pattern.Trim()))
  42. {
  43. throw new Exception("Empty pattern");
  44. }
  45. if (String.IsNullOrEmpty(result) || (result != "NG" && result != "OK"))
  46. {
  47. throw new Exception("Incorrect result");
  48. }
  49. try
  50. {
  51. int valid = Convert.ToInt32(alarmLocation);
  52. }
  53. catch
  54. {
  55. throw new Exception("Incorrect alarmLocation");
  56. }
  57. try
  58. {
  59. int valid = Convert.ToInt32(threshold);
  60. }
  61. catch
  62. {
  63. throw new Exception("Incorrect threshold");
  64. }
  65. }
  66. }
  67. }