Ejemplo n.º 1
0
        /// <summary>
        /// Initialises a new instance of the <see cref="AnalysisViewModel"/> class.
        /// </summary>
        public ClassAnalysisDashboardViewModel(
            IGroupsAndClassesIOController groupsAndClassesIoController,
            Action <ReportCounterManager <ClassCounter> > classGeneralReportResults,
            Action <ReportCounterManager <YearCounter>, string> classSingleYearReportResults,
            Action <ReportCounterManager <LocationCounter>, string> singleClassGeneralLocationReportResults,
            Action <ReportCounterManager <LocationCounter>, string, string> singleClassSingleYearLocationReportResults)
        {
            this.groupsAndClassesIoController = groupsAndClassesIoController;

            this.classGeneralReportResults                  = classGeneralReportResults;
            this.classSingleYearReportResults               = classSingleYearReportResults;
            this.singleClassGeneralLocationReportResults    = singleClassGeneralLocationReportResults;
            this.singleClassSingleYearLocationReportResults = singleClassSingleYearLocationReportResults;

            this.AllRunsPerClassCommand = new CommonCommand(this.GenerateAllRunsPerClassReport);
            this.ClsSingleYearReportCmd = new CommonCommand(this.GenerateClassSingleYearReport);
            this.AllLocationsForSpecificClassReportCommand        = new CommonCommand(this.GenerateAllLocationsVisitedPerClassReport);
            this.AllLocationsForSpecificClassAndYearReportCommand = new CommonCommand(this.GenerateAllLocationsVisitedPerClassReportPerYear);

            if (this.YearsCollection.Count > 0)
            {
                this.yearsIndex = this.YearsCollection.Count - 1;
            }

            if (this.ClsCollection.Count > 0)
            {
                this.clsIndex = 0;
            }

            this.fullList = false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialises a new instance of the <see cref="AnalysisViewModel"/> class.
        /// </summary>
        public AnalysisViewModel(IGroupsAndClassesIOController groupsAndClassesIoController)
        {
            this.groupsAndClassesIoController = groupsAndClassesIoController;
            this.reportStatus = string.Empty;

            this.ClassControls =
                new ClassAnalysisDashboardViewModel(
                    groupsAndClassesIoController,
                    this.ClassGeneralReportResults,
                    this.ClassSingleYearReportResults,
                    this.SingleClassGeneralLocationReportResults,
                    this.SingleClassSingleYearLocationReportResults);
            this.LocationControls =
                new LocationAnalysisDashboardViewModel(
                    this.LocationsGeneralReport,
                    this.LocationsYearReport,
                    this.SingleLocationGeneralReport,
                    this.SingleLocationYearReport);

            this.ClassControls.ProgressEvent     = this.UpdateReportStatus;
            this.LocationControls.ProgressEvent += this.UpdateReportStatus;

            this.OpenClassReportWindowCommand    = new CommonCommand(ShowClassAnalysisWindow);
            this.OpenLocationReportWindowCommand = new CommonCommand(ShowLocationAnalysisWindow);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 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.");
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Initialises a new instance of the <see cref="GroupsAndClassesViewModel"/> class.
    /// </summary>
    public GroupsAndClassesViewModel(IGroupsAndClassesIOController reader)
    {
      this.reader = reader;

      this.AddGroupCmd = new CommonCommand(this.AddGroup, this.CanAddGroup);
      this.DeleteGroupCmd = new CommonCommand(this.DeleteGroup, this.CanDeleteGroup);
      this.AddRangeCmd = new CommonCommand(this.AddRange, this.CanAddRange);
      this.DeleteRangeCmd = new CommonCommand(this.DeleteRange, this.CanDeleteRange);
      this.CompleteCmd = new CommonCommand<ICloseable>(this.SelectComplete, this.CanSelectComplete);

      this.groupsCollection = reader.LoadFile();
      this.SetupGroupsNamesCollection();

      this.rangeIndex = -1;
      this.groupIndex = -1;
    }
Ejemplo n.º 6
0
        /// <summary>
        /// Initialises a new instance of the <see cref="ClassAnalysisViewModel"/> class.
        /// </summary>
        /// <param name="groupsAndClassesIoController">
        /// IO Controller for groups and controllers.
        /// </param>
        public ClassAnalysisViewModel(
            IGroupsAndClassesIOController groupsAndClassesIoController)
        {
            this.ClassControls =
                new ClassAnalysisDashboardViewModel(
                    groupsAndClassesIoController,
                    this.ClassGeneralReportResults,
                    this.ClassSingleYearReportResults,
                    this.SingleClassGeneralLocationReportResults,
                    this.SingleClassSingleYearLocationReportResults);

            this.locationCounterResultsTable = new LocationCounterResultsViewModel();
            this.totalsCounterResultsTable   = new TotalsCounterResultsViewModel();
            this.fullYearCounterResultsTable = new FullYearCounterResultsViewModel();
            this.ResultsTable = this.locationCounterResultsTable;
        }
Ejemplo n.º 7
0
        /// ---------- ---------- ---------- ---------- ---------- ----------
        /// <name>updateClassesForYear</name>
        /// <date>15/09/13</date>
        /// <summary>
        ///   Loops through all month files in a year directory and analyses
        ///     each journey. It works out the class of each number in the
        ///     journey and updates the relevant arrays.
        ///   If singleCls is set then it is measuring all journeys for the
        ///     specified cls argument. If not set then it is measuring each
        ///     cls and counting examples per month.
        /// </summary>
        /// <param name="year">year to update</param>
        /// <param name="singleCls">single cls</param>
        /// <param name="cls">cls name</param>
        /// <returns name="success">is successful</returns>
        /// ---------- ---------- ---------- ---------- ---------- ----------
        public static void UpdateLocationsForYear(
            IGroupsAndClassesIOController groupsAndClassesIoController,
            string year,
            ReportCounterManager <LocationCounter> locations,
            string cls)
        {
            // Load the groups and set up the report class with an entry for each group.
            List <GroupsType> groups =
                groupsAndClassesIoController.LoadFile();

            int yearInteger = 0;

            // Convert year string to an integer
            if (!int.TryParse(year, out yearInteger))
            {
                Logger.Instance.WriteLog("ReportBuilder: Can't convert year " + year);
                return;
            }

            // loop through months
            for (int month = 1; month <= 12; ++month)
            {
                List <IJourneyDetailsType> journeysList =
                    DailyInputFactory.LoadMonth(
                        yearInteger,
                        month);

                // loop through everything in the month
                //foreach (string currentJourney in journeysList)
                foreach (IJourneyDetailsType currentJourneyDetails in journeysList)
                {
                    foreach (string unit in currentJourneyDetails.Units)
                    {
                        UpdateArraysBasedOnCls(
                            unit,
                            groups,
                            locations,
                            currentJourneyDetails,
                            cls);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initialises a new instance of the <see cref="ConfigViewModel"/> class.
        /// </summary>
        /// <param name="groupsAndClassesIoController">IO controller</param>
        public ConfigViewModel(
            IGroupsAndClassesIOController groupsAndClassesIoController,
            FirstExampleManager firstExamples)
        {
            this.groupsAndClassesIoController = groupsAndClassesIoController;
            this.firstExamples = firstExamples;
            this.PopulateYearCollection();
            this.PopulateOldNumbersAvailable();

            if (this.YearsCollection.Count > 0)
            {
                this.yearsIndex = this.YearsCollection.Count - 1;
            }

            this.CloseCmd                 = new CommonCommand(this.CloseWindow);
            this.RefreshYearCmd           = new CommonCommand(this.RefreshYear);
            this.RefreshAllCmd            = new CommonCommand(this.RefreshAll);
            this.ConfigClsCmd             = new CommonCommand(this.ConfigCls);
            this.ConfigStnCmd             = new CommonCommand(this.ConfigStn);
            this.UpdatePreviousIdCountCmd = new CommonCommand(this.UpdatePreviousIdCount);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initialises a new instance of the <see cref="MainWindowViewModel"/> class.
        /// </summary>
        /// <param name="unitsIoController"><
        /// Unit input output controller
        /// /param>
        /// <param name="unitsXmlIoController">
        /// Unit (xml) input output controller
        /// </param>
        /// <param name="firstExamples">
        /// First examples manager
        /// </param>
        public MainWindowViewModel(
            UnitsIOController unitsIoController,
            UnitsXmlIOController unitsXmlIoController,
            FirstExampleManager firstExamples)
        {
            this.unitsIoController            = unitsIoController;
            this.unitsXmlIoController         = unitsXmlIoController;
            this.firstExamples                = firstExamples;
            this.groupsAndClassesIoController = new GroupsAndClassesIOController();

            AddEditJnyDetailsCommand = new CommonCommand(this.ShowAddEditJnyDetailsWindow);
            AnalysisCommand          = new CommonCommand(this.ShowAnalysisWindow);
            ConfigurationCommand     = new CommonCommand(this.ShowConfigurationWindow);
            ExitCommand           = new CommonCommand(this.ExitProgram);
            OpenLogCommand        = new CommonCommand(this.ShowLog);
            OpenLogFolderCommand  = new CommonCommand(this.ShowLogFolder);
            ShowClassIndexCommand = new CommonCommand(this.ShowClassIndexWindow);
            ShowJnyDetailsCommand = new CommonCommand(this.ShowJnyDetailsWindow);
            ShowInputDataCommand  = new CommonCommand(this.ShowInputWindow);

            this.inputWindow = null;
        }
Ejemplo n.º 10
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);
        }