private static void ProcessTeams(List<ShooterStageData> results, List<TeamData> teams, Settings settings) { List<TeamResult> finalResults = new List<TeamResult>(); List<string> missingShooters = new List<string>(); foreach (var team in teams) { var scores = new List<ShooterStageData>(); foreach (string shooterName in team.ShooterNames) { ShooterStageData score = results.FirstOrDefault(s => CompareShootersNames(s.FullName, shooterName)); if (score != null) { scores.Add(score); } else { missingShooters.Add(shooterName); } } finalResults.Add(new TeamResult(team.Name, scores)); } if (missingShooters.Count > 0) { System.Console.WriteLine(); System.Console.WriteLine("Missing shooters: "); foreach (var shooter in missingShooters) { System.Console.WriteLine(shooter); } System.Console.WriteLine(); } File.Copy(settings.TeamResultsTemplatePath, settings.TeamResultsPath, true); using (FileStream stream = File.Open(settings.TeamResultsPath, FileMode.Open, FileAccess.ReadWrite)) { ExportTeamResultsAsExcel exporter = new ExportTeamResultsAsExcel(); var s = exporter.Export(finalResults, stream); } string content = GenerateTextResults(finalResults); string path = Path.ChangeExtension(settings.TeamResultsPath, "txt"); File.WriteAllText(path, content); }
private void ProcessTeams(List<ShooterStageData> results, List<TeamData> teams) { List<TeamResult> finalResults = new List<TeamResult>(); foreach (var team in teams) { var scores = new List<ShooterStageData>(); foreach (var shooterName in team.ShooterNames) { ShooterStageData score = results.FirstOrDefault(s => s.FullName.Equals(shooterName, System.StringComparison.CurrentCultureIgnoreCase)); if (score != null) { scores.Add(score); } } finalResults.Add(new TeamResult(team.Name, scores)); } File.Copy("team_results_template.xlsx", "team_results.xlsx", true); using (FileStream stream = File.Open("team_results.xlsx", FileMode.Open, FileAccess.ReadWrite)) { ExportTeamResultsAsExcel exporter = new ExportTeamResultsAsExcel(); var s = exporter.Export(finalResults, stream); } string content = GenerateTextResults(finalResults); File.WriteAllText("team_results.txt", content); }