/// <summary> /// Initialises a new instance of the <see cref="IndividualUnitFileContents"/> class. /// </summary> /// <param name="unitNumber">unit number</param> /// <param name="formerNumbers">collection of former numbers</param> /// <param name="inService">index of the service, see in service enumeration</param> /// <param name="lastCheckDate">last check date</param> /// <param name="journeys">journeys collection</param> /// <param name="notes">notes pertaining to unit</param> public IndividualUnitFileContents( string unitNumber, MilesChains distance, int entriesCount, IVehicleNumberType formerNumbers, VehicleServiceType inService, DateTime lastEntryDate, DateTime lastCheckDate, List <IJourneyDetailsType> journeys, string notes) { this.UnitNumber = unitNumber; this.Distance = distance; this.EntriesCount = entriesCount; this.FormerNumbers = formerNumbers; this.InService = inService; this.LastEntryDate = lastEntryDate; this.LastCheckDate = lastCheckDate; this.Journeys = journeys; this.Notes = notes; }
public static Color GetColour( VehicleServiceType serviceType, bool isBackground) { switch (serviceType) { case VehicleServiceType.InService: return(isBackground ? Color.FromRgb(00, 50, 00) : Colors.DarkOliveGreen); case VehicleServiceType.Preserved: return(Colors.Navy); case VehicleServiceType.Reclassified: return(Colors.DarkSlateGray); case VehicleServiceType.Withdrawn: return(Colors.Maroon); default: return(Colors.HotPink); } }
/// <date>10/003/19</date> /// <summary> /// Read the contents of a version 2 file. At the point this has been called, the /// first line has been read and is no longer relevant to the decoding process. /// The next line to be read will be the unit id. /// </summary> /// <param name="reader">the open file reader</param> /// <returns>contents of the file being read.</returns> private static IndividualUnitFileContents ReadIndividualUnitFileVersion2( StreamReader reader) { string currentLine = string.Empty; try { // {number} string unitNumber = reader.ReadLine(); // {mileage} //currentLine = reader.ReadLine(); MilesChains unitDistance = new MilesChains(reader.ReadLine()); // {number_entries} int entriesCount = IndividualUnitIOController.ConvertInteger( reader.ReadLine()); IVehicleNumberType formerNumbers = IndividualUnitIOController.GetFormerNumbers( reader.ReadLine()); DateTime lastEntryDate = IndividualUnitIOController.ConvertDate( reader.ReadLine()); DateTime lastCheckDate = IndividualUnitIOController.ConvertDate( reader.ReadLine()); // {Status} VehicleServiceType inService = VehicleServiceType.InService; inService = IndividualUnitIOController.GetServiceStatus(reader.ReadLine()); // {Note} string note = string.Empty; note = reader.ReadLine(); List <IJourneyDetailsType> journeys = new List <IJourneyDetailsType>(); currentLine = reader.ReadLine(); while (currentLine != null) { IJourneyDetailsType journey = IndividualUnitIOController.ConvertJourney( currentLine); if (journey != null) { journeys.Add(journey); } currentLine = reader.ReadLine(); } return(new IndividualUnitFileContents( unitNumber, unitDistance, entriesCount, formerNumbers, inService, lastEntryDate, lastCheckDate, journeys, note)); } catch (Exception ex) { Logger.Instance.WriteLog( $"ERROR: Error reading individual unit file (ver2). Error is {ex}"); return(null); } }