private string ForTableFlightRecords(PrintOptions printOptions = null) { AirportStatUtils.AirportStatsLogger(Log.FromPool("").WithCodepoint()); string str = string.Empty; IOrderedEnumerable <FlightRecord> flightRecords = string.IsNullOrWhiteSpace(printOptions.AirlineName) ? flights[printOptions.Day].OrderBy(x => x.arrivalTime).ThenBy(x => x.airline) : flights[printOptions.Day].Where(x => x.airline == printOptions.AirlineName).OrderBy(x => x.arrivalTime).ThenBy(x => x.airline); if (!flightRecords.Any()) { return(str); } str += "<tbody>"; bool oddRow = false; foreach (FlightRecord fr in flightRecords) { str += $"<tr{(oddRow ? " class=\"oddRow\"" : string.Empty)}>\n"; if (string.IsNullOrWhiteSpace(printOptions.AirlineName)) { str += $"<td><a href=\"/{fr.airline}?Day={printOptions.Day}\">{fr.airline}</a></td>\n"; } str += $"<td class=\"None\"><a class=\"ajax-dialog\" href=\"/aircraftstats?aircraft={fr.aircraft}\" rel=\"#dialog\">{fr.aircraft}</a></td>\n"; str += $"<td class=\"None\">{fr.originalGate}</td>\n"; str += $"<td class=\"None\">{DateTime.MinValue.AddSeconds(fr.arrivalTime * 60):t}</td>\n"; str += $"<td class=\"{(fr.actual_arrivalTime <= 0 ? AirportStatUtils.InfoLevels.None : fr.actual_arrivalTime > fr.arrivalTime ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)}\">{(fr.actual_arrivalTime > 0 ? DateTime.MinValue.AddSeconds(fr.actual_arrivalTime * 60).ToString("t") : string.Empty)}</td>\n"; str += $"<td class=\"None\">{DateTime.MinValue.AddSeconds(fr.departureTime * 60):t}</td>\n"; str += $"<td class=\"{(fr.actual_departureTime <= 0 ? AirportStatUtils.InfoLevels.None : fr.actual_departureTime - fr.departureTime > 15 ? AirportStatUtils.InfoLevels.Warning : fr.actual_departureTime - fr.departureTime > 0 ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)}\">{(fr.actual_departureTime > 0 ? DateTime.MinValue.AddSeconds(fr.actual_departureTime * 60).ToString("t") : string.Empty)}</td>\n"; str += $"<td class=\"None\">{fr.nArriving:#}</td>\n"; str += $"<td class=\"None\">{(fr.actual_arrivalTime > 0 ? new TimeSpan(0, 0, (int)fr.time_deplaning * 60).ToString("g") : string.Empty)}</td>\n"; str += $"<td class=\"None\">{fr.nDeparting:#}</td>\n"; str += $"<td class=\"None\">{fr.nCheckedIn:#}</td>\n"; str += $"<td class=\"{(fr.actual_departureTime <=0 ? AirportStatUtils.InfoLevels.None : fr.nBoarded < fr.nDeparting ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)}\">{fr.nBoarded:#}</td>\n"; str += $"<td class=\"None\">{(fr.nBoarded > 0 ? new TimeSpan(0, 0, (int)fr.time_boarding * 60).ToString("g") : string.Empty)}</td>\n"; str += $"<td class=\"None\">{fr.nArrivalBags:#}</td>\n"; str += $"<td class=\"None\">{fr.nBagsUnloaded:#}</td>\n"; str += $"<td class=\"None\">{(fr.nBagsUnloaded > 0 ? DateTime.MinValue.AddSeconds(fr.time_bag_unload * 60).ToString("t") : string.Empty)}</td>\n"; str += $"<td class=\"None\">{fr.nDepartingBags:#}</td>\n"; str += $"<td class=\"{(fr.actual_departureTime <= 0 ? AirportStatUtils.InfoLevels.None : fr.nBagsLoaded < fr.nDepartingBags ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)}\">{fr.nBagsLoaded:#}</td>\n"; str += $"<td class=\"None\">{(fr.nBagsLoaded > 0 ? new TimeSpan(0, 0, (int)fr.time_bag_load * 60).ToString("g") : string.Empty)}</td>\n"; str += $"<td class=\"None\">{fr.nFuelRequested / 1000:#,#}</td>\n"; str += $"<td class=\"{(fr.actual_departureTime <=0 ? AirportStatUtils.InfoLevels.None : fr.nFuelRefueled < fr.nFuelRequested ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)}\">{fr.nFuelRefueled / 1000:#,#}</td>\n"; string st = string.Empty; foreach (Flight.Status stat in Enum.GetValues(typeof(Flight.Status))) { if (AirportStatUtils.HasStatus(fr.status, stat)) { st += i18n.Get("TBFlash.AirportStats.flightstatus." + Enum.GetName(typeof(Flight.Status), stat)) + "<br/>"; } } str += $"<td class=\"None\">{st}</td>\n"; str += $"<td class=\"{(fr.reason.ToString().Length > 5 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)}\">{i18n.Get("UI.strings.flightstatusreason.") + fr.reason.ToString()}</td>\n"; str += "</tr>\n"; oddRow = !oddRow; } str += "</tbody>"; return(str); }
private bool LoadFuelStats(string airline) { AirportStatUtils.AirportStatsLogger(Log.FromPool("").WithCodepoint()); Title = i18n.Get("TBFlash.AirportStats.json.fuelStats") + $": {airline}"; Type = Types.multiAxisLine; NumSeries = 5; YAxisLabel = i18n.Get("TBFlash.AirportStats.json.litersOfFuel"); YAxisLabel2 = i18n.Get("TBFlash.AirportStats.json.planesServed"); dataArray = new string[NumSeries + 1, (GameTimer.Day <= 30 ? GameTimer.Day : 30) + additionalColumns]; int j = additionalColumns - 1; for (int i = GameTimer.Day; i >= (GameTimer.Day > 30 ? GameTimer.Day - 29 : 1); i--) { j++; IEnumerable <FlightRecord> flightRecords = Game.current.flightRecords.GetForDay(i - 1).Where(x => x.airline == airline); dataArray[0, j] = i.ToString(); dataArray[1, j] = (flightRecords.Sum(x => x.nFuelRequested) / 1000).ToString("F0"); dataArray[2, j] = (flightRecords.Sum(x => x.nFuelRefueled) / 1000).ToString("F0"); dataArray[3, j] = (flightRecords.Count(x => x.nFuelRefueled > 0)).ToString("F0"); dataArray[4, j] = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.Departed) && x.nFuelRefueled == 0 && x.nFuelRequested > 0).ToString("F0"); dataArray[5, j] = CalculateAverageFuelCost(i).ToString("F2"); } dataArray[1, 0] = i18n.Get("TBFlash.AirportStats.json.fuelRequested"); dataArray[2, 0] = i18n.Get("TBFlash.AirportStats.json.fuelProvided"); dataArray[3, 0] = i18n.Get("TBFlash.AirportStats.json.servedFuel"); dataArray[4, 0] = i18n.Get("TBFlash.AirportStats.json.fuelingFailures"); dataArray[5, 0] = i18n.Get("TBFlash.AirportStats.json.fuelPrice"); dataArray[1, 1] = "fuelReq"; dataArray[2, 1] = "fuelProv"; dataArray[3, 1] = "served"; dataArray[4, 1] = "failed"; dataArray[5, 1] = "price"; dataArray[1, 2] = "ivory"; dataArray[2, 2] = "green"; dataArray[3, 2] = "cyan"; dataArray[4, 2] = "red"; dataArray[5, 2] = "purple"; dataArray[1, 3] = "2"; dataArray[2, 3] = "1"; dataArray[3, 3] = "4"; dataArray[4, 3] = "5"; dataArray[5, 3] = "3"; dataArray[1, 6] = nameof(YAxisTypes.yAxisLeft); dataArray[2, 6] = nameof(YAxisTypes.yAxisLeft); dataArray[3, 6] = nameof(YAxisTypes.yAxisRight); dataArray[5, 6] = nameof(YAxisTypes.yAxisRight2); for (int i = 1; i <= NumSeries; i++) { dataArray[i, 5] = "visible"; } return(true); }
private string[,] LoadArray(Airline airline, int day) { IOrderedEnumerable <FlightRecord> flightRecords = airline == null ? Game.current.flightRecords.GetForDay(day - 1).OrderBy(x => x.arrivalTime).ThenBy(x => x.airline) : Game.current.flightRecords.GetForDay(day - 1).Where(x => x.airline == airline.name).OrderBy(x => x.arrivalTime).ThenBy(x => x.airline); int numFlights = flightRecords.Count(); string[,] arr = new string[numFlights + 1, arrayCols]; for (int i = 0; i < arrayCols; i++) { arr[0, i] = i18n.Get($"TBFlash.AirportStats.AirlineDailyStats.stats{i}"); } for (int i = 1; i <= numFlights; i++) { FlightRecord fr = flightRecords.ElementAt(i - 1); arr[i, 0] = fr.airline; arr[i, 1] = fr.aircraft; arr[i, 2] = AirportStatUtils.FormatTime(fr.arrivalTime * 60, true); arr[i, 3] = fr.actual_arrivalTime > 0 ? AirportStatUtils.FormatTime(fr.actual_arrivalTime * 60, true) : string.Empty; arr[i, 4] = AirportStatUtils.FormatTime(fr.departureTime * 60, true); arr[i, 5] = fr.actual_departureTime > 0 ? AirportStatUtils.FormatTime(fr.actual_departureTime * 60, true) : string.Empty; arr[i, 6] = fr.nArriving.ToString("#"); arr[i, 7] = fr.actual_arrivalTime > 0 ? AirportStatUtils.FormatTime(fr.time_deplaning * 60) : string.Empty; arr[i, 8] = fr.nDeparting.ToString("#"); arr[i, 9] = fr.nCheckedIn.ToString("#"); arr[i, 10] = fr.nBoarded.ToString("#"); arr[i, 11] = fr.nBoarded > 0 ? AirportStatUtils.FormatTime(fr.time_boarding * 60) : string.Empty; arr[i, 12] = fr.nArrivalBags.ToString("#"); arr[i, 13] = fr.nBagsUnloaded.ToString("#"); arr[i, 14] = fr.nBagsUnloaded > 0 ? AirportStatUtils.FormatTime(fr.time_bag_unload * 60, true) : string.Empty; arr[i, 15] = fr.nDepartingBags.ToString("#"); arr[i, 16] = fr.nBagsLoaded.ToString("#"); arr[i, 17] = fr.nBagsLoaded > 0 ? AirportStatUtils.FormatTime(fr.time_bag_load * 60) : string.Empty; arr[i, 18] = (fr.nFuelRequested / 1000).ToString("#,###"); arr[i, 19] = (fr.nFuelRefueled / 1000).ToString("#,###"); string st = string.Empty; foreach (Flight.Status stat in Enum.GetValues(typeof(Flight.Status))) { if (AirportStatUtils.HasStatus(fr.status, stat)) { st += i18n.Get("TBFlash.AirportStats.flightstatus." + Enum.GetName(typeof(Flight.Status), stat)) + "<br/>"; } } arr[i, 20] = st; arr[i, 21] = i18n.Get("UI.strings.flightstatusreason.") + fr.reason.ToString(); } return(arr); }
private string[,] LoadArray(Airline airline) { int numdays = GameTimer.Day <= 30 ? GameTimer.Day : 30; AirportStatUtils.AirportStatsLogger(Log.FromPool($"GameTimer:{GameTimer.Day}, numdays:{numdays}").WithCodepoint()); string[,] arr = new string[arrayRows, numdays + 1]; for (int i = 0; i < arrayRows; i++) { arr[i, 0] = i18n.Get($"TBFlash.AirportStats.AirlineCompanyStats.stats{i}"); } AirportStatUtils.AirportStatsLogger(Log.FromPool("").WithCodepoint()); int j = 0; for (int i = GameTimer.Day; i >= (GameTimer.Day > 30 ? GameTimer.Day - 29 : 1); i--) { j++; IEnumerable <FlightRecord> flightRecords = Game.current.flightRecords.GetForDay(i - 1).Where(x => x.airline == airline.name); arr[0, j] = flightRecords.Any() ? flightRecords.Count().ToString("#,###"):"None"; arr[1, j] = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.DelayedArrival)).ToString("#,###"); arr[2, j] = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.RequiresCrew)).ToString("#,###"); arr[3, j] = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.Departed) && !AirportStatUtils.HasStatus(x.status, global::Flight.Status.DelayedDeparture)).ToString("#,###"); arr[4, j] = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.DelayedDeparture)).ToString("#,###"); arr[5, j] = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.Canceled)).ToString("#,###"); arr[6, j] = flightRecords.Count(x => x.reason == global::Flight.StatusReason.AirportInvalid).ToString("#,###"); arr[7, j] = flightRecords.Count(x => x.reason == global::Flight.StatusReason.Weather).ToString("#,###"); arr[8, j] = flightRecords.Count(x => x.reason == global::Flight.StatusReason.Runway).ToString("#,###"); arr[9, j] = flightRecords.Count(x => x.reason == global::Flight.StatusReason.Gate).ToString("#,###"); arr[10, j] = flightRecords.Count(x => x.reason == global::Flight.StatusReason.Expired).ToString("#,###"); arr[11, j] = flightRecords.Count(x => x.reason == global::Flight.StatusReason.Reneged).ToString("#,###"); arr[12, j] = flightRecords.Sum(x => x.nArriving).ToString("#,###"); arr[13, j] = flightRecords.Sum(x => x.nDeparting).ToString("#,###"); arr[14, j] = flightRecords.Sum(x => x.nCheckedIn).ToString("#,###"); arr[15, j] = flightRecords.Sum(x => x.nBoarded).ToString("#,###"); arr[16, j] = flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.Departed) ? x.nDeparting - x.nBoarded : 0).ToString("#,###"); arr[17, j] = AirportStatUtils.FormatTime(flightRecords.Sum(x => x.time_deplaning) * 60f); arr[18, j] = AirportStatUtils.FormatTime(flightRecords.Sum(x => x.nBoarded > 0 ? x.time_boarding : 0) * 60f); arr[19, j] = (flightRecords.Sum(x => x.nFuelRequested) / 1000).ToString("#,###"); arr[20, j] = (flightRecords.Sum(x => x.nFuelRefueled) / 1000).ToString("#,###"); arr[21, j] = flightRecords.Sum(x => x.nBagsUnloaded).ToString("#,###"); arr[22, j] = flightRecords.Sum(x => x.nBagsLoaded).ToString("#,###"); arr[23, j] = flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.Departed) ? x.nDepartingBags - x.nBagsLoaded : 0).ToString("#,###"); arr[24, j] = AirportStatUtils.FormatTime(flightRecords.Sum(x => x.nBagsLoaded > 0 ? x.time_bag_load : 0) * 60f); } return(arr); }
private bool LoadFlightStats() { AirportStatUtils.AirportStatsLogger(Log.FromPool("").WithCodepoint()); Title = i18n.Get("TBFlash.AirportStats.json.flightStats"); Type = Types.line; NumSeries = 4; YAxisLabel = i18n.Get("TBFlash.AirportStats.json.numberFlights"); dataArray = new string[NumSeries + 1, (GameTimer.Day <= 30 ? GameTimer.Day : 30) + additionalColumns]; int j = additionalColumns - 1; for (int i = GameTimer.Day; i >= (GameTimer.Day > 30 ? GameTimer.Day - 29 : 1); i--) { j++; if (!Game.current.GameReports.TryGetValue(i, out GamedayReportingData GRD)) { break; } IEnumerable <FlightRecord> FlightRecords = Game.current.flightRecords.GetForDay(i - 1); dataArray[0, j] = i.ToString(); dataArray[1, j] = GRD.FlightsCount.ToString("F0"); dataArray[2, j] = (FlightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.Departed)) - FlightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.DelayedDeparture))).ToString("F0"); dataArray[3, j] = FlightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.DelayedDeparture)).ToString("F0"); dataArray[4, j] = GRD.FlightsCanceled.ToString("F0"); } dataArray[1, 0] = i18n.Get("TBFlash.AirportStats.json.scheduledDepartures"); dataArray[2, 0] = i18n.Get("TBFlash.AirportStats.json.ontimeDepartures"); dataArray[3, 0] = i18n.Get("TBFlash.AirportStats.json.delayedDepartures"); dataArray[4, 0] = i18n.Get("TBFlash.AirportStats.json.canceled"); dataArray[1, 1] = "schedDepart"; dataArray[2, 1] = "ontimeDepart"; dataArray[3, 1] = "delayDepart"; dataArray[4, 1] = "canx"; dataArray[1, 2] = "white"; dataArray[2, 2] = "green"; dataArray[3, 2] = "cyan"; dataArray[4, 2] = "red"; dataArray[1, 3] = "4"; dataArray[2, 3] = "1"; dataArray[3, 3] = "2"; dataArray[4, 3] = "3"; for (int i = 1; i <= NumSeries; i++) { dataArray[i, 5] = "visible"; } return(true); }
private bool LoadPaxStats(string airline) { AirportStatUtils.AirportStatsLogger(Log.FromPool("").WithCodepoint()); Title = i18n.Get("TBFlash.AirportStats.json.paxStats") + $": {airline}"; Type = Types.line; NumSeries = 3; YAxisLabel = i18n.Get("TBFlash.AirportStats.json.numPax"); dataArray = new string[NumSeries + 1, (GameTimer.Day <= 30 ? GameTimer.Day : 30) + additionalColumns]; int j = additionalColumns - 1; for (int i = GameTimer.Day; i >= (GameTimer.Day > 30 ? GameTimer.Day - 29 : 1); i--) { j++; IEnumerable <FlightRecord> flightRecords = Game.current.flightRecords.GetForDay(i - 1).Where(x => x.airline == airline); dataArray[0, j] = i.ToString(); dataArray[1, j] = flightRecords.Sum(x => x.nArriving).ToString("F0"); dataArray[2, j] = flightRecords.Sum(x => x.nBoarded).ToString("F0"); dataArray[3, j] = flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.Departed) ? x.nDeparting - x.nBoarded : 0).ToString("F0"); } dataArray[1, 0] = i18n.Get("TBFlash.AirportStats.json.arriving"); dataArray[2, 0] = i18n.Get("TBFlash.AirportStats.json.boarded"); dataArray[3, 0] = i18n.Get("TBFlash.AirportStats.json.missedFlight"); dataArray[1, 1] = "arrive"; dataArray[2, 1] = "board"; dataArray[3, 1] = "missed"; dataArray[1, 2] = "ivory"; dataArray[2, 2] = "green"; dataArray[3, 2] = "red"; dataArray[1, 3] = "3"; dataArray[2, 3] = "1"; dataArray[3, 3] = "2"; for (int i = 1; i <= NumSeries; i++) { dataArray[i, 5] = "visible"; } return(true); }
private string[,] LoadLifetimeArray() { int numdays = GameTimer.Day <= 30 ? GameTimer.Day : 30; GameLifetimeStats GLS = Game.current.lifetimeStats; string[,] arr = new string[arrayRows, numdays + 2]; for (int i = 0; i < arrayRows; i++) { arr[i, 0] = i18n.Get($"TBFlash.AirportStats.LifetimeStats.stats{i}"); } arr[1, 1] = GLS.flOnTime.ToString("#,###"); arr[2, 1] = GLS.flDelays.ToString("#,###"); arr[3, 1] = GLS.flCancels.ToString("#,###"); arr[4, 1] = GLS.flReneges.ToString("#,###"); arr[5, 1] = GLS.Landings.ToString("#,###"); arr[6, 1] = GLS.Takeoffs.ToString("#,###"); arr[9, 1] = GLS.pBoarded.ToString("#,###"); arr[10, 1] = GLS.pMissed.ToString("#,###"); arr[11, 1] = CalculateAverageFuelCost(0).ToString("C2"); arr[12, 1] = (GLS.fuelRequested / 1000).ToString("#,###"); arr[13, 1] = (GLS.fuelfRefueled / 1000).ToString("#,###"); arr[14, 1] = GLS.planesServedFuel.ToString("#,###"); arr[16, 1] = GLS.pBagsLoaded.ToString("#,###"); arr[17, 1] = GLS.pBagsUnloaded.ToString("#,###"); arr[18, 1] = GLS.pBagSuccess.ToString("#,###"); arr[19, 1] = GLS.pBagFail.ToString("#,###"); arr[20, 1] = GLS.outdoorBaggageLoads.ToString("#,###"); arr[21, 1] = GLS.mAdvertising.ToString("C0"); arr[23, 1] = GLS.mLoans.ToString("C0"); arr[24, 1] = GLS.mFuelRev.ToString("C0"); arr[29, 1] = GLS.mRetailRev.ToString("C0"); arr[30, 1] = GLS.mRwyUsageRev.ToString("C0"); arr[31, 1] = GLS.mTerminalUsageRev.ToString("C0"); arr[34, 1] = GLS.mRev.ToString("C0"); arr[36, 1] = GLS.mInterest.ToString("C0"); arr[44, 1] = GLS.mRetailExpense.ToString("C0"); arr[45, 1] = GLS.mStaffWages.ToString("C0"); arr[47, 1] = GLS.mIncomeTax.ToString("C0"); arr[48, 1] = GLS.mPropertyTax.ToString("C0"); arr[51, 1] = GLS.mExpense.ToString("C0"); arr[52, 1] = GLS.sHires.ToString("#,###"); arr[53, 1] = GLS.sFires.ToString("#,###"); arr[54, 1] = AirportStatUtils.FormatTime(GLS.tPaused); arr[55, 1] = AirportStatUtils.FormatTime(GLS.tSpeed1); arr[56, 1] = AirportStatUtils.FormatTime(GLS.tSpeed2); arr[57, 1] = AirportStatUtils.FormatTime(GLS.tSpeed3); arr[58, 1] = AirportStatUtils.FormatTime(GLS.tInactive); arr[59, 1] = GLS.tInteractions.ToString("#,###"); arr[60, 1] = GLS.tClicks.ToString("#,###"); arr[61, 1] = GLS.tClicksAlt.ToString("#,###"); int j = 1; for (int i = GameTimer.Day; i >= (GameTimer.Day > 30 ? GameTimer.Day - 29 : 1); i--) { j++; if (!Game.current.GameReports.TryGetValue(i, out GamedayReportingData GRD)) { break; } IEnumerable <FlightRecord> FlightRecords = Game.current.flightRecords.GetForDay(i - 1); arr[0, j] = GRD.FlightsCount.ToString("#,###"); arr[1, j] = FlightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.Departed) && !AirportStatUtils.HasStatus(x.status, global::Flight.Status.DelayedDeparture)).ToString("#,###"); arr[2, j] = FlightRecords.Count(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.DelayedDeparture)).ToString("#,###"); arr[3, j] = GRD.FlightsCanceled.ToString("#,###"); arr[7, j] = GRD.NumArrivalPax.ToString("#,###"); arr[8, j] = GRD.NumConnectPax.ToString("#,###"); arr[9, j] = GRD.BoardedFlight.ToString("#,###"); arr[10, j] = GRD.MissedFlight.ToString("#,###"); arr[11, j] = CalculateAverageFuelCost(i).ToString("C2"); arr[12, j] = (FlightRecords.Sum(x => x.nFuelRequested) / 1000).ToString("#,###"); arr[13, j] = (FlightRecords.Sum(x => x.nFuelRefueled) / 1000).ToString("#,###"); arr[14, j] = (FlightRecords.Count(x => x.nFuelRefueled > 0)).ToString("#,###"); arr[15, j] = GRD.FuelFailures.ToString("#,###"); arr[16, j] = FlightRecords.Sum(x => x.nBagsLoaded).ToString("#,###"); arr[17, j] = FlightRecords.Sum(x => x.nBagsUnloaded).ToString("#,###"); arr[19, j] = FlightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, global::Flight.Status.Departed) ? x.nDepartingBags - x.nBagsLoaded : 0).ToString("#,###"); arr[21, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Advertising, true); arr[22, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Airline_Fees, true); arr[23, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Bank, true); arr[24, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Fuel, true); arr[25, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Grant, true); arr[26, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Materials, true); arr[27, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Parking, true); arr[28, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Research, true); arr[29, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Retail, true); arr[30, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Runway_Fees, true); arr[31, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Terminal_Fees, true); arr[32, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Staff, true); arr[33, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Undefined, true); arr[35, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Airline_Fees, false); arr[36, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Bank, false); arr[37, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Fuel, false); arr[38, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Grant, false); arr[39, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Infrastructure, false); arr[40, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Land_Purchase, false); arr[41, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Maintenance, false); arr[42, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Materials, false); arr[43, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Research, false); arr[44, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Retail, false); arr[45, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Staff, false); arr[46, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Taxes, false); arr[49, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Transportation, false); arr[50, j] = GetDailyMoneyTotal(GRD, GamedayReportingData.MoneyCategory.Undefined, false); } return(arr); }
static private void LoadAirlineData(int start, int end) { AirportStatUtils.AirportStatsLogger(Log.FromPool($"start: {start}; end: {end}").WithCodepoint()); airportData.RemoveAirlineDataStats(start, end); Dictionary <AircraftGate.GateSize, int> gateSizes = new Dictionary <AircraftGate.GateSize, int> { { AircraftGate.GateSize.Small, 0 }, { AircraftGate.GateSize.Large, 0 }, { AircraftGate.GateSize.Extra_Large, 0 } }; foreach (Airline airline in AirlineManager.AllAirlines()) { AirlineDailyData thisAirline = airlineData.GetAirlineDailyData(airline.name); thisAirline.RemoveStats(start, end); for (int i = end; i >= start; i--) { IEnumerable <FlightRecord> flightRecords = Game.current.flightRecords.GetForDay(i).Where(x => x.airline == airline.name); if (flightRecords?.Any() != true) { continue; } // Load Flight Stats int nSchedFlights = flightRecords.Count(); int ontimeDepart = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) && !AirportStatUtils.HasStatus(x.status, Flight.Status.DelayedDeparture)); int delDep = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.DelayedDeparture)); int canx = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Canceled)); thisAirline.flightStats.nSchedFlights.AddStat(i, new IntStat(nSchedFlights)); thisAirline.flightStats.nDelayedArrival.AddStat(i, new IntStat(flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.DelayedArrival)))); thisAirline.flightStats.nRequiresCrew.AddStat(i, new IntStat(flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.RequiresCrew)))); thisAirline.flightStats.nOntimeDeparture.AddStat(i, new IntStat(ontimeDepart)); thisAirline.flightStats.nDelayedDeparture.AddStat(i, new IntStat(delDep, delDep > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); thisAirline.flightStats.nCancelled.AddStat(i, new IntStat(canx, canx > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); thisAirline.flightStats.nAirportInvalid.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.AirportInvalid))); thisAirline.flightStats.nWeather.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Weather))); thisAirline.flightStats.nRunway.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Runway))); thisAirline.flightStats.nGate.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Gate))); thisAirline.flightStats.nExpired.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Expired))); thisAirline.flightStats.nReneged.AddStat(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Reneged))); thisAirline.flightStats.ontimeDeparturePer.AddStat(i, new AverageStat(ontimeDepart, ontimeDepart + delDep + canx, typeof(PercentageStat))); airportData.flightStats.nSchedFlights.AddToValue(i, new IntStat(nSchedFlights)); airportData.flightStats.nDelayedArrival.AddToValue(i, new IntStat(flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.DelayedArrival)))); airportData.flightStats.nRequiresCrew.AddToValue(i, new IntStat(flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.RequiresCrew)))); airportData.flightStats.nOntimeDeparture.AddToValue(i, new IntStat(ontimeDepart)); airportData.flightStats.nDelayedDeparture.AddToValue(i, new IntStat(delDep, delDep > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); airportData.flightStats.nCancelled.AddToValue(i, new IntStat(canx, canx > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); airportData.flightStats.nAirportInvalid.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.AirportInvalid))); airportData.flightStats.nWeather.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Weather))); airportData.flightStats.nRunway.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Runway))); airportData.flightStats.nGate.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Gate))); airportData.flightStats.nExpired.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Expired))); airportData.flightStats.nReneged.AddToValue(i, new IntStat(flightRecords.Count(x => x.reason == Flight.StatusReason.Reneged))); airportData.flightStats.ontimeDeparturePer.AddToValue(i, new AverageStat(ontimeDepart, ontimeDepart + delDep + canx, typeof(PercentageStat))); //Load Passenger Stats int arrivingPax = flightRecords.Sum(x => x.nArriving); int boardedPax = flightRecords.Sum(x => x.nBoarded); int schedDepartingPax = flightRecords.Sum(x => x.nDeparting); int missed = flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) || AirportStatUtils.HasStatus(x.status, Flight.Status.Canceled) ? x.nDeparting - x.nBoarded : 0); double timeBoarding = flightRecords.Sum(x => x.nBoarded > 0 ? x.time_boarding : 0) * 60f; thisAirline.passengerStats.nArriving.AddStat(i, new IntStat(arrivingPax)); thisAirline.passengerStats.nBoarded.AddStat(i, new IntStat(boardedPax)); thisAirline.passengerStats.nCheckedIn.AddStat(i, new IntStat(flightRecords.Sum(x => x.nCheckedIn))); thisAirline.passengerStats.nSchedDep.AddStat(i, new IntStat(schedDepartingPax)); thisAirline.passengerStats.nMissed.AddStat(i, new IntStat(missed > 0 ? missed : 0, missed > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); thisAirline.passengerStats.timeBoarding.AddStat(i, new TimeStat(timeBoarding)); thisAirline.passengerStats.timeDeplaning.AddStat(i, new TimeStat(flightRecords.Sum(x => x.time_deplaning) * 60f)); thisAirline.passengerStats.arrPaxPerFlt.AddStat(i, new AverageStat(arrivingPax, nSchedFlights, typeof(IntStat))); thisAirline.passengerStats.departPaxPerFlt.AddStat(i, new AverageStat(schedDepartingPax, nSchedFlights, typeof(IntStat))); thisAirline.passengerStats.avgBoardTime.AddStat(i, new AverageStat(timeBoarding, ontimeDepart + delDep + canx, typeof(TimeStat))); thisAirline.passengerStats.boardedPerFlt.AddStat(i, new AverageStat(boardedPax, boardedPax + missed, typeof(PercentageStat))); airportData.passengerStats.nArriving.AddToValue(i, new IntStat(arrivingPax)); airportData.passengerStats.nBoarded.AddToValue(i, new IntStat(boardedPax)); airportData.passengerStats.nCheckedIn.AddToValue(i, new IntStat(flightRecords.Sum(x => x.nCheckedIn))); airportData.passengerStats.nSchedDep.AddToValue(i, new IntStat(schedDepartingPax)); airportData.passengerStats.nMissed.AddToValue(i, new IntStat(missed > 0 ? missed : 0, missed > 0 ? AirportStatUtils.InfoLevels.Warning : AirportStatUtils.InfoLevels.None)); airportData.passengerStats.timeBoarding.AddToValue(i, new TimeStat(timeBoarding)); airportData.passengerStats.timeDeplaning.AddToValue(i, new TimeStat(flightRecords.Sum(x => x.time_deplaning) * 60f)); airportData.passengerStats.arrPaxPerFlt.AddToValue(i, new AverageStat(arrivingPax, nSchedFlights, typeof(IntStat))); airportData.passengerStats.departPaxPerFlt.AddToValue(i, new AverageStat(schedDepartingPax, nSchedFlights, typeof(IntStat))); airportData.passengerStats.avgBoardTime.AddToValue(i, new AverageStat(timeBoarding, ontimeDepart + delDep + canx, typeof(TimeStat))); airportData.passengerStats.boardedPerFlt.AddToValue(i, new AverageStat(boardedPax, boardedPax + missed, typeof(PercentageStat))); //Load Fuel Stats int fuelDel = Convert.ToInt32(flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) ? x.nFuelRefueled : 0) / 1000); int fuelReq = Convert.ToInt32(flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) ? x.nFuelRequested : 0) / 1000); int fuelFailures = flightRecords.Count(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) && x.nFuelRequested > 0 && x.nFuelRefueled == 0); thisAirline.fuelStats.fuelDelivered.AddStat(i, new IntStat(fuelDel, fuelDel < fuelReq ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); thisAirline.fuelStats.fuelRequested.AddStat(i, new IntStat(fuelReq)); thisAirline.fuelStats.fuelingFailures.AddStat(i, new IntStat(fuelFailures, fuelFailures > 0 ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); thisAirline.fuelStats.planesRefueled.AddStat(i, new IntStat(flightRecords.Count(x => x.nFuelRefueled > 0))); airportData.fuelStats.fuelDelivered.AddToValue(i, new IntStat(fuelDel, fuelDel < fuelReq ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); airportData.fuelStats.fuelRequested.AddToValue(i, new IntStat(fuelReq)); airportData.fuelStats.fuelingFailures.AddToValue(i, new IntStat(fuelFailures, fuelFailures > 0 ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); airportData.fuelStats.planesRefueled.AddToValue(i, new IntStat(flightRecords.Count(x => x.nFuelRefueled > 0))); // Load Luggage Stats int lostBaggage = flightRecords.Sum(x => AirportStatUtils.HasStatus(x.status, Flight.Status.Departed) ? x.nDepartingBags - x.nBagsLoaded : 0); thisAirline.luggageStats.arrivingBags.AddStat(i, new IntStat(flightRecords.Sum(x => x.nArrivalBags))); thisAirline.luggageStats.bagsLoaded.AddStat(i, new IntStat(flightRecords.Sum(x => x.nBagsLoaded))); thisAirline.luggageStats.bagsUnloaded.AddStat(i, new IntStat(flightRecords.Sum(x => x.nBagsUnloaded))); thisAirline.luggageStats.departingBags.AddStat(i, new IntStat(flightRecords.Sum(x => x.nDepartingBags))); thisAirline.luggageStats.lostBags.AddStat(i, new IntStat(lostBaggage, lostBaggage > 0 ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); thisAirline.luggageStats.timeLoadingBags.AddStat(i, new TimeStat(flightRecords.Sum(x => x.nBagsLoaded > 0 ? x.time_bag_load : 0) * 60f)); airportData.luggageStats.arrivingBags.AddToValue(i, new IntStat(flightRecords.Sum(x => x.nArrivalBags))); airportData.luggageStats.bagsLoaded.AddToValue(i, new IntStat(flightRecords.Sum(x => x.nBagsLoaded))); airportData.luggageStats.bagsUnloaded.AddToValue(i, new IntStat(flightRecords.Sum(x => x.nBagsUnloaded))); airportData.luggageStats.departingBags.AddToValue(i, new IntStat(flightRecords.Sum(x => x.nDepartingBags))); airportData.luggageStats.lostBags.AddToValue(i, new IntStat(lostBaggage, lostBaggage > 0 ? AirportStatUtils.InfoLevels.Info : AirportStatUtils.InfoLevels.None)); airportData.luggageStats.timeLoadingBags.AddToValue(i, new TimeStat(flightRecords.Sum(x => x.nBagsLoaded > 0 ? x.time_bag_load : 0) * 60f)); //Load Gate Stats (into FlightStats) gateSizes[AircraftGate.GateSize.Small] = 0; gateSizes[AircraftGate.GateSize.Large] = 0; gateSizes[AircraftGate.GateSize.Extra_Large] = 0; foreach (FlightRecord fr in flightRecords) { AircraftConfig ac = AircraftConfigManager.FindByAnyName(fr.aircraft, false); if (ac != null) { gateSizes[ac.MinGateSize]++; } } foreach (KeyValuePair <AircraftGate.GateSize, int> kvp in gateSizes) { switch (kvp.Key) { case AircraftGate.GateSize.Small: thisAirline.flightStats.nSmallGates.AddStat(i, new IntStat(kvp.Value)); airportData.flightStats.nSmallGates.AddToValue(i, new IntStat(kvp.Value)); break; case AircraftGate.GateSize.Large: thisAirline.flightStats.nLargeGates.AddStat(i, new IntStat(kvp.Value)); airportData.flightStats.nLargeGates.AddToValue(i, new IntStat(kvp.Value)); break; case AircraftGate.GateSize.Extra_Large: thisAirline.flightStats.nXLGates.AddStat(i, new IntStat(kvp.Value)); airportData.flightStats.nXLGates.AddToValue(i, new IntStat(kvp.Value)); break; } } } } for (int i = end; i >= start; i--) { Game.current.GameReports.TryGetValue(i, out GamedayReportingData gamedayData); if (gamedayData == null) { continue; } airportData.passengerStats.nConnecting.AddStat(i, new IntStat(gamedayData.NumConnectPax)); airportData.fuelStats.avgFuelPrice.AddStat(i, new MoneyStat(GetAverageFuelCost(i), 2)); GamedayReportingData.MoneyCategory category; float val; foreach (string name in Enum.GetNames(typeof(GamedayReportingData.MoneyCategory))) { category = (GamedayReportingData.MoneyCategory)Enum.Parse(typeof(GamedayReportingData.MoneyCategory), name); if ((val = GetDailyMoneyTotal(gamedayData, category, true)) != 0) { airportData.revAndExpStats.revenueStats.AddStat(name, i, new MoneyStat(val)); } if ((val = GetDailyMoneyTotal(gamedayData, category, false)) != 0) { airportData.revAndExpStats.expenseStats.AddStat(name, i, new MoneyStat(val)); } } if ((val = GetDailyMoneyTotal(gamedayData, true)) != 0) { airportData.revAndExpStats.revenueStats.AddStat("total", i, new MoneyStat(val)); int boarded = ((IntStat)airportData.passengerStats.nBoarded.GetStat(i))?.GetValue() ?? 0; int missed = ((IntStat)airportData.passengerStats.nMissed.GetStat(i))?.GetValue() ?? 0; airportData.revAndExpStats.revenueStats.RevPerPax.AddStat(i, new AverageStat(val, boarded + missed, typeof(MoneyStat))); } if ((val = GetDailyMoneyTotal(gamedayData, false)) != 0) { airportData.revAndExpStats.expenseStats.AddStat("total", i, new MoneyStat(val)); } //set profits AirportStatUtils.AirportStatsLogger(Log.FromPool("Loading Profits").WithCodepoint()); val = ((MoneyStat)airportData.revAndExpStats.revenueStats.StatGroups["total"].GetStat(i))?.GetFloatValue() ?? 0; float netCost = -((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups["total"].GetStat(i))?.GetFloatValue() ?? 0; float operatingCost = netCost + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Taxes)].GetStat(i))?.GetFloatValue() ?? 0 - ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Bank)].GetStat(i))?.GetFloatValue() ?? 0; float grossCost = -(((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Fuel)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Infrastructure)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Land_Purchase)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Materials)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Retail)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Staff)].GetStat(i))?.GetFloatValue() ?? 0 + ((MoneyStat)airportData.revAndExpStats.expenseStats.StatGroups[nameof(GamedayReportingData.MoneyCategory.Maintenance)].GetStat(i))?.GetFloatValue() ?? 0); AirportStatUtils.AirportStatsLogger(Log.FromPool($"Revenue: {val}; NetCost: {netCost}; Operating: {operatingCost}; Gross: {grossCost}").WithCodepoint()); airportData.profitStats.GrossProfit.AddStat(i, new MoneyStat(val - grossCost)); airportData.profitStats.OperatingProfit.AddStat(i, new MoneyStat(val - operatingCost)); airportData.profitStats.NetProfit.AddStat(i, new MoneyStat(val - netCost)); if (val != 0) { if (val > grossCost) { airportData.profitStats.GrossMargin.AddStat(i, new PercentageStat((val - grossCost) / val)); } if (val > operatingCost) { airportData.profitStats.OperatingMargin.AddStat(i, new PercentageStat((val - operatingCost) / val)); } if (val > netCost) { airportData.profitStats.NetMargin.AddStat(i, new PercentageStat((val - netCost) / val)); } } AirportStatUtils.AirportStatsLogger(Log.FromPool("Completed Loading Profits").WithCodepoint()); } }