commit 127a92b143bc53a7030932d1069a0dc9059efaf2
Author: Eliška Mourycová <eliska.mourycova@seznam.cz>
Date:   Mon Jun 14 06:57:46 2021 +0200

    Cosmetic changes, documentation adding, warnings fixing.

diff --git a/Server/ServerApp/Connection/ConnectionListener.cs b/Server/ServerApp/Connection/ConnectionListener.cs
index c28d18a..457d745 100644
--- a/Server/ServerApp/Connection/ConnectionListener.cs
+++ b/Server/ServerApp/Connection/ConnectionListener.cs
@@ -5,15 +5,10 @@
 using ServerApp.Connection.XMLProtocolHandler;
 using ServerApp.Predictor;
 using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Diagnostics;
 using System.IO;
 using System.Net;
 using System.Reflection;
 using System.Net.Sockets;
-using System.Text;
-using System.Threading;
 using System.Web;
 using System.Security.Cryptography.X509Certificates;
 using log4net;
@@ -337,7 +332,14 @@ namespace ServerApp.Connection
 
 		}
 
-
+		/// <summary>
+		/// UNUSED
+		/// This method should modify the input time span if it is longer than mxTimeSpan given in days.
+		/// </summary>
+		/// <param name="startDate">The start of the time span</param>
+		/// <param name="endDate">The end of the time span</param>
+		/// <param name="maxTimeSpan">The maximum length of the time span in days</param>
+		/// <returns>New end date if it is more than maxTimeSpan away from start date, original endDate otherwise.</returns>
 		public XMLProtocolHandler.Date CheckTimeSpanModifyEnd(Date startDate, Date endDate, int maxTimeSpan)
 		{
 			int comp = startDate.CompareTo(endDate); // -1 if start date lower
@@ -358,6 +360,10 @@ namespace ServerApp.Connection
 			catch(ArgumentOutOfRangeException aore)
 			{
 				// hopefully the predictor will know what to do
+				logger.Debug("Wrong type of date passed to time span checking, argument out of range.");
+				logger.Debug("Start date: " + startDate.ToString());
+				logger.Debug("End date: " + endDate.ToString());
+				logger.Debug(aore.Message);
 				return endDate;
 			}
 
diff --git a/Server/ServerApp/DataDownload/DataDownloader.cs b/Server/ServerApp/DataDownload/DataDownloader.cs
index 3b6fcd5..c97b0df 100644
--- a/Server/ServerApp/DataDownload/DataDownloader.cs
+++ b/Server/ServerApp/DataDownload/DataDownloader.cs
@@ -90,6 +90,8 @@ namespace ServerApp.DataDownload
 			CreateSubdirectories(); // todo should we do it like this?
 
 			webClient = new WebClient();
+
+			logger.Info("Data downlader ready.");
 		}
 
 		/// <summary>
@@ -114,6 +116,7 @@ namespace ServerApp.DataDownload
 				// this shouldn't happen
 				//Console.WriteLine("Weather prediction download failed!");
 				logger.Error("Weather prediction download failed!");
+				logger.Error(e.Message);
 				return null;
 			}
 			
@@ -280,6 +283,7 @@ namespace ServerApp.DataDownload
 			try
 			{
 				//Console.WriteLine("Downloading .zip to " + Path.GetFullPath(nameZip) + "...");
+				logger.Info("Trying to download " + url);
 
 				// Download the zip file:
 				webClient.DownloadFile(url, nameZip);
@@ -332,8 +336,9 @@ namespace ServerApp.DataDownload
 			catch(System.Net.WebException we)
 			{
 				// download fails, if the specified url is invalid
-				//Console.WriteLine("Download from " + url + " failed.");
-				//Console.WriteLine(we.Message);
+				logger.Info("Download of " + url + " was not succesful. That is no problem if the given time span does not contain respective open data.");
+				logger.Info(we.Message);
+				
 			}
 
 
@@ -404,11 +409,6 @@ namespace ServerApp.DataDownload
 			return savedFiles;
 		}
 
-		public bool CheckForNewData()
-		{
-			throw new NotImplementedException();
-		}
-
 
 		/// <summary>
 		/// Retrieves all data files with dates falling within the specified range. If not all data for the specified range is found
diff --git a/Server/ServerApp/Program.cs b/Server/ServerApp/Program.cs
index 2710eac..8d065fe 100644
--- a/Server/ServerApp/Program.cs
+++ b/Server/ServerApp/Program.cs
@@ -48,24 +48,12 @@ namespace ServerApp
 			}
 			Console.WriteLine("Config parsing successful.");
 
-			//logger.Debug("ahoj");
-			//logger.Warn("ahoj2");
-			//Console.ReadLine();
 
 			// data download init
 			Console.WriteLine("Downloading open data...");
 			DataDownloader dd = DataDownloaderInit(config);
 			Console.WriteLine("Data downloaded and saved.");
 
-			//WeatherAsStringTest(dd);
-			//Console.ReadLine();
-
-			// xml building test
-			//XMLTest();
-
-
-			// json parser test
-			//JSONParserTest();
 
 			// model init
 			Console.WriteLine("Training the predictor...");
@@ -85,15 +73,19 @@ namespace ServerApp
 
         }
 
-
+		/// <summary>
+		/// Initializes DataDownloader. Downloads default span of data and saves the files.
+		/// </summary>
+		/// <param name="config">The Config instance</param>
+		/// <returns>New instance of DataDownloader</returns>
 		private static DataDownloader DataDownloaderInit(Config config)
 		{
-			//test scenario -data download:
+			
 			DataDownloader dd = new DataDownloader(config.DataRootDir, config.DataWebsite, config.DownloadedFilesNaming, config.WeatherSite);
 			dd.OverwriteExisting = false;
 			List<string> savedFiles = new List<string>();
 
-			// -> 12-2019 to exclude corona? But we lose a lot of data
+			// -> 12-2019 to exclude corona period which could mess with the predictor
 			savedFiles.AddRange(dd.DownloadData(DataType.JIS, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2019)));
 			savedFiles.AddRange(dd.DownloadData(DataType.STROJE, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2019)));
 			savedFiles.AddRange(dd.DownloadData(DataType.POCASI, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2019)));
@@ -130,33 +122,6 @@ namespace ServerApp
 		}
 
 
-		private static void XMLTest()
-		{
-			Response response = Response.Randomize();
-			var xml = XmlCommunication.Serialize(response);
-			//xml = "haha";
-			Response response1 = new Response();
-			Console.WriteLine(xml);
-			try
-			{
-				Response responseDeserialized = XmlCommunication.Deserialize<Response>(xml);
-			}
-			catch(Exception e)
-			{
-				Console.WriteLine("bad format");
-			}
-			
-
-			Console.WriteLine("------");
-
-
-			Request request = Request.Randomize();
-			xml = XmlCommunication.Serialize(request);
-			Console.WriteLine(xml);
-			Request requestDeserialized = XmlCommunication.Deserialize<Request>(xml);
-		}
-
-
 		private static void JSONParserTest()
 		{
             // FIXME pass the right references to the JsonParser constructor
@@ -175,6 +140,11 @@ namespace ServerApp
 			Console.WriteLine(dd.DownloadWeatherPrediction());
 		}
 
+		/// <summary>
+		/// Initializes and trains the predictor if need be.
+		/// </summary>
+		/// <param name="dd">The DataDownloader instance.</param>
+		/// <returns>New instance of the predictor.</returns>
 		private static IPredictionController PredictionControllerInit(DataDownloader dd)
 		{
 			IDataParser p = new DataParser(dd);
@@ -187,16 +157,23 @@ namespace ServerApp
 			return predictionController;
 		}
 
+		/// <summary>
+		/// Initializes waiting for the clients' requests.
+		/// </summary>
+		/// <param name="predictionController">The initialized and trained instance of the predictor.</param>
+		/// <param name="config">The Config class instance.</param>
 		private static void ConnectionInit(IPredictionController predictionController, Config config)
 		{
 			ConnectionListenerAsync cl = new ConnectionListenerAsync(int.Parse(config.Port), predictionController);
 			cl.StartListening();
 
-			//HttpRequestHandler hrh = new HttpRequestHandler(int.Parse(config.Port));
-			//hrh.ListenAsynchronously();
 		}
 
-
+		/// <summary>
+		/// Parses the configuration file and extracts valuable information from it.
+		/// </summary>
+		/// <param name="args">The arguments passed to the program.</param>
+		/// <returns>Filled instance of the Config class, null if there was a problem.</returns>
 		private static Config FillConfigInfo(string[] args)
 		{
 
@@ -215,6 +192,7 @@ namespace ServerApp
 			catch(Exception ex)
 			{
 				Console.WriteLine("Could not open " + fullPathConfig);
+				Console.WriteLine(ex.Message);
 				return null;
 			}
 			
@@ -256,7 +234,7 @@ namespace ServerApp
 			bool success = int.TryParse(extractedConfigInfo.Port, out parsedPort);
 			if (!success)
 			{
-				Console.WriteLine("Configured port " + extractedConfigInfo.Port + " is not an integer number! Abort.");
+				Console.WriteLine("Configured port " + extractedConfigInfo.Port + " is not an integer! Abort.");
 				return null;
 			}
 				
diff --git a/Server/ServerApp/User/Command.cs b/Server/ServerApp/User/Command.cs
index 3440f79..f13335f 100644
--- a/Server/ServerApp/User/Command.cs
+++ b/Server/ServerApp/User/Command.cs
@@ -2,11 +2,7 @@
 // Author: Eliska Mourycova
 //
 
-using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace ServerApp.User
 {
diff --git a/Server/ServerApp/User/CommandsAcceptor.cs b/Server/ServerApp/User/CommandsAcceptor.cs
index 00cc7d3..8def27b 100644
--- a/Server/ServerApp/User/CommandsAcceptor.cs
+++ b/Server/ServerApp/User/CommandsAcceptor.cs
@@ -167,7 +167,7 @@ namespace ServerApp.User
 						Console.WriteLine(f);
 
 				}
-				catch(Exception ex)
+				catch (Exception)
 				{
 					Console.WriteLine("Data download failed, please ensure the start date is before or same as end date.");
 					return;
@@ -188,10 +188,6 @@ namespace ServerApp.User
 		/// <param name="c">The command</param>
 		private void HandleModelCommand(Command c)
 		{
-			// TODO:
-			// model -files
-			// model -retrain
-			// model -rollback
 
 			// todo if the command has something else after the flag - abort?
 			if (c.FlagsAndData.ContainsKey("files"))
