Revize 23e8ae04
Přidáno uživatelem Alex Konig před téměř 4 roky(ů)
Server/ServerApp/Parser/InputData/CsvDataLoader.cs | ||
---|---|---|
70 | 70 |
|
71 | 71 |
data[0] = data[0].Substring(1, data[0].Length - 2); |
72 | 72 |
data[1] = data[1].Substring(1, data[1].Length - 2); |
73 |
|
|
74 |
var dateTime = DateTime.ParseExact(data[1], "G", cultureInfo); |
|
73 |
|
|
74 |
var dateTime = new DateTime(); |
|
75 |
try |
|
76 |
{ |
|
77 |
dateTime = DateTime.ParseExact(data[1], "G", cultureInfo); |
|
78 |
} |
|
79 |
catch |
|
80 |
{ |
|
81 |
continue; |
|
82 |
} |
|
75 | 83 |
|
76 | 84 |
int amount = 0; |
77 | 85 |
int.TryParse(data[2], out amount); |
... | ... | |
114 | 122 |
data[7] = data[7].Substring(1, data[7].Length - 2); |
115 | 123 |
data[8] = data[8].Substring(1, data[8].Length - 2); |
116 | 124 |
|
117 |
var dateTime = DateTime.ParseExact(data[0], "G", cultureInfo); |
|
118 |
var startTime = DateTime.ParseExact(data[3], "t", cultureInfo); |
|
119 |
var endTime = DateTime.ParseExact(data[4], "t", cultureInfo); |
|
125 |
var dateTime = new DateTime(); |
|
126 |
var startTime = new DateTime(); |
|
127 |
var endTime = new DateTime(); |
|
128 |
try |
|
129 |
{ |
|
130 |
dateTime = DateTime.ParseExact(data[0], "G", cultureInfo); |
|
131 |
startTime = DateTime.ParseExact(data[3], "t", cultureInfo); |
|
132 |
endTime = DateTime.ParseExact(data[4], "t", cultureInfo); |
|
133 |
} |
|
134 |
catch |
|
135 |
{ |
|
136 |
continue; |
|
137 |
} |
|
120 | 138 |
|
121 | 139 |
int count = 0; |
122 | 140 |
int.TryParse(data[1], out count); |
... | ... | |
155 | 173 |
continue; |
156 | 174 |
|
157 | 175 |
data[0] = data[0].Substring(1, data[0].Length - 2); |
158 |
|
|
159 |
var dateTime = DateTime.ParseExact(data[0], "G", cultureInfo); |
|
176 |
|
|
177 |
var dateTime = new DateTime(); |
|
178 |
try |
|
179 |
{ |
|
180 |
dateTime = DateTime.ParseExact(data[0], "G", cultureInfo); |
|
181 |
} |
|
182 |
catch |
|
183 |
{ |
|
184 |
continue; |
|
185 |
} |
|
160 | 186 |
|
161 | 187 |
double temp = 0; |
162 | 188 |
double.TryParse(data[1], out temp); |
Server/ServerApp/Parser/Parsers/DataParser.cs | ||
---|---|---|
93 | 93 |
loginList = loginParser.ParseLogInData(loginFiles, startTime, endTime, wholeDay, interval); |
94 | 94 |
|
95 | 95 |
//Console.WriteLine("WEATHER"); |
96 |
//WriteToConsole(weatherList);
|
|
96 |
//WriteToConsole(WeatherList);
|
|
97 | 97 |
//Console.WriteLine("JIS"); |
98 | 98 |
//WriteToConsole(jisList); |
99 | 99 |
//Console.WriteLine("LOGIN"); |
... | ... | |
104 | 104 |
AttendanceList = MergeAttendance(jisList, loginList); |
105 | 105 |
|
106 | 106 |
//Console.WriteLine("MERGED IN ONE LIST"); |
107 |
//WriteToConsole(attendanceList);
|
|
107 |
//WriteToConsole(AttendanceList);
|
|
108 | 108 |
|
109 | 109 |
if (WeatherList.Count == 0 || AttendanceList.Count == 0) |
110 | 110 |
return false; |
... | ... | |
229 | 229 |
Console.WriteLine(list.Count); |
230 | 230 |
|
231 | 231 |
for (int i = 0; i < list.Count; i++) |
232 |
Console.WriteLine(list[i].ToString()); |
|
232 |
{ |
|
233 |
if (list[i].startTime.Year >= 2019) |
|
234 |
Console.WriteLine(list[i].ToString()); |
|
235 |
} |
|
233 | 236 |
} |
234 | 237 |
|
235 | 238 |
/// <summary> |
Server/ServerApp/Parser/Parsers/JisParser.cs | ||
---|---|---|
44 | 44 |
{ |
45 | 45 |
List<ActivityInfo> list = new List<ActivityInfo>(); |
46 | 46 |
|
47 |
if (jisFiles == null || startTime == null || endTime == null || interval <= 0)
|
|
47 |
if (jisFiles == null || interval <= 0) |
|
48 | 48 |
return list; |
49 | 49 |
|
50 |
// parse all files
|
|
51 |
foreach (string fileName in jisFiles)
|
|
50 |
string current = "";
|
|
51 |
try
|
|
52 | 52 |
{ |
53 |
if (!File.Exists(fileName)) |
|
54 |
continue; |
|
55 |
|
|
56 |
// parse as one instance per day |
|
57 |
List<ActivityInfo> loadedData = null; |
|
58 |
if (wholeDay) |
|
59 |
loadedData = ProcessOneJisFileAsDays(fileName, startTime, endTime); |
|
60 |
// parse by interval length |
|
61 |
else |
|
62 |
loadedData = ProcessOneJisFileAsIntervals(fileName, interval, startTime, endTime); |
|
53 |
// parse all files |
|
54 |
foreach (string fileName in jisFiles) |
|
55 |
{ |
|
56 |
current = fileName; |
|
63 | 57 |
|
64 |
list.AddRange(loadedData); |
|
58 |
if (!File.Exists(fileName)) |
|
59 |
continue; |
|
60 |
|
|
61 |
// parse as one instance per day |
|
62 |
List<ActivityInfo> loadedData = null; |
|
63 |
if (wholeDay) |
|
64 |
loadedData = ProcessOneJisFileAsDays(fileName, startTime, endTime); |
|
65 |
// parse by interval length |
|
66 |
else |
|
67 |
loadedData = ProcessOneJisFileAsIntervals(fileName, interval, startTime, endTime); |
|
68 |
|
|
69 |
list.AddRange(loadedData); |
|
70 |
} |
|
71 |
} |
|
72 |
catch |
|
73 |
{ |
|
74 |
Console.WriteLine("Incorrect jis input file " + current); |
|
65 | 75 |
} |
66 | 76 |
|
67 | 77 |
return list; |
Server/ServerApp/Parser/Parsers/LogInParser.cs | ||
---|---|---|
43 | 43 |
{ |
44 | 44 |
List<ActivityInfo> list = new List<ActivityInfo>(); |
45 | 45 |
|
46 |
if (loginFiles == null || startTime == null || endTime == null || interval <= 0)
|
|
46 |
if (loginFiles == null || interval <= 0) |
|
47 | 47 |
return list; |
48 | 48 |
|
49 |
// for all files in folder
|
|
50 |
foreach (string fileName in loginFiles)
|
|
49 |
string current = "";
|
|
50 |
try
|
|
51 | 51 |
{ |
52 |
if (!File.Exists(fileName)) |
|
53 |
continue; |
|
54 |
|
|
55 |
// parse as one instance per day |
|
56 |
List<ActivityInfo> loadedData = null; |
|
57 |
if (wholeDay) |
|
58 |
loadedData = ProcessOneLogInFileAsDays(fileName, startTime, endTime); |
|
59 |
// parse by interval length |
|
60 |
else |
|
61 |
loadedData = ProcessOneLoginFileAsIntervals(fileName, interval, startTime, endTime); |
|
52 |
// for all files in folder |
|
53 |
foreach (string fileName in loginFiles) |
|
54 |
{ |
|
55 |
current = fileName; |
|
56 |
|
|
57 |
if (!File.Exists(fileName)) |
|
58 |
continue; |
|
62 | 59 |
|
63 |
list.AddRange(loadedData); |
|
60 |
// parse as one instance per day |
|
61 |
List<ActivityInfo> loadedData = null; |
|
62 |
if (wholeDay) |
|
63 |
loadedData = ProcessOneLogInFileAsDays(fileName, startTime, endTime); |
|
64 |
// parse by interval length |
|
65 |
else |
|
66 |
loadedData = ProcessOneLoginFileAsIntervals(fileName, interval, startTime, endTime); |
|
67 |
|
|
68 |
list.AddRange(loadedData); |
|
69 |
} |
|
70 |
} catch |
|
71 |
{ |
|
72 |
Console.WriteLine("Incorrect Login input file " + current); |
|
64 | 73 |
} |
65 | 74 |
|
66 | 75 |
return list; |
Server/ServerApp/Parser/Parsers/WeatherParser.cs | ||
---|---|---|
47 | 47 |
if (weatherFiles == null || interval <= 0) |
48 | 48 |
return list; |
49 | 49 |
|
50 |
// get all files in folder
|
|
51 |
foreach (string fileName in weatherFiles)
|
|
50 |
string current = "";
|
|
51 |
try
|
|
52 | 52 |
{ |
53 |
if (!File.Exists(fileName)) |
|
54 |
continue; |
|
55 |
|
|
56 |
// parse as one instance per day |
|
57 |
List<WeatherInfo> loadedData = null; |
|
58 |
if (wholeDay) |
|
59 |
loadedData = ProcessOneWeatherFileAsDays(fileName, startTime, endTime); |
|
60 |
// parse according to interval |
|
61 |
else |
|
53 |
// get all files in folder |
|
54 |
foreach (string fileName in weatherFiles) |
|
62 | 55 |
{ |
63 |
loadedData = ProcessOneWeatherFileAsIntervals(fileName, interval, startTime, endTime); |
|
64 |
} |
|
56 |
current = fileName; |
|
65 | 57 |
|
66 |
list.AddRange(loadedData); |
|
58 |
if (!File.Exists(fileName)) |
|
59 |
continue; |
|
60 |
|
|
61 |
// parse as one instance per day |
|
62 |
List<WeatherInfo> loadedData = null; |
|
63 |
if (wholeDay) |
|
64 |
loadedData = ProcessOneWeatherFileAsDays(fileName, startTime, endTime); |
|
65 |
// parse according to interval |
|
66 |
else |
|
67 |
{ |
|
68 |
loadedData = ProcessOneWeatherFileAsIntervals(fileName, interval, startTime, endTime); |
|
69 |
} |
|
70 |
|
|
71 |
list.AddRange(loadedData); |
|
72 |
} |
|
73 |
} catch |
|
74 |
{ |
|
75 |
Console.WriteLine("Incorrect Weather input file " + current); |
|
67 | 76 |
} |
68 | 77 |
|
69 | 78 |
return list; |
Server/ServerApp/WeatherPredictionParser/JsonParser.cs | ||
---|---|---|
163 | 163 |
} catch |
164 | 164 |
{ |
165 | 165 |
Console.WriteLine("Weather prediction file in incorrect format"); |
166 |
Current = new WeatherInfo(); |
|
167 |
Predictions = new List<WeatherInfo>(); |
|
166 | 168 |
} |
167 | 169 |
|
168 | 170 |
//TestConsoleOutput(); |
Server/ServerAppFunctionalTests/ParserTests/JisParserTesting.cs | ||
---|---|---|
9 | 9 |
namespace ServerAppFunctionalTests.ParserTests |
10 | 10 |
{ |
11 | 11 |
/// <summary> |
12 |
/// Summary description for WeatherParserTesting
|
|
12 |
/// Testing class for JisParser
|
|
13 | 13 |
/// </summary> |
14 | 14 |
[TestClass] |
15 | 15 |
public class JisParserTesting |
Server/ServerAppFunctionalTests/ParserTests/JsonParserTesting.cs | ||
---|---|---|
11 | 11 |
namespace ServerAppFunctionalTests.ParserTests |
12 | 12 |
{ |
13 | 13 |
/// <summary> |
14 |
/// Summary description for WeatherParserTesting
|
|
14 |
/// Testing class for JsonParser
|
|
15 | 15 |
/// </summary> |
16 | 16 |
[TestClass] |
17 | 17 |
public class JsonParserTesting |
... | ... | |
272 | 272 |
|
273 | 273 |
string SetIncorrectInput() |
274 | 274 |
{ |
275 |
// TODO |
|
276 |
return "data"; |
|
275 |
return |
|
276 |
@"{ |
|
277 |
""cnd"": [ |
|
278 |
{ |
|
279 |
""FeelsLikeC"": ""4"", |
|
280 |
""cloudcover"": ""100"", |
|
281 |
""localObsDateTime"": ""2021-05-25 01:29 PM"", |
|
282 |
""observation_time"": ""11:29 AM"", |
|
283 |
""precipMM"": ""0.1"", |
|
284 |
""temp_C"": ""8"", |
|
285 |
""windspeedKmph"": ""13"" |
|
286 |
} |
|
287 |
] |
|
288 |
} |
|
289 |
}"; |
|
277 | 290 |
} |
278 | 291 |
|
279 | 292 |
[TestMethod] |
Server/ServerAppFunctionalTests/ParserTests/LoginParserTesting.cs | ||
---|---|---|
9 | 9 |
namespace ServerAppFunctionalTests.ParserTests |
10 | 10 |
{ |
11 | 11 |
/// <summary> |
12 |
/// Summary description for WeatherParserTesting
|
|
12 |
/// Testing class for LoginParser
|
|
13 | 13 |
/// </summary> |
14 | 14 |
[TestClass] |
15 | 15 |
public class LoginParserTesting |
Server/ServerAppFunctionalTests/ParserTests/WeatherParserTesting.cs | ||
---|---|---|
9 | 9 |
namespace ServerAppFunctionalTests.ParserTests |
10 | 10 |
{ |
11 | 11 |
/// <summary> |
12 |
/// Summary description for WeatherParserTesting
|
|
12 |
/// Testing class for WeatherParser
|
|
13 | 13 |
/// </summary> |
14 | 14 |
[TestClass] |
15 | 15 |
public class WeatherParserTesting |
Také k dispozici: Unified diff
re #9036 Edits to be able to survive wrong inputs