Esempio n. 1
0
        protected void btnFindClubs_Click(object sender, EventArgs e)
        {
            txtHomeAirport.Text = HttpUtility.HtmlEncode(txtHomeAirport.Text).ToUpper(CultureInfo.CurrentCulture).Trim();

            SearchResults.Clear();

            bool fAdmin = Page.User.Identity.IsAuthenticated && util.GetIntParam(Request, "a", 0) != 0 && MyFlightbook.Profile.GetUser(Page.User.Identity.Name).CanManageData;

            if (String.IsNullOrEmpty(txtHomeAirport.Text))
            {
                SearchResults.AddRange(Club.AllClubs(fAdmin));
            }
            else
            {
                AirportList    al  = new AirportList(txtHomeAirport.Text);
                List <airport> lst = new List <airport>(al.GetAirportList());
                lst.RemoveAll(ap => !ap.IsPort);

                if (lst.Count == 0)
                {
                    lblErr.Text = Resources.Club.errHomeAirportNotFound;
                    return;
                }

                mfbGoogleMapManager2.Map.SetAirportList(al);
                SearchResults.AddRange(Club.ClubsNearAirport(hdnMatchingHomeAirport.Value = lst[0].Code, fAdmin));
            }

            DisplaySearchResults();
        }
 protected void doSearch()
 {
     airport[] rgap = m_alResults.GetAirportList();
     MfbGoogleMapManager1.Visible = rgap.Length > 0;     // avoid excess map loads
     gvResults.DataSource         = rgap;
     gvResults.DataBind();
     MfbGoogleMapManager1.Map.SetAirportList(m_alResults);
     lnkZoomOut.NavigateUrl = MfbGoogleMapManager1.ZoomToFitScript;
     lnkZoomOut.Visible     = (rgap.Length > 0);
 }
Esempio n. 3
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException(nameof(cfr));
            }

            decimal ifrTraining = Math.Min(cfr.Dual, cfr.IMC + cfr.IMCSim);

            // Aeronautical experience - can be in any aircraft or certified sim
            if (cfr.fIsCertifiedIFR)    // includes real aircraft
            {
                miAeronauticalExperience.AddEvent(Math.Max(cfr.GroundSim, cfr.Total));
            }

            // total pilot time and IFR time can both be in any real aircraft
            if (miPilotTime != null && cfr.fIsRealAircraft)
            {
                miPilotTime.AddEvent(cfr.Total);
            }
            miDualInstrumentTime.AddEvent((cfr.fIsRealAircraft || cfr.fIsCertifiedIFR) ? ifrTraining : 0);

            // everything else must be in a matching category AND must be in a real aircraft
            if (IsMatchingCategory(cfr.idCatClassOverride) && cfr.fIsRealAircraft)
            {
                decimal soloTime = 0.0M;
                cfr.FlightProps.ForEachEvent(pf =>
                {
                    if (pf.PropertyType.IsSolo)
                    {
                        soloTime += pf.DecValue;
                    }
                });

                miTimeInCategory.AddEvent(cfr.Total);
                miSoloTimeInCategory.AddEvent(soloTime);
                miSoloXCTimeInCategory.AddEvent(Math.Min(soloTime, cfr.XC));
                miDualInstrumentTimeInCategory.AddEvent(ifrTraining);

                bool fAllowLongXC = (soloTime > 0 || (!fLongCrossCountryMustBeSolo && cfr.PIC > 0));    // solo is always OK for cross country, otherwise need PIC.
                if (fAllowLongXC && !miSoloLongCrossCountry.IsSatisfied)
                {
                    AirportList al = AirportListOfRoutes.CloneSubset(cfr.Route, true);

                    int cRequiredLandings = fXCLandingsMustBeFullStop ? cfr.cFullStopLandings + cfr.cFullStopNightLandings : cfr.cLandingsThisFlight;

                    if (al.DistanceForRoute() >= reqXCDistance && al.GetAirportList().Length >= 3 && cRequiredLandings >= 2)
                    {
                        miSoloLongCrossCountry.MatchFlightEvent(cfr);
                    }
                }
            }
        }
Esempio n. 4
0
 protected void fvClub_ItemUpdating(object sender, FormViewUpdateEventArgs e)
 {
     if (e == null)
     {
         throw new ArgumentNullException("e");
     }
     Page.Validate("valEditClub");
     if (Page.IsValid)
     {
         Club c = ActiveClub ?? new Club();
         c.City            = (string)e.NewValues["City"];
         c.ContactPhone    = (string)e.NewValues["ContactPhone"];
         c.Country         = (string)e.NewValues["Country"];
         c.Description     = Controls_mfbHtmlEdit.FixHtml((string)e.NewValues["Description"]);
         c.HomeAirportCode = (string)e.NewValues["HomeAirportCode"];
         if (!String.IsNullOrEmpty(c.HomeAirportCode))
         {
             AirportList    al  = new AirportList(c.HomeAirportCode);
             List <airport> lst = new List <airport>(al.GetAirportList());
             airport        ap  = lst.FirstOrDefault(a => a.IsPort);
             c.HomeAirportCode = ap == null ? c.HomeAirportCode : ap.Code;
         }
         c.Name          = (string)e.NewValues["Name"];
         c.StateProvince = (string)e.NewValues["StateProvince"];
         c.URL           = (string)e.NewValues["URL"];
         c.ID            = Convert.ToInt32(e.NewValues["ID"], CultureInfo.InvariantCulture);
         c.RestrictEditingToOwnersAndAdmins = Convert.ToBoolean(e.NewValues["RestrictEditingToOwnersAndAdmins"], CultureInfo.InvariantCulture);
         c.IsPrivate = Convert.ToBoolean(e.NewValues["IsPrivate"], CultureInfo.InvariantCulture);
         c.PrependsScheduleWithOwnerName = Convert.ToBoolean(e.NewValues["PrependsScheduleWithOwnerName"], CultureInfo.InvariantCulture);
         c.DeleteNotifications           = (Club.DeleteNoficiationPolicy)Enum.Parse(typeof(Club.DeleteNoficiationPolicy), (string)e.NewValues["DeleteNotifications"]);
         c.DoubleBookRoleRestriction     = (Club.DoubleBookPolicy)Enum.Parse(typeof(Club.DoubleBookPolicy), (string)e.NewValues["DoubleBookRoleRestriction"]);
         c.AddModifyNotifications        = (Club.AddModifyNotificationPolicy)Enum.Parse(typeof(Club.AddModifyNotificationPolicy), (string)e.NewValues["AddModifyNotifications"]);
         c.TimeZone = TimeZoneInfo.FindSystemTimeZoneById((string)e.NewValues["TimeZone.Id"]);
         if (c.IsNew)
         {
             c.Creator = Page.User.Identity.Name;
         }
         if (c.FCommit())
         {
             if (ClubChanged != null)
             {
                 ClubChanged(this, new ClubChangedEventsArgs(ActiveClub));
             }
             this.ActiveClub = c;
         }
         else
         {
             lblErr.Text = c.LastError;
         }
     }
 }
Esempio n. 5
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        AirportList al = new AirportList(txtAirport.Text);

        airport[] rgAirports = al.GetAirportList();
        if (rgAirports.Length == 0)
        {
            lblSearchResult.Text = Resources.Airports.errNoAirportsFound;
        }
        else
        {
            txtLat.Text = rgAirports[0].LatLong.LatitudeString;
            txtLon.Text = rgAirports[0].LatLong.LongitudeString;
        }
    }
Esempio n. 6
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException("cfr");
            }

            // no provision for training devices.
            if (!cfr.fIsRealAircraft)
            {
                return;
            }

            // Must be a glider; motorgliders ("powered sailplanes") are subsets of gliders
            if (cfr.idCatClassOverride != CategoryClass.CatClassID.Glider)
            {
                return;
            }

            // Treat TMG time as if it were a training device.
            miTotal.AddTrainingEvent(cfr.Total, maxTMGTime, cfr.fMotorGlider);

            miDual.AddEvent(cfr.Dual);

            decimal soloTime           = 0.0M;
            bool    fInstructorOnBoard = false;
            decimal dutiesOfPICTime    = 0.0M;

            cfr.ForEachEvent(pf =>
            {
                if (pf.PropertyType.IsSolo)
                {
                    soloTime += pf.DecValue;
                }

                if (pf.PropTypeID == (int)CustomPropertyType.KnownProperties.IDPropInstructorOnBoard && !pf.IsDefaultValue)
                {
                    fInstructorOnBoard = true;    // instructor-on-board time only counts if you are acting as PIC
                }
                if (pf.PropTypeID == (int)CustomPropertyType.KnownProperties.IDPropDutiesOfPIC && !pf.IsDefaultValue)
                {
                    dutiesOfPICTime += pf.DecValue;
                }
            });

            if (fInstructorOnBoard)
            {
                soloTime += Math.Max(Math.Min(dutiesOfPICTime, cfr.Total - cfr.Dual), 0);    // dual received does NOT count as duties of PIC time here
            }
            miSolo.AddEvent(soloTime);
            miLandings.AddEvent(cfr.cLandingsThisFlight);

            if (!miCrossCountry.IsSatisfied)
            {
                AirportList al       = AirportListOfRoutes.CloneSubset(cfr.Route);
                double      distance = al.GetAirportList().Length > 1 ? al.DistanceForRoute() : 0.0;
                if ((soloTime > 0.0M && distance > minSoloXC) || (cfr.Dual > 0 && distance > minDualXC))
                {
                    miCrossCountry.MatchFlightEvent(cfr);
                }
            }
        }
Esempio n. 7
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException("cfr");
            }

            // no provision for training devices.
            if (!cfr.fIsRealAircraft)
            {
                return;
            }

            if (MatchesClassDual(cfr))
            {
                miMinDualInClass.AddEvent(cfr.Dual);
            }

            if (MatchesSoloOrTotalDual(cfr))
            {
                miMinTime.AddEvent(cfr.Total);

                decimal soloTime           = 0.0M;
                bool    fInstructorOnBoard = false;
                decimal dutiesOfPICTime    = 0.0M;
                cfr.ForEachEvent(pf => {
                    if (pf.PropertyType.IsSolo)
                    {
                        soloTime += pf.DecValue;
                    }

                    if (pf.PropTypeID == (int)CustomPropertyType.KnownProperties.IDPropInstructorOnBoard && !pf.IsDefaultValue)
                    {
                        fInstructorOnBoard = true;    // instructor-on-board time only counts if you are acting as PIC
                    }
                    if (pf.PropTypeID == (int)CustomPropertyType.KnownProperties.IDPropDutiesOfPIC && !pf.IsDefaultValue)
                    {
                        dutiesOfPICTime += pf.DecValue;
                    }
                });

                if (fInstructorOnBoard)
                {
                    soloTime += Math.Max(Math.Min(dutiesOfPICTime, cfr.Total - cfr.Dual), 0);    // dual received does NOT count as duties of PIC time here
                }
                if (soloTime > 0.0M)
                {
                    miMinSolo.AddEvent(soloTime);
                    miMinSoloXC.AddEvent(Math.Min(soloTime, cfr.XC));

                    if (cfr.cFullStopLandings >= 1 && !miMinSoloXCMinDist.IsSatisfied)
                    {
                        AirportList al = AirportListOfRoutes.CloneSubset(cfr.Route);
                        if (al.GetAirportList().Length > 1 && al.DistanceForRoute() >= MinSoloDistance)
                        {
                            miMinSoloXCMinDist.MatchFlightEvent(cfr);
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            bool fIsMatch = CatClassMatchesRatingSought(cfr.idCatClassOverride);
            bool fIsSim   = cfr.fIsCertifiedIFR && !cfr.fIsRealAircraft;

            if (!fIsMatch || !cfr.fIsCertifiedIFR)
            {
                return;
            }

            miTotal.AddTrainingEvent(Math.Min(cfr.Dual, cfr.fIsRealAircraft ? cfr.Total : cfr.GroundSim), JAASimSub, fIsSim);

            // Everything below here must be done in a real aircraft
            if (!cfr.fIsRealAircraft)
            {
                return;
            }

            miDual.AddEvent(cfr.Dual);
            miInstrumentDual.AddEvent(Math.Min(cfr.Dual, cfr.IMC + cfr.IMCSim));

            // Get solo time
            decimal soloTime = 0.0M;
            decimal instructorOnBoardTime = 0.0M;
            bool    fInstructorOnBoard    = false;
            decimal dutiesOfPICTime       = 0.0M;
            int     nightTakeoffs         = 0;

            cfr.ForEachEvent(pf =>
            {
                if (pf.PropertyType.IsSolo)
                {
                    soloTime += pf.DecValue;
                }
                if (pf.PropTypeID == (int)CustomPropertyType.KnownProperties.IDPropInstructorOnBoard && !pf.IsDefaultValue)
                {
                    fInstructorOnBoard = true;    // instructor-on-board time only counts if you are acting as PIC
                }
                if (pf.PropTypeID == (int)CustomPropertyType.KnownProperties.IDPropDutiesOfPIC && !pf.IsDefaultValue)
                {
                    dutiesOfPICTime += pf.DecValue;
                }
                if (pf.PropertyType.IsNightTakeOff)
                {
                    nightTakeoffs += pf.IntValue;
                }
            });

            if (fInstructorOnBoard)
            {
                instructorOnBoardTime = Math.Max(Math.Min(dutiesOfPICTime, cfr.Total - cfr.Dual), 0);    // dual received does NOT count as duties of PIC time here
            }
            decimal supervisedSolo = soloTime + Math.Min(instructorOnBoardTime, dutiesOfPICTime);

            miSolo.AddEvent(supervisedSolo);
            miSoloXC.AddEvent(Math.Min(supervisedSolo, cfr.XC));

            AirportList al = null;

            if (!miSoloLongXC.IsSatisfied && supervisedSolo > 0)
            {
                al = AirportListOfRoutes.CloneSubset(cfr.Route);

                if (al.DistanceForRoute() >= (double)miSoloLongXC.Threshold && al.GetAirportList().Length >= 3 && (cfr.cFullStopLandings + cfr.cFullStopNightLandings) >= 2)
                {
                    miSoloLongXC.MatchFlightEvent(cfr);
                }
            }

            // Night - optional
            if (cfr.Night > 0)
            {
                miNightTime.AddEvent(cfr.Night);
                decimal nightDual = Math.Min(cfr.Night, cfr.Dual);
                miNightDual.AddEvent(nightDual);
                miNightXC.AddEvent(Math.Min(nightDual, cfr.XC));
                if (soloTime > 0)
                {
                    miNightSoloTakeoffs.AddEvent(nightTakeoffs);
                    miNightSoloLandings.AddEvent(cfr.cFullStopNightLandings);
                }

                if (nightDual > 0)
                {
                    if (al == null)
                    {
                        al = AirportListOfRoutes.CloneSubset(cfr.Route);
                    }
                    if (al.DistanceForRoute() > (double)JAALongNightXCDistanceAirplane)
                    {
                        miNightLongXC.MatchFlightEvent(cfr);
                    }
                }
            }
        }
Esempio n. 9
0
        // Handle the slower queries.  Spawns a new thread; don't bother waiting for result.
        private void RefreshSlowData()
        {
            m_lstAirports.Clear();

            HashSet <string> hsAirportCodes = new HashSet <string>();
            HashSet <string> hsCountries    = new HashSet <string>();
            Dictionary <string, AirportStats> dictVisited = new Dictionary <string, AirportStats>();

            new Thread(() =>
            {
                Refresh30DayPublicFlights();
                RefreshUserCounts();
                RefreshAircraftAndModels();

                // Get all of the airports recorded for the last 30 days
                DBHelper dbh = new DBHelper(@"SELECT 
    f.route,
    f.username,
    ac.tailnumber,
    CONCAT(man.manufacturer,
            ' ',
            IF(m.typename = '',
                IF(m.family = '', m.model, m.family),
                m.typename)) AS family
FROM
    flights f
        INNER JOIN
    aircraft ac ON f.idaircraft = ac.idaircraft
        INNER JOIN
    models m ON ac.idmodel = m.idmodel
        INNER JOIN
    manufacturers man ON m.idmanufacturer = man.idmanufacturer
WHERE f.Date > ?dateMin AND f.Date < ?dateMax AND ac.InstanceType = 1");
                dbh.ReadRows((comm) =>
                {
                    comm.Parameters.AddWithValue("dateMin", DateTime.Now.AddDays(-MaxDays));
                    comm.Parameters.AddWithValue("dateMax", DateTime.Now.AddDays(1));
                },
                             (dr) =>
                {
                    foreach (string szCode in airport.SplitCodes(util.ReadNullableString(dr, "route").ToUpperInvariant()))
                    {
                        hsAirportCodes.Add(szCode);
                    }
                });

                // OK, now we have all of the airport codes - get the actual airports
                AirportList alMaster = new AirportList(String.Join(" ", hsAirportCodes));

                foreach (airport ap in alMaster.GetAirportList())
                {
                    if (!ap.IsPort)
                    {
                        continue;
                    }

                    dictVisited[ap.GeoHashKey] = new AirportStats(ap);

                    if (!String.IsNullOrWhiteSpace(ap.Country))
                    {
                        hsCountries.Add(ap.Country);
                    }
                }

                CountriesVisited = hsCountries.Count;

                // Now go through the flights a 2nd time and find longest route and the furthest route.
                dbh.ReadRows((comm) =>
                {
                    comm.Parameters.AddWithValue("dateMin", DateTime.Now.AddDays(-MaxDays));
                    comm.Parameters.AddWithValue("dateMax", DateTime.Now.AddDays(1));
                },
                             (dr) =>
                {
                    string szRoute  = util.ReadNullableString(dr, "route").ToUpperInvariant();
                    string szUser   = util.ReadNullableString(dr, "username");
                    string szTail   = util.ReadNullableString(dr, "tailnumber");
                    string szFamily = util.ReadNullableString(dr, "family");

                    AirportList al = alMaster.CloneSubset(szRoute, true);

                    foreach (airport ap in al.UniqueAirports)
                    {
                        if (dictVisited.ContainsKey(ap.GeoHashKey))
                        {
                            dictVisited[ap.GeoHashKey].Visit(szUser, szFamily, szTail);
                        }
                    }
                });

                m_lstAirports.Clear();
                m_lstAirports.AddRange(dictVisited.Values);

                // Sort the list by number of visits, descending, and remove anything that never matched to an airport.
                m_lstAirports.Sort((ap1, ap2) => { return(dictVisited[ap2.GeoHashKey].Visits.CompareTo(dictVisited[ap1.GeoHashKey].Visits)); });

                // Popular models
                const string szPopularModels = @"SELECT 
                    man.manufacturer, IF(m.typename='', IF(m.family = '', m.model, m.family), m.typename) AS icao, COUNT(f.idflight) AS num
                FROM
                    flights f
                        INNER JOIN
                    aircraft ac ON f.idaircraft = ac.idaircraft
                        INNER JOIN
                    models m ON ac.idmodel = m.idmodel
                        INNER JOIN
                    manufacturers man ON m.idmanufacturer = man.idmanufacturer
                WHERE
                    f.date > ?dateMin AND f.date <= ?dateMax
                        AND ac.InstanceType = 1
                GROUP BY icao
                ORDER BY num DESC
                LIMIT 30";

                m_lstPopularModels.Clear();
                dbh.CommandText = szPopularModels;
                dbh.ReadRows(
                    (comm) =>
                {
                    comm.Parameters.AddWithValue("dateMin", DateTime.Now.AddDays(-MaxDays));
                    comm.Parameters.AddWithValue("dateMax", DateTime.Now.AddDays(1));
                },
                    (dr) => { m_lstPopularModels.Add(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageRecentStatsModelInfo, dr["manufacturer"], dr["icao"], dr["num"])); });

                HasSlowInformation = true;
            }).Start();
        }