Exemplo n.º 1
0
    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 = MyFlightbook.Profile.GetUser(UserName);
                    if (pf.UserFullName.Length > 0)
                    {
                        lblHeader.Text = String.Format(CultureInfo.CurrentCulture, Resources.LogbookEntry.PublicFlightPageHeader, HttpUtility.HtmlEncode(pf.UserFullName));
                    }
                    rgle = LogbookEntry.GetPublicFlightsForUser(UserName, 0, PageSize);
                }
                catch (Exception ex) when(ex is NullReferenceException)
                {
                }
            }

            gvMyFlights.DataSource = rgle;
            gvMyFlights.DataBind();
        }
    }
Exemplo n.º 2
0
    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();
        }
    }
Exemplo n.º 3
0
 public static LogbookEntry[] GetFlights(string szUser, int skip, int pageSize)
 {
     return(LogbookEntry.GetPublicFlightsForUser(szUser, skip, pageSize));
 }