ningshuxia
2024-05-07 ec22b14b0395df0ab97d1adf5b589a187bb62e59
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
namespace IStation.Application
{
    /// <summary>
    /// 泵站调度
    /// </summary>
    public class StationDispatchInput : IValidatableObject
    {
        /// <summary>
        /// 对象列表
        /// </summary>
        public Dictionary<string, double> objects { get; set; }
 
        /// <summary>
        /// 计算状态  0:失败 1:成功
        /// </summary>
        public int flag { get; set; }
 
        /// <summary>
        /// 接收时间
        /// </summary>
        public DateTime ReceiptTime { get; set; }
 
        /// <summary>
        /// 返回时间
        /// </summary>
        public DateTime ReturnTime { get; set; }
 
        /// <summary>
        /// 备注信息
        /// </summary>
        public string message { get; set; }
 
 
        /// <summary>
        /// 验证
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (objects == null || objects.Count < 1)
            {
                yield return
                    new ValidationResult("objects 不能为空", new[] { nameof(objects) });
            }
            else if (objects.Count < 4)
            {
                yield return
                  new ValidationResult("objects 数据缺失", new[] { nameof(objects) });
            }
            else
            {
                if (!objects.ContainsKey("TotalFlow1"))
                {
                    yield return
                  new ValidationResult(" objects [TotalFlow1]数据缺失", new[] { nameof(objects) });
                }
                else
                {
                    if (objects["TotalFlow1"] < 1)
                    {
                        yield return
                            new ValidationResult($"一输水增水量过低! tag:TotalFlow1 Value:{objects["TotalFlow1"]}", new[] { nameof(objects) });
                    }
                }
 
                if (!objects.ContainsKey("TotalPressure1"))
                {
                    yield return
                  new ValidationResult(" objects [TotalPressure1]数据缺失", new[] { nameof(objects) });
                }
                else
                {
                    if (objects["TotalPressure1"] < 0.01)
                    {
                        yield return
                            new ValidationResult($"一输水增压过低! tag:TotalPressure1 Value:{objects["TotalPressure1"]}", new[] { nameof(objects) });
                    }
                }
 
                if (!objects.ContainsKey("TotalFlow2"))
                {
                    yield return
                  new ValidationResult(" objects [TotalFlow2]数据缺失", new[] { nameof(objects) });
                }
                else
                {
                    if (objects["TotalFlow2"] < 1)
                    {
                        yield return
                            new ValidationResult($"二输水增水量过低! tag:TotalFlow2 Value:{objects["TotalFlow2"]}", new[] { nameof(objects) });
                    }
                }
 
 
                if (!objects.ContainsKey("TotalPressure2"))
                {
                    yield return
                  new ValidationResult(" objects [TotalPressure2]数据缺失", new[] { nameof(objects) });
                }
                else
                {
                    if (objects["TotalPressure2"] < 0.01)
                    {
                        yield return
                            new ValidationResult($"二输水增压过低! tag:TotalPressure2 Value:{objects["TotalPressure2"]}", new[] { nameof(objects) });
                    }
                }
            }
        }
 
 
    }
}