root / GES_PAC / Model / Journee.cs @ 9601eaf0
Historique | Voir | Annoter | Télécharger (3,293 ko)
1 | 65ad7e66 | Lucas Bihannic | namespace GES_PAC.Model |
---|---|---|---|
2 | { |
||
3 | public class Journee |
||
4 | { |
||
5 | 5d673ce0 | Lucas Bihannic | #region Propriétés |
6 | 65ad7e66 | Lucas Bihannic | public Personne Responsable { get; set; } |
7 | public Lieu Lieu { get; set; } |
||
8 | public long Id { get; set; } |
||
9 | public DateTime Date { get; set; } |
||
10 | public string Regime { get; set; } |
||
11 | public List<Serie> Series { get; set; } |
||
12 | public List<Calibration> Calibrations { get; set; } |
||
13 | 5d673ce0 | Lucas Bihannic | #endregion |
14 | |||
15 | #region Constructeurs |
||
16 | public Journee(DateTime Date, Personne Responsable, Lieu Lieu, string Regime) |
||
17 | 65ad7e66 | Lucas Bihannic | { |
18 | this.Responsable = Responsable; |
||
19 | this.Lieu = Lieu; |
||
20 | this.Date = Date; |
||
21 | this.Regime = Regime; |
||
22 | 5d673ce0 | Lucas Bihannic | Series = []; |
23 | Calibrations = []; |
||
24 | } |
||
25 | #endregion |
||
26 | |||
27 | #region Méthodes |
||
28 | 09d4a0de | lbihannic | public bool AddCalibration(MesureCalibration mesureCalibration, PhaseCalibration phaseCalibration) |
29 | 5d673ce0 | Lucas Bihannic | { |
30 | 09d4a0de | lbihannic | var existing = Calibrations.FirstOrDefault(c => c.Phase == phaseCalibration); |
31 | |||
32 | if (existing == null) |
||
33 | 5d673ce0 | Lucas Bihannic | { |
34 | 09d4a0de | lbihannic | Calibrations.Add(new Calibration(phaseCalibration, mesureCalibration)); |
35 | return false; |
||
36 | 5d673ce0 | Lucas Bihannic | } |
37 | 09d4a0de | lbihannic | |
38 | existing.AddMesure(mesureCalibration); |
||
39 | return existing.IsComplete(); |
||
40 | } |
||
41 | |||
42 | 12ddf7ef | lbihannic | public void AddSet(Serie set) |
43 | 09d4a0de | lbihannic | { |
44 | Series.Add(set); |
||
45 | 5d673ce0 | Lucas Bihannic | } |
46 | |||
47 | public PhaseCalibration GetCurrentPhase() |
||
48 | { |
||
49 | 09d4a0de | lbihannic | if (Series.Count == 0) |
50 | 5d673ce0 | Lucas Bihannic | { |
51 | 9601eaf0 | lbihannic | return PhaseCalibration.DEBUT; |
52 | 5d673ce0 | Lucas Bihannic | } |
53 | 9601eaf0 | lbihannic | return PhaseCalibration.FIN; |
54 | 5d673ce0 | Lucas Bihannic | } |
55 | |||
56 | public Calibration GetCurrentCalibration() |
||
57 | { |
||
58 | return Calibrations.FirstOrDefault(c => c.Phase == GetCurrentPhase()); |
||
59 | } |
||
60 | |||
61 | public List<TypeCalibration> GetCurrentMissingCalibration() |
||
62 | { |
||
63 | if (Calibrations.Count == 0 || Calibrations.Last().IsComplete()) |
||
64 | { |
||
65 | return TypeCalibration.All; |
||
66 | } |
||
67 | return TypeCalibration.All.Except(Calibrations.Last().GetTypesDone()).ToList(); |
||
68 | 65ad7e66 | Lucas Bihannic | } |
69 | ba296a27 | lbihannic | |
70 | public Serie GetCurrentSet() |
||
71 | { |
||
72 | acb5dd8c | lbihannic | return Series.LastOrDefault(); |
73 | ba296a27 | lbihannic | } |
74 | 4e39035b | lbihannic | public bool HasAnySet() |
75 | { |
||
76 | return Series.Count > 0; |
||
77 | } |
||
78 | 957b1f34 | lbihannic | internal int GetSetCount() |
79 | { |
||
80 | return Series.Count; |
||
81 | } |
||
82 | internal int GetDayAnimalCount() |
||
83 | { |
||
84 | return Series.Sum(s => s.GetAnimalCount()); |
||
85 | } |
||
86 | |||
87 | internal int GetDayMeasureCount() |
||
88 | { |
||
89 | return Series.Sum(s => s.GetMeasureCount()); |
||
90 | } |
||
91 | |||
92 | internal int GetDayBehaviourCount() |
||
93 | { |
||
94 | return Series.Sum(s => s.GetBehaviourCount()); |
||
95 | } |
||
96 | internal Calibration GetLastCalibration() |
||
97 | { |
||
98 | return Calibrations.Last(); |
||
99 | } |
||
100 | internal Calibration GetDebutCalibration() |
||
101 | { |
||
102 | 9601eaf0 | lbihannic | return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.DEBUT); |
103 | acb5dd8c | lbihannic | } |
104 | internal bool IsCalibrationComplete(PhaseCalibration pc) |
||
105 | { |
||
106 | return Calibrations.FirstOrDefault(c => c.Phase == pc)?.IsComplete() ?? false; |
||
107 | } |
||
108 | internal bool IsComplete() |
||
109 | { |
||
110 | 9601eaf0 | lbihannic | return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.FIN)?.IsComplete() ?? false; |
111 | 957b1f34 | lbihannic | } |
112 | 5d673ce0 | Lucas Bihannic | #endregion |
113 | 65ad7e66 | Lucas Bihannic | } |
114 | } |