/// <summary>
        /// Computes the progress against this milestone
        /// </summary>
        /// <returns>A list of MilestoneItem objects</returns>
        virtual public Collection <MilestoneItem> Refresh()
        {
            if (String.IsNullOrEmpty(Username))
            {
                throw new MyFlightbookException("Cannot compute milestones on an empty user!");
            }

            List <ExaminerFlightRow> lstRows  = new List <ExaminerFlightRow>();
            StringBuilder            sbRoutes = new StringBuilder();

            DBHelper dbh = new DBHelper(CurrencyExaminer.CurrencyQuery(CurrencyExaminer.CurrencyQueryDirection.Descending));

            dbh.ReadRows(
                (comm) =>
            {
                comm.Parameters.AddWithValue("UserName", Username);
                comm.Parameters.AddWithValue("langID", System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName);
            },
                (dr) =>
            {
                ExaminerFlightRow cfr = new ExaminerFlightRow(dr);
                sbRoutes.AppendFormat(CultureInfo.InvariantCulture, "{0} ", cfr.Route);
                lstRows.Add(cfr);       // we'll examine it below, after we've populated the routes
            });

            // Set up the airport list once for DB efficiency
            AirportListOfRoutes = new AirportList(sbRoutes.ToString());

            lstRows.ForEach(cfr => { ExamineFlight(cfr); });

            return(Milestones);
        }
示例#2
0
        public ActionResult Index()
        {
            string              airportCode = Request.QueryString["airportCode"];
            DateTime            date        = DateTime.Parse(Request.QueryString["date"]);
            WeatherIncidentType?filterType  = GetWeatherIncidentTypeFromRequest(Request);

            double radius;

            if (!double.TryParse(Request.QueryString["radius"], out radius))
            {
                radius = 15;
            }

            var mainAirport = AirportList.GetAirport(airportCode);
            var airports    = new List <Airport> {
                mainAirport
            };

            airports.AddRange(AirportList.FindNearbyAirports(mainAirport.Geocode, radius));
            airports = airports.Distinct().ToList();

            var weatherUnderground = new WeatherUnderground();
            List <WeatherIncident> weatherUndergroundIncidents = new List <WeatherIncident>();

            foreach (var airport in airports)
            {
                weatherUndergroundIncidents.AddRange(weatherUnderground.GetEvents(airport.AirportCode, date, filterType));
            }
            return(Json(weatherUndergroundIncidents.Distinct(), JsonRequestBehavior.AllowGet));
        }
    private void ShowMap(LogbookEntry le)
    {
        double distance = 0.0;
        bool   fHasPath = le.Telemetry != null && le.Telemetry.HasPath;
        ListsFromRoutesResults result = null;

        if (le.Route.Length > 0 || fHasPath) // show a map.
        {
            result = AirportList.ListsFromRoutes(le.Route);
            MfbGoogleMap1.Map.Airports          = result.Result;
            MfbGoogleMap1.Map.ShowRoute         = ckShowRoute.Checked;
            MfbGoogleMap1.Map.AutofillOnPanZoom = (result.Result.Count() == 0);
            MfbGoogleMap1.Map.AllowDupeMarkers  = false;
            lnkZoomOut.NavigateUrl = MfbGoogleMap1.ZoomToFitScript;
            lnkZoomOut.Visible     = !result.MasterList.LatLongBox().IsEmpty;

            // display flight path, if available.
            if (ckShowPath.Checked && le.Telemetry.HasPath)
            {
                MfbGoogleMap1.Map.Path = le.Telemetry.Path();
                distance           = le.Telemetry.Distance();
                lnkViewKML.Visible = true;
            }

            string szURL = Request.Url.PathAndQuery;
            lnkShowMapOnly.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", szURL, szURL.Contains("?") ? "&" : "?", "show=map");
        }

        MfbGoogleMap1.Map.Images = ckShowImages.Checked ? mfbIlFlight.Images.ImageArray.ToArray() : new MFBImageInfo[0];

        bool fForceDynamicMap    = util.GetIntParam(Request, "dm", 0) != 0;
        bool fHasGeotaggedImages = false;

        if (le.FlightImages != null)
        {
            Array.ForEach <MFBImageInfo>(le.FlightImages, (mfbii) => { fHasGeotaggedImages = fHasGeotaggedImages || mfbii.Location != null; });
        }

        // By default, show only a static map (cut down on dynamic map hits)
        if (fForceDynamicMap || fHasGeotaggedImages || fHasPath)
        {
            MfbGoogleMap1.Mode = MyFlightbook.Mapping.GMap_Mode.Dynamic;
        }
        else
        {
            MfbGoogleMap1.Mode = MyFlightbook.Mapping.GMap_Mode.Static;
            popmenu.Visible    = false;
            lnkZoomOut.Visible = mfbAirportServices1.Visible = false;
        }

        if (result != null)
        {
            mfbAirportServices1.GoogleMapID = MfbGoogleMap1.MapID;
            mfbAirportServices1.AddZoomLink = (MfbGoogleMap1.Mode == MyFlightbook.Mapping.GMap_Mode.Dynamic);
            mfbAirportServices1.SetAirports(result.MasterList.GetNormalizedAirports());
        }

        lblDistance.Text    = le.GetPathDistanceDescription(distance);
        pnlDistance.Visible = lblDistance.Text.Length > 0;
    }
示例#4
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();
        }
示例#5
0
 /// <summary>
 /// Helper to set a single airportlist rather than an enumerable of them
 /// </summary>
 /// <param name="al"></param>
 public void SetAirportList(AirportList al)
 {
     m_Airports = new List <AirportList>()
     {
         al
     };
 }
        public AirportList DeserializeAirportListFile(string airportsFile)
        {
            AirportList airportList = null;

            if (File.Exists(airportsFile))
            {
                log.Info("Loading airports from file");

                // Annoying special characters issue.
                // Not sure why these don't work given that we're using UTF8 to encode and decode
                var airportFileString = File.ReadAllText(airportsFile);
                airportFileString = Regex.Replace(airportFileString, @"&#x?[^;]{1,6};", string.Empty);

                using (MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(airportFileString)))
                {
                    XmlSerializer xmlSerializer = new XmlSerializer(typeof(AirportList));
                    StreamReader  reader        = new StreamReader(memoryStream, Encoding.UTF8);
                    airportList = (AirportList)xmlSerializer.Deserialize(reader);
                }
            }
            else
            {
                log.Info("Airport file not found");
            }

            return(airportList);
        }
示例#7
0
        private void ShowMap(LogbookEntry le)
        {
            double distance = 0.0;
            bool   fHasPath = le.Telemetry != null && le.Telemetry.HasPath;
            ListsFromRoutesResults result = null;

            if (le.Route.Length > 0 || fHasPath) // show a map.
            {
                result = AirportList.ListsFromRoutes(le.Route);
                MfbGoogleMap1.Map.Airports                 = result.Result;
                MfbGoogleMap1.Map.Options.fShowRoute       = ckShowRoute.Checked;
                MfbGoogleMap1.Map.Options.fAutofillPanZoom = (result.Result.Count == 0);
                MfbGoogleMap1.Map.AllowDupeMarkers         = false;
                lnkZoomOut.NavigateUrl = MfbGoogleMap1.ZoomToFitScript;
                lnkZoomOut.Visible     = !result.MasterList.LatLongBox().IsEmpty;

                // display flight path, if available.
                if (ckShowPath.Checked && le.Telemetry.HasPath)
                {
                    MfbGoogleMap1.Map.Path = le.Telemetry.Path();
                    distance       = le.Telemetry.Distance();
                    rowKML.Visible = true;
                }
            }

            MfbGoogleMap1.Map.Images = ckShowImages.Checked ? mfbIlFlight.Images.ImageArray.ToArray() : Array.Empty <MFBImageInfo>();

            bool fForceDynamicMap    = util.GetIntParam(Request, "dm", 0) != 0;
            bool fHasGeotaggedImages = false;

            if (le.FlightImages != null)
            {
                foreach (MFBImageInfo mfbii in le.FlightImages)
                {
                    fHasGeotaggedImages = fHasGeotaggedImages || mfbii.Location != null;
                }
            }

            // By default, show only a static map (cut down on dynamic map hits)
            if (fForceDynamicMap || fHasGeotaggedImages || fHasPath)
            {
                MfbGoogleMap1.Mode = MyFlightbook.Mapping.GMap_Mode.Dynamic;
            }
            else
            {
                MfbGoogleMap1.Mode = MyFlightbook.Mapping.GMap_Mode.Static;
                popmenu.Visible    = false;
                lnkZoomOut.Visible = mfbAirportServices1.Visible = false;
            }

            if (result != null)
            {
                mfbAirportServices1.GoogleMapID = MfbGoogleMap1.MapID;
                mfbAirportServices1.AddZoomLink = (MfbGoogleMap1.Mode == MyFlightbook.Mapping.GMap_Mode.Dynamic);
                mfbAirportServices1.SetAirports(result.MasterList.GetNormalizedAirports());
            }

            lblDistance.Text    = le.GetPathDistanceDescription(distance);
            pnlDistance.Visible = lblDistance.Text.Length > 0;
        }
示例#8
0
    public void AccidentGenerate()
    {
        Accident accident = new Accident();

        for (int i = 0; i < AirportAccident; i++)
        {
            accident.type     = AccidentType.airport;
            accident.location = AirportList[rnd.Next(0, AirportList.Count)];
            AirportList.RemoveAll(x => x == accident.location);
            accident.duration  = rnd.Next(3, 31) * 10;
            accident.starttime = InitTime.AddMinutes(rnd.Next(0, 901));
            accident.text      = AirportAccidentTexts[rnd.Next(0, AirportAccidentTexts.Count)];
            accident           = stringProcess.AccidentStringProcess(accident);
            AccidentList.Add(accident);
        }
        for (int i = 0; i < RailAccident; i++)
        {
            accident.type     = AccidentType.rail;
            accident.location = RailList[rnd.Next(0, RailList.Count)];
            RailList.RemoveAll(x => x == accident.location);
            accident.duration  = rnd.Next(3, 31) * 10;
            accident.starttime = InitTime.AddMinutes(rnd.Next(0, 901));
            accident.text      = RailAccidentTexts[rnd.Next(0, RailAccidentTexts.Count)];
            accident           = stringProcess.AccidentStringProcess(accident);
            AccidentList.Add(accident);
        }


        PushAccidentList();
    }
示例#9
0
        /// <summary>
        /// Performs the computation on the milestones to see what progress has been made for each.  We MUST use LogbookEntryDisplays, so we override the base class (which uses ExaminerFlightRow)
        /// </summary>
        /// <returns>The resulting milestones.</returns>
        /// <exception cref="MyFlightbookException"></exception>
        public override Collection <MilestoneItem> Refresh()
        {
            if (String.IsNullOrEmpty(Username))
            {
                throw new MyFlightbookException("Cannot compute milestones on an empty user!");
            }

            StringBuilder sbRoutes = new StringBuilder();
            Profile       pf       = Profile.GetUser(Username);

            IList <LogbookEntryDisplay> lst = LogbookEntryDisplay.GetFlightsForQuery(LogbookEntryBase.QueryCommand(new FlightQuery(Username)), Username, string.Empty, System.Web.UI.WebControls.SortDirection.Descending, pf.UsesHHMM, pf.UsesUTCDateOfFlight);

            // Set up the airport list once for DB efficiency
            foreach (LogbookEntryDisplay led in lst)
            {
                sbRoutes.AppendFormat(CultureInfo.InvariantCulture, "{0} ", led.Route);
            }
            AirportListOfRoutes = new AirportList(sbRoutes.ToString());

            IDictionary <string, CannedQuery> d = UserQueries;

            foreach (LogbookEntryDisplay led in lst)
            {
                foreach (CustomRatingProgressItem cpi in ProgressItems)
                {
                    cpi.ExamineFlight(led, d);
                }
            }
            ;

            return(Milestones);
        }
示例#10
0
    /// <summary>
    /// Start the quiz.
    /// </summary>
    /// <param name="szDefaultAirportList">The list of airports to use</param>
    protected void BeginQuiz(IEnumerable <airport> rgAirports)
    {
        mvQuiz.SetActiveView(vwQuestions);

        // Strip any navaids from the list; not an issue for user airports, but an issue for US airports
        m_AirportQuiz.Init(AirportList.RemoveNavaids(rgAirports));
        NextQuestion();
    }
    protected void btnFind_Click(object sender, EventArgs e)
    {
        gvResults.Visible = true;
        m_alResults       = new AirportList();
        m_alResults.InitFromSearch(txtSearch.Text);
        ViewState[szVSResults] = m_alResults;

        doSearch();
    }
        private Dictionary <string, AssetListItem> CreateAssetLookup(AirportList airportList)

        {
            Dictionary <string, AssetListItem> assetList = new Dictionary <string, AssetListItem>();

            int i = 0;

            foreach (var airport in airportList.Airports)
            {
                log.InfoFormat("Reading assets for airport {0} of {1}", i + 1, airportList.Airports.Count);

                var airportXPFullDirectory  = DirectoryHelper.GetAirportXPFullDirectory(airport.AirportCode, XP2AFSConverterManager.Settings);
                var airportZipFilename      = airportXPFullDirectory + @"\" + airport.AirportCode + ".zip";
                var airportAFSFullDirectory = DirectoryHelper.GetAirportAFSFullDirectory(airport.AirportCode, XP2AFSConverterManager.Settings);

                if (File.Exists(airportZipFilename))
                {
                    // Parse the DST and DAT files
                    var dsfFileLoader = new DSFFileLoader();
                    var dsfFile       = dsfFileLoader.GetDSFFileFromXPZip(airport.AirportCode, airportZipFilename);

                    foreach (var obj in dsfFile.Objects)
                    {
                        if (!assetList.ContainsKey(obj.Reference))
                        {
                            var item = new AssetListItem();
                            item.Name = obj.Reference;
                            assetList.Add(obj.Reference, item);
                        }

                        assetList[obj.Reference].Count++;
                    }

                    foreach (var poly in dsfFile.Polygons)
                    {
                        if (!assetList.ContainsKey(poly.Reference))
                        {
                            var item = new AssetListItem();
                            item.Name = poly.Reference;
                            assetList.Add(poly.Reference, item);
                        }

                        assetList[poly.Reference].Count++;
                    }
                }

                i++;

                //if(i == 1000)
                //{
                //    break;
                //}
            }

            return(assetList);
        }
示例#13
0
        // GET: Airports
        public ActionResult Index()
        {
            var airportsList = new AirportList
            {
                Bounds   = CreateBounds(),
                Airports = db.Airports.ToList()
            };

            return(View(airportsList));
        }
示例#14
0
    protected void ShowMap(string szTLA)
    {
        // Create an airportlist object and initialize it with this airport string
        airport ap = new AirportList(szTLA).GetAirportList()[0];

        MfbGoogleMap1.Map.MapCenter  = ap.LatLong;
        MfbGoogleMap1.Map.ZoomFactor = GMap_ZoomLevels.Airport;
        MfbGoogleMap1.Map.MapType    = GMap_MapType.G_SATELLITE_MAP;
        MfbGoogleMap1.Map.StaticMapAdditionalParams = "style=feature:all|element:labels|visibility:off";
    }
    protected void MapAirports(string szAirports)
    {
        ListsFromRoutesResults result = AirportList.ListsFromRoutes(szAirports);

        SetAirportsInMap(result.Result);
        // and add the table to the page underneath the map
        mfbAirportServices1.SetAirports(result.MasterList.GetNormalizedAirports());

        lnkZoomOut.Visible = !result.MasterList.LatLongBox().IsEmpty;
        pnlMetars.Visible  = result != null && result.Result != null && result.Result.Count > 0;
    }
示例#16
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException("cfr");
            }

            // No training devices for sport pilots
            if (!cfr.fIsRealAircraft)
            {
                return;
            }

            // Minimum time can be in anything
            miMinTime.AddEvent(cfr.Total);

            // Everything else must be in matching category/class
            // allow perfect match or ASEL->ASES match
            if (CatClassID != cfr.idCatClassOverride && !(CatClassID == CategoryClass.CatClassID.ASEL && cfr.idCatClassOverride == CategoryClass.CatClassID.ASES))
            {
                return;
            }

            miMinInstruction.AddEvent(cfr.Dual);
            decimal soloTime = 0.0M;

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

            int cFSLandings = cfr.cFullStopLandings + cfr.cFullStopNightLandings;

            miMinCrossCountry.AddEvent(Math.Min(cfr.XC, cfr.Dual));
            miMinLandings.AddEvent(cFSLandings);
            if (soloTime > 0 && cFSLandings > 1)
            {
                AirportList al = AirportListOfRoutes.CloneSubset(cfr.Route, true);

                if (al.DistanceForRoute() > MinXCDistance && al.MaxSegmentForRoute() > 25)
                {
                    miSoloXCFlight.AddEvent(1);
                    miSoloXCFlight.MatchingEventID   = cfr.flightID;
                    miSoloXCFlight.MatchingEventText = String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.MatchingXCFlightTemplate, cfr.dtFlight.ToShortDateString(), cfr.Route);
                }
            }

            if (DateTime.Now.AddCalendarMonths(-2).CompareTo(cfr.dtFlight) <= 0)
            {
                miTestPrep.AddEvent(cfr.Dual);
            }
        }
示例#17
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);
                    }
                }
            }
        }
    protected void btnOptimizeRoute_Click(object sender, EventArgs e)
    {
        List <airport> lst = new List <airport>(AirportList.ListsFromRoutes(txtAirports.Text).Result[0].UniqueAirports);

        if (lst.Count == 0)
        {
            return;
        }
        IEnumerable <IFix> path = TravelingSalesman.ShortestPath(lst);

        txtAirports.Text = HttpUtility.HtmlEncode(String.Join(" ", path.Select(ap => ap.Code)));
        btnMapEm_Click(sender, e);
    }
        /// <summary>
        /// Computes the progress against this milestone
        /// </summary>
        /// <returns>A list of MilestoneItem objects</returns>
        public Collection <MilestoneItem> Refresh()
        {
            if (String.IsNullOrEmpty(Username))
            {
                throw new MyFlightbookException("Cannot compute milestones on an empty user!");
            }

            // get all custom flight properties that could contribute to currency of one sort or another
            // and stick them into a dictionary for retrieval down below by flightID.
            Dictionary <int, List <CustomFlightProperty> > dctFlightEvents = new Dictionary <int, List <CustomFlightProperty> >();     // flight events (IPC, Instrument checkrides, etc.), keyed by flight ID
            IEnumerable <CustomFlightProperty>             rgPfe           = CustomFlightProperty.GetFlaggedEvents(Username);

            foreach (CustomFlightProperty pfe in rgPfe)
            {
                List <CustomFlightProperty> lstpf = (dctFlightEvents.ContainsKey(pfe.FlightID) ? dctFlightEvents[pfe.FlightID] : null);
                if (lstpf == null)
                {
                    dctFlightEvents.Add(pfe.FlightID, lstpf = new List <CustomFlightProperty>());
                }
                lstpf.Add(pfe);
            }

            List <ExaminerFlightRow> lstRows  = new List <ExaminerFlightRow>();
            StringBuilder            sbRoutes = new StringBuilder();

            DBHelper dbh = new DBHelper(CurrencyExaminer.CurrencyQuery(CurrencyExaminer.CurrencyQueryDirection.Descending));

            dbh.ReadRows(
                (comm) =>
            {
                comm.Parameters.AddWithValue("UserName", Username);
                comm.Parameters.AddWithValue("langID", System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName);
            },
                (dr) =>
            {
                ExaminerFlightRow cfr = new ExaminerFlightRow(dr);
                if (dctFlightEvents.ContainsKey(cfr.flightID))
                {
                    cfr.AddEvents(dctFlightEvents[cfr.flightID]);
                }
                sbRoutes.AppendFormat("{0} ", cfr.Route);
                lstRows.Add(cfr);       // we'll examine it below, after we've populated the routes
            });

            // Set up the airport list once for DB efficiency
            AirportListOfRoutes = new AirportList(sbRoutes.ToString());

            lstRows.ForEach(cfr => { ExamineFlight(cfr); });

            return(Milestones);
        }
示例#20
0
    protected void RefreshData(bool fForceRefresh)
    {
        mfbSearchForm1.Restriction.UserName = User.Identity.Name;
        mfbSearchForm1.Restriction.Refresh();

        if (fForceRefresh || CurrentVisitedAirports == null)
        {
            CurrentVisitedAirports = VisitedAirport.VisitedAirportsForQuery(mfbSearchForm1.Restriction);
        }

        gvAirports.DataSource = CurrentVisitedAirports;
        gvAirports.DataBind();

        IEnumerable <VisitedRegion> d = VisitedAirport.VisitedCountriesAndAdmins(CurrentVisitedAirports);

        rptRegions.DataSource = d;
        rptRegions.DataBind();
        lblNone.Visible = !d.Any();

        mfbGoogleMapManager1.Visible = CurrentVisitedAirports.Length > 0;   //  Avoid excessive map loads.

        AirportList alMatches = new AirportList(CurrentVisitedAirports);

        // get an airport list of the airports
        mfbGoogleMapManager1.Map.SetAirportList(alMatches);

        bool fIncludeRoutes = util.GetIntParam(Request, "path", 0) != 0;

        if (mfbGoogleMapManager1.Map.Options.fShowRoute = fIncludeRoutes)
        {
            List <AirportList> lst = new List <AirportList>();

            DBHelper dbh = new DBHelper(LogbookEntry.QueryCommand(mfbSearchForm1.Restriction, lto: LogbookEntry.LoadTelemetryOption.None));
            dbh.ReadRows((comm) => { }, (dr) =>
            {
                object o       = dr["Route"];
                string szRoute = (string)(o == System.DBNull.Value ? string.Empty : o);

                if (!String.IsNullOrEmpty(szRoute))
                {
                    lst.Add(alMatches.CloneSubset(szRoute));
                }
            });
            mfbGoogleMapManager1.Map.Airports = lst;
        }

        lnkZoomOut.NavigateUrl = mfbGoogleMapManager1.ZoomToFitScript;
        lnkZoomOut.Visible     = (CurrentVisitedAirports.Length > 0);

        lblNumAirports.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.VisitedAirportsNumAirports, CurrentVisitedAirports.Length);
    }
示例#21
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;
         }
     }
 }
示例#22
0
    protected void UpdateCandidateStatus(List <airportImportCandidate> lst)
    {
        StringBuilder sbCodes = new StringBuilder();

        lst.ForEach((aic) =>
        {
            sbCodes.AppendFormat(" {0} ", aic.FAA);
            sbCodes.AppendFormat(" {0} ", aic.IATA);
            sbCodes.AppendFormat(" {0} ", aic.ICAO);
        });
        AirportList al = new AirportList(sbCodes.ToString());

        lst.ForEach((aic) => { aic.CheckStatus(al); });
    }
示例#23
0
    protected ListsFromRoutesResults RoutesList(string szRoute)
    {
        if (szRoute == null)
        {
            throw new ArgumentNullException(nameof(szRoute));
        }

        ListsFromRoutesResults lfrr = (ListsFromRoutesResults)ViewState[szkeyVSAirportListResult];

        if (lfrr == null)
        {
            ViewState[szkeyVSAirportListResult] = lfrr = AirportList.ListsFromRoutes(szRoute);
        }
        return(lfrr);
    }
示例#24
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;
        }
    }
示例#25
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException("cfr");
            }
            // we are not counting training device time.
            if (!cfr.fIsRealAircraft)
            {
                return;
            }

            bool    IsInMatchingCategory = CatClassMatchesRatingSought(cfr.idCatClassOverride);
            decimal XCPICTime            = Math.Min(cfr.PIC, cfr.XC);
            decimal IMCTime   = cfr.IMC + cfr.IMCSim;
            decimal IMCXCTime = Math.Min(IMCTime, cfr.XC);

            // 61.65(def)(1) - Look for cross-country time as PIC
            miMinXCTime.AddEvent(XCPICTime);
            if (IsInMatchingCategory)
            {
                miMinTimeInCategory.AddEvent(XCPICTime);
            }

            // 61.65(def)(2) - IMC time (total)
            miMinIMCTime.AddEvent(IMCTime);

            // 61.65(def)(2)(i) - recent test prep
            if (IsInMatchingCategory)
            {
                if (DateTime.Now.AddCalendarMonths(-2).CompareTo(cfr.dtFlight) <= 0)
                {
                    miMinIMCTestPrep.AddEvent(Math.Min(cfr.Dual, IMCTime));
                }

                if (cfr.cApproaches >= 3 && IMCXCTime > 0.0M)
                {
                    AirportList al = AirportListOfRoutes.CloneSubset(cfr.Route);
                    if (al.DistanceForRoute() >= MinXCDistance)
                    {
                        miIMCXC.AddEvent(1.0M);
                        miIMCXC.MatchingEventText = String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.MatchingXCFlightTemplate, cfr.dtFlight.ToShortDateString(), cfr.Route);
                        miIMCXC.MatchingEventID   = cfr.flightID;
                    }
                }
            }
        }
示例#26
0
        public async Task <AirportList> GetAirports(string[] includes, string orderBy = "", string orderDirection = "ASC", int?offset = null, int?take = null)
        {
            AirportList list = new AirportList();

            IQueryable <Airport> query = Context.Airports.Include(includes).IncludeOrderByJoins(orderBy).OrderBy(orderBy, orderDirection);

            list.TotalRecords = await query.CountAsync();

            if (offset.HasValue && take.HasValue)
            {
                query = query.Skip(offset.Value).Take(take.Value);
            }

            list.Airports = await query.ToListAsync();

            return(list);
        }
示例#27
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException(nameof(cfr));
            }
            bool fIsMatch = CatClassMatchesRatingSought(cfr.idCatClassOverride);

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

            // 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));

                decimal soloTime      = cfr.FlightProps.TotalTimeForPredicate(cfp => cfp.PropertyType.IsSolo);
                decimal nightTakeoffs = cfr.FlightProps.TotalCountForPredicate(cfp => cfp.PropertyType.IsNightTakeOff);

                if (soloTime > 0)
                {
                    miNightSoloTakeoffs.AddEvent(nightTakeoffs);
                    miNightSoloLandings.AddEvent(cfr.cFullStopNightLandings);
                }

                if (nightDual > 0)
                {
                    AirportList al = AirportListOfRoutes.CloneSubset(cfr.Route, true);

                    if (al == null)
                    {
                        al = AirportListOfRoutes.CloneSubset(cfr.Route, true);
                    }
                    if (al.DistanceForRoute() > (double)JAALongNightXCDistanceAirplane)
                    {
                        miNightLongXC.MatchFlightEvent(cfr);
                    }
                }
            }
        }
示例#28
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException("cfr");
            }
            if (!cfr.fIsRealAircraft)
            {
                return;
            }

            // 61.99
            miMinTime.AddEvent(cfr.Total);

            // 61.99(a)
            miMinInstruction.AddEvent(cfr.Dual);

            // 61.99(a)(1)
            if (cfr.cLandingsThisFlight >= 4 && cfr.Dual > 0)
            {
                AirportList al = AirportListOfRoutes.CloneSubset(cfr.Route, true);
                if (al.MaxDistanceForRoute() >= 25.0)
                {
                    miXCFlight.AddEvent(cfr.Dual);
                }
            }

            if (cfr.idCatClassOverride == CatClassID)
            {
                // 61.99(a)(2)
                if (DateTime.Now.AddCalendarMonths(-2).CompareTo(cfr.dtFlight) <= 0)
                {
                    miTestPrep.AddEvent(cfr.Dual);
                }

                // 61.99(b)
                decimal soloTime = 0.0M;
                cfr.FlightProps.ForEachEvent(pf => { if (pf.PropertyType.IsSolo)
                                                     {
                                                         soloTime += pf.DecValue;
                                                     }
                                             });
                miMinSolo.AddEvent(soloTime);
            }
        }
    protected static void UpdateCandidateStatus(List <airportImportCandidate> lst)
    {
        if (lst == null)
        {
            throw new ArgumentNullException(nameof(lst));
        }
        StringBuilder sbCodes = new StringBuilder();

        lst.ForEach((aic) =>
        {
            sbCodes.AppendFormat(CultureInfo.InvariantCulture, " {0} ", aic.FAA);
            sbCodes.AppendFormat(CultureInfo.InvariantCulture, " {0} ", aic.IATA);
            sbCodes.AppendFormat(CultureInfo.InvariantCulture, " {0} ", aic.ICAO);
        });
        AirportList al = new AirportList(sbCodes.ToString());

        lst.ForEach((aic) => { aic.CheckStatus(al); });
    }
示例#30
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            base.ExamineFlight(cfr);

            if (cfr == null)
            {
                throw new ArgumentNullException(nameof(cfr));
            }

            if (!cfr.fIsRealAircraft)
            {
                return;
            }

            switch (cfr.idCatClassOverride)
            {
            case CategoryClass.CatClassID.Helicopter:
            case CategoryClass.CatClassID.ASEL:
            case CategoryClass.CatClassID.ASES:
            case CategoryClass.CatClassID.AMEL:
            case CategoryClass.CatClassID.AMES:
                miXCPIC.AddEvent(Math.Min(cfr.PIC, cfr.XC));
                break;

            default:
                break;
            }

            if (cfr.IMC + cfr.IMCSim > 0 && cfr.Dual > 0 && CatClassMatchesRatingSought(cfr.idCatClassOverride))
            {
                miIFRTrainingInCategory.AddEvent(Math.Min(cfr.Dual, cfr.IMC + cfr.IMCSim));
            }

            if (cfr.cApproaches >= 2 && cfr.Dual > 0 && cfr.IMC + cfr.IMCSim > 0)
            {
                AirportList al = AirportListOfRoutes.CloneSubset(cfr.Route);
                if (al.DistanceForRoute() >= MinXCDistance)
                {
                    miXCDualXC.AddEvent(1.0M);
                    miXCDualXC.MatchingEventText = String.Format(CultureInfo.CurrentCulture, Resources.MilestoneProgress.MatchingXCFlightTemplate, cfr.dtFlight.ToShortDateString(), cfr.Route);
                    miXCDualXC.MatchingEventID   = cfr.flightID;
                }
            }
        }