Пример #1
0
        public IHttpActionResult Post(AirlineManager manager)
        {
            try
            {
                mng.Create(manager);


                apiResp = new ApiResponse
                {
                    Message = "Action was executed"
                };

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                var MessageManage = new ApplicationMessageManagement();
                MessageManage.Create(bex.AppMessage);
                return(InternalServerError(new Exception(bex.ExceptionId + "-"
                                                         + bex.AppMessage.Message)));
            }
            catch (Exception ex)
            {
                ApplicationMessage msg = new ApplicationMessage
                {
                    Message = ex.Message
                };
                var MessageManage = new ApplicationMessageManagement();
                MessageManage.Create(msg);
                return(InternalServerError(new Exception(ex.Message)));
            }
        }
Пример #2
0
        public IHttpActionResult UpdateAndSendEmailRejected(AirlineManager manager)
        {
            try
            {
                var CorreoElectronico = manager.Email;
                var pass = manager.Password;
                mng.Update(manager);
                string Mensaje = "Estimado " + manager.FirstName + "  " + manager.LastName + " lamentamos informarle que su aerolínea ha sido rechazada por nuestra administración";
                ToolsHelper.SendMail(CorreoElectronico, "Denegación de cuenta", Mensaje);
                apiResp = new ApiResponse
                {
                    Message = "Action was executed."
                };

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                var MessageManage = new ApplicationMessageManagement();
                MessageManage.Create(bex.AppMessage);
                return(InternalServerError(new Exception(bex.ExceptionId + "-"
                                                         + bex.AppMessage.Message)));
            }
            catch (Exception ex)
            {
                ApplicationMessage msg = new ApplicationMessage
                {
                    Message = ex.Message
                };
                var MessageManage = new ApplicationMessageManagement();
                MessageManage.Create(msg);
                return(InternalServerError(new Exception(ex.Message)));
            }
        }
Пример #3
0
        public IHttpActionResult GetAirlineAdminByAirlineId(string ID)
        {
            try
            {
                var AirlineManager = new AirlineManager
                {
                    ID = ID
                };

                AirlineManager = mng.RetrieveAirlineAdminByAirlineId(AirlineManager);
                apiResp.Data   = AirlineManager;
                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                var MessageManage = new ApplicationMessageManagement();
                MessageManage.Create(bex.AppMessage);
                return(InternalServerError(new Exception(bex.ExceptionId + "-"
                                                         + bex.AppMessage.Message)));
            }
            catch (Exception ex)
            {
                ApplicationMessage msg = new ApplicationMessage
                {
                    Message = ex.Message
                };
                var MessageManage = new ApplicationMessageManagement();
                MessageManage.Create(msg);
                return(InternalServerError(new Exception(ex.Message)));
            }
        }
Пример #4
0
        public BaseEntity BuildObject(Dictionary <string, object> row)
        {
            AirlineCrudFactory acf = new AirlineCrudFactory();
            var entity             = new Airline
            {
                Id = GetStringValue(row, DB_COL_ID_AIRLINE)
            };

            Airline airline = acf.Retrieve <Airline>(entity);

            var AirlineManager = new AirlineManager
            {
                ID             = GetStringValue(row, DB_COL_ID),
                FirstName      = GetStringValue(row, DB_COL_FIRST_NAME),
                SecondName     = GetStringValue(row, DB_COL_SECOND_NAME),
                LastName       = GetStringValue(row, DB_COL_LAST_NAME),
                SecondLastName = GetStringValue(row, DB_COL_SECOND_LAST_NAME),
                BirthDate      = Convert.ToDateTime(GetDateValue(row, DB_COL_BIRTHDATE)),
                Genre          = GetStringValue(row, DB_COL_GENRE),
                Email          = GetStringValue(row, DB_COL_EMAIL),
                Password       = GetStringValue(row, DB_COL_PASSWORD),
                Phone          = GetStringValue(row, DB_COL_PHONE),
                CivilStatus    = GetStringValue(row, DB_COL_CIVIL_STATUS),
                Status         = Convert.ToBoolean(GetIntValue(row, DB_COL_STATUS)),
                Rol            = GetStringValue(row, DB_COL_ID_ROL),
                AirlineID      = GetStringValue(row, DB_COL_ID_AIRLINE),
                AirlineName    = airline.Comercial_name
            };

            return(AirlineManager);
        }
Пример #5
0
        static private void LoadAirlineStats(bool deletePrevious = true)
        {
            if (deletePrevious)
            {
                airportData.ResetAirlineStats();
            }
            foreach (Airline airline in AirlineManager.AllAirlines())
            {
                airportData.airlineStats.airlineName.AddStat(airline.name, new StringStat(airline.name));
                airportData.airlineStats.includeInSatisfaction.AddStat(airline.name, new BoolStat(airline.IncludeInSatisfication));
                airportData.airlineStats.interest.AddStat(airline.name, new PercentageStat(airline.interest));
                AirlineNeed need = null;
                airportData.airlineStats.communication.AddStat(airline.name, new PercentageStat((airline.Needs?.AllNeeds.TryGetValue("Communication", out need) == true) ? 1f - need.AttenuatedScore : 0f));
                airportData.airlineStats.fuelSatisfaction.AddStat(airline.name, new PercentageStat((airline.Needs?.AllNeeds.TryGetValue("FuelSatisfaction", out need) == true) ? 1f - need.AttenuatedScore : 0f));
                airportData.airlineStats.paxSatisfaction.AddStat(airline.name, new PercentageStat((airline.Needs?.AllNeeds.TryGetValue("PaxSatisfaction", out need) == true) ? 1f - need.AttenuatedScore : 0f));
                airportData.airlineStats.fees.AddStat(airline.name, new PercentageStat((airline.Needs?.AllNeeds.TryGetValue("Fees", out need) == true) ? 1f - need.AttenuatedScore : 0f));
                airportData.airlineStats.reliability.AddStat(airline.name, new PercentageStat((airline.Needs?.AllNeeds.TryGetValue("Reliability", out need) == true) ? 1f - need.AttenuatedScore : 0f));
                airportData.airlineStats.trust.AddStat(airline.name, new PercentageStat((airline.Needs?.AllNeeds.TryGetValue("Trust", out need) == true) ? 1f - need.AttenuatedScore : 0f));
                airportData.airlineStats.facilityQuality.AddStat(airline.name, new PercentageStat((airline.Needs?.AllNeeds.TryGetValue("FacilityQuality", out need) == true) ? 1f - need.AttenuatedScore : 0f));
                airportData.airlineStats.nAcceptedOffers.AddStat(airline.name, new IntStat(airline.nAcceptedOffers));
                airportData.airlineStats.baseRefuelPercentage.AddStat(airline.name, new PercentageStat(airline.BaseRefuelPercentage));
                airportData.airlineStats.firstClassPercentage.AddStat(airline.name, new PercentageStat(airline.FirstClassPercentage));
                airportData.airlineStats.newFlightBonus.AddStat(airline.name, new MoneyStat((float)airline.Income_NewFlightBonus_PerFlight));
                airportData.airlineStats.peakFlightCount.AddStat(airline.name, new IntStat(airline.PeakFlightsCount));
                airportData.airlineStats.nReps.AddStat(airline.name, new IntStat(airline.Reps?.Count ?? 0));
                airportData.airlineStats.hasDeal.AddStat(airline.name, new BoolStat(airline.Needs?.HasDeal ?? false));

                if (airline.Needs?.HasDeal ?? false)
                {
                    airportData.airlineStats.runwayFees.AddStat(airline.name, new MoneyStat(airline.Needs.NegotiatedRunwayFees));
                    airportData.airlineStats.terminalFees.AddStat(airline.name, new MoneyStat(airline.Needs.NegotiatedTerminalFees));
                    airportData.airlineStats.dailyFees.AddStat(airline.name, new MoneyStat(airline.Needs.NegotiatedDailyFees));
                    airportData.airlineStats.fuelSatisfactionNegotiated.AddStat(airline.name, new PercentageStat(airline.Needs.AllNeeds.TryGetValue("NegotiatedFuelSatisfaction", out need) ? 1f - ((double)need.target / 100f) : 0f));
                    airportData.airlineStats.reliabilityNegotiated.AddStat(airline.name, new PercentageStat(airline.Needs.AllNeeds.TryGetValue("NegotiatedReliability", out need) ? 1f - ((double)need.target / 100f) : 0f));
                    airportData.airlineStats.offices.AddStat(airline.name, new IntStat(airline.Needs.AssignedZones.Count(x => x.type == Zone.ZoneType.Office)));
                    airportData.airlineStats.conferenceRoom.AddStat(airline.name, new BoolStat(airline.Needs.Conference != null));
                    airportData.airlineStats.stores.AddStat(airline.name, new IntStat(airline.Needs.AssignedZones.Count(x => x.type == Zone.ZoneType.Store)));
                    airportData.airlineStats.storeShare.AddStat(airline.name, new PercentageStat(airline.Needs.NegotiatedStoreShare / 100f));
                    airportData.airlineStats.cafes.AddStat(airline.name, new IntStat(airline.Needs.AssignedZones.Count(x => x.type == Zone.ZoneType.Cafe)));
                    airportData.airlineStats.cafeShare.AddStat(airline.name, new PercentageStat(airline.Needs.NegotiatedCafeShare / 100f));
                    airportData.airlineStats.firstClassLounges.AddStat(airline.name, new IntStat(airline.Needs.AssignedZones.Count(x => x.type == Zone.ZoneType.First_Class_Lounge)));
                    airportData.airlineStats.flightCrewLounges.AddStat(airline.name, new IntStat(airline.Needs.AssignedZones.Count(x => x.type == Zone.ZoneType.Flight_Crew_Lounge)));
                    airportData.airlineStats.smallGates.AddStat(airline.name, new IntStat(Game.current.objectCache.AircraftGate_All.All().Count(x => x.Owner == airline && x.Size == AircraftGate.GateSize.Small)));
                    airportData.airlineStats.largeGates.AddStat(airline.name, new IntStat(Game.current.objectCache.AircraftGate_All.All().Count(x => x.Owner == airline && x.Size == AircraftGate.GateSize.Large)));
                    airportData.airlineStats.XLGates.AddStat(airline.name, new IntStat(Game.current.objectCache.AircraftGate_All.All().Count(x => x.Owner == airline && x.Size == AircraftGate.GateSize.Extra_Large)));
                    airportData.airlineStats.paxPercent.AddStat(airline.name, new PercentageStat(airline.Needs.NegotiatedPaxPercent / 100f));
                    airportData.airlineStats.penalty.AddStat(airline.name, new MoneyStat(airline.Needs.NegotiatedPenalty));
                }
            }
        }
        protected virtual void ProcessRequest(HttpListenerContext context)
        {
            HttpListenerRequest  request  = context.Request;
            HttpListenerResponse response = context.Response;

            response.ContentType = "text/html";

            string requestedPage = request.RawUrl.TrimStart(new char[] { '/', '\\' });

            AirportStatUtils.AirportStatsLogger(Log.FromPool(requestedPage).WithCodepoint());

            int index = requestedPage.IndexOf("?");

            if (index > 0)
            {
                requestedPage = requestedPage.Substring(0, index);
            }
            requestedPage = requestedPage.Replace("%20", " ");
            int    day            = int.TryParse(request.QueryString["day"], out int value) ? value : -1;
            string aircraft       = request.QueryString["aircraft"];
            string dataset        = request.QueryString["dataset"];
            string airlineName    = request.QueryString["airline"];
            string responseString = string.Empty;

            switch (requestedPage.ToUpperInvariant())
            {
            case "AIRCRAFTSTATS":
                if (!string.IsNullOrWhiteSpace(aircraft) && AircraftConfigManager.FindByAnyName(aircraft, false) != null)
                {
                    responseString += Page.GetAircraftStats(AircraftConfigManager.FindByAnyName(aircraft, false));
                }
                else
                {
                    responseString += AirportStatUtils.InvalidAircraftType();
                }
                break;

            case "AIRLINES":
                responseString += Page.GetAirlineStats(true);
                break;

            case "AIRPORTSTATS.CSS":
                responseString      += new ResourceManager("TBFlash.AirportStats.Resource1", Assembly.GetExecutingAssembly()).GetString("AirportStats1");
                response.ContentType = "text/css";
                break;

            case "AIRPORTSTATS.JS":
                responseString      += new ResourceManager("TBFlash.AirportStats.Resource1", Assembly.GetExecutingAssembly()).GetString("AirportStats");
                response.ContentType = "text/javascript";
                break;

            case "ALLAIRLINES":
                responseString += Page.GetAirlineStats();
                break;

            case "CHART.MIN.CSS":
                responseString      += new ResourceManager("TBFlash.AirportStats.Resource1", Assembly.GetExecutingAssembly()).GetString("Chart_min");
                response.ContentType = "text/css";
                break;

            case "CHART.MIN.JS":
                responseString      += new ResourceManager("TBFlash.AirportStats.Resource1", Assembly.GetExecutingAssembly()).GetString("Chart_min1");
                response.ContentType = "text/javascript";
                break;

            case "CHARTDATA":
                responseString      += Page.GetChartData(dataset, airlineName);
                response.ContentType = "application/json";
                break;

            case "DAILY STATS":
                responseString += day == -1
                        ? Page.GetAirlineData()
                        : Page.GetFlightData(day);
                break;

            case "FAVICON.ICO":
                break;

            case "FUELFUTURES":
                responseString += Page.GetFuelFutures();
                break;

            case "INFORMATION":
                responseString += AirportStatUtils.InformationDialog();
                break;

            case "JQUERY.MIN.JS":
                responseString      += new ResourceManager("TBFlash.AirportStats.Resource1", Assembly.GetExecutingAssembly()).GetString("jquery_min");
                response.ContentType = "text/javascript";
                break;

            case "JQUERY-UI.MIN.JS":
                responseString      += new ResourceManager("TBFlash.AirportStats.Resource1", Assembly.GetExecutingAssembly()).GetString("jquery_ui_min1");
                response.ContentType = "text/javascript";
                break;

            case "JQUERY-UI.MIN.CSS":
                responseString      += new ResourceManager("TBFlash.AirportStats.Resource1", Assembly.GetExecutingAssembly()).GetString("jquery_ui_min");
                response.ContentType = "text/css";
                break;

            default:
                Airline airline = AirlineManager.FindByName(requestedPage);
                if (airline != null)
                {
                    responseString += day == -1
                            ? Page.GetAirlineData(airline)
                            : Page.GetFlightData(day, airline);
                }
                else
                {
                    responseString += Page.GetAirlineData();
                }
                break;
            }

            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
            response.ContentLength64 = buffer.Length;
            Stream outputStream = response.OutputStream;

            outputStream.Write(buffer, 0, buffer.Length);
            outputStream.Close();
        }
Пример #7
0
        private string[,] LoadArray(bool activeOnly = false)
        {
            AirportStatUtils.AirportStatsLogger(Log.FromPool("").WithCodepoint());

            IEnumerable <Airline> airlines = activeOnly ? AirlineManager.AllAirlines().Where(x => x.IncludeInSatisfication) : AirlineManager.AllAirlines();

            string[,] arr = new string[arrayRows, airlines.Count() + 1];
            for (int i = 1; i < arrayRows; i++)
            {
                arr[i, 0] = i18n.Get($"TBFlash.AirportStats.AllAirlineStats.stats{i}");
            }

            int j = 0;

            foreach (Airline airline in airlines.OrderBy(y => y.name))
            {
                j++;
                AirportStatUtils.AirportStatsLogger(Log.FromPool($"j:{j}; Num Airlines:{airlines.Count()}; name: {airline.name}").WithCodepoint());
                if (airline == null)
                {
                    break;
                }
                arr[0, j] = airline.name;
                arr[1, j] = airline.IncludeInSatisfication ? i18n.Get("TBFlash.AirportStats.utils.yes") : i18n.Get("TBFlash.AirportStats.utils.no");
                arr[2, j] = airline.interest.ToString("P1");
                AirlineNeed need = null;
                arr[3, j]  = ((airline.Needs?.AllNeeds.TryGetValue("Communication", out need) == true) ? 1f - need.AttenuatedScore : 0f).ToString("P1");
                arr[4, j]  = ((airline.Needs?.AllNeeds.TryGetValue("FuelSatisfaction", out need) == true) ? 1f - need.AttenuatedScore : 0f).ToString("P1");
                arr[5, j]  = ((airline.Needs?.AllNeeds.TryGetValue("PaxSatisfaction", out need) == true) ? 1f - need.AttenuatedScore : 0f).ToString("P1");
                arr[6, j]  = ((airline.Needs?.AllNeeds.TryGetValue("Fees", out need) == true) ? 1f - need.AttenuatedScore : 0f).ToString("P1");
                arr[7, j]  = ((airline.Needs?.AllNeeds.TryGetValue("Reliability", out need) == true) ? 1f - need.AttenuatedScore : 0f).ToString("P1");
                arr[8, j]  = ((airline.Needs?.AllNeeds.TryGetValue("Trust", out need) == true) ? 1f - need.AttenuatedScore : 0f).ToString("P1");
                arr[9, j]  = ((airline.Needs?.AllNeeds.TryGetValue("FacilityQuality", out need) == true) ? 1f - need.AttenuatedScore : 0f).ToString("P1");
                arr[10, j] = airline.nAcceptedOffers.ToString("#");
                arr[11, j] = airline.BaseRefuelPercentage.ToString("P1");
                arr[12, j] = airline.FirstClassPercentage.ToString("P1");
                arr[13, j] = airline.Income_NewFlightBonus_PerFlight.ToString("C0");
                arr[14, j] = airline.PeakFlightsCount.ToString("#");
                arr[15, j] = airline.Reps?.Count.ToString("#") ?? string.Empty;
                arr[16, j] = airline.Needs?.HasDeal == true?i18n.Get("TBFlash.AirportStats.utils.yes") : i18n.Get("TBFlash.AirportStats.utils.no");

                if (airline.Needs?.HasDeal == true)
                {
                    arr[17, j] = airline.Needs.NegotiatedRunwayFees.ToString("C0");
                    arr[18, j] = airline.Needs.NegotiatedTerminalFees.ToString("C0");
                    arr[19, j] = airline.Needs.NegotiatedDailyFees.ToString("C0");
                    arr[20, j] = (airline.Needs.AllNeeds.TryGetValue("NegotiatedFuelSatisfaction", out need) ? 1f - ((double)need.target / 100) : 0f).ToString("P1");
                    arr[21, j] = (airline.Needs.AllNeeds.TryGetValue("NegotiatedReliabilty", out need) ? 1f - ((double)need.target / 100) : 0f).ToString("P1");
                    arr[22, j] = airline.Needs.AssignedZones.Count(x => x.type == Zone.ZoneType.Office).ToString("#");
                    arr[23, j] = airline.Needs.Conference != null?i18n.Get("TBFlash.AirlineStats.utils.yes") : i18n.Get("TBFlash.AirlineStats.utils.no");

                    arr[24, j] = airline.Needs.AssignedZones.Count(x => x.type == Zone.ZoneType.Store).ToString("#");
                    arr[25, j] = (((double)airline.Needs.NegotiatedStoreShare) / 100f).ToString("P1");
                    arr[26, j] = airline.Needs.AssignedZones.Count(x => x.type == Zone.ZoneType.Cafe).ToString("#");
                    arr[27, j] = (((double)airline.Needs.NegotiatedCafeShare) / 100f).ToString("P1");
                    arr[28, j] = airline.Needs.AssignedZones.Count(x => x.type == Zone.ZoneType.First_Class_Lounge).ToString("#");
                    arr[29, j] = airline.Needs.AssignedZones.Count(x => x.type == Zone.ZoneType.Flight_Crew_Lounge).ToString("#");
                    arr[30, j] = Game.current.objectCache.AircraftGate_All.All().Count(x => x.Owner == airline && x.Size == AircraftGate.GateSize.Small).ToString("#");
                    arr[31, j] = Game.current.objectCache.AircraftGate_All.All().Count(x => x.Owner == airline && x.Size == AircraftGate.GateSize.Large).ToString("#");
                    arr[32, j] = Game.current.objectCache.AircraftGate_All.All().Count(x => x.Owner == airline && x.Size == AircraftGate.GateSize.Extra_Large).ToString("#");
                    arr[33, j] = ((double)airline.Needs.NegotiatedPaxPercent / 100).ToString("P0");
                    arr[34, j] = airline.Needs.NegotiatedPenalty.ToString("C0");
                }
            }
            return(arr);
        }
Пример #8
0
 public SurveyResultAdaptor()
 {
     _airlineManager = new AirlineManager();
 }
Пример #9
0
 public void Delete(AirlineManager manager)
 {
     crudAirlineManager.Delete(manager);
 }
Пример #10
0
 public void Update(AirlineManager manager)
 {
     manager.Password = EncryptionHelper.GetEncryptedMd5Value(manager.Password);
     crudAirlineManager.Update(manager);
 }
Пример #11
0
 public AirlineManager RetrieveAirlineAdminByAirlineId(AirlineManager manager)
 {
     return(crudAirlineManager.RetrieveAirlineAdminByAirlineId <AirlineManager>(manager));
 }
Пример #12
0
 public AirlineManager RetrieveById(AirlineManager manager)
 {
     return(crudAirlineManager.Retrieve <AirlineManager>(manager));
 }
Пример #13
0
 public void Create(AirlineManager manager)
 {
     crudAirlineManager.Create(manager);
 }
Пример #14
0
        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());
            }
        }