protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { lnkFeatures.Text = Branding.ReBrand(Resources.LocalizedText.AboutViewFeatures); lnkFacebook.Visible = !String.IsNullOrEmpty(lnkFacebook.NavigateUrl = Branding.CurrentBrand.FacebookFeed); lnkTwitter.Visible = !String.IsNullOrEmpty(lnkTwitter.NavigateUrl = Branding.CurrentBrand.TwitterFeed); lblFollowFacebook.Text = Branding.ReBrand(Resources.LocalizedText.FollowOnFacebook); lblFollowTwitter.Text = Branding.ReBrand(Resources.LocalizedText.FollowOnTwitter); FlightStats fs = FlightStats.GetFlightStats(); locRecentStats.Text = Branding.ReBrand(String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageRecentStatsHeader, fs.MaxDays)); rptStats.DataSource = fs.Stats; rptStats.DataBind(); if (fs.HasSlowInformation) { List <AirportStats> lstTopAirports = new List <AirportStats>(fs.AirportsVisited); if (lstTopAirports.Count > maxAirports) { lstTopAirports.RemoveRange(maxAirports, lstTopAirports.Count - maxAirports); } rptTopAirports.DataSource = lstTopAirports; rptTopAirports.DataBind(); rptTopModels.DataSource = fs.ModelsUsed; rptTopModels.DataBind(); pnlLazyStats.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { lnkFeatures.Text = Branding.ReBrand(Resources.LocalizedText.AboutViewFeatures); lnkFacebook.Visible = !String.IsNullOrEmpty(lnkFacebook.NavigateUrl = Branding.CurrentBrand.FacebookFeed); lnkTwitter.Visible = !String.IsNullOrEmpty(lnkTwitter.NavigateUrl = Branding.CurrentBrand.TwitterFeed); lblFollowFacebook.Text = Branding.ReBrand(Resources.LocalizedText.FollowOnFacebook); lblFollowTwitter.Text = Branding.ReBrand(Resources.LocalizedText.FollowOnTwitter); FlightStats fs = FlightStats.GetFlightStats(); lblRecentFlightsStats.Text = fs.ToString(); locRecentStats.Text = Branding.ReBrand(Resources.LocalizedText.DefaultPageRecentStats); List <string> lstStats = new List <string>() { String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageRecentStatsFlights, fs.NumFlightsTotal), String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageRecentStatsAircraft, fs.NumAircraft), String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPagerecentStatsModels, fs.NumModels) }; rptStats.DataSource = lstStats; rptStats.DataBind(); } }
public static FlightRow[] HtmlRowsForFlights(string szUser, int skip, int pageSize) { System.Threading.Thread.CurrentThread.CurrentCulture = util.SessionCulture ?? CultureInfo.CurrentCulture; // We have no Page, so things like Page_Load don't get called. // We fix this by faking a page and calling Server.Execute on it. This sets up the form and - more importantly - causes Page_load to be called on loaded controls. using (Page p = new FormlessPage()) { p.Controls.Add(new HtmlForm()); using (StringWriter sw = new StringWriter(CultureInfo.CurrentCulture)) HttpContext.Current.Server.Execute(p, sw, false); IEnumerable <LogbookEntry> rgle = Array.Empty <LogbookEntry>(); if (String.IsNullOrEmpty(szUser)) { List <LogbookEntry> lst = new List <LogbookEntry>(FlightStats.GetFlightStats().RecentPublicFlights); if (skip > 0) { lst.RemoveRange(0, Math.Min(skip, lst.Count)); } if (lst.Count > pageSize) { lst.RemoveRange(pageSize, lst.Count - pageSize); } rgle = lst; } else { rgle = GetFlights(szUser, skip, pageSize); } List <FlightRow> lstRows = new List <FlightRow>(); foreach (LogbookEntry le in rgle) { Controls_mfbPublicFlightItem pfe = (Controls_mfbPublicFlightItem)p.LoadControl("~/Controls/mfbPublicFlightItem.ascx"); p.Form.Controls.Add(pfe); pfe.Entry = le; // Now, write it out. System.Text.StringBuilder sb = new System.Text.StringBuilder(); using (StringWriter sw = new StringWriter(sb, CultureInfo.CurrentCulture)) { using (HtmlTextWriter htmlTW = new HtmlTextWriter(sw)) pfe.RenderControl(htmlTW); } lstRows.Add(new FlightRow() { HTMLRowText = sb.ToString(), FBDivID = string.Empty }); } return(lstRows.ToArray()); } }
protected void Page_Load(object sender, EventArgs e) { Master.SelectedTab = tabID.tabHome; Master.Title = String.Format(CultureInfo.CurrentCulture, Resources.Profile.WelcomeTitleWithDescription, Branding.CurrentBrand.AppName); Master.Layout = MasterPage.LayoutMode.Accordion; string s = util.GetStringParam(Request, "m"); if (s.Length > 0) { this.Master.SetMobile((string.Compare(s, "no", StringComparison.OrdinalIgnoreCase) != 0)); } FlightStats fs = FlightStats.GetFlightStats(); if (!IsPostBack) { List <AppAreaDescriptor> lst = new List <AppAreaDescriptor>() { new AppAreaDescriptor(Resources.Tabs.TabLogbook, "~/Member/LogbookNew.aspx", Branding.ReBrand(Resources.Profile.appDescriptionLogbook), tabID.tabLogbook), new AppAreaDescriptor(Resources.Tabs.TabAircraft, "~/Member/Aircraft.aspx", Branding.ReBrand(Resources.Profile.appDescriptionAircraft), tabID.tabAircraft), new AppAreaDescriptor(Resources.Tabs.TabAirports, "~/Public/MapRoute2.aspx", Branding.ReBrand(Resources.Profile.appDescriptionAirports), tabID.tabMaps), new AppAreaDescriptor(Resources.Tabs.TabInstruction, "~/Member/Training.aspx", Branding.ReBrand(Resources.Profile.appDescriptionTraining), tabID.tabTraining), new AppAreaDescriptor(Resources.Tabs.TabProfile, "~/Member/EditProfile.aspx", Branding.ReBrand(Resources.Profile.appDescriptionProfile), tabID.tabProfile) }; rptFeatures.DataSource = lst; rptFeatures.DataBind(); locRecentFlightsHeader.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageRecentFlightsHeader, Branding.CurrentBrand.AppName); if (User.Identity.IsAuthenticated) { lblHeader.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.DefaultPageWelcomeBack, MyFlightbook.Profile.GetUser(User.Identity.Name).UserFirstName); pnlWelcome.Visible = false; } else { lblHeader.Text = String.Format(CultureInfo.CurrentCulture, Resources.Profile.WelcomeTitle, Branding.CurrentBrand.AppName); pnlWelcome.Visible = true; } lblRecentFlightsStats.Text = fs.ToString(); } // redirect to a mobile view if this is from a mobile device UNLESS cookies suggest to do otherwise. if (this.Master.IsMobileSession()) { if ((Request.Cookies[MFBConstants.keyClassic] == null || String.Compare(Request.Cookies[MFBConstants.keyClassic].Value, "yes", StringComparison.OrdinalIgnoreCase) != 0)) { Response.Redirect("DefaultMini.aspx"); } } PopulateRecentImages(fs.RecentPublicFlights); }
protected void Page_Load(object sender, EventArgs e) { this.Master.SelectedTab = tabID.tabHome; PageSize = 15; // figure out who to show if (!IsPostBack) { IEnumerable <LogbookEntry> rgle = Array.Empty <LogbookEntry>(); string szUserEnc = util.GetStringParam(Request, "uid"); UserName = string.Empty; if (!String.IsNullOrEmpty(szUserEnc)) { SharedDataEncryptor enc = new SharedDataEncryptor(MFBConstants.keyEncryptMyFlights); UserName = enc.Decrypt(szUserEnc); } if (String.IsNullOrEmpty(UserName)) { FlightStats fs = FlightStats.GetFlightStats(); List <LogbookEntry> lst = new List <LogbookEntry>(fs.RecentPublicFlights); if (lst.Count > PageSize) { lst.RemoveRange(PageSize, lst.Count - PageSize); } rgle = lst; } else { try { // below can throw argument null exception if it's an invalid username Profile pf = Profile.GetUser(UserName); if (pf.UserFullName.Length > 0) { lblHeader.Text = String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.PublicFlightPageHeader, HttpUtility.HtmlEncode(pf.UserFullName)); } rgle = LogbookEntryBase.GetPublicFlightsForUser(UserName, 0, PageSize); } catch (Exception ex) when(ex is NullReferenceException) { } } gvMyFlights.DataSource = rgle; gvMyFlights.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { this.Master.SelectedTab = tabID.tabHome; PageSize = 15; // figure out who to show if (!IsPostBack) { IEnumerable <LogbookEntry> rgle = new LogbookEntry[0]; string szUserEnc = util.GetStringParam(Request, "uid"); UserName = string.Empty; if (!String.IsNullOrEmpty(szUserEnc)) { SharedDataEncryptor enc = new SharedDataEncryptor(MFBConstants.keyEncryptMyFlights); UserName = enc.Decrypt(szUserEnc); } if (String.IsNullOrEmpty(UserName)) { FlightStats fs = FlightStats.GetFlightStats(); List <LogbookEntry> lst = new List <LogbookEntry>(fs.RecentPublicFlights); if (lst.Count > PageSize) { lst.RemoveRange(PageSize, lst.Count - PageSize); } rgle = lst; } else { Profile pf = MyFlightbook.Profile.GetUser(UserName); if (pf.UserFullName.Length > 0) { lblHeader.Text = String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.PublicFlightPageHeader, pf.UserFullName); } rgle = LogbookEntry.GetPublicFlightsForUser(UserName, 0, PageSize); } gvMyFlights.DataSource = rgle; gvMyFlights.DataBind(); } }