private void BtnStore_Click(object sender, RoutedEventArgs e) { uint startNumber = 0U; try { startNumber = uint.Parse(txtStartNumber.Text); } catch (Exception) { } RaceParticipant participant = _race.GetParticipant(startNumber); string disqualifyText = RunResultExtension.JoinDisqualifyText(cmbDisqualifyReason.Text, txtDisqualify.Text); if (participant != null) { _currentRaceRun.SetResultCode(participant, (EResultCode)cmbDisqualify.SelectedValue, disqualifyText); } else { foreach (object item in dgDisqualifications.SelectedItems) { if (item is RunResult rr) { _currentRaceRun.SetResultCode(rr.Participant, (EResultCode)cmbDisqualify.SelectedValue, disqualifyText); } } } txtStartNumber.Focus(); }
private void BtnRowNaS(object sender, RoutedEventArgs e) { for (var vis = sender as Visual; vis != null; vis = VisualTreeHelper.GetParent(vis) as Visual) { if (vis is DataGridRow dataRow) { if (dataRow.Item is StartListEntry sle) { _currentRaceRun.SetResultCode(sle.Participant, RunResult.EResultCode.NaS); } } } }
private void processStartListTill(RaceParticipant participant) { // Copy starters (copy to avoid any side effects) StartListEntry[] starters = _raceRun.GetStartListProvider().GetViewList().ToArray(); // Participant enters track if (participant != null) { // Loop over StartList until the starter has been found, remember all not started participants List <StartListEntry> toPurge = new List <StartListEntry>(); foreach (StartListEntry se in starters) { if (se.Participant == participant) { break; } toPurge.Add(se); } // Loop for (int i = 0; i < toPurge.Count() - Math.Abs(_startersTillAutoNaS); i++) { RaceParticipant rp = toPurge[i].Participant; if (!_raceRun.IsOrWasOnTrack(rp)) { _raceRun.SetResultCode(rp, RunResult.EResultCode.NaS); } } } }
private void setToNiZ(RaceParticipant participant) { System.Windows.Application.Current.Dispatcher.Invoke(() => { _raceRun.SetResultCode(participant, RunResult.EResultCode.NiZ); }); }
public void TestMethod1() { TestDataGenerator tg = new TestDataGenerator(); tg.createCatsClassesGroups(); Race race = tg.Model.GetRace(0); tg.createRaceParticipant(cat: tg.findCat('M'), cla: tg.findClass("2M (2010)"), points: 1.0); // 1 tg.createRaceParticipant(cat: tg.findCat('M'), cla: tg.findClass("2M (2010)"), points: 2.0); tg.createRaceParticipant(cat: tg.findCat('M'), cla: tg.findClass("2M (2010)"), points: 3.0); tg.createRaceParticipant(cat: tg.findCat('W'), cla: tg.findClass("2W (2010)"), points: 1.5); // 4 tg.createRaceParticipant(cat: tg.findCat('W'), cla: tg.findClass("2W (2010)"), points: 2.5); tg.createRaceParticipant(cat: tg.findCat('W'), cla: tg.findClass("2W (2010)"), points: 3.5); // 6 RaceRun rr1 = race.GetRun(0); RaceRun rr2 = race.GetRun(1); rr1.SetStartFinishTime(race.GetParticipant(1), new TimeSpan(8, 0, 0), new TimeSpan(8, 1, 0)); rr2.SetRunTime(race.GetParticipant(1), new TimeSpan(0, 0, 2, 0, 123)); rr1.SetRunTime(race.GetParticipant(2), new TimeSpan(0, 1, 1)); rr1.SetResultCode(race.GetParticipant(3), RunResult.EResultCode.NiZ); Export export = new Export(tg.Model.GetRace(0)); DataSet ds = export.ExportToDataSet(); Assert.AreEqual("Name 1", ds.Tables[0].Rows[0]["Name"]); Assert.AreEqual("Name 2", ds.Tables[0].Rows[1]["Name"]); Assert.AreEqual("Name 3", ds.Tables[0].Rows[2]["Name"]); Assert.AreEqual("Name 4", ds.Tables[0].Rows[3]["Name"]); Assert.AreEqual("Name 5", ds.Tables[0].Rows[4]["Name"]); Assert.AreEqual("Name 6", ds.Tables[0].Rows[5]["Name"]); Assert.AreEqual("Firstname 1", ds.Tables[0].Rows[0]["Firstname"]); Assert.AreEqual(1.0, ds.Tables[0].Rows[0]["Points"]); Assert.AreEqual(new TimeSpan(0, 1, 0), ds.Tables[0].Rows[0]["Runtime_1"]); Assert.AreEqual("Normal", ds.Tables[0].Rows[0]["Resultcode_1"]); Assert.AreEqual(new TimeSpan(0, 0, 2, 0, 120), ds.Tables[0].Rows[0]["Runtime_2"]); Assert.AreEqual("Normal", ds.Tables[0].Rows[0]["Resultcode_2"]); Assert.AreEqual("NiZ", ds.Tables[0].Rows[2]["Resultcode_1"]); var excelExport = new ExcelExport(); excelExport.Export(@"c:\trash\test.xlsx", ds); var csvExport = new CsvExport(); csvExport.Export(@"c:\trash\test.csv", ds, true); var tsvExport = new TsvExport(); tsvExport.Export(@"c:\trash\test.txt", ds, true); }
public void DSVAlpinExport() { TestDataGenerator tg = new TestDataGenerator(); tg.createCatsClassesGroups(); Race race = tg.Model.GetRace(0); var rp = tg.createRaceParticipant(cat: tg.findCat('M'), cla: tg.findClass("2M (2010)"), points: 1.0); // 1 rp.Participant.SvId = "123"; rp.Participant.Year = 2010; rp.Participant.Nation = "Nation"; rp.Participant.Club = "Verein"; tg.createRaceParticipant(cat: tg.findCat('M'), cla: tg.findClass("2M (2010)"), points: 2.0); tg.createRaceParticipant(cat: tg.findCat('M'), cla: tg.findClass("2M (2010)"), points: 3.0); tg.createRaceParticipant(cat: tg.findCat('W'), cla: tg.findClass("2W (2010)"), points: 1.5); // 4 tg.createRaceParticipant(cat: tg.findCat('W'), cla: tg.findClass("2W (2010)"), points: 2.5); tg.createRaceParticipant(cat: tg.findCat('W'), cla: tg.findClass("2W (2010)"), points: 3.5); // 6 RaceRun rr1 = race.GetRun(0); RaceRun rr2 = race.GetRun(1); rr1.SetStartFinishTime(race.GetParticipant(1), new TimeSpan(8, 0, 0), new TimeSpan(8, 1, 0)); rr2.SetRunTime(race.GetParticipant(1), new TimeSpan(0, 0, 2, 0, 123)); rr1.SetRunTime(race.GetParticipant(2), new TimeSpan(0, 1, 1)); rr1.SetResultCode(race.GetParticipant(3), RunResult.EResultCode.NiZ); DSVAlpinExport export = new DSVAlpinExport(tg.Model.GetRace(0)); DataSet ds = export.ExportToDataSet(); // Check Column Names int i = 0; Assert.AreEqual("Idnr", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("Stnr", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("DSV-ID", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("Name", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("Kateg", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("JG", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("V/G", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("Verein", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("LPkte", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("Total", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("Zeit 1", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("Zeit 2", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("Klasse", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("Gruppe", ds.Tables[0].Columns[i++].ColumnName); Assert.AreEqual("RPkte", ds.Tables[0].Columns[i++].ColumnName); // Check first participant Assert.AreEqual(1U, ds.Tables[0].Rows[0]["Stnr"]); Assert.AreEqual("123", ds.Tables[0].Rows[0]["DSV-ID"]); Assert.AreEqual("Name 1, Firstname 1", ds.Tables[0].Rows[0]["Name"]); Assert.AreEqual("M", ds.Tables[0].Rows[0]["Kateg"]); Assert.AreEqual(2010u, ds.Tables[0].Rows[0]["JG"]); Assert.AreEqual("Nation", ds.Tables[0].Rows[0]["V/G"]); Assert.AreEqual("Verein", ds.Tables[0].Rows[0]["Verein"]); Assert.AreEqual("1,00", ds.Tables[0].Rows[0]["LPkte"]); Assert.AreEqual("1:00,00", ds.Tables[0].Rows[0]["Total"]); // BestRun => 60.0 Assert.AreEqual("1:00,00", ds.Tables[0].Rows[0]["Zeit 1"]); Assert.AreEqual("2:00,12", ds.Tables[0].Rows[0]["Zeit 2"]); Assert.AreEqual("Class 2M (2010)", ds.Tables[0].Rows[0]["Klasse"]); Assert.AreEqual("Group 2M", ds.Tables[0].Rows[0]["Gruppe"]); Assert.AreEqual("---", ds.Tables[0].Rows[0]["RPkte"]); // Participant 3, Run1: NIZ Assert.AreEqual("NIZ1", ds.Tables[0].Rows[2]["Total"]); Assert.AreEqual("NIZ", ds.Tables[0].Rows[2]["Zeit 1"]); Assert.AreEqual(DBNull.Value, ds.Tables[0].Rows[2]["Zeit 2"]); }