/// <summary> /// Initialises a new instance of the <see cref="SeriesConfigViewModel"/> class. /// </summary> /// <param name="seriesConfigurationManager">series configuration manager</param> /// <param name="logger">application logger</param> public SeriesConfigViewModel( ISeriesConfigMngr seriesConfigurationManager, IJHcLogger logger) { this.logger = logger; this.seriesConfigManager = seriesConfigurationManager; SeriesConfigType config = this.seriesConfigManager.ReadSeriesConfiguration(); if (config == null) { this.logger.WriteLog( "Series Config VM not initialised, Config reader has failed."); return; } numberPrefix = config.NumberPrefix; numberPrefixOrig = this.NumberPrefix; this.SaveCommand = new SeriesConfigSaveCmd(this); this.jointSecondThird = !config.AllPositionsShown; this.allPositions = config.AllPositionsShown; }
/// <summary> /// Write the Team Trophy 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 Write( IModel model, string folder, IEventData eventData, IJHcLogger logger) { Messenger.Default.Send( new HandicapProgressMessage( "Saving Team Trophy points table")); string folderPath = Path.GetFullPath(folder) + Path.DirectorySeparatorChar + model.CurrentSeason.Name + model.CurrentEvent.Name; bool overallSuccess = TeamTrophyTableWriter.WriteOverallSeasonTable( model, folderPath, eventData, logger); bool currentSuccess = TeamTrophyTableWriter.WriteCurrentEventTable( model, folderPath, logger); return(overallSuccess && currentSuccess); }
/// <summary> /// Initialises a new instance of the <see cref="SeasonPaneViewModel"/> class. /// </summary> /// <param name="model"></param> /// <param name="businessLayerManager"></param> /// <param name="generalIo">general IO manager</param> /// <param name="logger">program logger</param> public SeasonPaneViewModel( IModel model, IBLMngr businessLayerManager, IGeneralIo generalIo, IJHcLogger logger) { this.logger = logger; this.model = model; this.businessLayerManager = businessLayerManager; this.generalIo = generalIo; OpenAthleteSeasonSummaryCommand = new SimpleCommand( this.OpenAthleteSeasonSummaryDialog, this.IsLocationValid); this.NewSeasonCommand = new SimpleCommand( this.EnableNewSeasonFields, this.IsLocationValid); this.AddSeasonCommand = new SimpleCommand( this.AddNewSeason, this.NewSeasonValid); CancelSeasonCommand = new SimpleCommand( this.CancelNewSeasonFields); this.InitialiseSeasonPane(); this.LoadSeason(); Messenger.Default.Register <NewSeriesLoadedMessage>(this, this.NewSeriesLoaded); }
/// <summary> /// Save the Team Trophy current event table. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="folderPath">path of the folder to save the table to</param> /// <param name="logger">application logger</param> /// <returns>success flag</returns> private static bool WriteCurrentEventTable( IModel model, string folderPath, IJHcLogger logger) { bool success = true; try { string outPath = $"{folderPath}{ResultsPaths.teamTrophyPointsTableCurrentEvent}{ResultsPaths.csvExtension}"; using ( StreamWriter writer = new StreamWriter( outPath)) { string titleString = "Club" + ResultsPaths.separator + "Score" + ResultsPaths.separator + "Points"; writer.WriteLine(titleString); foreach (ClubSeasonDetails club in model.CurrentSeason.Clubs) { if (club.MobTrophy.TotalPoints > 0) { ITeamTrophyEvent foundEvent = club.TeamTrophy.Events.Find( e => e.Date == model.CurrentEvent.Date); if (foundEvent == null) { continue; } string entryString = $"{club.Name}{ResultsPaths.separator}{foundEvent.Score}{ResultsPaths.separator}{foundEvent.TotalAthletePoints}"; foreach (ICommonTeamTrophyPoints commonPoints in foundEvent.Points) { entryString = entryString + ResultsPaths.separator + commonPoints.Point; } writer.WriteLine(entryString); } } } } catch (Exception ex) { logger.WriteLog("Error, failed to print club points table: " + ex.ToString()); Messenger.Default.Send( new HandicapErrorMessage( "Failed to print club points table")); success = false; } return(success); }
/// <summary> /// Initialises a new instance of the <see cref="LabelGenerationViewModel"/> class. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="normalisationConfigManager">normalisation configuration manager</param> /// <param name="seriesConfigManager">series configuration manager</param> /// <param name="logger">application logger</param> /// <param name="saveFolder">folder to save the output to</param> public LabelGenerationViewModel( IModel model, INormalisationConfigMngr normalisationConfigManager, ISeriesConfigMngr seriesConfigManager, IJHcLogger logger, string saveFolder) { this.model = model; this.seriesConfigManager = seriesConfigManager; this.logger = logger; SaveFolder = saveFolder; NormalisationConfigType hcConfiguration = normalisationConfigManager.ReadNormalisationConfiguration(); // TODO, this is repeated code, see HandicapWriter.cs foreach (AthleteDetails athlete in model.Athletes.AthleteDetails) { TimeType newHandicap = model.CurrentSeason.GetAthleteHandicap(athlete.Key, hcConfiguration); // Only look at active athletes. if (athlete.Active) { List <string> runningNumbers = model.Athletes.GetAthleteRunningNumbers(athlete.Key); // Use default handicap, if the athlete is not registered for the current season. // TODO, I suspect this should never happen??? if (newHandicap == null) { newHandicap = athlete.RoundedHandicap; } // Ensure that the athlete is registered for the season. if (runningNumbers.Count > 0) { AthleteLabel modelAthlete = new AthleteLabel( athlete.Name, athlete.Club, runningNumbers[0], newHandicap, athlete.Appearances == 0); modelAthlete.AthleteLabelWidth = A4Details.GetLabelWidth96DPI(NoColumns); modelAthlete.AthleteLabelHeight = A4Details.GetLabelHeight96DPI(NoRows); this.AthleteDetails.Add(modelAthlete); } } } // Order the athletes alphabetically. this.AthleteDetails = this.AthleteDetails.OrderBy(athlete => athlete.Forename).ToList(); this.AthleteDetails = this.AthleteDetails.OrderBy(athlete => athlete.Surname).ToList(); this.saveDirectory = saveFolder; this.CreateRaceLabelsCommand = new CreateAndSaveRaceLabelsCmd(this); this.CreateSpareLabelsCommand = new CreateAndSaveSpareLabelsCmd(this); this.CreateAllLabelsCommand = new CreateAndSaveAllLabelsCmd(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(); }
/// <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> /// Initialises a new instance of the <see cref="SummaryData"/> class. /// </summary> /// <param name="logger"></param> public SummaryData(IJHcLogger logger) { this.logger = logger; this.summaryDataReader = new SummaryDataReader( this.logger); }
/// <summary> /// Initialises a new instance of the <see cref="EventIO"/> class. /// </summary> /// <param name="logger">application logger</param> public EventIO(IJHcLogger logger) { this.logger = logger; this.rootDirectory = RootIO.LoadRootFile(); this.dataPath = $"{this.rootDirectory}{Path.DirectorySeparatorChar}{IOPaths.dataPath}{Path.DirectorySeparatorChar}"; Messenger.Default.Register <ReinitialiseRoot>(this, this.ReinitialiseRoot); }
/// <summary> /// Initialises a new instance <see cref="EventData"/> class. /// </summary> /// <param name="logger">application logger</param> public EventData( IJHcLogger logger) { this.logger = logger; this.eventDataReader = new EventDataReader( this.logger); }
/// <summary> /// Initialises a new instance of the <see cref="AthleteDataReader"/> class. /// </summary> /// <param name="normalisationConfigManager">Normalisation config manager</param> /// <param name="seriesConfigManager">series config manager</param> /// <param name="logger">application logger</param> public AthleteDataReader( INormalisationConfigMngr normalisationConfigManager, ISeriesConfigMngr seriesConfigManager, IJHcLogger logger) { this.logger = logger; this.normalisationConfigManager = normalisationConfigManager; this.seriesConfigManager = seriesConfigManager; }
/// <summary> /// Initialises a new instance of the <see cref="DeleteResultsMngr"/> class. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="normalisationConfigManager">normalisation config manager</param> /// <param name="logger">application logger</param> public DeleteResultsMngr( IModel model, INormalisationConfigMngr normalisationConfigManager, IJHcLogger logger) : base(model) { this.logger = logger; this.normalisationConfigMngr = normalisationConfigManager; }
/// <summary> /// Initialises a new instance of the <see cref="SeriesConfigMngr"/> class /// </summary> /// <param name="generalIo">general IO manager</param> /// <param name="reader">series config reader</param> /// <param name="logger">application logger</param> public SeriesConfigMngr( IGeneralIo generalIo, ISeriesConfigReader reader, IJHcLogger logger) { this.generalIo = generalIo; this.reader = reader; this.logger = logger; }
/// <summary> /// Initialises a new instance of the <see cref="NormalisationConfigMngr"/> class /// </summary> /// <param name="generalIo">general IO manager</param> /// <param name="reader">normalisation config reader</param> /// <param name="logger">application logger</param> public NormalisationConfigMngr( IGeneralIo generalIo, INormalisationConfigReader reader, IJHcLogger logger) { this.generalIo = generalIo; this.reader = reader; this.logger = logger; }
/// <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> /// Initialises a new instance of the <see cref="ClubData"/> class. /// </summary> /// <param name="generalIo">general IO manager</param> /// <param name="logger">application logger</param> public ClubData( IGeneralIo generalIo, IJHcLogger logger) { this.logger = logger; this.generalIo = generalIo; this.clubDataReader = new ClubDataReader( this.logger); this.clubSeasonDataReader = new ClubSeasonDataReader( this.logger); }
/// <summary> /// Import the times from <paramref name="fileName"/> /// </summary> /// <param name="fileName">file containing times</param> /// <param name="commonIo">common Io manager</param> /// <param name="logger">program logger</param> /// <returns>collection of race times.</returns> public static List <RawPositionResults> Import( string fileName, ICommonIo commonIo, IJHcLogger logger) { List <RawPositionResults> rawImportedPositions = new List <RawPositionResults>(); List <string> rawPositions = commonIo.ReadFile(fileName); foreach (string positionAthleteData in rawPositions) { char splitChar = ','; string[] resultLine = positionAthleteData.Split(splitChar); // Ensure this line is not the first one and its valid. if (string.Equals(resultLine[0], StartString) || resultLine.Length != ImportParkrunPositionFactory.NumberOfSectionsInAValdEntry) { continue; } // Ensure that the interesting data is not empty. if (string.IsNullOrEmpty(resultLine[0]) || string.IsNullOrEmpty(resultLine[1]) || !ResultsDecoder.IsPositionValue(resultLine[1])) { continue; } int?position = ResultsDecoder.ConvertPositionValue( resultLine[1]); RawPositionResults result = new RawPositionResults( resultLine[0], (int)position); rawImportedPositions.Add(result); } rawImportedPositions = rawImportedPositions .OrderBy(position => position.Position) .ToList(); return(rawImportedPositions); }
/// <summary> /// Initialise a new instance of the <see cref="ResultsConfigMngr"/> class. /// </summary> /// <param name="generalIo">general IO manager</param> /// <param name="logger">application model</param> public ResultsConfigMngr( IGeneralIo generalIo, IJHcLogger logger) { this.logger = logger; this.generalIo = generalIo; this.configurationReader = new ResultsConfigReader( logger); this.ResultsConfigurationDetails = this.configurationReader.LoadResultsConfigData( this.generalIo.ResultsConfigurationFile); Messenger.Default.Register <LoadNewSeriesMessage>(this, this.LoadNewSeries); }
/// <summary> /// Initialise a new instance of the <see cref="EventPaneViewModel"/> class. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="businessLayerManager">business layer manager</param> /// <param name="generalIo">general IO manager</param> /// <param name="commonIo">common IO manager</param> /// <param name="logger">application logger</param> public EventPaneViewModel( IModel model, IBLMngr businessLayerManager, IGeneralIo generalIo, ICommonIo commonIo, IEventIo eventIo, IJHcLogger logger) { this.model = model; this.businessLayerManager = businessLayerManager; this.generalIo = generalIo; this.commonIo = commonIo; this.eventIo = eventIo; this.logger = logger; this.seasonName = this.model.CurrentSeason.Name; // TODO, this.IsLocationValid has been copied from PrimaryDisplayViewModel. Can this be rationalised. NewEventCommand = new SimpleCommand( this.EnableNewEventFields, this.IsLocationValid); AddEventCommand = new SimpleCommand( this.AddNewEvent, this.NewEventValid); CancelEventCommand = new SimpleCommand( this.CancelNewEventFields); OpenEventRawResultsDlgCommand = new SimpleCommand( this.OpenEventRawResultsDialog, this.IsLocationValid); OpenEventImportResultsDlgCommand = new SimpleCommand( this.OpenEventImportResultsDialog, this.IsLocationValid); CalculateResultsCommand = new SimpleCommand( this.CalculateResults, this.CanCalculateResults); this.InitialiseEventPane(); Messenger.Default.Register <LoadNewSeasonMessage>(this, this.NewSeasonSelected); }
/// <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> /// View model which manages raw results view. /// </summary> /// <param name="handicapEventModel">junior handicap model</param> /// <param name="athletesModel">athletes model</param> /// <param name="commonIo">common IO manager</param> /// <param name="logger">application logger</param> public EventRawResultsViewModel( IHandicapEvent handicapEventModel, Athletes athletesModel, ICommonIo commonIo, IJHcLogger logger) { this.handicapEventModel = handicapEventModel; this.athletesModel = athletesModel; this.commonIo = commonIo; this.logger = logger; // Get the list of athletes registered for the current season from the Business layer. // This doesn't include the raw results, so read this directly from a file and add // to the the list. this.LoadRegisteredInformation(athletesModel.AthleteDetails); LoadRawEventResults(); this.canSaveImported = false; this.importedState = string.Empty; AddNewResultCommand = new SimpleCommand( this.AddRawTimeCmd, this.AddRawTimeCmdAvailable); SaveImportedResultsCommand = new SimpleCommand( this.SaveImportResults, this.CanSaveImported); SaveCommand = new SimpleCommand( this.SaveRawResultsCmd, this.SaveRawResultsCmdAvailable); ImportPositionsCommand = new SimpleCommand( this.ImportPositionDataDialog); ImportTimesCommand = new SimpleCommand( this.ImportTimesDataDialog); this.unregisteredAthletesIndex = -1; }
/// <summary> /// Write the next runner to a file. /// </summary> /// <param name="model">junior handicap model</param> /// <param name="folder">output model</param> /// <param name="seriesConfigMngr">series configuraton manager</param> /// <param name="logger">application logger</param> /// <returns>success flag</returns> public static bool WriteNextRunnerTable( IModel model, string folder, ISeriesConfigMngr seriesConfigMngr, IJHcLogger logger) { bool success = true; Messenger.Default.Send( new HandicapProgressMessage( "Printing next runner.")); SeriesConfigType config = seriesConfigMngr.ReadSeriesConfiguration(); try { using (StreamWriter writer = new StreamWriter(Path.GetFullPath(folder) + Path.DirectorySeparatorChar + model.CurrentSeason.Name + model.CurrentEvent.Name + ResultsPaths.nextNewRunner + ResultsPaths.csvExtension)) { writer.WriteLine(config?.NumberPrefix + model.Athletes.NextAvailableRaceNumber.ToString("000000")); } } catch (Exception ex) { logger.WriteLog("Error, failed to print next runner: " + ex.ToString()); Messenger.Default.Send( new HandicapErrorMessage( "Failed to print next runner")); success = false; } return(success); }
/// <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> /// Initialises a new instance of the <see cref="EventHC"/> class /// </summary> /// <param name="eventData">event data</param> /// <param name="summaryData">summary data</param> /// <param name="resultsTableReader">results table reader</param> /// <param name="rawEventIo">raw events IO manager</param> /// <param name="logger">application logger</param> public EventHC( IEventData eventData, ISummaryData summaryData, IResultsTableReader resultsTableReader, IRawEventIo rawEventIo, IJHcLogger logger) { this.eventData = eventData; this.summaryData = summaryData; this.resultsTableReader = resultsTableReader; this.rawEventIo = rawEventIo; this.logger = logger; this.Name = string.Empty; this.seasonName = string.Empty; this.Date = new DateType(); this.summary = new Summary(); this.resultsTable = new EventResults(); Messenger.Default.Register <LoadNewSeasonMessage>(this, this.NewSeasonSelected); Messenger.Default.Register <LoadNewEventMessage>(this, this.LoadNewEvent); }
/// <summary> /// Initialises a new instance of the <see cref="NormalisationConfigViewModel"/> class. /// </summary> /// <param name="normalisationConfigManager">normalisation config manager</param> /// <param name="logger">application logger</param> public NormalisationConfigViewModel( INormalisationConfigMngr normalisationConfigManager, IJHcLogger logger) { this.normalisationConfigManager = normalisationConfigManager; this.logger = logger; NormalisationConfigType config = this.normalisationConfigManager.ReadNormalisationConfiguration(); useHandicap = config.UseCalculatedHandicap; handicapTime = config.HandicapTime.ToString(); minimumHandicap = config.MinimumHandicap.ToString(); this.handicapInterval = config.HandicapInterval.ToString(); useHandicapOrig = UseHandicap; handicapTimeOrig = HandicapTime; minimumHandicapOrig = MinimumHandicap; this.handicapIntervalOrig = this.HandicapInterval; SaveCommand = new NormalisationConfigSaveCmd(this); }
/// <summary> /// Initialises a new instance of the <see cref="AthleteData"/> class. /// </summary> /// <param name="generalIo">general IO manager</param> /// <param name="logger">application logger</param> public AthleteData( IGeneralIo generalIo, INormalisationConfigMngr normalisationConfigManager, ISeriesConfigMngr seriesConfigManager, IJHcLogger logger) { this.generalIo = generalIo; this.logger = logger; this.athleteDataReader = new AthleteDataReader( normalisationConfigManager, seriesConfigManager, this.logger); this.athleteSeasonDataReader = new AthleteSeasonDataReader( this.logger); string rootDirectory = RootIO.LoadRootFile(); this.dataPath = $"{rootDirectory}{Path.DirectorySeparatorChar}{IOPaths.dataPath}{Path.DirectorySeparatorChar}"; Messenger.Default.Register <ReinitialiseRoot>(this, this.ReinitialiseRoot); }
/// <summary> /// Initialises a new instance of the <see cref="RawEventIO"/> class. /// </summary> /// <param name="logger">application logger</param> public RawEventIO( IJHcLogger logger) { this.logger = logger; }
/// <summary> /// Initialises a new instance of the <see cref="ResultsTableReader"/> class. /// </summary> /// <param name="logger"></param> public ResultsTableReader(IJHcLogger logger) { this.logger = logger; }
/// <summary> /// Write the results to a comma separated file /// </summary> /// <param name="model">junior handicap model</param> /// <param name="folder">folder to save the file to</param> /// <param name="logger">application logger</param> /// <returns>success flag</returns> public static bool SavePointsTable( IModel model, string folder, IJHcLogger logger) { bool success = false; Messenger.Default.Send( new HandicapProgressMessage( "Saving results.")); try { using (StreamWriter writer = new StreamWriter(Path.GetFullPath(folder) + Path.DirectorySeparatorChar + model.CurrentSeason.Name + model.CurrentEvent.Name + ResultsPaths.pointsTable + ResultsPaths.csvExtension)) { foreach (AthleteSeasonDetails athlete in model.CurrentSeason.Athletes) { if (athlete.Points.TotalPoints > 0) { double averagePoints = 0; if (athlete.NumberOfAppearances > 0) { averagePoints = (double)athlete.Points.TotalPoints / (double)athlete.NumberOfAppearances; } string entryString = athlete.Name + ResultsPaths.separator + athlete.Points.TotalPoints.ToString() + ResultsPaths.separator + model.Athletes.GetPB(athlete.Key).ToString() + ResultsPaths.separator + athlete.SB.ToString() + ResultsPaths.separator + athlete.NumberOfAppearances.ToString() + ResultsPaths.separator + averagePoints.ToString("0.##"); writer.WriteLine(entryString); } } success = true; } } catch (Exception ex) { logger.WriteLog("Error, failed to print points table: " + ex.ToString()); Messenger.Default.Send( new HandicapErrorMessage( "Failed to print points table")); success = false; } return(success); }