public void setBaseDayMappings(String commaLine)
        {
            String[] line = commaLine.Split(',');
            //11 12 13
            DateTime s        = Convert.ToDateTime(line[11]);
            DateTime e        = Convert.ToDateTime(line[12]);
            String   absences = line[13].Trim();

            foreach (DateTime day in collectionDaysInfo.Keys)
            {
                Subject si    = (Subject) new Subject(commaLine, mapById);
                String  szDay = day.Month + "/" + day.Day + "/" + day.Year;

                DateTime start = new DateTime(day.Year, day.Month, day.Day, 0, 0, 0);
                DateTime end   = new DateTime(day.Year, day.Month, day.Day, 23, 59, 59);
                si.startDate = start;
                si.endDate   = end;


                DateTime endDateTime = e.Hour == 0?e.AddHours(23).AddMinutes(59).AddSeconds(59):e;
                // if (s <= day && e >= day.AddHours(23).AddMinutes(59).AddSeconds(59) && (!absences.Contains(szDay)))
                if (s <= start && endDateTime >= end && (!absences.Contains(szDay)))
                {
                    si.present = true;
                    DayCollectionInfo dayMaps = collectionDaysInfo[day];
                    addToRecType(si, day, dayMaps);///
                    if (!dayMaps.dayMapping.ContainsKey(si.mapId))
                    {
                        dayMaps.dayMapping.Add(si.mapId, new List <Subject>());
                    }
                    dayMaps.dayMapping[si.mapId].Add(si);
                }
                if (si.lenaId == "11563")
                {
                    bool stop = true;
                }
            }
        }
        public void appendYearClassDaysSubjectsInfo(TextWriter sw)
        {
            ///YEAR CLASS DAYS
            //sw.WriteLine("CLASSROOM,DATE,LONG_ID,SHORT_ID,STATUS,"+
            //"LENAID,LEFTUBI,RIGHTUBI,LENAMS,UBIMS,ULMS,LEFTUBILOGS,RIGHTUBILOGS,UBILOGS,ULLOGS,LENASTART,LENAEND,UBISTART,UBIEND,ULSTART,ULEND,ITSFILES," +
            //"TYPE,DIAGNOSIS,LANGUAGE,GENDER"
            // );
            foreach (DateTime day in collectionDaysInfo.Keys)
            {
                DayCollectionInfo dc = collectionDaysInfo[day];
                foreach (String subject in dc.dayMapping.Keys)
                {
                    foreach (Subject sm in dc.dayMapping[subject])
                    {
                        try
                        {
                            Subject sMap = sm;
                            if (this.baseMappings.ContainsKey(sm.mapId))
                            {
                                sMap = this.baseMappings[sm.mapId];
                            }


                            String lenaStarts = "";
                            String lenaEnds   = "";

                            foreach (DateTime startDate in sm.itsRecs.startTimes)
                            {
                                lenaStarts = lenaStarts + (lenaStarts != "" ? "|" : "") + getTimeStr(startDate);
                            }
                            foreach (DateTime endDate in sm.itsRecs.endTimes)
                            {
                                lenaEnds = lenaEnds + (lenaEnds != "" ? "|" : "") + getTimeStr(endDate);
                            }
                            sw.Write(classroom + "," + day.Month + "/" + day.Day + "/" + day.Year + "," +
                                     sm.longId + "," +
                                     sm.shortId + "," +
                                     (sm.present ? "PRESENT" : "ABSENT") + "," +
                                     sm.lenaId + "," +
                                     sm.leftUbi + "," +
                                     sm.rightUbi + "," +
                                     sm.itsRecs.ms + "," +
                                     sm.ubiRecs.ms + "," +
                                     sm.cotalkRecs.ms + "," +
                                     ((sm.itsRecs.ms / 60000) / 60) + "," +
                                     ((sm.ubiRecs.ms / 60000) / 60) + "," +
                                     ((sm.cotalkRecs.ms / 60000) / 60) + "," +
                                     sm.leftUbiRecs.totalLogs + "," +
                                     sm.rightUbiRecs.totalLogs + "," +
                                     sm.ubiRecs.totalLogs + "," +
                                     sm.cotalkRecs.totalLogs + "," +
                                     getTimeStr(sm.itsRecs.startTime) + "," +
                                     getTimeStr(sm.itsRecs.endTime) + "," +
                                     lenaStarts + "," +
                                     lenaEnds + "," +
                                     getTimeStr(sm.ubiRecs.startTime) + "," +
                                     getTimeStr(sm.ubiRecs.endTime) + "," +
                                     getTimeStr(sm.cotalkRecs.startTime) + "," +
                                     getTimeStr(sm.cotalkRecs.endTime) + "," +
                                     sMap.type + "," +
                                     sMap.diagnosis + "," +
                                     sMap.language + "," +
                                     sMap.gender + ",");
                            String szFiles = "";
                            foreach (String szItsFile in sm.itsRecs.dataFiles)
                            {
                                szFiles = szFiles + (szFiles != "" ? "|" : "") + szItsFile;
                            }
                            sw.WriteLine(szFiles);
                        }
                        catch (Exception e)
                        {
                            Boolean stop = true;
                        }
                    }
                }
            }
        }
        public void setDayMappings()
        {////
            String[] dateDirs = Directory.GetDirectories(dir, "*-*-*");

            foreach (String szDateDir in dateDirs)
            {
                String mappingDir = szDateDir + "//MAPPINGS//MAPPING_" + classroom + ".CSV";
                if (!File.Exists(mappingDir))
                {
                    error = "mappingDir not found : " + mappingDir;
                    Console.WriteLine(error);
                }
                else
                {
                    using (StreamReader sr = new StreamReader(mappingDir))
                    {
                        String szday = mappingDir.Substring(0, mappingDir.IndexOf("//MAPPINGS"));
                        szday = szday.Substring(szday.LastIndexOf("\\") + 1).Replace("-", "/");// day.Month + "/" + day.Day + "/" + day.Year;
                        DateTime day = Convert.ToDateTime(szday);

                        if (!sr.EndOfStream)
                        {
                            sr.ReadLine();
                        }

                        while ((!sr.EndOfStream))// && lineCount < 10000)
                        {
                            String   commaLine = sr.ReadLine();
                            String[] line      = commaLine.Split(',');
                            if (line.Length > 16 && line[1] != "")
                            {
                                Subject si = new Subject(commaLine, mapById);

                                if (collectionDaysInfo.ContainsKey(day))
                                {
                                    if (day.Year < 2021)
                                    {
                                        DateTime start = new DateTime(day.Year, day.Month, day.Day, 0, 0, 0);
                                        DateTime end   = new DateTime(day.Year, day.Month, day.Day, 23, 59, 59);
                                        si.startDate = start;
                                        si.endDate   = end;
                                    }
                                    else
                                    {
                                        DateTime start = new DateTime(day.Year, day.Month, day.Day, si.startDate.Hour, si.startDate.Minute, 0);
                                        DateTime end   = new DateTime(day.Year, day.Month, day.Day, si.endDate.Hour, si.endDate.Minute, 0);
                                        si.startDate = start;
                                        si.endDate   = end;
                                    }



                                    DayCollectionInfo dayMaps = collectionDaysInfo[day];
                                    if (!dayMaps.dayMapping.ContainsKey(si.mapId))
                                    {
                                        dayMaps.dayMapping.Add(si.mapId, new List <Subject>());
                                    }
                                    dayMaps.dayMapping[si.mapId].Add(si);

                                    if (!baseMappings.ContainsKey(si.mapId))
                                    {
                                        baseMappings.Add(si.mapId, si);
                                    }
                                    if (si.present)
                                    {
                                        addToRecType(si, day, dayMaps);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        public void addToRecType(Subject si, DateTime day, DayCollectionInfo di)
        {
            switch (si.type.Trim().ToUpper().Substring(0, 1))
            {
            case "C":
                if (!childrenRecs.ContainsKey(si.mapId))
                {
                    childrenRecs.Add(si.mapId, new List <DateTime>());
                }
                childrenRecs[si.mapId].Add(day);

                if (!di.children.Contains(si.mapId))
                {
                    di.children.Add(si.mapId);
                }

                if (baseMappings.ContainsKey(si.mapId))
                {
                    if (baseMappings[si.mapId].diagnosis.Trim().ToUpper() == "TYPICAL" || baseMappings[si.mapId].diagnosis.Trim() == "" || baseMappings[si.mapId].diagnosis.Trim() == "TD")
                    {
                        if (!tChildrenRecs.ContainsKey(si.mapId))
                        {
                            tChildrenRecs.Add(si.mapId, new List <DateTime>());
                        }
                        tChildrenRecs[si.mapId].Add(day);

                        if (!di.tChildren.Contains(si.mapId))
                        {
                            di.tChildren.Add(si.mapId);
                        }
                    }
                    else
                    {
                        if (!atChildrenRecs.ContainsKey(si.mapId))
                        {
                            atChildrenRecs.Add(si.mapId, new List <DateTime>());
                        }
                        atChildrenRecs[si.mapId].Add(day);

                        if (!di.atChildren.Contains(si.mapId))
                        {
                            di.atChildren.Add(si.mapId);
                        }
                    }
                }

                break;

            case "T":
                if (!adultRecs.ContainsKey(si.mapId))
                {
                    adultRecs.Add(si.mapId, new List <DateTime>());
                }
                adultRecs[si.mapId].Add(day);

                if (!di.adults.Contains(si.mapId))
                {
                    di.adults.Add(si.mapId);
                }

                if (!teacherRecs.ContainsKey(si.mapId))
                {
                    teacherRecs.Add(si.mapId, new List <DateTime>());
                }
                teacherRecs[si.mapId].Add(day);

                if (!di.teachers.Contains(si.mapId))
                {
                    di.teachers.Add(si.mapId);
                }

                break;

            case "L":
                if (!adultRecs.ContainsKey(si.mapId))
                {
                    adultRecs.Add(si.mapId, new List <DateTime>());
                }
                adultRecs[si.mapId].Add(day);

                if (!di.adults.Contains(si.mapId))
                {
                    di.adults.Add(si.mapId);
                }


                if (!labRecs.ContainsKey(si.mapId))
                {
                    labRecs.Add(si.mapId, new List <DateTime>());
                }
                labRecs[si.mapId].Add(day);

                if (!di.labs.Contains(si.mapId))
                {
                    di.labs.Add(si.mapId);
                }
                break;
            }
        }