commit 4129ce12adfa4169cb6e915177f2aba9f1ca1595
Author: Eliška Mourycová <eliska.mourycova@seznam.cz>
Date:   Sun May 16 19:33:46 2021 +0200

    Re #8838. Started refining commands accepting + modified GetData in DataDownloader.

diff --git a/Server/ServerApp/Connection/ConnectionListener.cs b/Server/ServerApp/Connection/ConnectionListener.cs
index eb32549..a0a1b80 100644
--- a/Server/ServerApp/Connection/ConnectionListener.cs
+++ b/Server/ServerApp/Connection/ConnectionListener.cs
@@ -4,6 +4,7 @@
 
 using ServerApp.Connection.XMLProtocolHandler;
 using System;
+using System.Collections.Generic;
 using System.IO;
 using System.Net;
 using System.Net.Sockets;
@@ -291,15 +292,19 @@ namespace ServerApp.Connection
     //  }
 
 
-    class ClientRequest
+    class ClientService
 	{
-        HttpListenerContext context;
-        string request;
+        int id;
+        Request request;
+        Response response;
     }
 
     public class ConnectionListener
     {
         private readonly int PORT;
+        private Dictionary<int, ClientService> allRequests;
+        private Queue<Request> waitingRequests;
+
 
         public ConnectionListener(int port)
         {
diff --git a/Server/ServerApp/DataDownload/DataDownloader.cs b/Server/ServerApp/DataDownload/DataDownloader.cs
index e76b3d6..ded22bc 100644
--- a/Server/ServerApp/DataDownload/DataDownloader.cs
+++ b/Server/ServerApp/DataDownload/DataDownloader.cs
@@ -385,6 +385,10 @@ namespace ServerApp.DataDownload
 		/// <returns></returns>
 		public List<string> GetData(string subDirectory, Date startDate, Date endDate)
 		{
+			if (startDate == null || endDate == null)
+				return GetData(subDirectory);
+
+
 			string[] files = Directory.GetFiles(subDirectory);
 			List<string> found00Files = new List<string>();
 			List<string> relevantFiles = new List<string>();
@@ -455,6 +459,22 @@ namespace ServerApp.DataDownload
 			return relevantFiles;
 		}
 
+		/// <summary>
+		/// Returns all file paths in a given directory
+		/// </summary>
+		/// <param name="subDirectory"></param>
+		/// <returns></returns>
+		private List<string> GetData(string subDirectory)
+		{
+			string[] files = Directory.GetFiles(subDirectory);
+			List<string> relevantFiles = new List<string>(files.Length);
+
+			for (int i = 0; i < files.Length; i++)
+				relevantFiles.Add(files[i]);
+
+			return relevantFiles;
+		}
+
 
 		#region UNUSED
 		//public string GetDirectoryListingRegexForUrl(string url)
diff --git a/Server/ServerApp/Program.cs b/Server/ServerApp/Program.cs
index ebc6347..532ddf5 100644
--- a/Server/ServerApp/Program.cs
+++ b/Server/ServerApp/Program.cs
@@ -48,38 +48,43 @@ namespace ServerApp
 			//p.Parse();
 
 			#region UNCOMMENT
-			//test scenario -data download:
-			DataDownloader dd = new DataDownloader(config.DataRootDir, config.DataWebsite, config.DownloadedFilesNaming);
-			dd.OverwriteExisting = false;
-			List<string> savedFiles = new List<string>();
-			savedFiles.AddRange(dd.DownloadData(DataType.JIS, DataFormat.CSV, new DataDownload.Date(1, 2019), new DataDownload.Date(12, 2020)));
-			savedFiles.AddRange(dd.DownloadData(DataType.STROJE, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2020)));
-			savedFiles.AddRange(dd.DownloadData(DataType.POCASI, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2020)));
-
-
-
-			Console.WriteLine("Saved files: ");
-			foreach (string s in savedFiles)
-			{
-				Console.WriteLine(s);
-			}
-
-			Console.WriteLine("subdirectories: ");
-			foreach (KeyValuePair<DataType, string> kvp in dd.DataSubDirectories)
-			{
-				Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
-			}
-
-			List<string> retrievedData = dd.GetData(dd.DataSubDirectories[DataType.JIS], new DataDownload.Date(10, 2019), new DataDownload.Date(12, 2020));
-			Console.WriteLine("Retrieved data: ");
-			foreach (string s in retrievedData)
-			{
-				Console.WriteLine(s);
-			}
-
-			// test - connection:
-			ConnectionListener cl = new ConnectionListener(int.Parse(config.Port));
-			cl.StartListening();
+			////test scenario -data download:
+			//DataDownloader dd = new DataDownloader(config.DataRootDir, config.DataWebsite, config.DownloadedFilesNaming);
+			//dd.OverwriteExisting = false;
+			//List<string> savedFiles = new List<string>();
+			//savedFiles.AddRange(dd.DownloadData(DataType.JIS, DataFormat.CSV, new DataDownload.Date(1, 2019), new DataDownload.Date(12, 2020)));
+			//savedFiles.AddRange(dd.DownloadData(DataType.STROJE, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2020)));
+			//savedFiles.AddRange(dd.DownloadData(DataType.POCASI, DataFormat.CSV, new DataDownload.Date(1, 2017), new DataDownload.Date(12, 2020)));
+
+
+
+			//Console.WriteLine("Saved files: ");
+			//foreach (string s in savedFiles)
+			//{
+			//	Console.WriteLine(s);
+			//}
+
+			//Console.WriteLine("subdirectories: ");
+			//foreach (KeyValuePair<DataType, string> kvp in dd.DataSubDirectories)
+			//{
+			//	Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
+			//}
+
+			//List<string> retrievedData = dd.GetData(dd.DataSubDirectories[DataType.JIS], new DataDownload.Date(10, 2019), new DataDownload.Date(12, 2020));
+			//Console.WriteLine("Retrieved data: ");
+			//foreach (string s in retrievedData)
+			//{
+			//	Console.WriteLine(s);
+			//}
+			//Console.WriteLine("all from directory:");
+			//retrievedData = dd.GetData(dd.DataSubDirectories[DataType.JIS], null, null);
+			//foreach (string s in retrievedData)
+			//{
+			//	Console.WriteLine(s);
+			//}
+			//// test - connection:
+			////ConnectionListener cl = new ConnectionListener(int.Parse(config.Port));
+			////cl.StartListening();
 			#endregion
 
 			#region XML_TEST
diff --git a/Server/ServerApp/ServerApp.csproj b/Server/ServerApp/ServerApp.csproj
index c7a2a76..8d14a55 100644
--- a/Server/ServerApp/ServerApp.csproj
+++ b/Server/ServerApp/ServerApp.csproj
@@ -165,6 +165,7 @@
     <Compile Include="Predictor\NaiveBayesClassifier.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="User\Command.cs" />
     <Compile Include="User\CommandsAcceptor.cs" />
   </ItemGroup>
   <ItemGroup>
diff --git a/Server/ServerApp/User/Command.cs b/Server/ServerApp/User/Command.cs
new file mode 100644
index 0000000..e5ad907
--- /dev/null
+++ b/Server/ServerApp/User/Command.cs
@@ -0,0 +1,38 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ServerApp.User
+{
+	public enum Commands
+	{
+		RETRAIN, ROLLBACK, DATA_LIST, NEW_DATA, HELP
+	}
+
+	public class Command
+	{
+		public string MainCommand { get; set; }
+		public Dictionary<string, List<string>> FlagsAndData { get; }
+		private string lastFlag;
+
+		public Command()
+		{
+			MainCommand = "";
+			FlagsAndData = new Dictionary<string, List<string>>();
+			lastFlag = "";
+		}
+
+		public void AddFlag(string flag)
+		{
+			FlagsAndData.Add(flag, new List<string>());
+			lastFlag = flag;
+		}
+
+		public void AddData(string data)
+		{
+			FlagsAndData[lastFlag].Add(data);
+		}
+	}
+}
diff --git a/Server/ServerApp/User/CommandsAcceptor.cs b/Server/ServerApp/User/CommandsAcceptor.cs
index 49c81fb..0d70551 100644
--- a/Server/ServerApp/User/CommandsAcceptor.cs
+++ b/Server/ServerApp/User/CommandsAcceptor.cs
@@ -6,6 +6,8 @@ using System.Threading.Tasks;
 
 namespace ServerApp.User
 {
+	
+
 	public class CommandsAcceptor
 	{
 
@@ -13,8 +15,51 @@ namespace ServerApp.User
 		{
 			while (true) {
 				string command = Console.ReadLine();
+				Command c = ParseString(command);
+				CheckCommand(c);
 				Program.NotifyUserMessage(command);
 			}
 		}
+
+		private static Command ParseString(string str)
+		{
+			string[] splits = str.Split(' ');
+			Command command = new Command();
+
+			command.MainCommand = splits[0];
+
+			for(int i = 1; i < splits.Length; i++)
+			{
+
+				string current = splits[i];
+				if (current.StartsWith("-"))
+				{
+					command.AddFlag(current.Substring(1));
+				}
+				else
+				{
+					command.AddData(current);
+				}
+			}
+
+			return command;
+		}
+
+		private static void CheckCommand(Command c)
+		{
+			Console.WriteLine(c);
+
+			switch (c.MainCommand)
+			{
+				case "data": break;
+				case "model": break;
+				case "help": break;
+			}
+		}
+
+		private void PrintUsage()
+		{
+
+		}
 	}
 }
