Revize d39750f3
Přidáno uživatelem Alex Konig před více než 3 roky(ů)
Server/ServerApp/Parser/InputData/CsvDataLoader.cs | ||
---|---|---|
21 | 21 |
/// <returns>Array with loaded data</returns> |
22 | 22 |
private string[] LoadCsv(string name) |
23 | 23 |
{ |
24 |
if (!File.Exists(name)) |
|
25 |
return null; |
|
26 |
|
|
24 | 27 |
string[] lines = File.ReadAllLines(name); |
25 | 28 |
return lines; |
26 | 29 |
} |
... | ... | |
35 | 38 |
var lines = LoadCsv(pathToFile); |
36 | 39 |
List<JisInstance> list = new List<JisInstance>(); |
37 | 40 |
|
41 |
if (lines == null) |
|
42 |
return list; |
|
43 |
|
|
38 | 44 |
for (int i = 0; i < lines.Length; i++) |
39 | 45 |
{ |
40 | 46 |
var data = lines[i].Split(';'); |
47 |
|
|
48 |
if (data.Length < 3) |
|
49 |
continue; |
|
50 |
|
|
41 | 51 |
data[0] = data[0].Substring(1, data[0].Length - 2); |
42 | 52 |
data[1] = data[1].Substring(1, data[1].Length - 2); |
43 | 53 |
|
... | ... | |
63 | 73 |
var lines = LoadCsv(pathToFile); |
64 | 74 |
List<LogInInstance> list = new List<LogInInstance>(); |
65 | 75 |
|
76 |
if (lines == null) |
|
77 |
return list; |
|
78 |
|
|
66 | 79 |
for (int i = 0; i < lines.Length; i++) |
67 | 80 |
{ |
68 | 81 |
var data = lines[i].Split(';'); |
82 |
|
|
83 |
if (data.Length < 9) |
|
84 |
continue; |
|
85 |
|
|
69 | 86 |
data[0] = data[0].Substring(1, data[0].Length - 2); |
70 | 87 |
data[3] = data[3].Substring(1, data[3].Length - 2); |
71 | 88 |
data[4] = data[4].Substring(1, data[4].Length - 2); |
... | ... | |
99 | 116 |
public List<WeatherInstance> LoadWeatherFile(string pathToFile) |
100 | 117 |
{ |
101 | 118 |
var lines = LoadCsv(pathToFile); |
102 |
|
|
103 | 119 |
List<WeatherInstance> list = new List<WeatherInstance>(); |
120 |
|
|
121 |
if (lines == null) |
|
122 |
return list; |
|
123 |
|
|
104 | 124 |
for (int i = 0; i < lines.Length; i++) |
105 | 125 |
{ |
106 | 126 |
var data = lines[i].Split(';'); |
127 |
|
|
128 |
if (data.Length < 5) |
|
129 |
continue; |
|
130 |
|
|
107 | 131 |
data[0] = data[0].Substring(1, data[0].Length - 2); |
108 | 132 |
|
109 | 133 |
var dateTime = DateTime.ParseExact(data[0], "G", cultureInfo); |
Server/ServerApp/Parser/OutputInfo/ActivityInfo.cs | ||
---|---|---|
9 | 9 |
/// <author>Alex Konig</author> |
10 | 10 |
class ActivityInfo |
11 | 11 |
{ |
12 |
/// <summary> Faculty </summary>
|
|
13 |
public string faculty;
|
|
12 |
/// <summary> Building </summary>
|
|
13 |
public string building;
|
|
14 | 14 |
/// <summary> Number of events </summary> |
15 | 15 |
public int amount; |
16 | 16 |
/// <summary> Start of interval </summary> |
... | ... | |
27 | 27 |
/// <param name="intervalLength">Length of recorded interval</param> |
28 | 28 |
public ActivityInfo(string faculty, int amount, DateTime startTime, int intervalLength) |
29 | 29 |
{ |
30 |
this.faculty = faculty;
|
|
30 |
this.building = faculty;
|
|
31 | 31 |
this.amount = amount; |
32 | 32 |
this.startTime = startTime; |
33 | 33 |
this.intervalLength = intervalLength; |
... | ... | |
39 | 39 |
/// <returns>"start time faculty number of events"</returns> |
40 | 40 |
public override string ToString() |
41 | 41 |
{ |
42 |
return $"{startTime.ToString()} \t {faculty} \t {amount}";
|
|
42 |
return $"{startTime} \t {building} \t {amount}";
|
|
43 | 43 |
} |
44 | 44 |
} |
45 | 45 |
} |
Server/ServerApp/Parser/OutputInfo/LogInInfo.cs | ||
---|---|---|
8 | 8 |
{ |
9 | 9 |
class LogInInfo |
10 | 10 |
{ |
11 |
string faculty;
|
|
11 |
string building;
|
|
12 | 12 |
int amount; |
13 | 13 |
DateTime startTime; |
14 | 14 |
int intervalLength; |
15 | 15 |
|
16 |
public LogInInfo(string faculty, int amount, DateTime startTime, int intervalLength)
|
|
16 |
public LogInInfo(string building, int amount, DateTime startTime, int intervalLength)
|
|
17 | 17 |
{ |
18 |
this.faculty = faculty;
|
|
18 |
this.building = building;
|
|
19 | 19 |
this.amount = amount; |
20 | 20 |
this.startTime = startTime; |
21 | 21 |
this.intervalLength = intervalLength; |
... | ... | |
23 | 23 |
|
24 | 24 |
public override string ToString() |
25 | 25 |
{ |
26 |
return $"{startTime.ToString()} \t {faculty} \t {amount}";
|
|
26 |
return $"{startTime} \t {building} \t {amount}";
|
|
27 | 27 |
} |
28 | 28 |
} |
29 | 29 |
} |
Server/ServerApp/Parser/Parsers/CsvParser.cs | ||
---|---|---|
1 |
using Parser.OutputInfo; |
|
2 |
using ServerApp.Parser.InputData; |
|
3 |
using ServerApp.Parser.OutputInfo; |
|
4 |
using ServerApp.Parser.Parsers; |
|
5 |
using System; |
|
6 |
using System.Collections.Generic; |
|
7 |
using System.Globalization; |
|
8 |
using System.Threading; |
|
9 |
|
|
10 |
namespace Parser.Parsers |
|
11 |
{ |
|
12 |
class CsvParser |
|
13 |
{ |
|
14 |
|
|
15 |
string path; |
|
16 |
WeatherParser weatherParser; |
|
17 |
JisParser jisParser; |
|
18 |
LogInParser loginParser; |
|
19 |
|
|
20 |
public List<WeatherInfo> weatherList; |
|
21 |
public List<ActivityInfo> jisList; |
|
22 |
public List<ActivityInfo> loginList; |
|
23 |
|
|
24 |
public CsvParser() |
|
25 |
{ |
|
26 |
TagInfo.CreateDictionaries(); |
|
27 |
path = "data/"; |
|
28 |
|
|
29 |
CsvDataLoader loader = new CsvDataLoader(); |
|
30 |
|
|
31 |
weatherParser = new WeatherParser(loader); |
|
32 |
jisParser = new JisParser(loader); |
|
33 |
loginParser = new LogInParser(loader); |
|
34 |
} |
|
35 |
|
|
36 |
public void Parse() |
|
37 |
{ |
|
38 |
var cultureInfo = CultureInfo.GetCultureInfo("en-GB"); |
|
39 |
Thread.CurrentThread.CurrentCulture = cultureInfo; |
|
40 |
Thread.CurrentThread.CurrentUICulture = cultureInfo; |
|
41 |
|
|
42 |
string pathWeather = path + "weather"; |
|
43 |
string pathJis = path + "jis"; |
|
44 |
string pathLogIn = path + "login"; |
|
45 |
|
|
46 |
weatherList = weatherParser.ParseWeatherData(pathWeather); |
|
47 |
jisList = jisParser.ParseJisData(pathJis); |
|
48 |
loginList = loginParser.ParseLogInData(pathLogIn); |
|
49 |
|
|
50 |
Console.WriteLine("WEATHER"); |
|
51 |
WriteToConsole(weatherList); |
|
52 |
Console.WriteLine("JIS"); |
|
53 |
WriteToConsole(jisList); |
|
54 |
Console.WriteLine("LOGIN"); |
|
55 |
WriteToConsole(loginList); |
|
56 |
} |
|
57 |
|
|
58 |
private void WriteToConsole<T>(List<T> list) |
|
59 |
{ |
|
60 |
if (list == null) |
|
61 |
{ |
|
62 |
Console.WriteLine("Unsuccessful parsing"); |
|
63 |
return; |
|
64 |
} |
|
65 |
Console.WriteLine(list.Count); |
|
66 |
|
|
67 |
for (int i = 0; i < list.Count; i++) |
|
68 |
Console.WriteLine(list[i].ToString()); |
|
69 |
} |
|
70 |
|
|
71 |
} |
|
72 |
} |
Server/ServerApp/Parser/Parsers/DataParser.cs | ||
---|---|---|
24 | 24 |
LogInParser loginParser; |
25 | 25 |
|
26 | 26 |
/// <summary> WeatherInfo </summary> |
27 |
public List<WeatherInfo> weatherList; |
|
27 |
List<WeatherInfo> weatherList; |
|
28 |
public List<WeatherInfo> WeatherList { get => weatherList; } |
|
29 |
/// <summary> ActivityInfo repersenting overall activity </summary> |
|
30 |
List<ActivityInfo> attendanceList; |
|
31 |
public List<ActivityInfo> AttendanceList { get => attendanceList; } |
|
32 |
|
|
28 | 33 |
/// <summary> ActivityInfo representing jis activity </summary> |
29 |
public List<ActivityInfo> jisList;
|
|
34 |
List<ActivityInfo> jisList; |
|
30 | 35 |
/// <summary> ActivityInfo representing login activity</summary> |
31 |
public List<ActivityInfo> loginList;
|
|
36 |
List<ActivityInfo> loginList; |
|
32 | 37 |
|
33 | 38 |
/// <summary> |
34 | 39 |
/// Constructor |
... | ... | |
37 | 42 |
{ |
38 | 43 |
TagInfo.CreateDictionaries(); |
39 | 44 |
|
40 |
// TODO ask for data folder?
|
|
45 |
// TODO ask for data folder |
|
41 | 46 |
this.path = path; |
42 | 47 |
DataLoader loader = new CsvDataLoader(); |
43 | 48 |
|
... | ... | |
51 | 56 |
/// </summary> |
52 | 57 |
/// <param name="interval">Length of an interval</param> |
53 | 58 |
/// <param name="wholeDay">Parse data as one instance per day</param> |
54 |
public void Parse(int interval = 1, bool wholeDay = true)
|
|
59 |
public bool Parse(DateTime startTime, DateTime endTime, int interval = 1, bool wholeDay = true)
|
|
55 | 60 |
{ |
61 |
// TODO start and end time -> ask for files from this span, plus validate if the data really is from this span (issue with 00 files) |
|
62 |
|
|
56 | 63 |
var cultureInfo = CultureInfo.GetCultureInfo("en-GB"); |
57 | 64 |
Thread.CurrentThread.CurrentCulture = cultureInfo; |
58 | 65 |
Thread.CurrentThread.CurrentUICulture = cultureInfo; |
... | ... | |
61 | 68 |
string pathJis = path + "jis"; |
62 | 69 |
string pathLogIn = path + "login"; |
63 | 70 |
|
64 |
weatherList = weatherParser.ParseWeatherData(pathWeather, false, 2); // wholeDay, interval);
|
|
65 |
jisList = jisParser.ParseJisData(pathJis, false, 2); // wholeDay, interval);
|
|
66 |
loginList = loginParser.ParseLogInData(pathLogIn, false, 2); // wholeDay, interval);
|
|
71 |
weatherList = weatherParser.ParseWeatherData(pathWeather, wholeDay, interval); |
|
72 |
jisList = jisParser.ParseJisData(pathJis, wholeDay, interval); |
|
73 |
loginList = loginParser.ParseLogInData(pathLogIn, wholeDay, interval); |
|
67 | 74 |
|
68 | 75 |
//Console.WriteLine("WEATHER"); |
69 | 76 |
//WriteToConsole(weatherList); |
70 |
Console.WriteLine("JIS"); |
|
71 |
WriteToConsole(jisList); |
|
77 |
//Console.WriteLine("JIS");
|
|
78 |
//WriteToConsole(jisList);
|
|
72 | 79 |
//Console.WriteLine("LOGIN"); |
73 | 80 |
//WriteToConsole(loginList); |
81 |
|
|
82 |
//WriteToConsole(AddListToOne(jisList)); |
|
83 |
|
|
84 |
MergeAttendance(); |
|
85 |
|
|
86 |
//Console.WriteLine("MERGED IN ONE LIST"); |
|
87 |
//WriteToConsole(attendanceList); |
|
88 |
|
|
89 |
if (weatherList.Count == 0 || attendanceList.Count == 0) |
|
90 |
return false; |
|
91 |
|
|
92 |
return true; |
|
93 |
} |
|
94 |
|
|
95 |
/// <summary> |
|
96 |
/// Merges ActivityInfo lists with jis and login activity into one |
|
97 |
/// Adds information from the same time period together, doesn't change the rest |
|
98 |
/// </summary> |
|
99 |
private void MergeAttendance() |
|
100 |
{ |
|
101 |
attendanceList = new List<ActivityInfo>(); |
|
102 |
|
|
103 |
int indexJis = 0, indexLogin = 0; |
|
104 |
while (true) |
|
105 |
{ |
|
106 |
if (indexJis >= jisList.Count && indexLogin >= loginList.Count) |
|
107 |
break; |
|
108 |
|
|
109 |
ActivityInfo jis = jisList[indexJis]; |
|
110 |
int jisTag = TagInfo.IndexOfBuilding(jis.building); |
|
111 |
ActivityInfo login = loginList[indexLogin]; |
|
112 |
int loginTag = TagInfo.IndexOfBuilding(login.building); |
|
113 |
|
|
114 |
// if same time times -> add to one info |
|
115 |
if (jis.startTime == login.startTime) |
|
116 |
{ |
|
117 |
// need to have same building tags |
|
118 |
if (jisTag == loginTag) |
|
119 |
{ |
|
120 |
jis.amount += login.amount; |
|
121 |
attendanceList.Add(jis); |
|
122 |
indexJis++; indexLogin++; |
|
123 |
} |
|
124 |
|
|
125 |
if (jisTag < loginTag) |
|
126 |
{ |
|
127 |
indexJis++; |
|
128 |
attendanceList.Add(jis); |
|
129 |
} |
|
130 |
|
|
131 |
if (jisTag > loginTag) |
|
132 |
{ |
|
133 |
indexLogin++; |
|
134 |
attendanceList.Add(login); |
|
135 |
} |
|
136 |
|
|
137 |
} |
|
138 |
|
|
139 |
// if jis time is smaller -> add jis and move |
|
140 |
if (jis.startTime < login.startTime) |
|
141 |
{ |
|
142 |
indexJis++; |
|
143 |
attendanceList.Add(jis); |
|
144 |
} |
|
145 |
|
|
146 |
// if login time is smaller -> add login and move |
|
147 |
if (login.startTime < jis.startTime) |
|
148 |
{ |
|
149 |
indexLogin++; |
|
150 |
attendanceList.Add(login); |
|
151 |
} |
|
152 |
|
|
153 |
} |
|
154 |
|
|
155 |
} |
|
156 |
|
|
157 |
/// <summary> |
|
158 |
/// Sum all info for separate intervals in the list to the appropriate day |
|
159 |
/// </summary> |
|
160 |
/// <param name="list">List with activity info, info separated into buildings and intervals</param> |
|
161 |
/// <returns></returns> |
|
162 |
private List<ActivityInfo> AddListToOne(List<ActivityInfo> list) |
|
163 |
{ |
|
164 |
List<ActivityInfo> a2 = new List<ActivityInfo>(); |
|
165 |
for (int i = 0; i < list.Count; i+=TagInfo.buildings.Length) |
|
166 |
{ |
|
167 |
int amount = 0; |
|
168 |
for (int j = 0; j < TagInfo.buildings.Length; j++) |
|
169 |
{ |
|
170 |
amount += list[i + j].amount; |
|
171 |
} |
|
172 |
ActivityInfo info = new ActivityInfo("ALL", amount, list[i].startTime, list[i].intervalLength); |
|
173 |
a2.Add(info); |
|
174 |
} |
|
175 |
return a2; |
|
176 |
} |
|
177 |
|
|
178 |
/// <summary> |
|
179 |
/// Debug method - writing lists to console |
|
180 |
/// </summary> |
|
181 |
private void WriteToConsole(List<ActivityInfo> list) |
|
182 |
{ |
|
183 |
// TODO useless in finished app |
|
184 |
if (list == null) |
|
185 |
{ |
|
186 |
Console.WriteLine("Unsuccessful parsing"); |
|
187 |
return; |
|
188 |
} |
|
189 |
Console.WriteLine(list.Count); |
|
190 |
|
|
191 |
for (int i = 0; i < list.Count; i++) |
|
192 |
Console.WriteLine(list[i].ToString()); |
|
74 | 193 |
} |
75 | 194 |
|
76 | 195 |
/// <summary> |
77 | 196 |
/// Debug method - writing lists to console |
78 | 197 |
/// </summary> |
79 |
private void WriteToConsole<T>(List<T> list)
|
|
198 |
private void WriteToConsole(List<WeatherInfo> list)
|
|
80 | 199 |
{ |
81 | 200 |
// TODO useless in finished app |
82 | 201 |
if (list == null) |
Server/ServerApp/Parser/Parsers/JisParser.cs | ||
---|---|---|
74 | 74 |
List<JisInstance> list = loader.LoadJisFile(path); |
75 | 75 |
|
76 | 76 |
// data for each faculty |
77 |
int[] recordedAmount = new int[TagInfo.faculties.Length];
|
|
77 |
int[] recordedAmount = new int[TagInfo.buildings.Length];
|
|
78 | 78 |
// min/max hour taken into account |
79 | 79 |
int[] minmaxHour = new int[] { 7, 18 }; |
80 | 80 |
// interval length |
... | ... | |
94 | 94 |
if (!date.Equals(lastStartTime)) |
95 | 95 |
{ |
96 | 96 |
// data for each faculty separate |
97 |
for (int k = 0; k < TagInfo.faculties.Length; k++)
|
|
97 |
for (int k = 0; k < TagInfo.buildings.Length; k++)
|
|
98 | 98 |
{ |
99 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[k], recordedAmount[k], lastStartTime, range);
|
|
99 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], lastStartTime, range);
|
|
100 | 100 |
jisInfo.Add(dayInfo); |
101 | 101 |
} |
102 | 102 |
|
103 |
recordedAmount = new int[TagInfo.faculties.Length];
|
|
103 |
recordedAmount = new int[TagInfo.buildings.Length];
|
|
104 | 104 |
lastStartTime = date; |
105 | 105 |
} |
106 | 106 |
|
... | ... | |
109 | 109 |
{ |
110 | 110 |
int index = TagInfo.jisPlaces[place]; |
111 | 111 |
if (index == -1) |
112 |
for (int l = 0; l < TagInfo.faculties.Length; l++)
|
|
112 |
for (int l = 0; l < TagInfo.buildings.Length; l++)
|
|
113 | 113 |
recordedAmount[l] += list[i].amount; |
114 | 114 |
else |
115 | 115 |
recordedAmount[index] += list[i].amount; |
... | ... | |
117 | 117 |
} |
118 | 118 |
else |
119 | 119 |
{ |
120 |
// TODO uknown code handling |
|
121 |
Console.WriteLine("Unknown code " + list[i].placeTag); |
|
120 |
// TODO uknown code handling -> to file?
|
|
121 |
// Console.WriteLine("Unknown code " + list[i].placeTag);
|
|
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
} |
125 | 125 |
|
126 | 126 |
// last day |
127 |
for (int k = 0; k < TagInfo.faculties.Length; k++)
|
|
127 |
for (int k = 0; k < TagInfo.buildings.Length; k++)
|
|
128 | 128 |
{ |
129 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[k], recordedAmount[k], lastStartTime, range);
|
|
129 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], lastStartTime, range);
|
|
130 | 130 |
jisInfo.Add(dayInfo); |
131 | 131 |
} |
132 | 132 |
|
... | ... | |
148 | 148 |
List<JisInstance> list = loader.LoadJisFile(path); |
149 | 149 |
|
150 | 150 |
// data for each faculty |
151 |
int[] recordedAmount = new int[TagInfo.faculties.Length];
|
|
151 |
int[] recordedAmount = new int[TagInfo.buildings.Length];
|
|
152 | 152 |
// min/max hour taken into account |
153 | 153 |
int[] minmaxHour = new int[] { 7, 18 }; |
154 | 154 |
int range = minmaxHour[1] - minmaxHour[0]; |
... | ... | |
203 | 203 |
startTime = to[index - 1]; |
204 | 204 |
|
205 | 205 |
// data for each faculty separate |
206 |
for (int k = 0; k < TagInfo.faculties.Length; k++)
|
|
206 |
for (int k = 0; k < TagInfo.buildings.Length; k++)
|
|
207 | 207 |
{ |
208 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[k], recordedAmount[k], stTime, interval);
|
|
208 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], stTime, interval);
|
|
209 | 209 |
jisInfo.Add(dayInfo); |
210 | 210 |
} |
211 | 211 |
|
212 |
recordedAmount = new int[TagInfo.faculties.Length];
|
|
212 |
recordedAmount = new int[TagInfo.buildings.Length];
|
|
213 | 213 |
lastStartTime = date; |
214 | 214 |
} |
215 | 215 |
|
... | ... | |
218 | 218 |
{ |
219 | 219 |
int faculty = TagInfo.jisPlaces[place]; |
220 | 220 |
if (faculty == -1) |
221 |
for (int l = 0; l < TagInfo.faculties.Length; l++)
|
|
221 |
for (int l = 0; l < TagInfo.buildings.Length; l++)
|
|
222 | 222 |
recordedAmount[l] += list[i].amount; |
223 | 223 |
else |
224 | 224 |
recordedAmount[faculty] += list[i].amount; |
... | ... | |
226 | 226 |
} |
227 | 227 |
else |
228 | 228 |
{ |
229 |
// TODO uknown code handling |
|
230 |
Console.WriteLine("Unknown code " + list[i].placeTag); |
|
229 |
// TODO uknown code handling -> to file?
|
|
230 |
// Console.WriteLine("Unknown code " + list[i].placeTag);
|
|
231 | 231 |
} |
232 | 232 |
|
233 | 233 |
} |
234 | 234 |
|
235 | 235 |
// last day |
236 |
for (int k = 0; k < TagInfo.faculties.Length; k++)
|
|
236 |
for (int k = 0; k < TagInfo.buildings.Length; k++)
|
|
237 | 237 |
{ |
238 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[k], recordedAmount[k], lastStartTime, interval);
|
|
238 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], lastStartTime, interval);
|
|
239 | 239 |
jisInfo.Add(dayInfo); |
240 | 240 |
} |
241 | 241 |
|
Server/ServerApp/Parser/Parsers/LogInParser.cs | ||
---|---|---|
73 | 73 |
List<LogInInstance> list = loader.LoadLoginFile(path); |
74 | 74 |
|
75 | 75 |
// data for each faculty |
76 |
int[] recordedAmount = new int[TagInfo.faculties.Length];
|
|
76 |
int[] recordedAmount = new int[TagInfo.buildings.Length];
|
|
77 | 77 |
// min/max hour taken into account |
78 | 78 |
int[] minmaxHour = new int[] { 7, 18 }; |
79 | 79 |
// interval length |
... | ... | |
93 | 93 |
if (!date.Equals(lastStartDay)) |
94 | 94 |
{ |
95 | 95 |
// data for each faculty separate |
96 |
for (int k = 0; k < TagInfo.faculties.Length; k++)
|
|
96 |
for (int k = 0; k < TagInfo.buildings.Length; k++)
|
|
97 | 97 |
{ |
98 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[k], recordedAmount[k], lastStartDay, range);
|
|
98 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], lastStartDay, range);
|
|
99 | 99 |
loginInfo.Add(dayInfo); |
100 | 100 |
} |
101 | 101 |
|
102 |
recordedAmount = new int[TagInfo.faculties.Length];
|
|
102 |
recordedAmount = new int[TagInfo.buildings.Length];
|
|
103 | 103 |
lastStartDay = date; |
104 | 104 |
} |
105 | 105 |
|
... | ... | |
107 | 107 |
if (TagInfo.buildingTags.ContainsKey(place)) |
108 | 108 |
{ |
109 | 109 |
int index = TagInfo.buildingTags[place]; |
110 |
//Console.WriteLine(place + " " + index); |
|
111 |
|
|
110 | 112 |
// to all |
111 | 113 |
if (index == -1) |
112 |
for (int l = 0; l < TagInfo.faculties.Length; l++)
|
|
114 |
for (int l = 0; l < TagInfo.buildings.Length; l++)
|
|
113 | 115 |
recordedAmount[l] += list[i].amount; |
114 |
// to first two |
|
115 |
else if (index == -2) |
|
116 |
{ |
|
117 |
recordedAmount[0] += list[i].amount; |
|
118 |
recordedAmount[1] += list[i].amount; |
|
119 |
} |
|
120 | 116 |
else |
121 | 117 |
recordedAmount[index] += list[i].amount; |
122 | 118 |
|
123 | 119 |
} |
124 | 120 |
else |
125 | 121 |
{ |
126 |
// TODO uknown code handling |
|
127 |
Console.WriteLine("Unknown code " + list[i].building); |
|
122 |
// TODO uknown code handling -> to file?
|
|
123 |
// Console.WriteLine("Unknown code " + list[i].building);
|
|
128 | 124 |
} |
129 | 125 |
|
130 | 126 |
} |
131 | 127 |
|
132 | 128 |
// last day |
133 |
for (int k = 0; k < TagInfo.faculties.Length; k++)
|
|
129 |
for (int k = 0; k < TagInfo.buildings.Length; k++)
|
|
134 | 130 |
{ |
135 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[k], recordedAmount[k], lastStartDay, range);
|
|
131 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], lastStartDay, range);
|
|
136 | 132 |
loginInfo.Add(dayInfo); |
137 | 133 |
} |
138 | 134 |
|
... | ... | |
166 | 162 |
for (int i = 0; i < to.Length; i++) |
167 | 163 |
{ |
168 | 164 |
to[i] = minmaxHour[0] + interval * (i + 1); |
169 |
data[i] = new int[TagInfo.faculties.Length];
|
|
165 |
data[i] = new int[TagInfo.buildings.Length];
|
|
170 | 166 |
} |
171 | 167 |
|
172 | 168 |
// first day |
... | ... | |
191 | 187 |
DateTime stTime = new DateTime(lastStartTime.Year, lastStartTime.Month, lastStartTime.Day, to[k] - interval, 0, 0); |
192 | 188 |
|
193 | 189 |
// data for each faculty separate |
194 |
for (int l = 0; l < TagInfo.faculties.Length; l++)
|
|
190 |
for (int l = 0; l < TagInfo.buildings.Length; l++)
|
|
195 | 191 |
{ |
196 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[l], data[k][l], stTime, interval);
|
|
192 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[l], data[k][l], stTime, interval);
|
|
197 | 193 |
loignInfo.Add(dayInfo); |
198 | 194 |
} |
199 | 195 |
|
200 |
data[k] = new int[TagInfo.faculties.Length];
|
|
196 |
data[k] = new int[TagInfo.buildings.Length];
|
|
201 | 197 |
} |
202 | 198 |
lastStartTime = date; |
203 | 199 |
} |
... | ... | |
219 | 215 |
int faculty = TagInfo.buildingTags[place]; |
220 | 216 |
// to all |
221 | 217 |
if (faculty == -1) |
222 |
for (int l = 0; l < TagInfo.faculties.Length; l++)
|
|
218 |
for (int l = 0; l < TagInfo.buildings.Length; l++)
|
|
223 | 219 |
data[index][l] += list[i].amount; |
224 | 220 |
// to first two |
225 | 221 |
else if (faculty == -2) |
... | ... | |
233 | 229 |
} |
234 | 230 |
else |
235 | 231 |
{ |
236 |
// TODO uknown code handling |
|
237 |
Console.WriteLine("Unknown code " + list[i].building); |
|
232 |
// TODO uknown code handling -> write to file?
|
|
233 |
// Console.WriteLine("Unknown code " + list[i].building);
|
|
238 | 234 |
} |
239 | 235 |
|
240 | 236 |
} |
... | ... | |
244 | 240 |
DateTime stTime = new DateTime(lastStartTime.Year, lastStartTime.Month, lastStartTime.Day, to[k] - interval, 0, 0); |
245 | 241 |
|
246 | 242 |
// data for each faculty separate |
247 |
for (int l = 0; l < TagInfo.faculties.Length; l++)
|
|
243 |
for (int l = 0; l < TagInfo.buildings.Length; l++)
|
|
248 | 244 |
{ |
249 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[l], data[k][l], stTime, interval);
|
|
245 |
ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[l], data[k][l], stTime, interval);
|
|
250 | 246 |
loignInfo.Add(dayInfo); |
251 | 247 |
} |
252 | 248 |
} |
Server/ServerApp/Parser/Parsers/TagInfo.cs | ||
---|---|---|
7 | 7 |
/// <author>Alex Konig</author> |
8 | 8 |
class TagInfo |
9 | 9 |
{ |
10 |
public static string[] faculties;
|
|
10 |
public static string[] buildings;
|
|
11 | 11 |
|
12 | 12 |
// -1 all |
13 | 13 |
public static Dictionary<string, int> jisPlaces; |
... | ... | |
15 | 15 |
// -1 all -2 FST, FEK |
16 | 16 |
public static Dictionary<string, int> buildingTags; |
17 | 17 |
|
18 |
public static int IndexOfBuilding(string tag) |
|
19 |
{ |
|
20 |
for (int i = 0; i < buildings.Length; i++) |
|
21 |
{ |
|
22 |
if (buildings[i].Equals(tag)) |
|
23 |
return i; |
|
24 |
} |
|
25 |
|
|
26 |
return -1; |
|
27 |
} |
|
28 |
|
|
18 | 29 |
public static void CreateDictionaries() |
19 | 30 |
{ |
20 | 31 |
jisPlaces = new Dictionary<string, int>(); |
... | ... | |
22 | 33 |
|
23 | 34 |
// FACULTIES |
24 | 35 |
|
25 |
faculties = new string[] { "FST+FEK", "FDU", "FAV", "FEL", "REK", "MENZA", "LIB", "CIV", "UNI14", "DOM", "HUS", "CHOD", "JUNG", "KLAT", "KOLL", "RIEG", "SADY", "SED+VEL", "TES",
|
|
36 |
buildings = new string[] { "FST+FEK", "FDU", "FAV", "FEL", "REK", "MENZA", "LIB", "CIV", "UNI14", "DOM", "HUS", "CHOD", "JUNG", "KLAT", "KOLL", "RIEG", "SADY", "SED+VEL", "TES",
|
|
26 | 37 |
"TYL", "KARMA", "KBORY", "KLOCH", "KKLAT" }; |
27 | 38 |
|
28 | 39 |
// BUILDING TAGS |
... | ... | |
34 | 45 |
buildingTags.Add("UL", 0); |
35 | 46 |
buildingTags.Add("UP", 0); |
36 | 47 |
buildingTags.Add("UF", 0); |
37 |
buildingTags.Add("UT", 0); |
|
38 | 48 |
buildingTags.Add("UH", 0); |
39 | 49 |
buildingTags.Add("UD", 0); |
40 | 50 |
buildingTags.Add("UX", 0); |
Server/ServerApp/Program.cs | ||
---|---|---|
12 | 12 |
{ |
13 | 13 |
DataParser p = new DataParser("data/"); |
14 | 14 |
|
15 |
//p.Parse(); |
|
15 |
p.Parse(new DateTime(), new DateTime()); |
|
16 |
|
|
17 |
Console.ReadLine(); |
|
16 | 18 |
|
17 | 19 |
|
18 | 20 |
// test scenario - data download: |
... | ... | |
29 | 31 |
// Console.WriteLine(s); |
30 | 32 |
//} |
31 | 33 |
|
32 |
|
|
34 |
/* |
|
33 | 35 |
|
34 | 36 |
// test - connection: |
35 | 37 |
AsynchronousSocketListener asl = new AsynchronousSocketListener(); |
... | ... | |
55 | 57 |
} |
56 | 58 |
|
57 | 59 |
Console.ReadLine(); |
60 |
*/ |
|
58 | 61 |
} |
59 | 62 |
} |
60 | 63 |
} |
Server/ServerApp/ServerApp.csproj | ||
---|---|---|
145 | 145 |
<Compile Include="Parser\OutputInfo\WeatherConditions.cs" /> |
146 | 146 |
<Compile Include="Parser\OutputInfo\WeatherInfo.cs" /> |
147 | 147 |
<Compile Include="Parser\OutputInfo\WindInfo.cs" /> |
148 |
<Compile Include="Parser\Parsers\CsvParser.cs" /> |
|
149 | 148 |
<Compile Include="Parser\Parsers\DataParser.cs" /> |
150 | 149 |
<Compile Include="Parser\Parsers\JisParser.cs" /> |
151 | 150 |
<Compile Include="Parser\Parsers\LogInParser.cs" /> |
... | ... | |
225 | 224 |
<None Include="data\jis\OD_ZCU_JIS_10_2019.CSV" /> |
226 | 225 |
<None Include="data\jis\OD_ZCU_JIS_11_2019.CSV" /> |
227 | 226 |
<None Include="data\jis\OD_ZCU_JIS_12_2019.CSV" /> |
228 |
<None Include="data\jis\OD_ZCU_JIS_13_2019.CSV" /> |
|
227 |
<None Include="data\jis\OD_ZCU_JIS_13_2019.CSV"> |
|
228 |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
229 |
</None> |
|
229 | 230 |
<None Include="data\login\OD_ZCU_STROJE_06_2019.CSV" /> |
230 | 231 |
<None Include="data\login\OD_ZCU_STROJE_09_2019.CSV" /> |
231 | 232 |
<None Include="data\login\OD_ZCU_STROJE_10_2019.CSV" /> |
232 | 233 |
<None Include="data\login\OD_ZCU_STROJE_11_2019.CSV" /> |
233 | 234 |
<None Include="data\login\OD_ZCU_STROJE_12_2019.CSV" /> |
234 |
<None Include="data\login\OD_ZCU_STROJE_13_2019.CSV" /> |
|
235 |
<None Include="data\weather\OD_ZCU_POCASI_06_2019.CSV" /> |
|
236 |
<None Include="data\weather\OD_ZCU_POCASI_09_2019.CSV" /> |
|
237 |
<None Include="data\weather\OD_ZCU_POCASI_10_2019.CSV" /> |
|
238 |
<None Include="data\weather\OD_ZCU_POCASI_11_2019.CSV" /> |
|
239 |
<None Include="data\weather\OD_ZCU_POCASI_12_2019.CSV" /> |
|
240 |
<None Include="data\weather\OD_ZCU_POCASI_13_2019.CSV" /> |
|
235 |
<None Include="data\login\OD_ZCU_STROJE_13_2019.CSV"> |
|
236 |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
237 |
</None> |
|
238 |
<None Include="data\weather\OD_ZCU_POCASI_06_2019.CSV"> |
|
239 |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
240 |
</None> |
|
241 |
<None Include="data\weather\OD_ZCU_POCASI_09_2019.CSV"> |
|
242 |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
243 |
</None> |
|
244 |
<None Include="data\weather\OD_ZCU_POCASI_10_2019.CSV"> |
|
245 |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
246 |
</None> |
|
247 |
<None Include="data\weather\OD_ZCU_POCASI_11_2019.CSV"> |
|
248 |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
249 |
</None> |
|
250 |
<None Include="data\weather\OD_ZCU_POCASI_12_2019.CSV"> |
|
251 |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
252 |
</None> |
|
253 |
<None Include="data\weather\OD_ZCU_POCASI_13_2019.CSV"> |
|
254 |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
255 |
</None> |
|
241 | 256 |
<None Include="packages.config" /> |
242 | 257 |
</ItemGroup> |
243 | 258 |
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
Server/ServerApp/data/jis/OD_ZCU_JIS_13_2019.CSV | ||
---|---|---|
3 | 3 |
"L2";"01.12.2019 08:22:53";1 |
4 | 4 |
"A1";"01.12.2019 14:31:19";1 |
5 | 5 |
"M14";"01.12.2019 14:35:40";1 |
6 |
|
|
6 | 7 |
"A3";"02.12.2019 07:47:04";1 |
7 | 8 |
"L2";"02.12.2019 10:48:11";1 |
8 | 9 |
"A1";"02.12.2019 11:53:10";1 |
9 | 10 |
"M16";"02.12.2019 12:19:27";1 |
10 | 11 |
"L1L2-vchod";"02.12.2019 12:30:06";1 |
12 |
|
|
11 | 13 |
"L2";"03.12.2019 07:30:23";1 |
12 | 14 |
"M16";"03.12.2019 07:44:09";1 |
13 | 15 |
"A3";"03.12.2019 15:45:05";1 |
14 | 16 |
"L1";"03.12.2019 16:26:58";1 |
15 | 17 |
"A1";"03.12.2019 17:27:46";1 |
18 |
|
|
19 |
"Zavora-FEL";"05.12.2019 09:48:26";1 |
|
16 | 20 |
"M16";"05.12.2019 17:48:26";1 |
17 | 21 |
"L1L2-vchod";"05.12.2019 18:15:33";1 |
18 | 22 |
"L2";"05.12.2019 18:15:48";1 |
Server/ServerApp/data/login/OD_ZCU_STROJE_13_2019.CSV | ||
---|---|---|
4 | 4 |
"01.12.2019 00:00:00";4;2;"12:25";"09:10";"UL";"Laboratoř";"UL-109";"ul109p03-kks" |
5 | 5 |
"01.12.2019 00:00:00";4;2;"08:25";"09:10";"UL";"Laboratoř";"UL-109";"ul109p02-kks" |
6 | 6 |
"01.12.2019 00:00:00";4;3;"09:20";"10:05";"UL";"Laboratoř";"UL-109";"ul109p02-kks" |
7 |
|
|
7 | 8 |
"02.12.2019 00:00:00";4;8;"13:55";"14:40";"UL";"Laboratoř";"UL-107";"ul107p07-kks" |
8 | 9 |
"02.12.2019 00:00:00";6;5;"11:10";"11:55";"UB";"Jiná";"UB-211";"ub211p63-uk" |
9 | 10 |
"02.12.2019 00:00:00";1;2;"08:25";"09:10";"CD";"Učebna";"CD-203";"cd203p16-fek" |
... | ... | |
11 | 12 |
"02.12.2019 00:00:00";1;11;"16:40";"17:25";"UC";"Laboratoř";"UC-411";"uc411p12-kme" |
12 | 13 |
"02.12.2019 00:00:00";6;6;"12:05";"12:50";"UB";"Jiná";"UB-211";"ub211p39-uk" |
13 | 14 |
"02.12.2019 00:00:00";6;3;"09:20";"10:05";"UI";"Učebna";"UI-202";"ui202p06-sup" |
14 |
"03.12.2019 00:00:00";6;6;"12:05";"12:50";"UI";"Učebna";"UI-202";"ui202p18-sup" |
|
15 |
|
|
16 |
"03.12.2019 00:00:00";3;6;"12:05";"12:50";"UI";"Učebna";"UI-202";"ui202p18-sup" |
|
15 | 17 |
"03.12.2019 00:00:00";12;11;"16:40";"17:25";"LS";"Učebna";"LS-234";"ls233p02-fdu" |
16 | 18 |
"03.12.2019 00:00:00";1;1;"07:30";"08:15";"EU";"Laboratoř";"EU-505";"eu505x08-fel" |
17 | 19 |
"03.12.2019 00:00:00";1;5;"11:10";"11:55";"KL";"Učebna";"KL-206";"kl206p03-kvd" |
... | ... | |
21 | 23 |
"03.12.2019 00:00:00";1;7;"13:00";"13:45";"PS";"Jiná";"PS-303";"ps303p24-uk" |
22 | 24 |
"03.12.2019 00:00:00";6;4;"10:15";"11:00";"UI";"Učebna";"UI-202";"ui202p13-sup" |
23 | 25 |
"03.12.2019 00:00:00";6;6;"12:05";"12:50";"UI";"Učebna";"UI-202";"ui202p06-sup" |
24 |
"03.12.2019 00:00:00";6;3;"09:20";"10:05";"LS";"Učebna";"LS-234";"ls234p40-fdu" |
|
26 |
|
|
27 |
"05.12.2019 00:00:00";6;3;"09:20";"10:05";"EU";"Učebna";"LS-234";"ls234p40-fdu" |
|
28 |
"05.12.2019 00:00:00";12;11;"16:40";"17:25";"EP";"Učebna";"LS-234";"ls233p02-fdu" |
|
29 |
"05.12.2019 00:00:00";1;1;"07:30";"08:15";"UB";"Laboratoř";"EU-505";"eu505x08-fel" |
|
30 |
"05.12.2019 00:00:00";1;5;"11:10";"11:55";"UV";"Učebna";"KL-206";"kl206p03-kvd" |
|
31 |
"05.12.2019 00:00:00";1;4;"10:15";"11:00";"UU";"Učebna";"KL-206";"kl206p05-kvd" |
|
32 |
"05.12.2019 00:00:00";1;2;"08:25";"09:10";"UK";"Učebna";"KL-206";"kl206p15-kvd" |
|
33 |
"05.12.2019 00:00:00";6;6;"12:05";"12:50";"LS";"Učebna";"LS-234";"ls234p45-fdu" |
|
34 |
"05.12.2019 00:00:00";1;7;"13:00";"13:45";"UI";"Jiná";"PS-303";"ps303p24-uk" |
|
35 |
"05.12.2019 00:00:00";6;4;"10:15";"11:00";"UT";"Učebna";"UI-202";"ui202p13-sup" |
|
36 |
"05.12.2019 00:00:00";6;6;"12:05";"12:50";"DD";"Učebna";"UI-202";"ui202p06-sup" |
|
37 |
"05.12.2019 00:00:00";6;3;"09:20";"10:05";"RJ";"Učebna";"LS-234";"ls234p40-fdu" |
Také k dispozici: Unified diff
re #8682 Modified parser to aggregate data according to buildings. Also added a method that merges information about jis and webauth activity into one list.