Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new recentachievements
        /// </summary>
        /// <param name="dtStart">Start Date of period</param>
        /// <param name="dtEnd">End date of period</param>
        public RecentAchievements(DateTime dtStart, DateTime dtEnd) : base()
        {
            StartDate = dtStart.Date;
            EndDate   = dtEnd.Date;

            FlightDates      = new Dictionary <string, int>();
            FlightLandings   = new Dictionary <string, int>();
            DistinctAircraft = new HashSet <int>();
            DistinctModels   = new HashSet <int>();
            DistinctICAO     = new HashSet <string>();
            Airports         = new HashSet <string>();

            miFlightCount        = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementsFlightsLogged, MilestoneItem.MilestoneType.Count, 1);
            miLongestStreak      = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementFlyingStreakTitle, MilestoneItem.MilestoneType.Count, 1);
            miLongestNoFlyStreak = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementsNoFlyingStreakTitle, MilestoneItem.MilestoneType.Count, 1);
            miFlyingDates        = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementsFlyingDayCountTitle, MilestoneItem.MilestoneType.Count, 1);
            miMostFlightsInDay   = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementMostFlightsInDayTitle, MilestoneItem.MilestoneType.Count, 2);
            miMostLandingsInDay  = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementMostLandingsInDayTitle, MilestoneItem.MilestoneType.Count, 2);
            miLongestFlight      = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementsLongestFlightTitle, MilestoneItem.MilestoneType.AchieveOnce, 1);
            miFurthestFlight     = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementsFurthestFlightTitle, MilestoneItem.MilestoneType.AchieveOnce, 1);
            miAircraft           = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementsDistinctAircraftTitle, MilestoneItem.MilestoneType.Count, 1);
            miModels             = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementsDistinctModelsTitle, MilestoneItem.MilestoneType.Count, 1);
            miAirports           = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementsAirportsVisitedTitle, MilestoneItem.MilestoneType.Count, 1)
            {
                QueryLinkTemplate = "~/Member/Airports.aspx?fq={0}"
            };
            miMostAirportsFlight = new RecentAchievementMilestone(Resources.Achievements.RecentAchievementsAirportsOnFlightTitle, MilestoneItem.MilestoneType.AchieveOnce, 1);
        }
        public RecentAchievementMilestone ToMilestone(string Username)
        {
            RecentAchievementMilestone ra = new RecentAchievementMilestone(ToString(), MilestoneItem.MilestoneType.AchieveOnce, (int)Threshold);

            if (IsMet)
            {
                if (StartDate != null && EndDate != null)
                {
                    ra.Query = new FlightQuery(Username)
                    {
                        DateRange = FlightQuery.DateRanges.Custom, DateMin = StartDate.Value, DateMax = EndDate.Value
                    };
                    ra.MatchingEventText = String.Format(CultureInfo.CurrentCulture, Resources.Achievements.FastestHrs, Threshold, ShortestSpan.TotalDays, StartDate.Value, EndDate.Value);
                }
                ra.AddEvent(1);
            }
            return(ra);
        }