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