-
Notifications
You must be signed in to change notification settings - Fork 1
/
meosworker.cs
152 lines (140 loc) · 4.93 KB
/
meosworker.cs
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
namespace MeOSReplay
{
internal class meosworker
{
string dbg = "";
List<int> _postes = new List<int>();
public List<int> Postes
{
get { return _postes; }
set { _postes = value; }
}
List<runner> _runners = new List<runner>();
internal List<runner> Runners
{
get { return _runners; }
set { _runners = value; }
}
string _filename;
public string Filename
{
get { return _filename; }
set { _filename = value; }
}
DateTime _date;
public DateTime Date
{
get { return _date; }
set { _date = value; }
}
int _zeroTime;
public int ZeroTime
{
get { return _zeroTime; }
set { _zeroTime = value; }
}
int _firstStart = int.MaxValue;
public int FirstStart
{
get { return _firstStart; }
set { _firstStart = value; }
}
int _lastFinish = int.MinValue;
public int LastFinish
{
get { return _lastFinish; }
set { _lastFinish = value; }
}
internal meosworker()
{
}
internal void init(string filename)
{
string xmlContent = string.Empty;
_filename = filename;
xmlContent = File.ReadAllText(filename);
using (XmlReader reader = XmlReader.Create(new StringReader(xmlContent)))
{
reader.ReadToFollowing("Date");
_date = reader.ReadElementContentAsDateTime();
reader.ReadToFollowing("ZeroTime");
_zeroTime = reader.ReadElementContentAsInt();
int id;
string name;
//int start;
//int finish;
int status;
int cardNo;
int startNo;
int classe;
string punchesstr;
int cardReadId;
int cardId;
while (reader.ReadToFollowing("Runner"))
{
try
{
reader.ReadToFollowing("Id"); id = reader.ReadElementContentAsInt();
reader.ReadToFollowing("Name"); name = reader.ReadElementContentAsString();
//reader.ReadToFollowing("Start"); start = reader.ReadElementContentAsInt();
//reader.ReadToFollowing("Finish"); finish = reader.ReadElementContentAsInt();
reader.ReadToFollowing("Status"); status = reader.ReadElementContentAsInt();
reader.ReadToFollowing("CardNo"); cardNo = reader.ReadElementContentAsInt();
reader.ReadToFollowing("StartNo"); startNo = reader.ReadElementContentAsInt();
reader.ReadToFollowing("Class"); classe = reader.ReadElementContentAsInt();
reader.ReadToFollowing("Punches"); punchesstr = reader.ReadElementContentAsString();
reader.ReadToFollowing("ReadId"); cardReadId = reader.ReadElementContentAsInt();
reader.ReadToFollowing("Id"); cardId = reader.ReadElementContentAsInt();
runner r = new runner(id, name, /*start, finish, */status, cardNo, startNo, classe, punchesstr, cardReadId, cardId, _postes);
if (r.Start < _firstStart)
{
_firstStart = r.Start;
}
if (r.Finish > _lastFinish)
{
_lastFinish = r.Finish;
}
_runners.Add(r);
}
catch (Exception ex)
{
dbg = ex.Message;
}
}
}
_postes.Sort();
}
internal List<object[]> tick(int tickTime)
{
List<object[]> lo = new List<object[]>();
// cherchons tous les trucs dont la date est < dt
foreach (runner r in _runners)
{
List<int[]> punchesOk = r.Card.Punches.tick(tickTime);
if (punchesOk == null)
{
// c'est que fini
lo.Add(new object[] { r });
}
else
{
if (punchesOk.Count > 0)
{
lo.Add(new object[] { r, punchesOk });
}
else
{
// déjà fini ou rien a dire
}
}
}
return lo;
}
}
}