lixiaojun
2024-11-25 839d9f96be96108dc9ca9359b3db32596e7e2454
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
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 水力工况信息ViewModel
    /// </summary>
    public class HydroWorkingInfoViewModel
    {
        /// <summary>
        /// 
        /// </summary>
        public HydroWorkingInfoViewModel()
        {
            this.Reservoirs = new List<HydroWorkingReservoirViewModel>();
            this.Tanks = new List<HydroWorkingTankViewModel>();
            this.Pumps = new List<HydroWorkingPumpViewModel>();
            this.Valves = new List<HydroWorkingValveViewModel>();
            this.Resistances = new List<HydroWorkingResistanceViewModel>();
        }
 
        /// <summary>
        /// 水库
        /// </summary>
        public List<HydroWorkingReservoirViewModel> Reservoirs { get; set; }
 
        /// <summary>
        /// 水池
        /// </summary>
        public List<HydroWorkingTankViewModel> Tanks { get; set; }
 
        /// <summary>
        /// 水泵
        /// </summary>
        public List<HydroWorkingPumpViewModel> Pumps { get; set; }
 
        /// <summary>
        /// 阀门
        /// </summary>
        public List<HydroWorkingValveViewModel> Valves { get; set; }
 
        /// <summary>
        /// 阻件
        /// </summary>
        public List<HydroWorkingResistanceViewModel> Resistances { get; set; }
 
 
        /// <summary>
        /// 获取所有工况列表
        /// </summary>
        public List<HydroWorkingVisualViewModel> GetAllWorkingList()
        {
            var list = new List<HydroWorkingVisualViewModel>();
            this.Reservoirs?.ForEach(x => list.Add(x));
            this.Tanks?.ForEach(x => list.Add(x));
            this.Pumps?.ForEach(x => list.Add(x));
            this.Valves?.ForEach(x => list.Add(x));
            return list;
        }
 
        /// <summary>
        /// 添加工况
        /// </summary>
        public bool AppendWorking(HydroWorkingVisualViewModel working)
        {
            if (working == null)
            {
                return false;
            }
            var type = working.GetType();
            if (type.FullName == typeof(HydroWorkingReservoirViewModel).FullName)
            {
                if (this.Reservoirs.Exists(x => x.Code == working.Code))
                {
                    return false;
                }
                this.Reservoirs.Add(working as HydroWorkingReservoirViewModel);
                return true;
            }
            else if (type.FullName == typeof(HydroWorkingTankViewModel).FullName)
            {
                if (this.Tanks.Exists(x => x.Code == working.Code))
                {
                    return false;
                }
                this.Tanks.Add(working as HydroWorkingTankViewModel);
                return true;
            }
            else if (type.FullName == typeof(HydroWorkingPumpViewModel).FullName)
            {
                if (this.Pumps.Exists(x => x.Code == working.Code))
                {
                    return false;
                }
                this.Pumps.Add(working as HydroWorkingPumpViewModel);
                return true;
            }
            else if (type.FullName == typeof(HydroWorkingValveViewModel).FullName)
            {
                if (this.Valves.Exists(x => x.Code == working.Code))
                {
                    return false;
                }
                this.Valves.Add(working as HydroWorkingValveViewModel);
                return true;
            }
            return false;
        }
 
 
 
    }
}