private AppDataModel createTestDataModel2() { AppDataModel dm = new AppDataModel(new DummyDataBase("dummy")); foreach (var o in new List <ParticipantCategory> { new ParticipantCategory('M', "Männlich", 1), new ParticipantCategory('W', "Weiblich", 2) }) { dm.GetParticipantCategories().Add(o); } foreach (var o in new List <ParticipantGroup> { new ParticipantGroup("1", "G_U14", 1), new ParticipantGroup("2", "G_U16", 2) }) { dm.GetParticipantGroups().Add(o); } foreach (var o in new List <ParticipantClass> { new ParticipantClass("1", dm.GetParticipantGroups()[0], "U14", dm.GetParticipantCategories()[0], 2006, 1), new ParticipantClass("1", dm.GetParticipantGroups()[0], "U14", dm.GetParticipantCategories()[1], 2006, 2), new ParticipantClass("2", dm.GetParticipantGroups()[1], "U16", dm.GetParticipantCategories()[0], 2004, 3), new ParticipantClass("2", dm.GetParticipantGroups()[1], "U16", dm.GetParticipantCategories()[1], 2004, 4) }) { dm.GetParticipantClasses().Add(o); } return(dm); }
public OnTrackDataProvider(AppDataModel dm) { _dm = dm; _dm.CurrentRaceChanged += OnCurrentRaceChanged; ListenToCurrentRaceRun(); }
public DatabaseDelegatorCompetition(AppDataModel dm, IAppDataModelDataBase db) { _dm = dm; _db = db; _dm.GetRaces().CollectionChanged += OnRacesChanged; }
public void GlobalRaceConfig_SaveAndLoad() { string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_Empty.mdb"); RaceHorologyLib.Database db = new RaceHorologyLib.Database(); db.Connect(dbFilename); AppDataModel model = new AppDataModel(db); // Default Config Assert.AreEqual("Vereinsrennen - BestOfTwo", model.GlobalRaceConfig.Name); var testConfig1 = new RaceConfiguration { Name = "BaseName", Runs = 2, DefaultGrouping = "DefaultG", ActiveFields = new List <string> { "eins", "zwei" }, RaceResultView = "RaceResultView", RaceResultViewParams = new Dictionary <string, object>(), Run1_StartistView = "Run1_StartistView", Run1_StartistViewGrouping = "Run1_StartistViewGrouping", Run1_StartistViewParams = new Dictionary <string, object>(), Run2_StartistView = "Run2_StartistView", Run2_StartistViewGrouping = "Run2_StartistViewGrouping", Run2_StartistViewParams = new Dictionary <string, object>(), LivetimingParams = new Dictionary <string, string> { { "key", "value" } }, ValueF = 100, ValueA = 200, MinimumPenalty = 300 }; // Check for PropertyChanged event string propertyChanged = null; model.PropertyChanged += delegate(object sender, System.ComponentModel.PropertyChangedEventArgs e) { propertyChanged = e.PropertyName; }; model.GlobalRaceConfig = testConfig1; Assert.AreEqual("GlobalRaceConfig", propertyChanged); TestUtilities.AreEqualByJson(testConfig1, model.GlobalRaceConfig); model.Close(); // Check saving and loading from in DB RaceHorologyLib.Database db2 = new RaceHorologyLib.Database(); db2.Connect(dbFilename); AppDataModel model2 = new AppDataModel(db2); TestUtilities.AreEqualByJson(testConfig1, model2.GlobalRaceConfig); }
/// <summary> /// Constructor /// </summary> /// <param name="dm">The DataMOdel to work on.</param> /// <param name="autoAddParticipants">true in case participants with a startnumber not existing shall be created.</param> public LiveTimingMeasurement(AppDataModel dm, bool autoAddParticipants = false) { _dm = dm; _syncContext = System.Threading.SynchronizationContext.Current; _isRunning = false; _autoAddParticipants = autoAddParticipants; }
public void StartNumberAssignment_LoadFromRace_Test() { string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants_MultipleRaces.mdb"); RaceHorologyLib.Database db = new RaceHorologyLib.Database(); db.Connect(dbFilename); AppDataModel model = new AppDataModel(db); var race = model.GetRaces().FirstOrDefault(r => r.RaceType == Race.ERaceType.GiantSlalom); StartNumberAssignment sna = new StartNumberAssignment(); sna.LoadFromRace(race); var rps = race.GetParticipants().ToList(); foreach (var snap in sna.ParticipantList) { if (snap.StartNumber != 0) { var rp = rps.FirstOrDefault(x => x.StartNumber == snap.StartNumber); Assert.AreEqual(snap.Participant, rp); } } Assert.IsFalse(sna.DifferentToRace(race)); sna.Assign(1000, race.GetParticipant(1)); Assert.IsTrue(sna.DifferentToRace(race)); sna.LoadFromRace(race); Assert.IsFalse(sna.DifferentToRace(race)); sna.DeleteAll(); Assert.IsTrue(sna.DifferentToRace(race)); }
public void Init(AppDataModel dm, Race race) { _dm = dm; _race = race; _race.RunsChanged += OnRaceRunsChanged; UiUtilities.FillCmbRaceRun(cmbRaceRun, _race); UiUtilities.FillGrouping(cmbResultGrouping, _currentRaceRun.GetResultViewProvider().ActiveGrouping); cmbFilter.Items.Clear(); cmbFilter.Items.Add(new CBItem { Text = "alle Teilnehmer", Value = "all" }); cmbFilter.Items.Add(new CBItem { Text = "Teilnehmer ohne Zeit", Value = "no_time" }); cmbFilter.Items.Add(new CBItem { Text = "ausgeschiedene Teilnehmer", Value = "out" }); cmbFilter.Items.Add(new CBItem { Text = "offene Teilnehmer (keine Zeit oder Ausscheidung)", Value = "no_data" }); cmbFilter.SelectedIndex = 1; cmbDisqualify.ItemsSource = ListOfResultCodesToSet; cmbDisqualifyReason.Items.Add("Vorbei am Tor"); cmbDisqualifyReason.Items.Add("Eingefädelt am Tor"); cmbDisqualifyReason.Items.Add("Nicht weit genug zurückgestiegen am Tor"); cmbDisqualifyReason.Items.Add("Hilfe durch fremde Person am Tor"); this.KeyDown += new KeyEventHandler(Timing_KeyDown); }
public static void AnonymizeDB(string path) { Database db = new Database(); db.Connect(path); AppDataModel model = new AppDataModel(db); var particpants = db.GetParticipants(); var races = db.GetRaces(); var raceParticipants = db.GetRaceParticipants(new Race(db, model, races[0])); Dictionary <string, string> clubMap = new Dictionary <string, string>(); foreach (var rp in raceParticipants) { rp.Participant.Firstname = string.Format("Vorname {0}", rp.StartNumber); rp.Participant.Name = string.Format("Name {0}", rp.StartNumber); rp.Participant.Club = mapClub(clubMap, rp.Participant.Club); db.CreateOrUpdateParticipant(rp.Participant); } db.Close(); }
public void ImportParticpantsWithClassAssignment() { string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_EmptyManyClasses.mdb"); RaceHorologyLib.Database db = new RaceHorologyLib.Database(); db.Connect(dbFilename); AppDataModel dm = new AppDataModel(db); var ir = new ImportReader(@"Teilnehmer_V1_202001301844.csv"); RaceMapping mapping = new RaceMapping(ir.Columns); ClassAssignment cla = new ClassAssignment(dm.GetParticipantClasses()); RaceImport im = new RaceImport(dm.GetRace(0), mapping, cla); var impRes = im.DoImport(ir.Data); Assert.AreEqual(153, impRes.SuccessCount); Assert.AreEqual(0, impRes.ErrorCount); for (int i = 0; i < 153; i++) { Participant p = dm.GetParticipants()[i]; RaceParticipant rp = dm.GetRace(0).GetParticipants()[i]; Assert.AreEqual(string.Format("Name {0}", i + 1), p.Name); Assert.AreEqual(string.Format("Name {0}", i + 1), rp.Name); Assert.IsTrue(rp.Participant == p); Assert.AreSame(cla.DetermineClass(p), p.Class); Assert.IsNotNull(p.Class); } }
public void Integration_1554MSBS() { string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"1554MSBS.mdb"); RaceHorologyLib.Database db = new RaceHorologyLib.Database(); db.Connect(dbFilename); AppDataModel model = new AppDataModel(db); Race race = model.GetRace(0); { IPDFReport report = new StartListReport(race.GetRun(0)); Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"1554MSBS - Startliste 1. Durchgang.pdf", 4)); } { IPDFReport report = new StartListReport2ndRun(race.GetRun(1)); Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"1554MSBS - Startliste 2. Durchgang.pdf", 3)); } { IPDFReport report = new RaceRunResultReport(race.GetRun(0)); Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"1554MSBS - Ergebnis 1. Durchgang.pdf", 5)); } { IPDFReport report = new RaceRunResultReport(race.GetRun(1)); Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"1554MSBS - Ergebnis 2. Durchgang.pdf", 3)); } { IPDFReport report = new RaceResultReport(race); Assert.IsTrue(TestUtilities.GenerateAndCompareAgainstPdf(TestContext, report, @"1554MSBS - Ergebnis Gesamt.pdf", 2)); } }
public void HandTimingsVM() { string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"1557MRBR_RH.mdb"); string hsFilename = @"--Handzeit-Start.txt"; string hfFilename = @"--Handzeit-Ziel.txt"; Database db = new Database(); db.Connect(dbFilename); AppDataModel model = new AppDataModel(db); FromFileHandTiming hsTiming = new FromFileHandTiming(hsFilename); FromFileHandTiming hfTiming = new FromFileHandTiming(hfFilename); hsTiming.Connect(); hfTiming.Connect(); List <TimingData> hsList = new List <TimingData>(hsTiming.TimingData()); List <TimingData> hfList = new List <TimingData>(hfTiming.TimingData()); HandTimingVM htVM = new HandTimingVM(HandTimingVMEntry.ETimeModus.EStartTime); htVM.AddRunResults(model.GetRace(0).GetRun(0).GetResultList()); htVM.AddHandTimings(hsList); }
public void UpdatePoints2() { // Setup Data Model & Co string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"1554MSBS.mdb"); Database db = new Database(); db.Connect(dbFilename); AppDataModel model = new AppDataModel(db); Race race = model.GetRace(0); // Import DSV Point List DSVImportReader dsvImportReader = new DSVImportReader(new DSVImportReaderZip(@"Punktelisten.zip", DSVImportReaderZipBase.EDSVListType.Pupils_U14U16)); // Check two prior Assert.AreEqual(148.86, race.GetParticipants().First(r => r.SvId == "24438").Points); Assert.AreEqual(129.12, race.GetParticipants().First(r => r.SvId == "25399").Points); var impRes = DSVUpdatePoints.UpdatePoints(model, dsvImportReader.Data, dsvImportReader.Mapping, dsvImportReader.UsedDSVList); Assert.AreEqual(1, impRes.Count); Assert.AreEqual(125, impRes[0].SuccessCount); Assert.AreEqual(2, impRes[0].ErrorCount); Assert.AreEqual(110.96, race.GetParticipants().First(r => r.SvId == "24438").Points); Assert.AreEqual(100.33, race.GetParticipants().First(r => r.SvId == "25399").Points); Assert.AreEqual("DSVSA20END", model.GetDB().GetKeyValue("DSV_UsedDSVList")); }
public FieldScribeModernDesign() { InitializeComponent(); _appDataModel = AppDataModel.Instance; this.DataContext = AppDataModel.Instance; _watcher = FolderWatcher.Instance; _tokenManager = TokenManager.Instance; _watcher.FSWatcher.Changed += File_Changed; // Add event handlers setupPanel.MeetSelection_Changed += MeetSelectionChanged; setupPanel.FolderSelection_Changed += FolderSelectionChanged; setupPanel.StartStopBtn_Clicked += StartStopBtnClicked; setupPanel.DeleteBtn_Clicked += DeleteBtnClicked; setupPanel.EditBtn_Clicked += EditBtnClicked; setupPanel.CreateMeetBtn_Clicked += CreateMeetBtnClicked; setupPanel.SaveMeetBtn_Clicked += SaveMeetBtnClicked; setupPanel.MeetPicker_Open += MeetPickerOpen; try { _meets = GetMeets(); } catch (Exception e) { // Will throw exception if not connected to internet // TODO: Handle exception } }
public RaceUC(AppDataModel dm, Race race, LiveTimingMeasurement liveTimingMeasurement, TextBox txtLiveTimingStatus) { _dataModel = dm; _thisRace = race; _liveTimingMeasurement = liveTimingMeasurement; _liveTimingMeasurement.LiveTimingMeasurementStatusChanged += OnLiveTimingMeasurementStatusChanged; _txtLiveTimingStatus = txtLiveTimingStatus; _txtLiveTimingStatus.TextChanged += new DelayedEventHandler( TimeSpan.FromMilliseconds(400), TxtLiveTimingStatus_TextChanged ).Delayed; InitializeComponent(); ucStartNumbers.Init(_dataModel, _thisRace, tabControlRace1, tabItemStartNumberAssignment); ucDisqualify.Init(_dataModel, _thisRace); InitializeConfiguration(); InitializeRaceProperties(); InitializeLiveTiming(_thisRace); InitializeTiming(); ucRaceLists.Init(_thisRace); }
public void StartNumberAssignment_SaveToRace_Test2() { string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants_MultipleRacesNoStartnumber.mdb"); RaceHorologyLib.Database db = new RaceHorologyLib.Database(); db.Connect(dbFilename); AppDataModel model = new AppDataModel(db); var race = model.GetRaces().FirstOrDefault(r => r.RaceType == Race.ERaceType.GiantSlalom); StartNumberAssignment sna = new StartNumberAssignment(); sna.LoadFromRace(race); uint sn = 1; foreach (var p in race.GetParticipants()) { sna.Assign(sn, p); sn++; } sna.SaveToRace(race); sn = 1; foreach (var p in race.GetParticipants()) { Assert.AreEqual(sn, p.StartNumber); sn++; } }
public void CgcTest_Store_ImportReplace() { AppDataModel dm = createTestDataModel12(); ClassesGroupsCategoriesEditVM cge = new ClassesGroupsCategoriesEditVM(dm); cge.Clear(); Assert.IsTrue(cge.DifferentToDataModel()); cge.Import(createTestDataModel1()); Assert.IsTrue(cge.DifferentToDataModel()); cge.Store(); Assert.IsFalse(cge.DifferentToDataModel()); // Verify Data Model Assert.AreEqual(2, dm.GetParticipantCategories().Count); Assert.AreEqual("Männlich", dm.GetParticipantCategories()[0].PrettyName); Assert.AreEqual("Weiblich", dm.GetParticipantCategories()[1].PrettyName); Assert.AreEqual(2, dm.GetParticipantGroups().Count); Assert.AreEqual("G_U10", dm.GetParticipantGroups()[0].Name); Assert.AreEqual("G_U12", dm.GetParticipantGroups()[1].Name); Assert.AreEqual(4, dm.GetParticipantClasses().Count); Assert.AreEqual("U10", dm.GetParticipantClasses()[0].Name); Assert.AreEqual("U10", dm.GetParticipantClasses()[1].Name); Assert.AreEqual("U12", dm.GetParticipantClasses()[2].Name); Assert.AreEqual("U12", dm.GetParticipantClasses()[3].Name); }
public void Init(AppDataModel dm) { _dm = dm; connectDataGrids(); ucSaveOrReset.Init("Klassen- und Gruppenänderungen", null, null, changed, save, reset); }
public void Init(AppDataModel dm, Race race) { _dm = dm; _race = race; InitializeComponent(); }
public RemainingStartListDataProvider(AppDataModel dm, int limit) { _limit = limit; _dm = dm; _dm.CurrentRaceChanged += OnCurrentRaceChanged; ListenToCurrentRaceRun(); }
public void UseDataModel(AppDataModel dm) { _dataModel = dm; var handler = DataModelChanged; handler?.Invoke(dm); }
public void StartNumberAssignment_ParticpantSelector1_Test() { string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"1554MSBS.mdb"); RaceHorologyLib.Database db = new RaceHorologyLib.Database(); db.Connect(dbFilename); AppDataModel model = new AppDataModel(db); var race = model.GetRace(0); StartNumberAssignment sna = new StartNumberAssignment(); sna.LoadFromRace(race); ParticipantSelector ps = new ParticipantSelector(race, sna, "Class"); foreach (var g in ps.Group2Participant) { foreach (var rp in g.Value) { Assert.AreEqual(rp.Class, g.Key); } } ParticipantSelector ps2 = new ParticipantSelector(race, sna, "Sex"); foreach (var g in ps2.Group2Participant) { foreach (var rp in g.Value) { Assert.AreEqual(rp.Sex, g.Key); } } ParticipantSelector ps3 = new ParticipantSelector(race, sna, null); foreach (var g in ps3.Group2Participant) { Assert.AreEqual("", g.Key); Assert.AreEqual(race.GetParticipants().Count, g.Value.Count); } ps3.GroupProperty = "Sex"; foreach (var g in ps3.Group2Participant) { foreach (var rp in g.Value) { Assert.AreEqual(rp.Sex, g.Key); } } // TEST: Iterating through groups Assert.AreEqual(((ParticipantCategory)ps2.CurrentGroup).Name, 'W'); Assert.IsTrue(ps2.SwitchToNextGroup()); Assert.AreEqual(((ParticipantCategory)ps2.CurrentGroup).Name, 'M'); Assert.IsFalse(ps2.SwitchToNextGroup()); Assert.IsNull(ps2.CurrentGroup); }
public void Init(AppDataModel dm, DSVInterfaceModel dsvData) { _dm = dm; _dsvData = dsvData; this.KeyDown += new KeyEventHandler(KeyDownHandler); initDSVAddToList(); }
public void Init(AppDataModel dm, FISInterfaceModel fisData) { _dm = dm; _importData = fisData; this.KeyDown += new KeyEventHandler(KeyDownHandler); initAddToList(); }
public void Init(AppDataModel dm, Race race, IImportTime importTimeDevice) { _importTimeVM = new ImportTimeEntryVM(race, importTimeDevice); dgImportTime.ItemsSource = _importTimeVM.ImportEntries; cmbRun.SelectedValuePath = "Value"; UiUtilities.FillCmbRaceRun(cmbRun, race); }
public ThreadIconViewer() { _model = App.Model; if (_model != null) { _model.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnModelPropertyChanged); } }
void fillMandatoryFields(AppDataModel model) { var raceProps = new AdditionalRaceProperties(); model.GetRace(0).AdditionalProperties = raceProps; raceProps.DateResultList = DateTime.Today; model.GetRace(0).AdditionalProperties.RaceNumber = "1234"; model.GetRace(0).AdditionalProperties.Organizer = "WSV Glonn"; model.GetRace(0).AdditionalProperties.Description = "Test Race"; model.GetRace(0).AdditionalProperties.Location = "Test Location"; model.GetDB().StoreKeyValue("DSV_UsedDSVList", "123"); model.GetRace(0).AdditionalProperties.RaceManager = new AdditionalRaceProperties.Person { Name = "Race Manager", Club = "Club" }; model.GetRace(0).AdditionalProperties.RaceReferee = new AdditionalRaceProperties.Person { Name = "Referee, Race", Club = "Club" }; model.GetRace(0).AdditionalProperties.TrainerRepresentative = new AdditionalRaceProperties.Person { Name = "T.Rep", Club = "Club" }; raceProps.CoarseName = "Kurs 1"; raceProps.StartHeight = 1000; raceProps.FinishHeight = 100; raceProps.CoarseLength = 1000; raceProps.RaceRun1.Gates = 10; raceProps.RaceRun1.Turns = 9; raceProps.RaceRun1.CoarseSetter = new AdditionalRaceProperties.Person { Name = "Sven Flossmann", Club = "WSV Glonn" }; raceProps.RaceRun1.Forerunner1 = new AdditionalRaceProperties.Person { Name = "F. Runner", Club = "WSV Glonn" }; if (model.GetRace(0).GetMaxRun() > 1) { raceProps.RaceRun2.Gates = 10; raceProps.RaceRun2.Turns = 9; raceProps.RaceRun2.CoarseSetter = new AdditionalRaceProperties.Person { Name = "Sven Flossmann", Club = "WSV Glonn" }; raceProps.RaceRun2.Forerunner1 = new AdditionalRaceProperties.Person { Name = "F. Runner", Club = "WSV Glonn" }; } model.GetRace(0).RaceConfiguration.ValueF = 720.0; var rvp = new DSVSchoolRaceResultViewProvider(); rvp.Init(model.GetRace(0), model); model.GetRace(0).SetResultViewProvider(rvp); }
public DatabaseDelegatorCategories(AppDataModel dm, IAppDataModelDataBase db) { _dm = dm; _db = db; _notifierClasses = new ItemsChangedNotifier(_dm.GetParticipantCategories()); _notifierClasses.ItemChanged += OnItemChanged; _notifierClasses.CollectionChanged += OnCollectionChanged; }
public DSVInterfaceModel(AppDataModel dm) { _dm = dm; _pathLocalDSV = System.IO.Path.Combine( _dm.GetDB().GetDBPathDirectory(), _dm.GetDB().GetDBFileName() + ".dsv"); loadLocal(); }
public StartListDataProvider(AppDataModel dm) { _dm = dm; Application.Current.Dispatcher.Invoke(() => { _notifier = new ItemsChangedNotifier(_dm.GetCurrentRace().GetRun(0).GetStartList()); _notifier.CollectionChanged += StartListChanged; _notifier.ItemChanged += StartListItemChanged; }); }
public RaceResultDataProvider(AppDataModel dm) { _dm = dm; Application.Current.Dispatcher.Invoke(() => { _notifier = new ItemsChangedNotifier(_dm.GetCurrentRace().GetResultViewProvider().GetView()); _notifier.CollectionChanged += DataListChanged; _notifier.ItemChanged += DataListItemChanged; }); }