/// <summary> /// Create new series data in the current folder. /// </summary> public void CreateNewSeries() { HandicapProgressMessage progress = new HandicapProgressMessage("New Series Created"); CreateNewSeriesMessage createNew = new CreateNewSeriesMessage(); LoadNewSeriesMessage loadNewMessage = new LoadNewSeriesMessage(); NewSeriesLoadedMessage newLoadedMessage = new NewSeriesLoadedMessage(); Messenger.Default.Send(createNew); Messenger.Default.Send(loadNewMessage); Messenger.Default.Send(newLoadedMessage); Messenger.Default.Send(progress); }
/// <summary> /// Gets a new location and load it. /// </summary> public void LoadNewSeries() { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.SelectedPath = this.businessLayerManager.ModelRootDirectory; DialogResult result = dialog.ShowDialog(); this.businessLayerManager.SaveRootDirectory(dialog.SelectedPath); LoadNewSeriesMessage loadNewMessage = new LoadNewSeriesMessage(); NewSeriesLoadedMessage newLoadedMessage = new NewSeriesLoadedMessage(); HandicapProgressMessage progress = new HandicapProgressMessage("New Series Loaded"); Messenger.Default.Send(loadNewMessage); Messenger.Default.Send(newLoadedMessage); Messenger.Default.Send(progress); }
/// <summary> /// Populate the progress information /// </summary> /// <param name="progressInformaion">progress information</param> public void PopulateProgressInformation(HandicapProgressMessage progressInformaion) { this.ProgressInformation = progressInformaion.ProgressMessage; }
/// <summary> /// Cancel the print command /// </summary> public void CancelPrint() { HandicapProgressMessage progress = new HandicapProgressMessage("Print cancelled"); Messenger.Default.Send(progress); }
/// <summary> /// Calculate the results for the loaded event. /// </summary> public void CalculateResults() { this.logger.WriteLog("Calculate results"); HandicapProgressMessage startMessage = new HandicapProgressMessage("Calculate Results"); Messenger.Default.Send(startMessage); if (this.resultsConfiguration == null) { this.logger.WriteLog("Error reading the results config file. Results not generated"); HandicapErrorMessage faultMessage = new HandicapErrorMessage( "Can't calculate results - invalid config"); Messenger.Default.Send(faultMessage); HandicapProgressMessage terminateMessage = new HandicapProgressMessage("Calculate Results - Terminated"); Messenger.Default.Send(terminateMessage); return; } if (this.resultsConfiguration.ResultsConfigurationDetails.TeamTrophyPoints == null) { this.logger.WriteLog("Can't calculate results, Team Trophy points are invalid"); HandicapErrorMessage faultMessage = new HandicapErrorMessage( "Can't calculate results - check config"); Messenger.Default.Send(faultMessage); HandicapProgressMessage terminateMessage = new HandicapProgressMessage("Calculate Results - Terminated"); Messenger.Default.Send(terminateMessage); return; } List <IRaw> rawResults = this.Model.CurrentEvent.LoadRawResults(); // Set up the array to work out the points table List <MobTrophyPoints> mobTrophyPoints = this.SetupMobTrophyPoints(); // ensure that each athlete is registered for season. this.RegisterAllAthletesForTheCurrentSeason(rawResults); // Analyse results EventResults resultsTable = this.GenerateResultsTable( rawResults); // Sort by running time to work out the speed order. resultsTable.ApplySpeedOrder(); // Sort by time: Add position points, note first boy, first girl, second and third. this.AddPositionPoints( resultsTable, this.Model.CurrentEvent.Date); resultsTable.OrderByFinishingTime(); this.AddPlacings(resultsTable); this.AssignMobTrophyPoints( resultsTable, this.Model.CurrentEvent.Date, mobTrophyPoints); this.CalculateTeamTrophyPoints( resultsTable, this.Model.CurrentEvent.Date); this.Model.CurrentEvent.SetResultsTable(resultsTable); this.SaveAll(); this.logger.WriteLog("Calculate results completed."); HandicapProgressMessage finishedMessage = new HandicapProgressMessage("Calculate Results - Completed"); Messenger.Default.Send(finishedMessage); }
/// <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 <List <string> > rawPositions = commonIo.ReadPairedStringListFomFile(fileName); foreach (List <string> positionAthleteData in rawPositions) { // Ensure 2 results present if (positionAthleteData.Count == 2) { int? position = null; string raceNumber = null; string result1 = ResultsDecoder.OpnScannerResultsBarcode(positionAthleteData[0]); string result2 = ResultsDecoder.OpnScannerResultsBarcode(positionAthleteData[1]); UpdatePositionAthleteData( result1, ref position, ref raceNumber); UpdatePositionAthleteData( result2, ref position, ref raceNumber); if (position != null && raceNumber != null) { RawPositionResults results = new RawPositionResults( raceNumber, (int)position); rawImportedPositions.Add(results); } else { string errorString = $"Can't decode {positionAthleteData[0]}/{positionAthleteData[1]}"; HandicapProgressMessage message = new HandicapProgressMessage( errorString); Messenger.Default.Send( new HandicapProgressMessage( errorString)); logger.WriteLog(errorString); } } else { string errorString = "Please check results, result/barcode pair invalid"; Messenger.Default.Send( new HandicapProgressMessage( errorString)); logger.WriteLog(errorString); } } rawImportedPositions = rawImportedPositions .OrderBy(position => position.Position) .ToList(); return(rawImportedPositions); }