Exemple #1
0
 /// <summary>
 /// Set points to an existing entry
 /// </summary>
 /// <param name="eventIndex">event index</param>
 /// <param name="updatedPoints">points received</param>
 public void SetMobTrophyPoints(
     int eventIndex,
     ICommonPoints updatedPoints)
 {
     this.MobTrophy.SetPoints(
         eventIndex,
         updatedPoints);
 }
Exemple #2
0
 /// <summary>
 /// Set points to an existing entry
 /// </summary>
 /// <param name="eventIndex">event index</param>
 /// <param name="updatedPoints">points received</param>
 public void SetClubCompetitionPoints(
     int eventIndex,
     ICommonPoints updatedPoints)
 {
     this.ClubCompetition.SetPoints(
         eventIndex,
         updatedPoints);
 }
Exemple #3
0
 /// <summary>
 /// Set points to an existing entry
 /// </summary>
 /// <param name="eventIndex">event index</param>
 /// <param name="updatedPoints">points received</param>
 public void SetPoints(
     int eventIndex,
     ICommonPoints updatedPoints)
 {
     if (eventIndex < this.Points.Count)
     {
         this.Points[eventIndex] = updatedPoints;
     }
 }
Exemple #4
0
        /// <summary>
        /// Add points to the named club
        /// </summary>
        /// <param name="clubName">name of club</param>
        /// <param name="points">points to add</param>
        public void AddNewMobTrophyPoints(
            string clubName,
            ICommonPoints points)
        {
            IClubSeasonDetails clubDetails = Clubs.Find(club => club.Name.CompareTo(clubName) == 0);

            if (clubDetails != null)
            {
                clubDetails.AddNewEvent(points);
            }
            else
            {
                ClubSeasonDetails newClubDetails = new ClubSeasonDetails(clubName);
                newClubDetails.AddNewEvent(points);

                Clubs.Add(newClubDetails);
            }

            this.ClubsChangedEvent?.Invoke(this, new EventArgs());
        }
Exemple #5
0
        /// <summary>
        /// Write the Mob Trophy points table to a file
        /// </summary>
        /// <param name="model">junior handicap model</param>
        /// <param name="folder">output folder</param>
        /// <param name="eventData">event data wrapper</param>
        /// <param name="logger">application logger</param>
        /// <returns>success flag</returns>
        public static bool WriteMobTrophyPointsTable(
            IModel model,
            string folder,
            IEventData eventData,
            IJHcLogger logger)
        {
            bool            success    = true;
            List <DateType> eventDates = new List <DateType>();

            Messenger.Default.Send(
                new HandicapProgressMessage(
                    "Saving Mob Trophy points table"));

            // Export the overall season table.
            try
            {
                string outPath =
                    Path.GetFullPath(folder) +
                    Path.DirectorySeparatorChar +
                    model.CurrentSeason.Name +
                    model.CurrentEvent.Name +
                    ResultsPaths.mobTrophyPointsTable +
                    ResultsPaths.csvExtension;

                using (StreamWriter writer = new StreamWriter(outPath))
                {
                    string titleString = "Club" + ResultsPaths.separator + "TotalPoints";

                    foreach (string eventName in model.CurrentSeason.Events)
                    {
                        titleString = titleString + ResultsPaths.separator + eventName;
                        eventDates.Add(eventData.LoadEventData(model.CurrentSeason.Name, eventName).EventDate);
                    }

                    writer.WriteLine(titleString);

                    foreach (ClubSeasonDetails club in model.CurrentSeason.Clubs)
                    {
                        if (club.MobTrophy.TotalPoints > 0)
                        {
                            string entryString =
                                $"{club.Name}{ResultsPaths.separator}{club.MobTrophy.TotalPoints}";

                            foreach (DateType eventDate in eventDates)
                            {
                                if (club.MobTrophy.Points.Exists(points => points.Date == eventDate))
                                {
                                    int eventPoints = club.MobTrophy.Points.Find(points => points.Date == eventDate).TotalPoints;

                                    entryString = entryString + ResultsPaths.separator + eventPoints;
                                }
                                else
                                {
                                    entryString = entryString + ResultsPaths.separator;
                                }
                            }

                            writer.WriteLine(entryString);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.WriteLog("Error, failed to print mob trophy points table: " + ex.ToString());

                Messenger.Default.Send(
                    new HandicapErrorMessage(
                        "Failed to print mob trophy points table"));

                success = false;
            }

            // Export the table for the current event.
            try
            {
                using (
                    StreamWriter writer =
                        new StreamWriter(
                            Path.GetFullPath(folder) +
                            Path.DirectorySeparatorChar +
                            model.CurrentSeason.Name +
                            model.CurrentEvent.Name +
                            ResultsPaths.mobTrophyPointsTableCurrentEvent +
                            ResultsPaths.csvExtension))
                {
                    string titleString =
                        "Club" + ResultsPaths.separator +
                        "Total Points" + ResultsPaths.separator +
                        "Finishing Points" + ResultsPaths.separator +
                        "Position Points" + ResultsPaths.separator +
                        "Season Best Points";

                    writer.WriteLine(titleString);

                    foreach (ClubSeasonDetails club in model.CurrentSeason.Clubs)
                    {
                        if (club.MobTrophy.TotalPoints > 0)
                        {
                            ICommonPoints currentEventPoints =
                                club.MobTrophy.Points.Find(
                                    e => e.Date == model.CurrentEvent.Date);

                            if (currentEventPoints == null)
                            {
                                continue;
                            }

                            string entryString =
                                club.Name + ResultsPaths.separator +
                                currentEventPoints.TotalPoints + ResultsPaths.separator +
                                currentEventPoints.FinishingPoints + ResultsPaths.separator +
                                currentEventPoints.PositionPoints + ResultsPaths.separator +
                                currentEventPoints.BestPoints;
                            writer.WriteLine(entryString);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.WriteLog("Error, failed to print mob trophy points table: " + ex.ToString());

                Messenger.Default.Send(
                    new HandicapErrorMessage(
                        "Failed to print mob trophy points table"));

                success = false;
            }

            return(success);
        }
Exemple #6
0
 /// <summary>
 /// Add a new event.
 /// </summary>
 /// <param name="newPoints">points received</param>
 public void AddNewEvent(
     ICommonPoints newPoints)
 {
     this.MobTrophy.AddNewEvent(newPoints);
 }
Exemple #7
0
 /// <summary>
 /// Add a new event.
 /// </summary>
 /// <param name="newPoints">points received</param>
 public void AddNewEvent(
     ICommonPoints newPoints)
 {
     this.ClubCompetition.AddNewEvent(newPoints);
 }
Exemple #8
0
 /// <summary>
 /// Add a new event.
 /// </summary>
 /// <param name="newPoints">points received</param>
 public void AddNewEvent(ICommonPoints newPoints)
 {
     this.Points.Add(newPoints);
 }