protected void lnkViewKML_Click(object sender, EventArgs e)
    {
        DataSourceType dst = DataSourceType.DataSourceTypeFromFileType(DataSourceType.FileType.KML);

        Response.Clear();
        Response.ContentType = dst.Mimetype;
        Response.AddHeader("Content-Disposition", String.Format(CultureInfo.CurrentCulture, "attachment;filename={0}-AllFlights.{1}", Branding.CurrentBrand.AppName, dst.DefaultExtension));

        // Get the flight IDs that contribute to the report
        sqlDSReports.SelectParameters.Clear();
        sqlDSReports.SelectParameters.Add(new Parameter("idclub", System.Data.DbType.Int32, CurrentClub.ID.ToString(CultureInfo.InvariantCulture)));
        sqlDSReports.SelectParameters.Add(new Parameter("startDate", System.Data.DbType.Date, dateStart.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)));
        sqlDSReports.SelectParameters.Add(new Parameter("endDate", System.Data.DbType.Date, dateEnd.Date.HasValue() ? dateEnd.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) : DateTime.UtcNow.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)));

        List <int> lstIds = new List <int>();

        using (DataView dv = (DataView)sqlDSReports.Select(DataSourceSelectArguments.Empty))
        {
            foreach (DataRowView dr in dv)
            {
                lstIds.Add(Convert.ToInt32(dr["idflight"], CultureInfo.InvariantCulture));
            }
        }

        string szErr;

        VisitedAirport.AllFlightsAsKML(new FlightQuery(), Response.OutputStream, out szErr, lstIds);
        if (String.IsNullOrEmpty(szErr))
        {
            lblErr.Text = szErr;
        }
        Response.End();
    }
示例#2
0
    protected airport[] GetUserAirports(string szDefault)
    {
        if (!Page.User.Identity.IsAuthenticated)
        {
            lblDebug.Text = Resources.LocalizedText.AirportGameUnauthenticated;
            return((new AirportList(szDefault)).GetAirportList());
        }

        VisitedAirport[] rgva = VisitedAirport.VisitedAirportsForUser(Page.User.Identity.Name);

        if (rgva.Length < 15)
        {
            lblDebug.Text = Resources.LocalizedText.AirportGameTooFewAirports;
            return(airport.AirportsWithExactMatch(szDefault).ToArray());
        }

        airport[] rgap = new airport[rgva.Length];

        int i = 0;

        foreach (VisitedAirport va in rgva)
        {
            rgap[i++] = va.Airport;
        }

        return(rgap);
    }
示例#3
0
    public void WriteKMLToStream(Stream s, int ClubID, DateTime dateStart, DateTime dateEnd)
    {
        if (s == null)
        {
            throw new ArgumentNullException("s");
        }

        // Get the flight IDs that contribute to the report
        SetParams(ClubID, dateStart, dateEnd);
        List <int> lstIds = new List <int>();

        using (DataView dv = (DataView)sqlDSReports.Select(DataSourceSelectArguments.Empty))
        {
            foreach (DataRowView dr in dv)
            {
                lstIds.Add(Convert.ToInt32(dr["idflight"], CultureInfo.InvariantCulture));
            }
        }

        string szErr;

        VisitedAirport.AllFlightsAsKML(new FlightQuery(), s, out szErr, lstIds);
        if (!String.IsNullOrEmpty(szErr))
        {
            throw new MyFlightbookException("Error writing KML to stream: " + szErr);
        }
    }
    protected void btnGetTotalKML(object sender, EventArgs e)
    {
        DataSourceType dst = DataSourceType.DataSourceTypeFromFileType(DataSourceType.FileType.KML);

        Response.Clear();
        Response.ContentType = dst.Mimetype;
        Response.AddHeader("Content-Disposition", String.Format(CultureInfo.CurrentCulture, "attachment;filename={0}-AllFlights.{1}", Branding.CurrentBrand.AppName, dst.DefaultExtension));
        VisitedAirport.AllFlightsAsKML(mfbSearchForm1.Restriction, Response.OutputStream, out _);
        Response.End();
    }
    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);
    }
    protected void gvAirports_DataBound(Object sender, GridViewRowEventArgs e)
    {
        if (e != null && e.Row.RowType == DataControlRowType.DataRow)
        {
            PlaceHolder p = (PlaceHolder)e.Row.FindControl("plcZoomCode");
            HtmlAnchor  a = new HtmlAnchor();
            p.Controls.Add(a);
            VisitedAirport va = (VisitedAirport)e.Row.DataItem;

            string szLink = String.Format(CultureInfo.InvariantCulture, "javascript:{0}.gmap.setCenter(new google.maps.LatLng({1}, {2}));{0}.gmap.setZoom(14);",
                                          mfbGoogleMapManager1.MapID, va.Airport.LatLong.Latitude, va.Airport.LatLong.Longitude);
            a.InnerText = va.Code;
            a.HRef      = szLink;
        }
    }
    protected void btnEstimateDistance_Click(object sender, EventArgs e)
    {
        lblErr.Text = string.Empty;
        double distance = VisitedAirport.DistanceFlownByUser(mfbSearchForm1.Restriction, util.GetIntParam(Request, "df", 0) != 0, out string szErr);

        if (String.IsNullOrEmpty(szErr))
        {
            btnEstimateDistance.Visible = false;
            pnlDistanceResults.Visible  = true;
            lblDistanceEstimate.Text    = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.VisitedAirportsDistanceEstimate, distance);
        }
        else
        {
            lblErr.Text = szErr;
        }
    }
        protected void RefreshVisitedAirports()
        {
            if (CurrentVisitedAirports == null)
            {
                CurrentVisitedAirports = VisitedAirport.VisitedAirportsForQuery(Restriction);
            }
            lblNumAirports.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.VisitedAirportsNumAirports, CurrentVisitedAirports.Length);

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

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

            lnkZoomOut.NavigateUrl = mfbGoogleMapManager1.ZoomToFitScript;
            lnkZoomOut.Visible     = (CurrentVisitedAirports.Length > 0);
        }
示例#9
0
        public void WriteKMLToStream(Stream s, int ClubID, DateTime dateStart, DateTime dateEnd, string szUser, int idAircraft)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }

            RefreshReportQuery(ClubID, dateStart, dateEnd, szUser, idAircraft);

            // Get the flight IDs that contribute to the report
            List <int> lstIds = new List <int>();

            using (DataView dv = (DataView)sqlDSReports.Select(DataSourceSelectArguments.Empty))
            {
                foreach (DataRowView dr in dv)
                {
                    lstIds.Add(Convert.ToInt32(dr["idflight"], CultureInfo.InvariantCulture));
                }
            }


            if (lstIds.Count == 0)
            {
                using (MyFlightbook.Telemetry.KMLWriter kw = new MyFlightbook.Telemetry.KMLWriter(s))
                {
                    kw.BeginKML();
                    kw.EndKML();
                }
            }
            else
            {
                VisitedAirport.AllFlightsAsKML(new FlightQuery(), s, out string szErr, lstIds);
                if (!String.IsNullOrEmpty(szErr))
                {
                    throw new MyFlightbookException("Error writing KML to stream: " + szErr);
                }
            }
        }