示例#1
0
        /// <summary>
        ///   Run a cls report based on the year. It counts the number of
        ///     each cls for each month in the given year.
        /// </summary>
        /// <param name="year">current year</param>
        /// <param name="fullList">fullList</param>
        /// <returns>is successful</returns>
        public static ReportCounterManager <YearCounter> RunYearReportForAllCls(
            IGroupsAndClassesIOController groupsAndClassesIoController,
            string year,
            bool fullList)
        {
            ReportCounterManager <YearCounter> classTotals =
                new ReportCounterManager <YearCounter>();

            List <GroupsType> groupsList =
                groupsAndClassesIoController.LoadFile();

            foreach (GroupsType group in groupsList)
            {
                classTotals.AddNewCounter(new YearCounter(group.Name));
            }

            //string writeName = $"ClsReport_{year}_{DateTime.Now.ToString(ReportFactoryCommon.DatePattern)}.csv";
            //string faultMessage = $"ReportBuilder: Failed to write Annual Cls Report for {year}.";

            ClassReportFactory.UpdateClassesForYear(
                classTotals,
                groupsList,
                year);

            if (!fullList)
            {
                classTotals.RemoveEmptyClasses();
            }

            return(classTotals);

            //classTotals.WriteCSVFile(
            //  writeName,
            //  faultMessage);
        }
示例#2
0
        /// <summary>
        ///   Run a report based on a stn. It counts the number of other
        ///     stns visited from the given stn across all records.
        /// </summary>
        /// <param name="stn">stn name</param>
        /// <param name="fullList">full list of locations</param>
        /// <returns>is successful</returns>
        public static ReportCounterManager <LocationCounter> RunSingleStnGeneralReport(
            string stn,
            bool fullList)
        {
            string[] dirNamesArray =
                System.IO.Directory.GetDirectories(
                    BasePathReader.GetBasePath() + StaticResources.baPath);

            ReportCounterManager <LocationCounter> locationTotals =
                LocationReportFactory.CreateLocations();

            for (int i = 0; i < dirNamesArray.Count(); ++i)
            {
                // get directory name from the path and convert it into it's integer value.
                string dirName = dirNamesArray[i].Substring(dirNamesArray[i].LastIndexOf('\\') + 1);
                LocationReportFactory.UpdateStnsForYear(
                    locationTotals,
                    dirName,
                    stn);
            }

            if (!fullList)
            {
                locationTotals.RemoveEmptyClasses();
            }

            return(locationTotals);

            //string writeName = $"{stn}_Report_Gen_{DateTime.Now.ToString(ReportFactoryCommon.DatePattern)}.csv";
            //string faultMessage = $"ReportBuilder: ReportBuilder: Failed to write General Stn Report for {stn}.";

            //locationTotals.WriteCSVFile(
            //  writeName,
            //  faultMessage);
        }
示例#3
0
        /// <summary>
        ///   Run a stn report. It counts the number of occurrences of each
        ///     stn in the given year.
        /// </summary>
        /// <param name="year">chosen year</param>
        /// <param name="fullList">fullList</param>
        /// <returns>success flag</returns>
        public static ReportCounterManager <LocationCounter> RunStnAnnualReport(
            string year,
            bool fullList)
        {
            ReportCounterManager <LocationCounter> locationTotals =
                LocationReportFactory.CreateLocations();

            LocationReportFactory.UpdateStnsForYear(
                locationTotals,
                year);

            if (!fullList)
            {
                locationTotals.RemoveEmptyClasses();
            }

            return(locationTotals);

            //string writeName = $"StnReport_{year}_{DateTime.Now.ToString(ReportFactoryCommon.DatePattern)}.csv";
            //string faultMessage = $"ReportBuilder: ReportBuilder: Failed to write Annual Stn Report for {year}.";

            //locationTotals.WriteCSVFile(
            //  writeName,
            //  faultMessage);
        }
示例#4
0
        /// <summary>
        /// Run a general class report.
        /// This provides the count for each class across all records.
        /// </summary>
        /// <param name="fullList">
        /// return a full list of locations or just none zero ones.
        /// </param>
        /// <returns>success flag</returns>
        public static ReportCounterManager <ClassCounter> RunGeneralReportForAllCls(
            IGroupsAndClassesIOController groupsAndClassesIoController,
            bool fullList)
        {
            // Set up paths.
            string basePath =
                BasePathReader.GetBasePath();

            string[] dirNamesArray =
                System.IO.Directory.GetDirectories(
                    $"{basePath}{StaticResources.baPath}");

            // Load the groups and set up the report class with an entry for each group.
            List <GroupsType> groupsList =
                groupsAndClassesIoController.LoadFile();

            ReportCounterManager <ClassCounter> classTotals =
                new ReportCounterManager <ClassCounter>();

            foreach (GroupsType group in groupsList)
            {
                classTotals.AddNewCounter(
                    new ClassCounter(
                        group.Name));
            }

            // Loop through all paths.
            for (int directoryIndex = 0; directoryIndex < dirNamesArray.Count(); ++directoryIndex)
            {
                // get directory name from the path and convert it into it's integer value.
                string dirName =
                    dirNamesArray[directoryIndex].Substring(
                        dirNamesArray[directoryIndex].LastIndexOf('\\') + 1);
                ClassReportFactory.UpdateClassesForYear(
                    classTotals,
                    groupsList,
                    dirName);
            }

            if (!fullList)
            {
                classTotals.RemoveEmptyClasses();
            }

            return(classTotals);

            //classTotals.WriteCSVFile(
            //  $"ClsReport_Gen_{DateTime.Now.ToString(ReportFactoryCommon.DatePattern)}.csv",
            //  "ReportBuilder: Failed to write General Cls Report.");
        }
示例#5
0
        /// ---------- ---------- ---------- ---------- ---------- ----------
        /// <name>runYearReportForSingleCls</name>
        /// <date>15/09/13</date>
        /// <summary>
        ///   Run a report based on a cls. It counts all the locations for
        ///     the cls across all records.
        /// </summary>
        /// <param name="cls">cls name</param>
        /// <param name="fullList">full list of locations</param>
        /// <returns>is successful</returns>
        /// ---------- ---------- ---------- ---------- ---------- ----------
        public static ReportCounterManager <LocationCounter> RunReportForASingleClass(
            IGroupsAndClassesIOController groupsAndClassesIoController,
            string cls,
            bool fullList,
            string year = "")
        {
            string faultMessage;
            string writeName;

            // Set up paths.
            string basePath =
                BasePathReader.GetBasePath();

            ReportCounterManager <LocationCounter> locationTotals =
                new ReportCounterManager <LocationCounter>();

            List <FirstExampleType> firstExampleList =
                Stats.FirstExampleIOController.GetInstance().GetFirstExampleListLocation();

            firstExampleList = firstExampleList.OrderBy(loc => loc.Item).ToList();

            foreach (FirstExampleType location in firstExampleList)
            {
                locationTotals.AddNewCounter(
                    new LocationCounter(
                        location.Item));
            }

            if (string.IsNullOrEmpty(year))
            {
                //writeName = $"{cls}_Report_{DateTime.Now.ToString(ReportFactoryCommon.DatePattern)}.csv";
                //faultMessage = "ReportBuilder: Failed to write General Cls Report.";

                string[] dirNamesArray =
                    System.IO.Directory.GetDirectories(
                        $"{basePath}{StaticResources.baPath}");

                // Loop through all paths.
                for (int directoryIndex = 0; directoryIndex < dirNamesArray.Count(); ++directoryIndex)
                {
                    // get directory name from the path and convert it into it's integer value.
                    string dirName =
                        dirNamesArray[directoryIndex].Substring(
                            dirNamesArray[directoryIndex].LastIndexOf('\\') + 1);
                    ClassReportFactory.UpdateLocationsForYear(
                        groupsAndClassesIoController,
                        dirName,
                        locationTotals,
                        cls);
                }
            }
            else
            {
                //writeName = $"{cls}_Report_{year}_{DateTime.Now.ToString(ReportFactoryCommon.DatePattern)}.csv";
                //faultMessage = $"ReportBuilder: Failed to write Single Year {year} Cls Report.";

                ClassReportFactory.UpdateLocationsForYear(
                    groupsAndClassesIoController,
                    year,
                    locationTotals,
                    cls);
            }

            if (!fullList)
            {
                locationTotals.RemoveEmptyClasses();
            }

            return(locationTotals);

            //locationTotals.WriteCSVFile(
            //  writeName,
            //  faultMessage);
        }