Exemple #1
0
        /// <summary>
        /// Save the form.
        /// </summary>
        private void SaveDay()
        {
            ColourResourcesClass colourResources = ColourResourcesClass.GetInstance();

            //bool success = true;

            Status = "Saving";

            List <IJourneyDetailsType> currentDayJourneys =
                new List <IJourneyDetailsType>();

            foreach (IJourneyViewModel journey in this.JnyList)
            {
                IJourneyDetailsType converted =
                    JourneyFactory.ToJourneyModel(
                        journey);

                currentDayJourneys.Add(converted);
            }

            DailyInputFactory.SaveDay(
                this.Year,
                this.Month,
                this.Day,
                currentDayJourneys);

            this.firstExamples.CheckNewJnyList(
                currentDayJourneys);

            this.RaisePropertyChangedOnJnyList();

            this.Status = $"Save Completed for {this.Day}/{this.Month}/{this.Year}";
        }
Exemple #2
0
        /// <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="classTotals">class counter for the current search</param>
        /// <param name="year">year to update</param>
        /// <param name="cls">cls name</param>
        /// <returns name="success">is successful</returns>
        private static void UpdateClassesForYear(
            ReportCounterManager <ClassCounter> classTotals,
            List <GroupsType> groups,
            string year)
        {
            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;
            }

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

                foreach (IJourneyDetailsType currentJourneyDetails in journeysList)
                {
                    // Update the class totals for each unit in the journey.
                    foreach (string unit in currentJourneyDetails.Units)
                    {
                        ClassReportFactory.UpdateClassTotals(
                            unit,
                            groups,
                            classTotals);
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Set up the days ribbon.
        /// </summary>
        private void SetupDays()
        {
            this.days =
                DailyInputFactory.GetAllDaysInMonth(
                    this.Year,
                    this.Month);

            foreach (DayViewModel day in this.days)
            {
                if (day.CurrentDate.Date == this.Date.Date)
                {
                    day.IsSelected = true;
                }

                day.NewDateCallback = new DateTimeDelegate(this.SetNewDate);
            }
        }
Exemple #4
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);
                    }
                }
            }
        }
Exemple #5
0
        ///// <summary>
        ///// Set the day factory field.
        ///// </summary>
        ///// <remarks>
        ///// This is a crap solution, this really shouldn't be a singleton, but am working on something else at the moment.
        ///// </remarks>
        ///// <param name="dayFactory"></param>
        //public void SetDailyInputFactory(
        //  IDailyInputFactory dayFactory)
        //{
        //  this.dayFactory = dayFactory;
        //}

        /// <summary>
        /// fileNamesArray contains a list of all the filenames (and paths)
        ///   for the raw data of a single year, currentYear). This searches
        ///   through each one looking for numbers and locations which have
        ///   previously not been used.
        /// </summary>
        /// <param name="currentYear">current year</param>
        /// <param name="fileNamesArray">array of file names</param>
        private void SearchThroughSingleYear(
            int currentYear,
            string[] fileNamesArray)
        {
            //string   fileName        = string.Empty;
            //int      currentMonth    = 0;

            //DailyIOController dailyController         = DailyIOController.GetInstance();

            // loop through months
            //foreach (string currentFilename in fileNamesArray)
            //{
            for (int month = 1; month <= 12; ++month)
            {
                // Get file name from the path and convert it into it's integer value.
                //fileName      = currentFilename.Substring(currentFilename.LastIndexOf('\\') + 1);
                //fileName      = fileName.Substring(0, fileName.LastIndexOf('.'));
                //if (fileName.Length == 4)
                //{
                //fileName      = fileName.Substring(2);
                //if (int.TryParse(fileName, out currentMonth))
                //{
                // Searching all lines from this point forward.
                //List<string> journeysList =
                List <IJourneyDetailsType> journeysList =
                    DailyInputFactory.LoadMonth(
                        currentYear,
                        month);

                // loop through everything in the month
                //foreach (string currentJourney in journeysList)
                //{
                foreach (IJourneyDetailsType currentJourneyDetails in journeysList)
                {
                    //JourneyDetailsType currentJourneyDetails = new JourneyDetailsType(currentJourney, currentYear, currentMonth);
                    SearchNumbersForMatch(currentJourneyDetails);
                    SearchLocationsForMatch(currentJourneyDetails);
                }
                //}
                //}
            }
        }
Exemple #6
0
        /// <summary>
        /// Jnys for the selected day are loaded into the form.
        /// </summary>
        /// <returns>success flag</returns>
        private bool LoadJourneysForSelectedDay()
        {
            List <JourneyDetailsType> dayDetails = new List <JourneyDetailsType>();
            string filePath = string.Empty;
            Logger logger   = Logger.Instance;

            this.JnyList = new ObservableCollection <IJourneyViewModel>();
            foreach (IJourneyDetailsType jny in DailyInputFactory.LoadDay(this.Date))
            {
                IJourneyViewModel journey =
                    JourneyFactory.ToJourneyViewModel(
                        jny,
                        this.firstExamples);

                this.JnyList.Add(journey);
            }

            this.RaisePropertyChangedEvent(nameof(this.JnyList));
            return(true);
        }
Exemple #7
0
        /// <summary>
        ///   Loops through all month files in a year directory and analyses
        ///     each journey. It updates the relevant arrays.
        ///   If singleStn is set then it is measuring all journeys for the
        ///     specified stn argument. If not set then it is counting all
        ///     stns.
        /// </summary>
        /// <param name="year">year to update</param>
        /// <param name="singleStn">single stn flag</param>
        /// <param name="stn">stn name</param>
        /// <returns name="success">success flag</returns>
        private static void UpdateStnsForYear(
            ReportCounterManager <LocationCounter> locations,
            string year,
            string stn = "")
        {
            int    yearInteger = 0;
            string monthNumber = string.Empty;

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

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

                foreach (IJourneyDetailsType currentJourneyDetails in journeysList)
                {
                    if (string.IsNullOrEmpty(stn))
                    {
                        locations.AddOne(
                            currentJourneyDetails.To,
                            currentJourneyDetails.From);
                    }
                    else
                    {
                        LocationReportFactory.UpdateArraysForSingleStn(
                            locations,
                            stn,
                            currentJourneyDetails);
                    }
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// Analyse the requested month
        /// </summary>
        /// <param name="year">year to check</param>
        /// <param name="month">month to check</param>
        /// <param name="currentNumber">current number</param>
        /// <param name="previousNumbersList">colelction of previous numbers</param>
        /// <returns>The last jny checked</returns>
        private static List <IJourneyDetailsType> AnalyseMonth(
            int year,
            int month,
            string currentNumber,
            List <int> previousNumbersList,
            ref DateTime lastChecked)
        {
            List <IJourneyDetailsType> foundJourneys = new List <IJourneyDetailsType>();

            // Searching all lines from this point forward.
            List <IJourneyDetailsType> jnysList =
                DailyInputFactory.LoadMonth(
                    year,
                    month);

            if (jnysList.Count == 0)
            {
                return(foundJourneys);
            }

            // loop through everything in the month
            foreach (JourneyDetailsType currentJourneyDetails in jnysList)
            {
                currentJourneyDetails.ParentUnitNumber = currentNumber;

                if (
                    Searcher.NumbersMatch(
                        currentNumber,
                        previousNumbersList,
                        currentJourneyDetails.Units))
                {
                    foundJourneys.Add(currentJourneyDetails);
                }
            }

            lastChecked = jnysList[jnysList.Count - 1].Date;

            return(foundJourneys);
        }