Lot3Dto.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using EInk.Models;
  2. using Microsoft.Extensions.FileSystemGlobbing.Internal;
  3. using System.ComponentModel;
  4. using static System.Collections.Specialized.BitVector32;
  5. namespace EInk.Dtos
  6. {
  7. public class Lot3Dto
  8. {
  9. public string id { get; set; }
  10. public string slidesNumber { get; set; }
  11. public string topic { get; set; }
  12. public string createTime { get; set; }
  13. public string result { get; set; }
  14. public string isrepeatupload { get; set; }
  15. public List<itemCheckData>? itemCheckDatas { get; set; } = new List<itemCheckData>();
  16. public void Valid()
  17. {
  18. if (String.IsNullOrEmpty(id) || String.IsNullOrEmpty(id.Trim()))
  19. {
  20. throw new Exception("Empty id");
  21. }
  22. if (String.IsNullOrEmpty(slidesNumber) || String.IsNullOrEmpty(slidesNumber.Trim()))
  23. {
  24. throw new Exception("Empty slidesNumber");
  25. }
  26. if (String.IsNullOrEmpty(topic) || String.IsNullOrEmpty(topic.Trim()))
  27. {
  28. throw new Exception("Empty topic");
  29. }
  30. if (String.IsNullOrEmpty(result) || String.IsNullOrEmpty(result.Trim()))
  31. {
  32. throw new Exception("Empty result");
  33. }
  34. if (result != "NG" && result != "OK")
  35. {
  36. throw new Exception("Incorrect result");
  37. }
  38. if (String.IsNullOrEmpty(isrepeatupload) || String.IsNullOrEmpty(isrepeatupload.Trim()))
  39. {
  40. throw new Exception("Empty isrepeatupload");
  41. }
  42. //0、正常数据
  43. //1、上抛失败重抛数据
  44. //2、不完整数据
  45. //3、数据不完整,后补充重复上报数据
  46. if (isrepeatupload != "0" && isrepeatupload != "1" && isrepeatupload != "2" && isrepeatupload != "3")
  47. {
  48. throw new Exception("Incorrect isrepeatupload");
  49. }
  50. if (String.IsNullOrEmpty(createTime) || String.IsNullOrEmpty(createTime.Trim()))
  51. {
  52. throw new Exception("Empty createTime");
  53. }
  54. try
  55. {
  56. DateTime valid = Convert.ToDateTime(createTime);
  57. }
  58. catch
  59. {
  60. throw new Exception("Incorrect createTime");
  61. }
  62. foreach (var itemCheckData in itemCheckDatas)
  63. {
  64. itemCheckData.Valid();
  65. }
  66. }
  67. }
  68. }