/// <summary> /// Creates the JSON representation of an aircraft. /// </summary> /// <param name="aircraft"></param> /// <param name="args"></param> /// <returns></returns> private ReportAircraftJson CreateReportAircraftJson(BaseStationAircraft aircraft, RequestReceivedEventArgs args) { var result = new ReportAircraftJson() { AircraftClass = aircraft.AircraftClass, AircraftId = aircraft.AircraftID, CofACategory = aircraft.CofACategory, CofAExpiry = aircraft.CofAExpiry, Country = aircraft.Country, CurrentRegDate = aircraft.CurrentRegDate, DeRegDate = aircraft.DeRegDate, FirstRegDate = aircraft.FirstRegDate, GenericName = aircraft.GenericName, IcaoTypeCode = aircraft.ICAOTypeCode, InfoUrl = aircraft.InfoUrl, Manufacturer = aircraft.Manufacturer, Icao = aircraft.ModeS, ModeSCountry = aircraft.ModeSCountry, MTOW = aircraft.MTOW, OperatorFlagCode = aircraft.OperatorFlagCode, OwnershipStatus = aircraft.OwnershipStatus, PictureUrl1 = aircraft.PictureUrl1, PictureUrl2 = aircraft.PictureUrl2, PictureUrl3 = aircraft.PictureUrl3, PopularName = aircraft.PopularName, PreviousId = aircraft.PreviousID, Registration = aircraft.Registration, RegisteredOwners = aircraft.RegisteredOwners, SerialNumber = aircraft.SerialNo, Status = aircraft.Status, TotalHours = aircraft.TotalHours, Type = aircraft.Type, Notes = aircraft.UserNotes, YearBuilt = aircraft.YearBuilt, HasPicture = args.IsInternetRequest && !_InternetClientCanSeePictures ? false : _PictureManager.FindPicture(_PictureFolderCache, aircraft.ModeS, aircraft.Registration) != null, }; var aircraftType = String.IsNullOrEmpty(aircraft.ICAOTypeCode) ? null : StandingDataManager.FindAircraftType(aircraft.ICAOTypeCode); if (aircraftType != null) { result.WakeTurbulenceCategory = (int)aircraftType.WakeTurbulenceCategory; result.Engines = aircraftType.Engines; result.EngineType = (int)aircraftType.EngineType; result.Species = (int)aircraftType.Species; } var codeBlock = String.IsNullOrEmpty(aircraft.ModeS) ? null : StandingDataManager.FindCodeBlock(aircraft.ModeS); if (codeBlock != null) { result.Military = codeBlock.IsMilitary; } return(result); }
public void ReportAircraftJson_Constructor_Initialises_To_Known_State_And_Properties_Work() { var json = new ReportAircraftJson(); TestUtilities.TestProperty(json, r => r.AircraftClass, null, "Ab"); TestUtilities.TestProperty(json, r => r.AircraftId, 0, 1); TestUtilities.TestProperty(json, "AirframeReg", null, "Ab"); // Tagged obsolete TestUtilities.TestProperty(json, r => r.CofACategory, null, "Ab"); TestUtilities.TestProperty(json, r => r.CofAExpiry, null, "Ab"); TestUtilities.TestProperty(json, r => r.Country, null, "Ab"); TestUtilities.TestProperty(json, r => r.CurrentRegDate, null, "Ab"); TestUtilities.TestProperty(json, r => r.DeRegDate, null, "Ab"); TestUtilities.TestProperty(json, r => r.Engines, null, "Ab"); TestUtilities.TestProperty(json, r => r.EngineType, null, 1); TestUtilities.TestProperty(json, r => r.FirstRegDate, null, "Ab"); TestUtilities.TestProperty(json, r => r.GenericName, null, "Ab"); TestUtilities.TestProperty(json, r => r.HasPicture, false); TestUtilities.TestProperty(json, r => r.Icao, null, "Ab"); TestUtilities.TestProperty(json, r => r.IcaoTypeCode, null, "Ab"); TestUtilities.TestProperty(json, r => r.InfoUrl, null, "Ab"); TestUtilities.TestProperty(json, r => r.Interested, false); TestUtilities.TestProperty(json, r => r.IsUnknown, false); TestUtilities.TestProperty(json, r => r.Manufacturer, null, "Ab"); TestUtilities.TestProperty(json, r => r.Military, false); TestUtilities.TestProperty(json, r => r.ModeSCountry, null, "Ab"); TestUtilities.TestProperty(json, r => r.MTOW, null, "Ab"); TestUtilities.TestProperty(json, r => r.Notes, null, "Ab"); TestUtilities.TestProperty(json, r => r.OperatorFlagCode, null, "Ab"); TestUtilities.TestProperty(json, r => r.OwnershipStatus, null, "Ab"); TestUtilities.TestProperty(json, r => r.PictureUrl1, null, "Ab"); TestUtilities.TestProperty(json, r => r.PictureUrl2, null, "Ab"); TestUtilities.TestProperty(json, r => r.PictureUrl3, null, "Ab"); TestUtilities.TestProperty(json, r => r.PictureWidth, 0, 1203); TestUtilities.TestProperty(json, r => r.PictureHeight, 0, 9182); TestUtilities.TestProperty(json, r => r.PopularName, null, "Ab"); TestUtilities.TestProperty(json, r => r.PreviousId, null, "Ab"); TestUtilities.TestProperty(json, r => r.RegisteredOwners, null, "Ab"); TestUtilities.TestProperty(json, r => r.Registration, null, "Ab"); TestUtilities.TestProperty(json, r => r.SerialNumber, null, "Ab"); TestUtilities.TestProperty(json, r => r.Species, null, 1); TestUtilities.TestProperty(json, r => r.Status, null, "Ab"); TestUtilities.TestProperty(json, r => r.TotalHours, null, "Ab"); TestUtilities.TestProperty(json, r => r.Type, null, "Ab"); TestUtilities.TestProperty(json, r => r.UserTag, null, "Ab"); TestUtilities.TestProperty(json, r => r.WakeTurbulenceCategory, null, 1); TestUtilities.TestProperty(json, r => r.YearBuilt, null, "Ab"); }
public void ReportAircraftJson_Constructor_Initialises_To_Known_State_And_Properties_Work() { var json = new ReportAircraftJson(); TestUtilities.TestProperty(json, "AircraftClass", null, "Ab"); TestUtilities.TestProperty(json, "AircraftId", 0, 1); TestUtilities.TestProperty(json, "AirframeReg", null, "Ab"); TestUtilities.TestProperty(json, "CofACategory", null, "Ab"); TestUtilities.TestProperty(json, "CofAExpiry", null, "Ab"); TestUtilities.TestProperty(json, "Country", null, "Ab"); TestUtilities.TestProperty(json, "CurrentRegDate", null, "Ab"); TestUtilities.TestProperty(json, "DeRegDate", null, "Ab"); TestUtilities.TestProperty(json, "Engines", null, "Ab"); TestUtilities.TestProperty(json, "EngineType", null, 1); TestUtilities.TestProperty(json, "FirstRegDate", null, "Ab"); TestUtilities.TestProperty(json, "GenericName", null, "Ab"); TestUtilities.TestProperty(json, "HasPicture", false); TestUtilities.TestProperty(json, "Icao", null, "Ab"); TestUtilities.TestProperty(json, "IcaoTypeCode", null, "Ab"); TestUtilities.TestProperty(json, "InfoUrl", null, "Ab"); TestUtilities.TestProperty(json, "Interested", false); TestUtilities.TestProperty(json, "IsUnknown", false); TestUtilities.TestProperty(json, "Manufacturer", null, "Ab"); TestUtilities.TestProperty(json, "Military", false); TestUtilities.TestProperty(json, "ModeSCountry", null, "Ab"); TestUtilities.TestProperty(json, "MTOW", null, "Ab"); TestUtilities.TestProperty(json, "Notes", null, "Ab"); TestUtilities.TestProperty(json, "OperatorFlagCode", null, "Ab"); TestUtilities.TestProperty(json, "OwnershipStatus", null, "Ab"); TestUtilities.TestProperty(json, "PictureUrl1", null, "Ab"); TestUtilities.TestProperty(json, "PictureUrl2", null, "Ab"); TestUtilities.TestProperty(json, "PictureUrl3", null, "Ab"); TestUtilities.TestProperty(json, "PictureWidth", 0, 1203); TestUtilities.TestProperty(json, "PictureHeight", 0, 9182); TestUtilities.TestProperty(json, "PopularName", null, "Ab"); TestUtilities.TestProperty(json, "PreviousId", null, "Ab"); TestUtilities.TestProperty(json, "RegisteredOwners", null, "Ab"); TestUtilities.TestProperty(json, "Registration", null, "Ab"); TestUtilities.TestProperty(json, "SerialNumber", null, "Ab"); TestUtilities.TestProperty(json, "Species", null, 1); TestUtilities.TestProperty(json, "Status", null, "Ab"); TestUtilities.TestProperty(json, "TotalHours", null, "Ab"); TestUtilities.TestProperty(json, "Type", null, "Ab"); TestUtilities.TestProperty(json, "WakeTurbulenceCategory", null, 1); TestUtilities.TestProperty(json, "YearBuilt", null, "Ab"); }
/// <summary> /// Creates the JSON representation of an aircraft. /// </summary> /// <param name="aircraft"></param> /// <param name="config"></param> /// <returns></returns> private ReportAircraftJson CreateReportAircraftJson(BaseStationAircraft aircraft, Configuration config) { var result = new ReportAircraftJson() { AircraftClass = aircraft.AircraftClass, AircraftId = aircraft.AircraftID, CofACategory = aircraft.CofACategory, CofAExpiry = aircraft.CofAExpiry, Country = aircraft.Country, CurrentRegDate = aircraft.CurrentRegDate, DeRegDate = aircraft.DeRegDate, FirstRegDate = aircraft.FirstRegDate, GenericName = aircraft.GenericName, IcaoTypeCode = aircraft.ICAOTypeCode, InfoUrl = aircraft.InfoUrl, Interested = aircraft.Interested, Manufacturer = aircraft.Manufacturer, Icao = aircraft.ModeS, ModeSCountry = aircraft.ModeSCountry, MTOW = aircraft.MTOW, OperatorFlagCode = aircraft.OperatorFlagCode, OwnershipStatus = aircraft.OwnershipStatus, PictureUrl1 = aircraft.PictureUrl1, PictureUrl2 = aircraft.PictureUrl2, PictureUrl3 = aircraft.PictureUrl3, PopularName = aircraft.PopularName, PreviousId = aircraft.PreviousID, Registration = aircraft.Registration, RegisteredOwners = aircraft.RegisteredOwners, SerialNumber = aircraft.SerialNo, Status = aircraft.Status, TotalHours = aircraft.TotalHours, Type = aircraft.Type, Notes = aircraft.UserNotes, YearBuilt = aircraft.YearBuilt, }; if (PipelineRequest.IsLocalOrLan || config.InternetClientSettings.CanShowPictures) { try { var pictureDetails = SharedState.AircraftPictureManager.FindPicture(SharedState.PictureFolderCache, aircraft.ModeS, aircraft.Registration); if (pictureDetails != null) { result.HasPicture = true; result.PictureWidth = pictureDetails.Width; result.PictureHeight = pictureDetails.Height; } } catch (Exception ex) { try { var log = Factory.ResolveSingleton <ILog>(); log.WriteLine($"Caught exception when fetching picture for {aircraft.ModeS}/{aircraft.Registration} for a report: {ex.ToString()}"); } catch { } } } var aircraftType = String.IsNullOrEmpty(aircraft.ICAOTypeCode) ? null : SharedState.StandingDataManager.FindAircraftType(aircraft.ICAOTypeCode); if (aircraftType != null) { result.WakeTurbulenceCategory = (int)aircraftType.WakeTurbulenceCategory; result.Engines = aircraftType.Engines; result.EngineType = (int)aircraftType.EngineType; result.EnginePlacement = (int)aircraftType.EnginePlacement; result.Species = (int)aircraftType.Species; } var codeBlock = String.IsNullOrEmpty(aircraft.ModeS) ? null : SharedState.StandingDataManager.FindCodeBlock(aircraft.ModeS); if (codeBlock != null) { result.Military = codeBlock.IsMilitary; } return(result); }