protected void Page_Load(object sender, EventArgs e) { // wire up the logbook to the current user mfbSearchForm1.Username = Page.User.Identity.Name; Master.SelectedTab = tabID.lbtPrintView; CurrentUser = MyFlightbook.Profile.GetUser(Page.User.Identity.Name); pnlResults.Visible = false; // since we aren't saving viewstate, bind to nothing (e.g., in case we're editing a flight query) Master.SuppressTopNavPrint = true; string szPath = Request.Url.PathAndQuery.Substring(0, Request.Url.PathAndQuery.LastIndexOf("/", StringComparison.Ordinal) + 1); string szURL = String.Format(CultureInfo.InvariantCulture, "{0}://{1}{2}", Request.Url.Scheme, Request.Url.Host, szPath); Master.Page.Header.Controls.Add(new LiteralControl(String.Format(CultureInfo.InvariantCulture, "<base href=\"{0}\" />", szURL))); if (!IsPostBack) { string szFQParam = util.GetStringParam(Request, "fq"); if (!String.IsNullOrEmpty(szFQParam)) { mfbSearchForm1.Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam); Master.HasFooter = Master.HasHeader = false; if (!mfbSearchForm1.Restriction.IsDefault) { TabContainer1.ActiveTab = tpFilter; } lnkReturnToFlights.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/LogbookNew.aspx?fq={0}", szFQParam); } if (util.GetIntParam(Request, "pdfErr", 0) != 0) { lblErr.Text = Resources.LocalizedText.PDFGenerationFailed; } string szOptionsParam = util.GetStringParam(Request, "po"); if (!String.IsNullOrEmpty(szOptionsParam)) { PrintOptions1.Options = JsonConvert.DeserializeObject <PrintingOptions>(Convert.FromBase64String(szOptionsParam).Uncompress()); } Master.Title = lblUserName.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.LocalizedText.LogbookForUserHeader, MyFlightbook.Profile.GetUser(User.Identity.Name).UserFullName); mfbQueryDescriptor.DataSource = mfbTotalSummary1.CustomRestriction = mfbSearchForm1.Restriction; mfbQueryDescriptor.DataBind(); mfbTotalSummary1.DataBind(); // Set up endorsements mfbEndorsementList.Student = CurrentUser.UserName; int cEndorsements = mfbEndorsementList.RefreshEndorsements(); ImageList il = new ImageList(MFBImageInfo.ImageClass.Endorsement, CurrentUser.UserName); il.Refresh(fIncludeDocs: false, fIncludeVids: false); cEndorsements += il.ImageArray.Count(); rptImages.DataSource = il.ImageArray; rptImages.DataBind(); ckEndorsements.Checked = ckIncludeEndorsementImages.Checked = pnlEndorsements.Visible = (cEndorsements > 0); RefreshLogbookData(); } }
protected void Page_Load(object sender, EventArgs e) { // wire up the logbook to the current user MfbLogbook1.User = User.Identity.Name; this.Master.SelectedTab = tabID.lbtFindFlights; if (!IsPostBack) { Master.Title = lblUserName.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture, Resources.LocalizedText.LogbookForUserHeader, MyFlightbook.Profile.GetUser(User.Identity.Name).UserFullName); Boolean fDoSearch = false; string szSearch = util.GetStringParam(Request, "s"); if (szSearch.Length > 0) { fDoSearch = true; } string szFQParam = util.GetStringParam(Request, "fq"); if (!String.IsNullOrEmpty(szFQParam)) { fDoSearch = true; mfbSearchAndTotals1.Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam); } string szAirport = util.GetStringParam(Request, "ap"); if (szAirport.Length > 0) { fDoSearch = true; mfbSearchAndTotals1.AirportQuery = szAirport; } int month = util.GetIntParam(Request, "m", -1); int year = util.GetIntParam(Request, "y", -1); if (month >= 0 && month < 12 && year > 0) { fDoSearch = true; DateTime dtStart = new DateTime(year, month + 1, 1); DateTime dtEnd = dtStart.AddMonths(1).AddDays(-1); mfbSearchAndTotals1.Restriction.DateRange = FlightQuery.DateRanges.Custom; mfbSearchAndTotals1.Restriction.DateMin = dtStart; mfbSearchAndTotals1.Restriction.DateMax = dtEnd; } if (fDoSearch) { SearchResults(szSearch); } } if (this.Master.IsMobileSession()) { MfbLogbook1.MiniMode = true; } }
protected void InitializeRestriction() { string szSearchParam = util.GetStringParam(Request, "s"); string szFQParam = util.GetStringParam(Request, "fq"); string szAirportParam = util.GetStringParam(Request, "ap"); int month = util.GetIntParam(Request, "m", -1); int year = util.GetIntParam(Request, "y", -1); int day = util.GetIntParam(Request, "d", -1); int week = util.GetIntParam(Request, "w", -1); if (!String.IsNullOrEmpty(szFQParam)) { try { Restriction = mfbSearchForm1.Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam); } catch (ArgumentNullException) { } catch (FormatException) { } catch (JsonSerializationException) { } catch (JsonException) { } } else { Restriction = mfbSearchForm1.Restriction = new FlightQuery(Page.User.Identity.Name); } if (!String.IsNullOrEmpty(szSearchParam)) { Restriction.GeneralText = szSearchParam; } if (!String.IsNullOrEmpty(szAirportParam)) { Restriction.AirportList = MyFlightbook.Airports.AirportList.NormalizeAirportList(szAirportParam); } if (year > 1900) { if (month >= 0 && month < 12 && year > 1900) { DateTime dtStart = new DateTime(year, month + 1, day > 0 ? day : 1); DateTime dtEnd = (day > 0) ? (week > 0 ? dtStart.AddDays(6) : dtStart) : dtStart.AddMonths(1).AddDays(-1); Restriction.DateRange = FlightQuery.DateRanges.Custom; Restriction.DateMin = dtStart; Restriction.DateMax = dtEnd; } else { Restriction.DateRange = FlightQuery.DateRanges.Custom; Restriction.DateMin = new DateTime(year, 1, 1); Restriction.DateMax = new DateTime(year, 12, 31); } } Refresh(); }
private void InitializeRestriction() { string szFQParam = util.GetStringParam(Request, "fq"); if (!String.IsNullOrEmpty(szFQParam)) { mfbSearchForm1.Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam); Master.HasFooter = Master.HasHeader = false; if (!mfbSearchForm1.Restriction.IsDefault) { TabContainer1.ActiveTab = tpFilter; } lnkReturnToFlights.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/LogbookNew.aspx?fq={0}", szFQParam); } }
protected void InitPassedRestriction() { string szFQParam = util.GetStringParam(Request, "fq"); if (!String.IsNullOrEmpty(szFQParam)) { try { Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam); Restriction.Refresh(); } catch (Exception ex) when(ex is ArgumentNullException || ex is FormatException || ex is Newtonsoft.Json.JsonSerializationException || ex is Newtonsoft.Json.JsonException) { } } }
private void InitPassedQuery(string szFQParam) { if (!String.IsNullOrEmpty(szFQParam)) { try { Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam); } catch (Exception ex) when(ex is ArgumentNullException || ex is FormatException || ex is JsonSerializationException || ex is JsonException) { } } else { Restriction = new FlightQuery(Page.User.Identity.Name); } }
private void InitializeRestriction() { string szFQParam = util.GetStringParam(Request, "fq"); if (!String.IsNullOrEmpty(szFQParam)) { FlightQuery fq = FlightQuery.FromBase64CompressedJSON(szFQParam); if (fq.UserName.CompareCurrentCultureIgnoreCase(CurrentUser.UserName) != 0) { return; // do nothing if this isn't for the current user } mfbSearchForm1.Restriction = fq; Master.HasFooter = Master.HasHeader = false; if (!mfbSearchForm1.Restriction.IsDefault) { TabContainer1.ActiveTab = tpFilter; } lnkReturnToFlights.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Member/LogbookNew.aspx?fq={0}", szFQParam); } }
protected void Page_Load(object sender, EventArgs e) { this.Master.SelectedTab = tabID.mptVisited; Title = Resources.Airports.visitedAirportTitle; if (!IsPostBack) { string szQuery = util.GetStringParam(Request, "fq"); if (!String.IsNullOrEmpty(szQuery)) { FlightQuery fq = FlightQuery.FromBase64CompressedJSON(szQuery); if (fq.UserName.CompareCurrentCultureIgnoreCase(User.Identity.Name) == 0) { mfbSearchForm1.Restriction = fq; mfbSearchForm1.Restriction.Refresh(); UpdateDescription(); } } } RefreshData(!IsPostBack); }
protected void Page_Load(object sender, EventArgs e) { Master.SelectedTab = tabID.tabLogbook; if (!IsPostBack) { try { if (Request.PathInfo.Length > 0) { try { CurrentFlightID = Convert.ToInt32(Request.PathInfo.Substring(1), CultureInfo.InvariantCulture); } catch (FormatException) { CurrentFlightID = LogbookEntry.idFlightNone; } } if (CurrentFlightID == LogbookEntry.idFlightNone) { throw new MyFlightbookException("No valid ID passed"); } string szFQParam = util.GetStringParam(Request, "fq"); if (!String.IsNullOrEmpty(szFQParam)) { try { Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam); Restriction.Refresh(); } catch (ArgumentNullException) { } catch (FormatException) { } catch (JsonSerializationException) { } catch (JsonException) { } } DetailsTab dtRequested = DetailsTab.Flight; if (Enum.TryParse <DetailsTab>(util.GetStringParam(Request, "tabID"), out dtRequested)) { int iTab = (int)dtRequested; if (AccordionCtrl.Panes[iTab].Visible) { AccordionCtrl.SelectedIndex = iTab; } } LogbookEntryDisplay led = CurrentFlight = LoadFlight(CurrentFlightID); SetUpChart(TelemetryData); UpdateChart(); UpdateRestriction(); if (Viewer.CloudAhoyToken == null || Viewer.CloudAhoyToken.AccessToken == null) { lnkSendCloudAhoy.Visible = false; } lblOriginalFormat.Text = DataSourceType.DataSourceTypeFromFileType(led.Telemetry.TelemetryType).DisplayName; // allow selection of units if units are not implicitly known. switch (led.Telemetry.TelemetryType) { case DataSourceType.FileType.GPX: case DataSourceType.FileType.KML: case DataSourceType.FileType.NMEA: case DataSourceType.FileType.IGC: cmbAltUnits.Enabled = cmbSpeedUnits.Enabled = false; break; default: cmbAltUnits.Enabled = cmbSpeedUnits.Enabled = true; break; } // Bind details - this will bind everything else. fmvLE.DataSource = new LogbookEntryDisplay[] { led }; fmvLE.DataBind(); // shouldn't happen but sometimes does: GetUserAircraftByID returns null. Not quite sure why. Aircraft ac = (new UserAircraft(led.User).GetUserAircraftByID(led.AircraftID)) ?? new Aircraft(led.AircraftID); fmvAircraft.DataSource = new Aircraft[] { ac }; fmvAircraft.DataBind(); if (String.IsNullOrEmpty(CurrentFlight.FlightData) && dtRequested != DetailsTab.Aircraft && dtRequested != DetailsTab.Flight) { AccordionCtrl.SelectedIndex = (int)DetailsTab.Flight; } } catch (MyFlightbookException ex) { lblPageErr.Text = ex.Message; AccordionCtrl.Visible = mfbGoogleMapManager1.Visible = pnlMap.Visible = pnlAccordionMenuContainer.Visible = pnlFlightDesc.Visible = false; return; } // for debugging, have a download option that skips all the rest if (util.GetIntParam(Request, "d", 0) != 0 && !String.IsNullOrEmpty(CurrentFlight.FlightData)) { Response.Clear(); Response.ContentType = "application/octet-stream"; // Give it a name that is the brand name, user's name, and date. Convert spaces to dashes, and then strip out ANYTHING that is not alphanumeric or a dash. string szFilename = String.Format(CultureInfo.InvariantCulture, "Data{0}-{1}-{2}", Branding.CurrentBrand.AppName, MyFlightbook.Profile.GetUser(Page.User.Identity.Name).UserFullName, DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)).Replace(" ", "-"); string szDisposition = String.Format(CultureInfo.InvariantCulture, "inline;filename={0}.csv", System.Text.RegularExpressions.Regex.Replace(szFilename, "[^0-9a-zA-Z-]", "")); Response.AddHeader("Content-Disposition", szDisposition); Response.Write(CurrentFlight.FlightData); Response.End(); return; } } else { m_fd.Data = TelemetryData; UpdateChart(); } if (Restriction != null && !Restriction.IsDefault) { mfbFlightContextMenu.EditTargetFormatString = mfbFlightContextMenu.EditTargetFormatString + "?fq=" + HttpUtility.UrlEncode(Restriction.ToBase64CompressedJSONString()); } mfbFlightContextMenu.Flight = CurrentFlight; cmbAltUnits.SelectedValue = ((int)m_fd.AltitudeUnits).ToString(CultureInfo.InvariantCulture); cmbSpeedUnits.SelectedValue = ((int)m_fd.SpeedUnits).ToString(CultureInfo.InvariantCulture); if (!m_fd.HasDateTime) { lnkSendCloudAhoy.Visible = false; } // Set up any maps. mfbGoogleMapManager1.Map.Airports = RoutesList.Result; mfbGoogleMapManager1.ShowMarkers = true; mfbGoogleMapManager1.Map.PathVarName = PathLatLongArrayID; mfbGoogleMapManager1.Map.Path = m_fd.GetPath(); if (m_fd.HasLatLongInfo && m_fd.Data.Rows.Count > 1) { cmbFormat.Items[(int)DownloadFormat.KML].Enabled = true; cmbFormat.Items[(int)DownloadFormat.GPX].Enabled = true; mfbGoogleMapManager1.Mode = MyFlightbook.Mapping.GMap_Mode.Dynamic; pnlMapControls.Visible = true; } else { cmbFormat.Items[(int)DownloadFormat.KML].Enabled = false; cmbFormat.Items[(int)DownloadFormat.GPX].Enabled = false; mfbGoogleMapManager1.Mode = MyFlightbook.Mapping.GMap_Mode.Static; pnlMapControls.Visible = false; } lnkZoomToFit.NavigateUrl = mfbGoogleMapManager1.ZoomToFitScript; }
protected void Page_Load(object sender, EventArgs e) { Master.SelectedTab = tabID.tabLogbook; Master.Layout = MasterPage.LayoutMode.Accordion; if (!IsPostBack) { try { if (Request.PathInfo.Length > 0) { try { CurrentFlightID = Convert.ToInt32(Request.PathInfo.Substring(1), CultureInfo.InvariantCulture); } catch (FormatException) { CurrentFlightID = LogbookEntry.idFlightNone; } } if (CurrentFlightID == LogbookEntry.idFlightNone) { throw new MyFlightbookException("No valid ID passed"); } string szFQParam = util.GetStringParam(Request, "fq"); if (!String.IsNullOrEmpty(szFQParam)) { try { Restriction = FlightQuery.FromBase64CompressedJSON(szFQParam); Restriction.Refresh(); } catch (ArgumentNullException) { } catch (FormatException) { } catch (JsonSerializationException) { } catch (JsonException) { } } DetailsTab dtRequested = DetailsTab.Flight; if (Enum.TryParse <DetailsTab>(util.GetStringParam(Request, "tabID"), out dtRequested)) { int iTab = (int)dtRequested; if (AccordionCtrl.Panes[iTab].Visible) { AccordionCtrl.SelectedIndex = iTab; } } LogbookEntryDisplay led = CurrentFlight = LoadFlight(CurrentFlightID); SetUpChart(TelemetryData); UpdateChart(); UpdateRestriction(); // Bind details - this will bind everything else. fmvLE.DataSource = new LogbookEntryDisplay[] { led }; fmvLE.DataBind(); fmvAircraft.DataSource = new Aircraft[] { new UserAircraft(led.User).GetUserAircraftByID(led.AircraftID) }; fmvAircraft.DataBind(); if (String.IsNullOrEmpty(CurrentFlight.FlightData) && dtRequested != DetailsTab.Aircraft && dtRequested != DetailsTab.Flight) { AccordionCtrl.SelectedIndex = (int)DetailsTab.Flight; } } catch (MyFlightbookException ex) { lblPageErr.Text = ex.Message; AccordionCtrl.Visible = mfbGoogleMapManager1.Visible = pnlMap.Visible = pnlAccordionMenuContainer.Visible = pnlFlightDesc.Visible = false; return; } // for debugging, have a download option that skips all the rest if (util.GetIntParam(Request, "d", 0) != 0 && !String.IsNullOrEmpty(CurrentFlight.FlightData)) { Response.Clear(); Response.ContentType = "application/octet-stream"; // Give it a name that is the brand name, user's name, and date. Convert spaces to dashes, and then strip out ANYTHING that is not alphanumeric or a dash. string szFilename = String.Format(CultureInfo.InvariantCulture, "Data{0}-{1}-{2}", Branding.CurrentBrand.AppName, MyFlightbook.Profile.GetUser(Page.User.Identity.Name).UserFullName, DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)).Replace(" ", "-"); string szDisposition = String.Format(CultureInfo.InvariantCulture, "inline;filename={0}.csv", System.Text.RegularExpressions.Regex.Replace(szFilename, "[^0-9a-zA-Z-]", "")); Response.AddHeader("Content-Disposition", szDisposition); Response.Write(CurrentFlight.FlightData); Response.End(); return; } } else { m_fd.Data = TelemetryData; UpdateChart(); } // Set up any maps. mfbGoogleMapManager1.Map.Airports = RoutesList.Result; mfbGoogleMapManager1.ShowMarkers = true; mfbGoogleMapManager1.Map.PathVarName = PathLatLongArrayID; mfbGoogleMapManager1.Map.Path = m_fd.GetPath(); if (m_fd.HasLatLongInfo && m_fd.Data.Rows.Count > 1) { cmbFormat.Items[(int)DownloadFormat.KML].Enabled = true; cmbFormat.Items[(int)DownloadFormat.GPX].Enabled = true; } else { cmbFormat.Items[(int)DownloadFormat.KML].Enabled = false; cmbFormat.Items[(int)DownloadFormat.GPX].Enabled = false; } lnkZoomToFit.NavigateUrl = mfbGoogleMapManager1.ZoomToFitScript; }