示例#1
0
        public void InsertInBadge(BadgeSet badge)
        {
            var repo = this._repostitoryFactory.GetBadgeRepository(this._dbContext);

            repo.Insert(badge);
            repo.SaveChanges();
        }
    public void Refresh(string szUser, DateTime dtStart, DateTime dtEnd, bool fIncludeBadges)
    {
        if (szUser == null)
        {
            throw new ArgumentNullException("szUser");
        }
        if (String.IsNullOrWhiteSpace(szUser))
        {
            throw new MyFlightbookValidationException("Invalid user");
        }

        lblTitle.Text = String.Format(CultureInfo.CurrentCulture, Resources.Achievements.RecentAchievementsTitle, dtStart, dtEnd);

        RecentAchievements ra = new RecentAchievements(dtStart, dtEnd)
        {
            Username = szUser
        };
        Collection <MilestoneItem> c = ra.Refresh();

        rptRecentAchievements.DataSource = c;
        rptRecentAchievements.DataBind();

        List <Badge> lstBadges = null;

        if (fIncludeBadges)
        {
            lstBadges = new Achievement(szUser).BadgesForUser();
            lstBadges.RemoveAll(b => b.DateEarned.CompareTo(dtStart) < 0 || b.DateEarned.CompareTo(dtEnd) > 0);
            rptRecentlyearnedBadges.DataSource = BadgeSet.BadgeSetsFromBadges(lstBadges);
            rptRecentlyearnedBadges.DataBind();
        }

        pnlStatsAndAchievements.Visible = (lstBadges != null && lstBadges.Count > 0) || (c != null && c.Count() > 0);
    }
示例#3
0
        public void SaveOnBadge(string name, string typeBadge, int dimX, int dimY)
        {
            BadgeSet b = new BadgeSet();

            b.Name        = name;
            b.TypeBadge   = typeBadge;
            b.Dimension_X = dimX;
            b.Dimension_Y = dimY;
            this._dbEntities.InsertInBadge(b);
            this.ListBadgeType = LoadBadgesType();
        }
    protected void RefreshPage()
    {
        List <Badge> lst = new Achievement(Page.User.Identity.Name).BadgesForUser();

        if (lst == null || lst.Count == 0)
        {
            mvBadges.SetActiveView(vwNoBadges);
        }
        else
        {
            mvBadges.SetActiveView(vwBadges);
            rptBadgeset.DataSource = BadgeSet.BadgeSetsFromBadges(lst);
            rptBadgeset.DataBind();
        }
    }
示例#5
0
    protected void RefreshPage()
    {
        List <Badge> lst = new Achievement(Page.User.Identity.Name).BadgesForUser();

        if (lst == null || lst.Count == 0)
        {
            mvBadges.SetActiveView(vwNoBadges);
        }
        else
        {
            mvBadges.SetActiveView(vwBadges);
            rptBadgeset.DataSource = BadgeSet.BadgeSetsFromBadges(lst);
            rptBadgeset.DataBind();
        }
        mfbRecentAchievements.AutoDateRange = true;
        mfbRecentAchievements.Refresh(Page.User.Identity.Name, DateTime.MaxValue, DateTime.MinValue, false);
    }
    public int Refresh(string szUser, DateTime dtStart, DateTime dtEnd, bool fIncludeBadges)
    {
        if (szUser == null)
        {
            throw new ArgumentNullException(nameof(szUser));
        }
        if (String.IsNullOrWhiteSpace(szUser))
        {
            throw new MyFlightbookValidationException("Invalid user");
        }

        RecentAchievements ra = new RecentAchievements(dtStart, dtEnd)
        {
            Username = szUser, AutoDateRange = AutoDateRange
        };
        Collection <MilestoneItem> c = ra.Refresh();

        rptRecentAchievements.DataSource = c;
        rptRecentAchievements.DataBind();

        AchievementCount = c.Count;

        Summary = String.Format(CultureInfo.CurrentCulture, fIncludeBadges ? Resources.Achievements.RecentAchievementsTitle : Resources.Achievements.RecentStatsTitle, ra.StartDate, ra.EndDate);

        List <Badge> lstBadges = null;

        if (fIncludeBadges)
        {
            lstBadges = new Achievement(szUser).BadgesForUser();
            lstBadges.RemoveAll(b => b.DateEarned.CompareTo(dtStart) < 0 || b.DateEarned.CompareTo(dtEnd) > 0);
            AchievementCount += lstBadges.Count;
            rptRecentlyearnedBadges.DataSource = BadgeSet.BadgeSetsFromBadges(lstBadges);
            rptRecentlyearnedBadges.DataBind();
        }

        pnlStatsAndAchievements.Visible = (lstBadges != null && lstBadges.Count > 0) || (c != null && c.Count > 0);
        if (ShowCalendar)
        {
            RefreshCalendar(ra);
        }

        return(AchievementCount);
    }
    protected void fmvLE_DataBound(object sender, EventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException("e");
        }

        FormView              fv          = sender as FormView;
        LogbookEntryDisplay   le          = (LogbookEntryDisplay)fv.DataItem;
        Controls_mfbImageList mfbilFlight = (Controls_mfbImageList)fv.FindControl("mfbilFlight");

        mfbilFlight.Key = le.FlightID.ToString(CultureInfo.InvariantCulture);
        mfbilFlight.Refresh();
        mfbGoogleMapManager1.Map.Images = mfbilFlight.Images.ImageArray;

        Controls_mfbVideoEntry ve = (Controls_mfbVideoEntry)fv.FindControl("mfbVideoEntry1");

        ve.Videos.Clear();
        foreach (VideoRef vr in le.Videos)
        {
            ve.Videos.Add(vr);
        }

        Controls_mfbAirportServices aptSvc = (Controls_mfbAirportServices)fv.FindControl("mfbAirportServices1");

        aptSvc.GoogleMapID = mfbGoogleMapManager1.MapID;
        aptSvc.AddZoomLink = (mfbGoogleMapManager1.Mode == MyFlightbook.Mapping.GMap_Mode.Dynamic);
        aptSvc.SetAirports(RoutesList.MasterList.GetNormalizedAirports());

        ((Controls_mfbSignature)fv.FindControl("mfbSignature")).Flight = le;

        IEnumerable <Badge> cached = Viewer.CachedBadges;
        List <Badge>        badges = (cached == null ? null : new List <Badge>(cached));

        if (badges != null)
        {
            Repeater rptBadges = (Repeater)fv.FindControl("rptBadges");
            rptBadges.DataSource = BadgeSet.BadgeSetsFromBadges(badges.FindAll(b => b.IDFlightEarned == le.FlightID));
            rptBadges.DataBind();
        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ShareKey sk = CurrentShareKey;  // set in Page_Init
                Profile  pf = Profile.GetUser(sk.Username);

                lblHeader.Text = String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.LogbookForUserHeader, pf.UserFullName);

                // Indicate success.
                sk.FUpdateAccess();

                int privCount = sk.PrivilegeCount;

                apcAnalysis.Container.Style["display"]   = apcCurrency.Container.Style["display"] = apcTotals.Container.Style["display"] =
                    apcFilter.Container.Style["display"] = apcAchievements.Container.Style["display"] = apcAirports.Container.Style["display"] = "none";

                if (sk.CanViewCurrency)
                {
                    apcCurrency.Container.Style["display"] = "inline-block";
                    mfbCurrency.Visible  = true;
                    mfbCurrency.UserName = sk.Username;
                    mfbCurrency.RefreshCurrencyTable();
                    if (privCount == 1) // if ONLY showing currency, expand it and hide the accordion
                    {
                        pnlAccordionMenuContainer.Visible = false;
                        SetAccordionPane(acpPaneCurrency.ID);
                    }
                }

                if (sk.CanViewTotals)
                {
                    apcTotals.Container.Style["display"] = "inline-block";
                    mfbTotalSummary.Visible           = true;
                    mfbTotalSummary.Username          = sk.Username;
                    mfbTotalSummary.CustomRestriction = new FlightQuery(sk.Username); // will call bind

                    if (privCount == 1)                                               // if ONLY showing totals, expand it and hide the accordion
                    {
                        pnlAccordionMenuContainer.Visible = false;
                        SetAccordionPane(acpPaneTotals.ID);
                    }
                }

                if (sk.CanViewFlights)
                {
                    apcAnalysis.Container.Style["display"] = apcFilter.Container.Style["display"] = "inline-block";
                    mfbLogbook.Visible     = true;
                    mfbSearchForm.Username = mfbLogbook.User = sk.Username;
                    mfbLogbook.RefreshData();

                    mfbChartTotals.Visible = true;
                    mfbChartTotals.Refresh(mfbLogbook.Data);
                }

                if (sk.CanViewAchievements)
                {
                    apcAchievements.Container.Style["display"] = "inline-block";
                    mfbRecentAchievements.Visible = mvBadges.Visible = true;

                    List <Badge> lst = new Achievement(sk.Username).BadgesForUser();
                    if (lst == null || lst.Count == 0)
                    {
                        mvBadges.SetActiveView(vwNoBadges);
                    }
                    else
                    {
                        mvBadges.SetActiveView(vwBadges);
                        rptBadgeset.DataSource = BadgeSet.BadgeSetsFromBadges(lst);
                        rptBadgeset.DataBind();
                    }
                    mfbRecentAchievements.AutoDateRange = true;
                    mfbRecentAchievements.Refresh(sk.Username, DateTime.MaxValue, DateTime.MinValue, false);
                    lblRecentAchievementsTitle.Text = mfbRecentAchievements.Summary;
                    if (privCount == 1) // if ONLY showing achievements, expand it
                    {
                        SetAccordionPane(acpPaneAchievements.ID);
                    }
                }

                if (sk.CanViewVisitedAirports)
                {
                    apcAirports.Container.Style["display"] = "inline-block";
                    Restriction.UserName = mfbSearchForm.Username = mfbLogbook.User = sk.Username;
                    if (privCount == 1) // if ONLY showing airports, expand it
                    {
                        SetAccordionPane(acpPaneAirports.ID);
                    }
                }
            }

            if (mfbLogbook.Visible && apcAnalysis.Visible)
            {
                mfbChartTotals.SourceData = mfbLogbook.Data;   // do this every time, since charttotals doesn't persist its data.
            }
            if (CurrentShareKey.CanViewVisitedAirports)
            {
                RefreshVisitedAirports();
            }
        }
示例#9
0
    protected void RefreshPage()
    {
        List <Badge> lst = new Achievement(Page.User.Identity.Name).BadgesForUser();

        if (lst == null || lst.Count == 0)
        {
            mvBadges.SetActiveView(vwNoBadges);
        }
        else
        {
            mvBadges.SetActiveView(vwBadges);
            rptBadgeset.DataSource = BadgeSet.BadgeSetsFromBadges(lst);
            rptBadgeset.DataBind();
        }

        FlightQuery.DateRanges dr;
        DateTime dtMin, dtMax = DateTime.Now;

        if (!Enum.TryParse <FlightQuery.DateRanges>(cmbAchievementDates.SelectedValue, out dr))
        {
            throw new MyFlightbookValidationException("Invalid date range: " + cmbAchievementDates.SelectedValue);
        }
        mfbRecentAchievements.AutoDateRange = false;

        switch (dr)
        {
        default:
        case FlightQuery.DateRanges.AllTime:
            mfbRecentAchievements.AutoDateRange = true;
            dtMin = DateTime.MaxValue;
            dtMax = DateTime.MinValue;
            break;

        case FlightQuery.DateRanges.PrevMonth:
            dtMax = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddDays(-1);
            dtMin = new DateTime(dtMax.Year, dtMax.Month, 1);
            break;

        case FlightQuery.DateRanges.PrevYear:
            dtMin = new DateTime(DateTime.Now.Year - 1, 1, 1);
            dtMax = new DateTime(DateTime.Now.Year - 1, 12, 31);
            break;

        case FlightQuery.DateRanges.Tailing6Months:
            dtMin = DateTime.Now.AddMonths(-6);
            break;

        case FlightQuery.DateRanges.ThisMonth:
            dtMin = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            break;

        case FlightQuery.DateRanges.Trailing12Months:
            dtMin = DateTime.Now.AddYears(-1);
            break;

        case FlightQuery.DateRanges.Trailing30:
            dtMin = DateTime.Now.AddDays(-30);
            break;

        case FlightQuery.DateRanges.Trailing90:
            dtMin = DateTime.Now.AddDays(-90);
            break;

        case FlightQuery.DateRanges.YTD:
            dtMin = new DateTime(DateTime.Now.Year, 1, 1);
            break;
        }
        lblNoStats.Visible = mfbRecentAchievements.Refresh(Page.User.Identity.Name, dtMin, dtMax, false) == 0;
        lblRecentAchievementsTitle.Text = mfbRecentAchievements.Summary;
    }