commit 260b1217b790533955652eb12d9199b6fa199060
Author: A-Konig <alex-nebulae@seznam.cz>
Date:   Wed Apr 14 19:55:30 2021 +0200

    re #8610 Parsing in intervals dependand on data

diff --git a/Server/.vs/ServerApp/v16/.suo b/Server/.vs/ServerApp/v16/.suo
index d964e63..518c7ef 100644
Binary files a/Server/.vs/ServerApp/v16/.suo and b/Server/.vs/ServerApp/v16/.suo differ
diff --git a/Server/ServerApp/Parser/Parsers/DataParser.cs b/Server/ServerApp/Parser/Parsers/DataParser.cs
index 96c20f6..c8a20ea 100644
--- a/Server/ServerApp/Parser/Parsers/DataParser.cs
+++ b/Server/ServerApp/Parser/Parsers/DataParser.cs
@@ -59,15 +59,15 @@ namespace ServerApp.Parser.Parsers
             string pathLogIn = path + "login";
 
             weatherList = weatherParser.ParseWeatherData(pathWeather, wholeDay, interval);
-            jisList = jisParser.ParseJisData(pathJis, wholeDay, interval);
+            jisList = jisParser.ParseJisData(pathJis, false, 2); // wholeDay, interval);
             loginList = loginParser.ParseLogInData(pathLogIn, wholeDay, interval);
 
-            Console.WriteLine("WEATHER");
-            WriteToConsole(weatherList);
+            //Console.WriteLine("WEATHER");
+            //WriteToConsole(weatherList);
             Console.WriteLine("JIS");
             WriteToConsole(jisList);
-            Console.WriteLine("LOGIN");
-            WriteToConsole(loginList);
+            //Console.WriteLine("LOGIN");
+            //WriteToConsole(loginList);
         }
 
         /// <summary>
diff --git a/Server/ServerApp/Parser/Parsers/JisParser.cs b/Server/ServerApp/Parser/Parsers/JisParser.cs
index 5aaa591..893621c 100644
--- a/Server/ServerApp/Parser/Parsers/JisParser.cs
+++ b/Server/ServerApp/Parser/Parsers/JisParser.cs
@@ -39,10 +39,7 @@ namespace ServerApp.Parser.Parsers
                     loadedData = ProcessOneJisFileAsDays(fileName);
                 // parse by interval length
                 else
-                {
-                    // pokud: konec dne nebo konec aktuálního intervalu -> vemu to co sem nasčítal
-                    throw new NotImplementedException();
-                }
+                    loadedData = ProcessOneJisFileAsIntervals(fileName, interval);
 
                 list.AddRange(loadedData);
             }
@@ -125,7 +122,87 @@ namespace ServerApp.Parser.Parsers
 
         private static List<ActivityInfo> ProcessOneJisFileAsIntervals(string path, int interval)
         {
-            throw new NotImplementedException();
+            if (!File.Exists(path))
+                return null;
+
+            List<ActivityInfo> jisInfo = new List<ActivityInfo>();
+            List<JisInstance> list = CsvDataLoader.LoadJisFile(path);
+
+            // data for each faculty
+            int[] recordedAmount = new int[TagInfo.faculties.Length];
+            // min/max hour taken into account
+            int[] minmaxHour = new int[] { 7, 18 };
+            int range = minmaxHour[1] - minmaxHour[0];
+
+            if (interval > range)
+                return null;
+
+            int indices = (int) Math.Ceiling(range / (double)interval);
+            int[] from = new int[indices];
+            for (int i = 0; i < from.Length; i++) {
+                from[i] = minmaxHour[0] + interval * (i+1);
+                Console.Write(from[i] + " ");
+            }
+            Console.WriteLine();
+
+            // first day
+            DateTime lastStartTime = new DateTime(list[0].dateTime.Year, list[0].dateTime.Month, list[0].dateTime.Day, minmaxHour[0], 0, 0);
+            for (int i = 0; i < list.Count; i++)
+            {
+                int currHour = list[i].dateTime.Hour;
+                if (currHour < minmaxHour[0] || currHour > minmaxHour[1])
+                    continue;
+
+                // start of the day -> make an instance
+                string place = list[i].placeTag;
+                bool trigger = false;
+                DateTime date = new DateTime(list[i].dateTime.Year, list[i].dateTime.Month, list[i].dateTime.Day, list[i].dateTime.Hour, 0, 0);
+               
+                // end of the day
+                if (!(date.Year == lastStartTime.Year && date.Month == lastStartTime.Month && date.Day == lastStartTime.Day))
+                    trigger = true;
+
+                // end of interval period
+                if ( (date.Hour - lastStartTime.Hour) >= interval || trigger)
+                {
+                    // data for each faculty separate
+                    for (int k = 0; k < TagInfo.faculties.Length; k++)
+                    {
+                        ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[k], recordedAmount[k], lastStartTime, interval);
+                        jisInfo.Add(dayInfo);
+                    }
+
+                    recordedAmount = new int[TagInfo.faculties.Length];
+                    lastStartTime = date;
+                }
+
+                // aggregate data
+                if (TagInfo.jisPlaces.ContainsKey(place))
+                {
+                    int index = TagInfo.jisPlaces[place];
+                    if (index == -1)
+                        for (int l = 0; l < TagInfo.faculties.Length; l++)
+                            recordedAmount[l] += list[i].amount;
+                    else
+                        recordedAmount[index] += list[i].amount;
+
+                }
+                else
+                {
+                    // TODO uknown code handling
+                    Console.WriteLine("Unknown code " + list[i].placeTag);
+                }
+
+            }
+
+            // last day
+            for (int k = 0; k < TagInfo.faculties.Length; k++)
+            {
+                ActivityInfo dayInfo = new ActivityInfo(TagInfo.faculties[k], recordedAmount[k], lastStartTime, interval);
+                jisInfo.Add(dayInfo);
+            }
+
+            return jisInfo;
         }
     }
 }
diff --git a/Server/ServerApp/bin/Debug/ServerApp.exe b/Server/ServerApp/bin/Debug/ServerApp.exe
index 98bf674..1757f2a 100644
Binary files a/Server/ServerApp/bin/Debug/ServerApp.exe and b/Server/ServerApp/bin/Debug/ServerApp.exe differ
diff --git a/Server/ServerApp/bin/Debug/ServerApp.pdb b/Server/ServerApp/bin/Debug/ServerApp.pdb
index 6d09d82..823f419 100644
Binary files a/Server/ServerApp/bin/Debug/ServerApp.pdb and b/Server/ServerApp/bin/Debug/ServerApp.pdb differ
diff --git a/Server/ServerApp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Server/ServerApp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
index 50cd1a9..5fdbcc9 100644
Binary files a/Server/ServerApp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/Server/ServerApp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/Server/ServerApp/obj/Debug/ServerApp.csprojAssemblyReference.cache b/Server/ServerApp/obj/Debug/ServerApp.csprojAssemblyReference.cache
index f42cdc6..262abda 100644
Binary files a/Server/ServerApp/obj/Debug/ServerApp.csprojAssemblyReference.cache and b/Server/ServerApp/obj/Debug/ServerApp.csprojAssemblyReference.cache differ
diff --git a/Server/ServerApp/obj/Debug/ServerApp.exe b/Server/ServerApp/obj/Debug/ServerApp.exe
index 98bf674..1757f2a 100644
Binary files a/Server/ServerApp/obj/Debug/ServerApp.exe and b/Server/ServerApp/obj/Debug/ServerApp.exe differ
diff --git a/Server/ServerApp/obj/Debug/ServerApp.pdb b/Server/ServerApp/obj/Debug/ServerApp.pdb
index 6d09d82..823f419 100644
Binary files a/Server/ServerApp/obj/Debug/ServerApp.pdb and b/Server/ServerApp/obj/Debug/ServerApp.pdb differ
