baowei преди 5 месеца
родител
ревизия
0a6964aeb9
променени са 1 файла, в които са добавени 41 реда и са изтрити 5 реда
  1. 41 5
      EInk.Lot3/Dtos/ColourCastDto.cs

+ 41 - 5
EInk.Lot3/Dtos/ColourCastDto.cs

@@ -10,9 +10,9 @@ namespace EInk.Dtos
         public string topic { get; set; }
         public string pattern { get; set; }
         public string result { get; set; }
-        public List<int> values { get; set; } = new List<int>();
-        public int alarmLocation { get; set; }
-        public int threshold { get; set; }
+        public List<double> values { get; set; } = new List<double>();
+        public List<int> alarmLocation { get; set; } = new List<int>();
+        public List<double> threshold { get; set; } = new List<double>();
         public void Valid()
         {
             if (String.IsNullOrEmpty(id) || String.IsNullOrEmpty(id.Trim()))
@@ -52,23 +52,59 @@ namespace EInk.Dtos
                 throw new Exception("Incorrect result");
             }
 
+            if (values.Count != 15)
+            {
+                throw new Exception("Incorrect values length");
+            }
             try
             {
-                int valid = Convert.ToInt32(alarmLocation);
+                foreach (var item in values)
+                {
+                    Convert.ToDouble(item);
+                }
+            }
+            catch
+            {
+                throw new Exception("Incorrect values");
+            }
+
+            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");
             }
 
+            if (threshold.Count != 2)
+            {
+                throw new Exception("Incorrect threshold length");
+            }
             try
             {
-                int valid = Convert.ToInt32(threshold);
+                foreach (var item in threshold)
+                {
+                    Convert.ToDouble(item);
+                }
             }
             catch
             {
                 throw new Exception("Incorrect threshold");
             }
+
         }
     }
 }