/// ---------- ---------- ---------- ---------- ---------- ---------- /// <name>updateArraysBasedOnCls</name> /// <date>15/09/13</date> /// <summary> /// If singleCls is set then use the currentJourney to update all /// location arrays. If not set then update the cls array for the /// current month. /// </summary> /// <param name="classId">class id</param> /// <param name="cls">cls name</param> /// <param name="currentJourneyDetails">current journey details</param> /// <param name="month">month to update</param> /// ---------- ---------- ---------- ---------- ---------- ---------- private static void UpdateArraysBasedOnCls( string vehicleNumber, List <GroupsType> groups, ReportCounterManager <LocationCounter> locations, IJourneyDetailsType currentJourneyDetails, string cls) { if (vehicleNumber == string.Empty) { return; } List <string> classIds = ClassReportFactory.GetClassAndFamilies( groups, vehicleNumber); foreach (string classId in classIds) { if (classId == cls) { locations.AddOne( currentJourneyDetails.To, currentJourneyDetails.From); } } }
/// <summary> /// Determine the groups for the <paramref name="vehicleNumber"/> then increase /// the totals. /// </summary> /// <param name="vehicleNumber">current vehicle number</param> /// <param name="groups">group details</param> /// <param name="classTotals">class total array</param> private static void UpdateClassTotals( string vehicleNumber, List <GroupsType> groups, ReportCounterManager <YearCounter> classTotals, int month) { if (vehicleNumber == string.Empty) { return; } List <string> classIds = ClassReportFactory.GetClassAndFamilies( groups, vehicleNumber); if (classIds == null || classIds.Count == 0) { return; } foreach (string classId in classIds) { classTotals.AddOne(classId, month); } }
/// <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); } } } }