public override LogbookEntry ToLogbookEntry() { OnDuty = FixedUTCDateFromTime(Date, OnDuty); OffDuty = FixedUTCDateFromTime(Date, OffDuty, OnDuty); TimeOut = FixedUTCDateFromTime(Date, TimeOut); TimeIn = FixedUTCDateFromTime(Date, TimeIn, TimeOut); List <string> lstApproachStrings = new List <string>() { Approach1, Approach2, Approach3, Approach4, Approach5, Approach6 }; StringBuilder sbApproaches = new StringBuilder(); int cApproaches = 0; foreach (string szApproach in lstApproachStrings) { if (!String.IsNullOrWhiteSpace(szApproach)) { string szFixedApproach = Regex.Replace(szApproach, " ?\\(GPS\\)", "/GPS", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline); try { MatchCollection mc = regApproach.Matches(szFixedApproach); foreach (Match m in mc) { ApproachDescription ad = new ApproachDescription(m); sbApproaches.Append(ad.ToCanonicalString() + Resources.LocalizedText.LocalizedSpace + m.Groups["remark"].Value + Resources.LocalizedText.LocalizedSpace); cApproaches += ad.Count; } } catch (FormatException) { } } } StudentNames = new List <string>(); InstructorNames = new List <string>(); ExaminerNames = new List <string>(); PassengerNames = new List <string>(); // try to parse people's role on the flight Person1 = AddToRole(Person1); Person2 = AddToRole(Person2); Person3 = AddToRole(Person3); Person4 = AddToRole(Person4); Person5 = AddToRole(Person5); Person6 = AddToRole(Person6); if (!String.IsNullOrEmpty(InstructorName)) { InstructorNames.Add(InstructorName); } InstructorName = JoinStrings(InstructorNames); if (AircraftID == null) { AircraftID = string.Empty; } if (AircraftID.StartsWith(CountryCodePrefix.szSimPrefix, StringComparison.CurrentCultureIgnoreCase)) { AircraftID = CountryCodePrefix.szSimPrefix; } string szModel = Regex.Replace(((String.IsNullOrEmpty(Model) ? TypeCode : Model) ?? string.Empty), " *[([]?SIM[)\\]]?$", String.Empty, RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline); LogbookEntry le = new LogbookEntry() { Date = this.Date, ModelDisplay = szModel, TailNumDisplay = String.IsNullOrWhiteSpace(AircraftID) ? (SimulatedFlight > 0 ? CountryCodePrefix.SimCountry.Prefix : CountryCodePrefix.AnonymousCountry.Prefix) : AircraftID, Route = rLatLon.Replace(JoinStrings(new string[] { From, Route, To }), (m) => { return("@" + m.Groups[1].Value + m.Groups[2].Value + m.Groups[3].Value + m.Groups[4].Value); }), EngineStart = TimeOut, EngineEnd = TimeIn, TotalFlightTime = TotalTime, PIC = this.PIC, SIC = this.SIC, Nighttime = Night, CrossCountry = CrossCountry, IMC = ActualInstrument, SimulatedIFR = SimulatedInstrument, CFI = DualGiven, Dual = DualReceived, GroundSim = SimulatedFlight, FullStopLandings = DayLandingsFullStop, NightLandings = NightLandingsFullStop, Landings = AllLandings, HobbsStart = HobbsStart, HobbsEnd = HobbsEnd, Approaches = cApproaches, fHoldingProcedures = (Holds > 0), CFIName = InstructorName, Comment = JoinStrings(new string[] { PilotComments, Text, sbApproaches.ToString().Trim(), Person1, Person2, Person3, Person4, Person5, Person6 }), CustomProperties = PropertiesWithoutNullOrDefault(new CustomFlightProperty[] { PropertyWithValue(CustomPropertyType.KnownProperties.IDPropFlightDutyTimeStart, OnDuty, true), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropFlightDutyTimeEnd, OffDuty, true), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropSolo, Solo), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropNightTakeoff, NightTakeoffs), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropTachStart, TachStart), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropTachEnd, TachEnd), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropInstructorName, InstructorName), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropPassengerNames, JoinStrings(PassengerNames)), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropStudentName, JoinStrings(StudentNames)), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropNameOfExaminer, JoinStrings(ExaminerNames)), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropGroundInstructionGiven, DualGiven > 0 ? GroundTraining : 0), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropGroundInstructionReceived, DualReceived > 0 ? GroundTraining : 0), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropFlightReview, FlightReview), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropIPC, IPC), PropertyWithValue(CustomPropertyType.KnownProperties.IDPropCheckRide, Checkride) }).ToArray() }; return(le); }
private void CheckIFRIssues(LogbookEntryBase le) { AddConditionalIssue(le.Approaches > 0 && !le.CustomProperties.PropertyExistsWithID(CustomPropertyType.KnownProperties.IDPropApproachName) && !ApproachDescription.ExtractApproaches(le.Comment).Any(), LintOptions.IFRIssues, Resources.FlightLint.warningIFRNoApproachDescription); AddConditionalIssue(le.SimulatedIFR > 0 && le.Dual == 0 && currentAircraft.InstanceType == AircraftInstanceTypes.RealAircraft && !le.CustomProperties.PropertyExistsWithID(CustomPropertyType.KnownProperties.IDPropSafetyPilotName) && !le.CustomProperties.PropertyExistsWithID(CustomPropertyType.KnownProperties.IDPropNameOfExaminer), LintOptions.IFRIssues, Resources.FlightLint.warningIFRNoSafetyPilot); AddConditionalIssue((le.Approaches > 0 || le.fHoldingProcedures) && le.SimulatedIFR + le.IMC == 0, LintOptions.IFRIssues, Resources.FlightLint.warningIFRApproachesButNoIFR); }