/// <summary> /// Initialises a new instance of the <see cref="ResultsConfigViewModel"/> class. /// </summary> /// <param name="resultsConfigurationManager">results configuration manager</param> /// <param name="logger">application logger</param> public ResultsConfigViewModel( IResultsConfigMngr resultsConfigurationManager, IJHcLogger logger) { this.logger = logger; this.resultsConfigurationManager = resultsConfigurationManager; this.finishingPoints = resultsConfigurationManager.ResultsConfigurationDetails.FinishingPoints.ToString(); this.seasonBestPoints = resultsConfigurationManager.ResultsConfigurationDetails.SeasonBestPoints.ToString(); this.scoringPositions = resultsConfigurationManager.ResultsConfigurationDetails.NumberOfScoringPositions.ToString(); this.teamFinishingPoints = resultsConfigurationManager.ResultsConfigurationDetails.TeamFinishingPoints.ToString(); this.teamSize = resultsConfigurationManager.ResultsConfigurationDetails.NumberInTeam.ToString(); this.teamSeasonBestPoints = resultsConfigurationManager.ResultsConfigurationDetails.TeamSeasonBestPoints.ToString(); this.scoresToCount = resultsConfigurationManager.ResultsConfigurationDetails.ScoresToCount.ToString(); this.allResults = resultsConfigurationManager.ResultsConfigurationDetails.AllResults; this.useTeams = resultsConfigurationManager.ResultsConfigurationDetails.UseTeams; this.scoresAreDescending = resultsConfigurationManager.ResultsConfigurationDetails.ScoresAreDescending; this.exludeFirstTimers = resultsConfigurationManager.ResultsConfigurationDetails.ExcludeFirstTimers; this.numberInTeamTrophyTeam = resultsConfigurationManager.ResultsConfigurationDetails.NumberInTeamTrophyTeam.ToString(); this.numberInTeamTrophyTeamOrig = this.numberInTeamTrophyTeam; this.teamTrophyPointsScoring = resultsConfigurationManager.ResultsConfigurationDetails.TeamTrophyPointsScoring; this.teamTrophyPointsScoringOrig = this.teamTrophyPointsScoring; this.finishingPointsOrig = finishingPoints; this.seasonBestPointsOrig = seasonBestPoints; this.scoringPositionsOrig = scoringPositions; this.teamFinishingPointsOrig = teamFinishingPoints; this.teamSizeOrig = teamSize; this.teamSeasonBestPointsOrig = teamSeasonBestPoints; this.scoresToCountOrig = this.scoresToCount; this.SaveCommand = new ResultsConfigSaveCmd(this); }
/// <summary> /// Creates a new instance of the <see cref="PrimaryDisplayViewModel"/> class /// </summary> /// <param name="model">application model</param> /// <param name="businessLayerManager">business layer manager</param> /// <param name="normalisationConfigurationManager">normalisation configuration manager</param> /// <param name="resultsConfigurationManager">results configuration manager</param> /// <param name="seriesConfigurationManager">series configuration manager</param> /// <param name="generalIo">general IO manager</param> /// <param name="commonIo">Common IO manager</param> /// <param name="logger">application logger</param> public PrimaryDisplayViewModel( IModel model, IBLMngr businessLayerManager, INormalisationConfigMngr normalisationConfigurationManager, IResultsConfigMngr resultsConfigurationManager, ISeriesConfigMngr seriesConfigurationManager, IGeneralIo generalIo, ICommonIo commonIo, IJHcLogger logger) { this.logger = logger; this.logger.WriteLog("HandicapMainViewModel created"); this.model = model; this.normalisationConfigManager = normalisationConfigurationManager; this.resultsConfigurationManager = resultsConfigurationManager; this.seriesConfigManager = seriesConfigurationManager; this.businessLayerManager = businessLayerManager; this.generalIo = generalIo; this.commonIo = commonIo; this.isValidLocation = this.businessLayerManager.IsValid; Messenger.Default.Register <HandicapErrorMessage>(this, this.PopulateErrorInformation); Messenger.Default.Register <HandicapProgressMessage>(this, this.PopulateProgressInformation); Messenger.Default.Register <ValidLocationMessage>(this, this.InvalidLocationMessage); this.InitialiseViewModels(); this.InitialiseOpenAppCommands(); }
/// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- /// <name>LoadAthleteSeasonData</name> /// <date>03/04/15</date> /// <summary> /// Loads the season athlete details. /// </summary> /// <param name="seasonName">season name</param> /// <returns>season athlete details</returns> /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- public List <AthleteSeasonDetails> LoadAthleteSeasonData( string seasonName, IResultsConfigMngr resultsConfigurationManager) { return(this.athleteSeasonDataReader.LoadAthleteSeasonData( this.dataPath + seasonName + Path.DirectorySeparatorChar + IOPaths.athleteDataFile, resultsConfigurationManager)); }
/// <summary> /// Initialises a new instance of the <see cref="CalculateResultsMngr"/> class. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="normalisationConfigurationManager"> /// normalisation configuration manager /// </param> /// <param name="resultsConfigurationManager"> /// results configuration manager /// </param> /// <param name="seriesConfigurationManager"> /// series configuration manager /// </param> /// <param name="logger">application logger</param> public CalculateResultsMngr( IModel model, INormalisationConfigMngr normalisationConfigurationManager, IResultsConfigMngr resultsConfigurationManager, ISeriesConfigMngr seriesConfigurationManager, IJHcLogger logger) : base(model) { this.logger = logger; this.resultsConfiguration = resultsConfigurationManager; this.hcConfiguration = normalisationConfigurationManager.ReadNormalisationConfiguration(); this.seriesConfiguration = seriesConfigurationManager.ReadSeriesConfiguration(); }
/// <summary> /// Creates a new instance of the HandicapSeason class /// </summary> /// <param name="key">new key</param> public AthleteSeasonDetails( int key, string name, IResultsConfigMngr resultsConfigurationManager) { Key = key; this.Name = name; Points = new AthleteSeasonPoints( resultsConfigurationManager); this.Times = new List <Appearances>(); this.HarmonyPoints = new AthleteSeasonHarmonyPoints(); }
/// <summary> /// Initialises a new instance of the <see cref="AthleteSummaryViewModel"/> class. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="normalisationConfigManager">Normalisation configuration manager</param> /// <param name="resultsConfigurationManager">results configuration manager</param> public AthleteSummaryViewModel( IModel model, INormalisationConfigMngr normalisationConfigManager, IResultsConfigMngr resultsConfigurationManager) { this.model = model; this.normalisationConfigManager = normalisationConfigManager; this.resultsConfigurationManager = resultsConfigurationManager; this.LoadAthleteInformation(model.Athletes.AthleteDetails); //model.AthletesCallback = new AthletesDelegate(AthleteInfoUpdated); this.athleteCollectionIndex = -1; string testString = this.AthleteSummaryKey; }
/// <summary> /// Prevents a new instance of the HandicapModel class from being created. /// </summary> /// <param name="normalisationConfigMngr">Normalisation configuration manager</param> /// <param name="resultsConfigurationManager">Results configuration manager</param> /// <param name="athleteData">athlete data</param> /// <param name="clubData">club data</param> /// <param name="eventData">event data</param> /// <param name="summaryData">summary data</param> /// <param name="resultsTableReader">results table reader</param> /// <param name="seasonIo">season IO Manager</param> /// <param name="eventIo">event IO manager</param> /// <param name="rawEventIo">raw event IO manager</param> /// <param name="generalIo">general IO manager</param> /// <param name="logger">application logger</param> public Model( INormalisationConfigMngr normalisationConfigMngr, IResultsConfigMngr resultsConfigurationManager, IAthleteData athleteData, IClubData clubData, IEventData eventData, ISummaryData summaryData, IResultsTableReader resultsTableReader, ISeasonIO seasonIo, IEventIo eventIo, IRawEventIo rawEventIo, IGeneralIo generalIo, IJHcLogger logger) { this.normalisationConfigurationManager = normalisationConfigMngr; this.resultsConfigurationManager = resultsConfigurationManager; this.athleteData = athleteData; this.clubData = clubData; this.summaryData = summaryData; this.eventIo = eventIo; this.seasonIo = seasonIo; this.logger = logger; // Setup local models. this.CurrentSeason = new Season( resultsConfigurationManager, this.athleteData, this.clubData, this.summaryData, this.eventIo, this.logger); this.CurrentEvent = new EventHC( eventData, this.summaryData, resultsTableReader, rawEventIo, this.logger); this.Seasons = seasonIo.GetSeasons(); this.Athletes = this.athleteData.ReadAthleteData(); this.Clubs = this.clubData.LoadClubData(); this.GlobalSummary = this.summaryData.LoadSummaryData(); Messenger.Default.Register <LoadNewSeriesMessage>(this, this.LoadNewSeries); }
/// <summary> /// Initialises a new instance of the <see cref="BLMngr"/> class. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="normalisationConfigurationManager">the normalisation config manager</param> /// <param name="resultsConfigurationManager">the results config manager</param> /// <param name="seriesConfigurationManager">the series config manager</param> /// <param name="athleteData">athlete data</param> /// <param name="clubData">club data</param> /// <param name="eventData">event data</param> /// <param name="summaryData">summary data</param> /// <param name="seasonIO">season IO manager</param> /// <param name="eventIo">event IO manager</param> /// <param name="generalIo">general IO manager</param> /// <param name="logger">application logger</param> public BLMngr( IModel model, INormalisationConfigMngr normalisationConfigurationManager, IResultsConfigMngr resultsConfigurationManager, ISeriesConfigMngr seriesConfigurationManager, IAthleteData athleteData, IClubData clubData, IEventData eventData, ISummaryData summaryData, ISeasonIO seasonIO, IEventIo eventIo, IGeneralIo generalIo, IJHcLogger logger) { this.logger = logger; this.model = model; this.normalisationConfigurationManager = normalisationConfigurationManager; this.resultsConfigurationManager = resultsConfigurationManager; this.seriesConfigurationManager = seriesConfigurationManager; this.athleteData = athleteData; this.clubData = clubData; this.eventData = eventData; this.summaryData = summaryData; this.seasonIO = seasonIO; this.eventIo = eventIo; this.generalIo = generalIo; this.ModelRootDirectory = RootIO.LoadRootFile(); this.currentSeason = string.Empty; this.resultsCalculator = new CalculateResultsMngr( this.model, this.normalisationConfigurationManager, this.resultsConfigurationManager, this.seriesConfigurationManager, this.logger); this.IsValid = this.generalIo.DataFolderExists && this.generalIo.ConfigurationFolderExists; Messenger.Default.Register <LoadNewSeasonMessage>(this, this.NewCurrentSeason); Messenger.Default.Register <LoadNewEventMessage>(this, this.NewCurrentEvent); Messenger.Default.Register <LoadNewSeriesMessage>(this, this.LoadNewSeries); Messenger.Default.Register <CreateNewSeriesMessage>(this, this.CreateNewSeries); Messenger.Default.Register <ReinitialiseRoot>(this, this.ReinitialiseRoot); }
/// <summary> /// Initialises a new instance of the <see cref="Season"/> class /// </summary> /// <param name="resultsConfigurationManager"> /// The results configuration manager /// </param> /// <param name="athleteData">athlete data</param> /// <param name="clubData">club data</param> /// <param name="summaryData">summary data</param> /// <param name="eventIo">event IO manager</param> /// <param name="logger">application logger</param> public Season( IResultsConfigMngr resultsConfigurationManager, IAthleteData athleteData, IClubData clubData, ISummaryData summaryData, IEventIo eventIo, IJHcLogger logger) { this.resultsConfigurationManager = resultsConfigurationManager; this.athleteData = athleteData; this.clubData = clubData; this.summaryData = summaryData; this.eventIo = eventIo; this.logger = logger; this.athletes = new List <IAthleteSeasonDetails>(); this.clubs = new List <IClubSeasonDetails>(); this.summary = new Summary(); this.events = new List <string>(); Messenger.Default.Register <LoadNewSeasonMessage>(this, this.LoadNewSeason); }
/// <summary> /// Initialise a new instance of the <see cref="AthleteSeasonPoints"/> class. /// </summary> /// <param name="config">Instructions on how to read the scores</param> public AthleteSeasonPoints(IResultsConfigMngr resultsConfigurationManager) { this.resultsConfigurationManager = resultsConfigurationManager; this.AllPoints = new List <CommonPoints>(); }
/// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- /// <name>SaveAthleteSeasonData</name> /// <date>30/03/15</date> /// <summary> /// Reads the athlete season details xml from file and decodes it. /// </summary> /// <param name="fileName">name of xml file</param> /// <returns>decoded athlete's details</returns> /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- public List <IAthleteSeasonDetails> LoadAthleteSeasonData( string fileName, IResultsConfigMngr resultsConfigurationManager) { List <IAthleteSeasonDetails> seasonDetails = new List <IAthleteSeasonDetails>(); try { XDocument reader = XDocument.Load(fileName); XElement rootElement = reader.Root; var athleteList = from Athlete in rootElement.Elements(c_athleteElement) select new { key = (int)Athlete.Attribute(c_keyAttribute), name = (string)Athlete.Attribute(c_nameAttribute), runningNumbers = from RunningNumbers in Athlete.Elements(c_runningNumbersElement) select new { numbers = from Numbers in RunningNumbers.Elements(c_numberElement) select new { number = (string)Numbers.Attribute(c_numberAttribute) } }, eventTimes = from EventTimes in Athlete.Elements(c_timesElement) select new { events = from Times in EventTimes.Elements(c_eventTimeElement) select new { time = (string)Times.Attribute(c_eventTimeAttribute), date = (string)Times.Attribute(c_eventDateAttribute) } }, mobTrophyPoints = from Points in Athlete.Elements(MobTrophyPointsElement) select new { point = from Point in Points.Elements(c_eventPointsElement) select new { finishing = (int)Point.Attribute(c_finishingPoints), position = (int)Point.Attribute(c_positionPoints), best = (int)Point.Attribute(c_bestPoints), date = (string)Point.Attribute(c_eventDateAttribute) } }, teamTrophyPoints = from Points in Athlete.Elements(TeamTrophyPointsElement) select new { point = from Point in Points.Elements(c_eventPointsElement) select new { teamTrophyPoint = (int)Point.Attribute(TeamTrophyPointsAttribute), date = (string)Point.Attribute(c_eventDateAttribute) } } }; foreach (var athlete in athleteList) { AthleteSeasonDetails athleteDetails = new AthleteSeasonDetails( athlete.key, athlete.name); foreach (var eventTms in athlete.eventTimes) { foreach (var times in eventTms.events) { athleteDetails.AddNewTime(new Appearances(new RaceTimeType(times.time), new DateType(times.date))); } } foreach (var points in athlete.mobTrophyPoints) { foreach (var point in points.point) { DateType eventDate = new DateType( point.date); CommonPoints commonPoints = new CommonPoints( point.finishing, point.position, point.best, eventDate); athleteDetails.Points.AddNewEvent(commonPoints); // TODO, should probably check that there are the correct number read from the xml file. // i.e. there is one for each event in the currently loaded season. // Will want to change it to proper serialisation at some point. } } foreach (var points in athlete.teamTrophyPoints) { foreach (var point in points.point) { DateType date = new DateType(point.date); IAthleteTeamTrophyPoints newEvent = new AthleteTeamTrophyPoints( point.teamTrophyPoint, date); athleteDetails.TeamTrophyPoints.AddNewEvent(newEvent); } } seasonDetails.Add(athleteDetails); } } catch (Exception ex) { this.logger.WriteLog("Error reading athlete data: " + ex.ToString()); seasonDetails = new List <IAthleteSeasonDetails>(); } return(seasonDetails); }