Beispiel #1
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);
                    }
                }
            }
        }