public override void ExamineFlight(ExaminerFlightRow cfr) { if (cfr == null) { throw new ArgumentNullException("cfr"); } if (!cfr.fIsRealAircraft) { return; } // 61.99 miMinTime.AddEvent(cfr.Total); // 61.99(a) miMinInstruction.AddEvent(cfr.Dual); // 61.99(a)(1) if (cfr.cLandingsThisFlight >= 4 && cfr.Dual > 0) { AirportList al = AirportListOfRoutes.CloneSubset(cfr.Route, true); if (al.MaxDistanceForRoute() >= 25.0) { miXCFlight.AddEvent(cfr.Dual); } } if (cfr.idCatClassOverride == CatClassID) { // 61.99(a)(2) if (DateTime.Now.AddCalendarMonths(-2).CompareTo(cfr.dtFlight) <= 0) { miTestPrep.AddEvent(cfr.Dual); } // 61.99(b) decimal soloTime = 0.0M; cfr.FlightProps.ForEachEvent(pf => { if (pf.PropertyType.IsSolo) { soloTime += pf.DecValue; } }); miMinSolo.AddEvent(soloTime); } }
public override string CSVFromDataTable(DataTable dt) { // We ignore the data table passed in - we have our data from Matches, which was initialized in CanParse. // Build up the list of CrewTrac objects first; we'll then fill in cross-country time. List <CrewTrac> lstCt = new List <CrewTrac>(); foreach (Match ctMatch in Matches) { GroupCollection gc = ctMatch.Groups; string szEmployees = gc["employees"].Value; // replace runs of 2 or more spaces with a tab for better finding boundaries (e.g., multiple employees). while (szEmployees.Contains(" ")) { szEmployees = szEmployees.Replace(" ", "\t"); } MatchCollection mcEmployees = regCrewMember.Matches(szEmployees); List <CrewTracEmployee> lst = new List <CrewTracEmployee>(); foreach (Match empMatch in mcEmployees) { GroupCollection gcEmployee = empMatch.Groups; if (!Enum.TryParse <CrewTracEmployee.CrewTracRole>(gcEmployee["pos"].Value, out CrewTracEmployee.CrewTracRole role)) { role = CrewTracEmployee.CrewTracRole.CA; } lst.Add(new CrewTracEmployee() { Role = role, Name = gcEmployee["empname"].Value }); } try { CrewTrac ct = new CrewTrac() { FlightNumber = String.IsNullOrEmpty(gc["flightnum"].Value) ? 0 : Convert.ToInt32(gc["flightnum"].Value, CultureInfo.CurrentCulture), Date = Convert.ToDateTime(gc["date"].Value, CultureInfo.CurrentCulture), From = gc["from"].Value, To = gc["to"].Value, BlockHours = gc["block"].Value.DecimalFromHHMM(), Tail = gc["tail"].Value, Model = gc["model"].Value, Landings = String.IsNullOrEmpty(gc["landings"].Value) ? 0 : Convert.ToInt32(gc["landings"].Value, CultureInfo.CurrentCulture), Employees = lst }; lstCt.Add(ct); } catch (Exception ex) when(ex is FormatException) { } } // Build up a list of airports so that we can determine cross-country time. StringBuilder sbRoutes = new StringBuilder(); foreach (CrewTrac ct in lstCt) { sbRoutes.AppendFormat(CultureInfo.CurrentCulture, " {0} {1}", ct.From, ct.To); } AirportList alRoutes = new AirportList(sbRoutes.ToString()); foreach (CrewTrac ct in lstCt) { AirportList alFlight = alRoutes.CloneSubset(ct.From + " " + ct.To); if (alFlight.MaxDistanceForRoute() > 50.0) { ct.CrossCountry = ct.BlockHours; } } using (DataTable dtDst = new DataTable()) { dtDst.Locale = CultureInfo.CurrentCulture; CSVImporter.InitializeDataTable(dtDst); foreach (CrewTrac ct in lstCt) { CSVImporter.WriteEntryToDataTable(ct.ToLogbookEntry(), dtDst); } return(CsvWriter.WriteToString(dtDst, true, true)); } }
public override string CSVFromDataTable(DataTable dt) { // We ignore the data table passed in - we have our data from Matches, which was initialized in CanParse. // Build up the list of CrewTrac objects first; we'll then fill in cross-country time. List <AAScheduler> lstAA = new List <AAScheduler>(); foreach (Match aaMatch in Matches) { GroupCollection gc = aaMatch.Groups; try { DateTime dtDep = Convert.ToDateTime(String.Format(CultureInfo.CurrentCulture, "{0} {1}", gc["startdate"].Value, gc["starttime"].Value), CultureInfo.CurrentCulture); DateTime dtArr = Convert.ToDateTime(String.Format(CultureInfo.CurrentCulture, "{0} {1}", gc["enddate"].Value, gc["endtime"].Value), CultureInfo.CurrentCulture); AAScheduler aas = new AAScheduler() { ScheduledDeparture = dtDep, ScheduledArrival = dtArr, BlockTime = gc["blocktime"].Value.DecimalFromHHMM(), FlightNumber = gc["flightnum"].Value, Deadhead = !String.IsNullOrEmpty(gc["deadhead"].Value), From = gc["from"].Value, To = gc["to"].Value, Sequence = gc["seq"].Value, Leg = String.IsNullOrEmpty(gc["leg"].Value) ? 0 : Convert.ToInt32(gc["leg"].Value, CultureInfo.CurrentCulture) }; lstAA.Add(aas); } catch (Exception ex) when(ex is FormatException) { } // Build up a list of airports so that we can determine cross-country time. StringBuilder sbRoutes = new StringBuilder(); foreach (AAScheduler aas in lstAA) { sbRoutes.AppendFormat(CultureInfo.CurrentCulture, " {0} {1}", aas.From, aas.To); } AirportList alRoutes = new AirportList(sbRoutes.ToString()); foreach (AAScheduler aas in lstAA) { AirportList alFlight = alRoutes.CloneSubset(aas.From + " " + aas.To); if (alFlight.MaxDistanceForRoute() > 50.0) { aas.CrossCountry = aas.BlockTime; } } } using (DataTable dtDst = new DataTable()) { dtDst.Locale = CultureInfo.CurrentCulture; CSVImporter.InitializeDataTable(dtDst); foreach (AAScheduler aa in lstAA) { CSVImporter.WriteEntryToDataTable(aa.ToLogbookEntry(), dtDst); } return(CsvWriter.WriteToString(dtDst, true, true)); } }