commit 23e8ae0432dbd41449a3b1de14ecfbb056cd228d
Author: A-Konig <alex-nebulae@seznam.cz>
Date:   Sun Jun 6 11:38:31 2021 +0200

    re #9036 Edits to be able to survive wrong inputs

diff --git a/Server/ServerApp/Parser/InputData/CsvDataLoader.cs b/Server/ServerApp/Parser/InputData/CsvDataLoader.cs
index b66a942..d39c2dd 100644
--- a/Server/ServerApp/Parser/InputData/CsvDataLoader.cs
+++ b/Server/ServerApp/Parser/InputData/CsvDataLoader.cs
@@ -70,8 +70,16 @@ namespace ServerApp.Parser.InputData
 
                 data[0] = data[0].Substring(1, data[0].Length - 2);
                 data[1] = data[1].Substring(1, data[1].Length - 2);
-                
-                var dateTime = DateTime.ParseExact(data[1], "G", cultureInfo);
+
+                var dateTime = new DateTime();
+                try
+                {
+                    dateTime = DateTime.ParseExact(data[1], "G", cultureInfo);
+                }
+                catch
+                {
+                    continue;
+                }
 
                 int amount = 0;
                 int.TryParse(data[2], out amount);
@@ -114,9 +122,19 @@ namespace ServerApp.Parser.InputData
                 data[7] = data[7].Substring(1, data[7].Length - 2);
                 data[8] = data[8].Substring(1, data[8].Length - 2);
 
-                var dateTime = DateTime.ParseExact(data[0], "G", cultureInfo);
-                var startTime = DateTime.ParseExact(data[3], "t", cultureInfo);
-                var endTime = DateTime.ParseExact(data[4], "t", cultureInfo);
+                var dateTime = new DateTime();
+                var startTime = new DateTime();
+                var endTime = new DateTime();
+                try
+                {
+                    dateTime = DateTime.ParseExact(data[0], "G", cultureInfo);
+                    startTime = DateTime.ParseExact(data[3], "t", cultureInfo);
+                    endTime = DateTime.ParseExact(data[4], "t", cultureInfo);
+                }
+                catch
+                {
+                    continue;
+                }
 
                 int count = 0;
                 int.TryParse(data[1], out count);
@@ -155,8 +173,16 @@ namespace ServerApp.Parser.InputData
                     continue;
 
                 data[0] = data[0].Substring(1, data[0].Length - 2);
-                
-                var dateTime = DateTime.ParseExact(data[0], "G", cultureInfo);
+
+                var dateTime = new DateTime();
+                try
+                {
+                    dateTime = DateTime.ParseExact(data[0], "G", cultureInfo);
+                }
+                catch
+                {
+                    continue;
+                }
                 
                 double temp = 0;
                 double.TryParse(data[1], out temp);
diff --git a/Server/ServerApp/Parser/Parsers/DataParser.cs b/Server/ServerApp/Parser/Parsers/DataParser.cs
index 28af53e..1d8bf52 100644
--- a/Server/ServerApp/Parser/Parsers/DataParser.cs
+++ b/Server/ServerApp/Parser/Parsers/DataParser.cs
@@ -93,7 +93,7 @@ namespace ServerApp.Parser.Parsers
             loginList = loginParser.ParseLogInData(loginFiles, startTime, endTime, wholeDay, interval);
 
             //Console.WriteLine("WEATHER");
-            //WriteToConsole(weatherList);
+            //WriteToConsole(WeatherList);
             //Console.WriteLine("JIS");
             //WriteToConsole(jisList);
             //Console.WriteLine("LOGIN");
@@ -104,7 +104,7 @@ namespace ServerApp.Parser.Parsers
             AttendanceList = MergeAttendance(jisList, loginList);
 
             //Console.WriteLine("MERGED IN ONE LIST");
-            //WriteToConsole(attendanceList);
+            //WriteToConsole(AttendanceList);
 
             if (WeatherList.Count == 0 || AttendanceList.Count == 0)
                 return false;
@@ -229,7 +229,10 @@ namespace ServerApp.Parser.Parsers
             Console.WriteLine(list.Count);
 
             for (int i = 0; i < list.Count; i++)
-                Console.WriteLine(list[i].ToString());
+            {
+                if (list[i].startTime.Year >= 2019)
+                    Console.WriteLine(list[i].ToString());
+            }
         }
 
         /// <summary>
diff --git a/Server/ServerApp/Parser/Parsers/JisParser.cs b/Server/ServerApp/Parser/Parsers/JisParser.cs
index 0d1d3d0..d35a3cd 100644
--- a/Server/ServerApp/Parser/Parsers/JisParser.cs
+++ b/Server/ServerApp/Parser/Parsers/JisParser.cs
@@ -44,24 +44,34 @@ namespace ServerApp.Parser.Parsers
         {
             List<ActivityInfo> list = new List<ActivityInfo>();
 
-            if (jisFiles == null || startTime == null || endTime == null || interval <= 0)
+            if (jisFiles == null || interval <= 0)
                 return list;
 
-            // parse all files
-            foreach (string fileName in jisFiles)
+            string current = "";
+            try
             {
-                if (!File.Exists(fileName))
-                    continue;
-                
-                // parse as one instance per day
-                List<ActivityInfo> loadedData = null;
-                if (wholeDay)
-                    loadedData = ProcessOneJisFileAsDays(fileName, startTime, endTime);
-                // parse by interval length
-                else
-                    loadedData = ProcessOneJisFileAsIntervals(fileName, interval, startTime, endTime);
+                // parse all files
+                foreach (string fileName in jisFiles)
+                {
+                    current = fileName;
 
-                list.AddRange(loadedData);
+                    if (!File.Exists(fileName))
+                        continue;
+
+                    // parse as one instance per day
+                    List<ActivityInfo> loadedData = null;
+                    if (wholeDay)
+                        loadedData = ProcessOneJisFileAsDays(fileName, startTime, endTime);
+                    // parse by interval length
+                    else
+                        loadedData = ProcessOneJisFileAsIntervals(fileName, interval, startTime, endTime);
+
+                    list.AddRange(loadedData);
+                }
+            }
+            catch
+            {
+                Console.WriteLine("Incorrect jis input file " + current);
             }
 
             return list;
diff --git a/Server/ServerApp/Parser/Parsers/LogInParser.cs b/Server/ServerApp/Parser/Parsers/LogInParser.cs
index a36f198..40c6f69 100644
--- a/Server/ServerApp/Parser/Parsers/LogInParser.cs
+++ b/Server/ServerApp/Parser/Parsers/LogInParser.cs
@@ -43,24 +43,33 @@ namespace ServerApp.Parser.Parsers
         {
             List<ActivityInfo> list = new List<ActivityInfo>();
 
-            if (loginFiles == null || startTime == null || endTime == null || interval <= 0)
+            if (loginFiles == null || interval <= 0)
                 return list;
 
-            // for all files in folder
-            foreach (string fileName in loginFiles)
+            string current = "";
+            try
             {
-                if (!File.Exists(fileName))
-                    continue;
-                
-                // parse as one instance per day
-                List<ActivityInfo> loadedData = null;
-                if (wholeDay)
-                    loadedData = ProcessOneLogInFileAsDays(fileName, startTime, endTime);
-                // parse by interval length
-                else
-                    loadedData = ProcessOneLoginFileAsIntervals(fileName, interval, startTime, endTime);
+                // for all files in folder
+                foreach (string fileName in loginFiles)
+                {
+                    current = fileName;
+
+                    if (!File.Exists(fileName))
+                        continue;
 
-                list.AddRange(loadedData);
+                    // parse as one instance per day
+                    List<ActivityInfo> loadedData = null;
+                    if (wholeDay)
+                        loadedData = ProcessOneLogInFileAsDays(fileName, startTime, endTime);
+                    // parse by interval length
+                    else
+                        loadedData = ProcessOneLoginFileAsIntervals(fileName, interval, startTime, endTime);
+
+                    list.AddRange(loadedData);
+                }
+            } catch
+            {
+                Console.WriteLine("Incorrect Login input file " + current);
             }
 
             return list;
diff --git a/Server/ServerApp/Parser/Parsers/WeatherParser.cs b/Server/ServerApp/Parser/Parsers/WeatherParser.cs
index e814186..499c5b2 100644
--- a/Server/ServerApp/Parser/Parsers/WeatherParser.cs
+++ b/Server/ServerApp/Parser/Parsers/WeatherParser.cs
@@ -47,23 +47,32 @@ namespace ServerApp.Parser.Parsers
             if (weatherFiles == null || interval <= 0)
                 return list;
 
-            // get all files in folder
-            foreach (string fileName in weatherFiles)
+            string current = "";
+            try
             {
-                if (!File.Exists(fileName))
-                    continue;
-
-                // parse as one instance per day
-                List<WeatherInfo> loadedData = null;
-                if (wholeDay)
-                    loadedData = ProcessOneWeatherFileAsDays(fileName, startTime, endTime);
-                // parse according to interval
-                else
+                // get all files in folder
+                foreach (string fileName in weatherFiles)
                 {
-                    loadedData = ProcessOneWeatherFileAsIntervals(fileName, interval, startTime, endTime);
-                }
+                    current = fileName;
 
-                list.AddRange(loadedData);
+                    if (!File.Exists(fileName))
+                        continue;
+
+                    // parse as one instance per day
+                    List<WeatherInfo> loadedData = null;
+                    if (wholeDay)
+                        loadedData = ProcessOneWeatherFileAsDays(fileName, startTime, endTime);
+                    // parse according to interval
+                    else
+                    {
+                        loadedData = ProcessOneWeatherFileAsIntervals(fileName, interval, startTime, endTime);
+                    }
+
+                    list.AddRange(loadedData);
+                }
+            } catch
+            {
+                Console.WriteLine("Incorrect Weather input file " + current);
             }
 
             return list;
diff --git a/Server/ServerApp/WeatherPredictionParser/JsonParser.cs b/Server/ServerApp/WeatherPredictionParser/JsonParser.cs
index 1f297b2..9228a4e 100644
--- a/Server/ServerApp/WeatherPredictionParser/JsonParser.cs
+++ b/Server/ServerApp/WeatherPredictionParser/JsonParser.cs
@@ -163,6 +163,8 @@ namespace ServerApp.WeatherPredictionParser
             } catch
             {
                 Console.WriteLine("Weather prediction file in incorrect format");
+                Current = new WeatherInfo();
+                Predictions = new List<WeatherInfo>();
             }
 
             //TestConsoleOutput();
diff --git a/Server/ServerAppFunctionalTests/ParserTests/JisParserTesting.cs b/Server/ServerAppFunctionalTests/ParserTests/JisParserTesting.cs
index 799d95b..9f15f2b 100644
--- a/Server/ServerAppFunctionalTests/ParserTests/JisParserTesting.cs
+++ b/Server/ServerAppFunctionalTests/ParserTests/JisParserTesting.cs
@@ -9,7 +9,7 @@ using ServerApp.Parser.InputData;
 namespace ServerAppFunctionalTests.ParserTests
 {
     /// <summary>
-    /// Summary description for WeatherParserTesting
+    /// Testing class for JisParser
     /// </summary>
     [TestClass]
     public class JisParserTesting
diff --git a/Server/ServerAppFunctionalTests/ParserTests/JsonParserTesting.cs b/Server/ServerAppFunctionalTests/ParserTests/JsonParserTesting.cs
index f4c76e6..112982d 100644
--- a/Server/ServerAppFunctionalTests/ParserTests/JsonParserTesting.cs
+++ b/Server/ServerAppFunctionalTests/ParserTests/JsonParserTesting.cs
@@ -11,7 +11,7 @@ using ServerApp.DataDownload;
 namespace ServerAppFunctionalTests.ParserTests
 {
     /// <summary>
-    /// Summary description for WeatherParserTesting
+    /// Testing class for JsonParser
     /// </summary>
     [TestClass]
     public class JsonParserTesting
@@ -272,8 +272,21 @@ namespace ServerAppFunctionalTests.ParserTests
 
         string SetIncorrectInput()
         {
-            // TODO
-            return "data";
+            return
+    @"{
+    ""cnd"": [
+        {
+            ""FeelsLikeC"": ""4"",
+            ""cloudcover"": ""100"",
+            ""localObsDateTime"": ""2021-05-25 01:29 PM"",
+            ""observation_time"": ""11:29 AM"",
+            ""precipMM"": ""0.1"",
+            ""temp_C"": ""8"",
+            ""windspeedKmph"": ""13""
+        }
+    ]
+}
+}";
         }
 
         [TestMethod]
diff --git a/Server/ServerAppFunctionalTests/ParserTests/LoginParserTesting.cs b/Server/ServerAppFunctionalTests/ParserTests/LoginParserTesting.cs
index 31415a3..64b87d6 100644
--- a/Server/ServerAppFunctionalTests/ParserTests/LoginParserTesting.cs
+++ b/Server/ServerAppFunctionalTests/ParserTests/LoginParserTesting.cs
@@ -9,7 +9,7 @@ using ServerApp.Parser.InputData;
 namespace ServerAppFunctionalTests.ParserTests
 {
     /// <summary>
-    /// Summary description for WeatherParserTesting
+    /// Testing class for LoginParser
     /// </summary>
     [TestClass]
     public class LoginParserTesting
diff --git a/Server/ServerAppFunctionalTests/ParserTests/WeatherParserTesting.cs b/Server/ServerAppFunctionalTests/ParserTests/WeatherParserTesting.cs
index 504e14f..18a537e 100644
--- a/Server/ServerAppFunctionalTests/ParserTests/WeatherParserTesting.cs
+++ b/Server/ServerAppFunctionalTests/ParserTests/WeatherParserTesting.cs
@@ -9,7 +9,7 @@ using ServerApp.Parser.InputData;
 namespace ServerAppFunctionalTests.ParserTests
 {
     /// <summary>
-    /// Summary description for WeatherParserTesting
+    /// Testing class for WeatherParser
     /// </summary>
     [TestClass]
     public class WeatherParserTesting
