public void RemoveEvent(AEvent Event) { Event.Championship = null; //!*! DState.IO.Delete <AEvent> (Event); __Events.refresh( ); //_Events.Remove ( Event ); }
internal void EnterAthletes( ) { foreach (AthleteStorage athlete in Athletes) { try { DM.Athlete ath; if (athlete.GlobalID != 0) { ath = FileIO.FConnFile.GetFileDetails( ).IO.GetID <DM.Athlete> (athlete.GlobalID); if (ath == null) { ath = new DM.Athlete( ); } } else { ath = new DM.Athlete( ); } ath.setFullName(athlete.Name); FileIO.FConnFile.GetFileDetails( ).IO.Update <DM.Person> (ath); ath.setTeam(athlete.Team, ((App)App.Current).CurrentChampionship.Championship); ath.Attends = athlete.School; ath.DateOfBirth = athlete.DateOfBirth; ath.Gender = athlete.Gender; FileIO.FConnFile.GetFileDetails( ).IO.Update <DM.Person> (ath); foreach (string EventCode in athlete.EventCodes) { DM.AEvent Event = (DM.AEvent)((App)App.Current).CurrentChampionship.Championship.getEventShortName(EventCode); if (Event == null) { throw new Exception($"Event with code '{EventCode}' could not be found in the database."); } Event.enterAthlete(ath); } } catch (Exception ex) { var result = MessageBox.Show("Failed to enter an athlete " + athlete.Name + "\n" + ex.Message + "\nDo you wish to abort the rest of the import process?" , "Import Error", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.No); Console.WriteLine("Failed to enter an athlete " + athlete.Name); Console.WriteLine(ex.Message); if (result == MessageBoxResult.Yes) { Console.WriteLine("Aborted import process"); return; } continue; } } }
internal static void CopyStandards(AEvent aEvent, Standard[] standards) { foreach (Standard std in standards) { aEvent.addStandard(new Standard( ) { _RawValue = std._RawValue }); } }
public virtual void addEvent(AEvent Event) { Event.DState = DState.IO.getDataState( ); Event.Championship = this; Event._Championship_ID = ID; __Events.refresh( ); //_Events.Add(Event); //!*! DState.IO.Add <AEvent> (Event); }
private void btnDone_Click(object sender, RoutedEventArgs e) { if (rbtnIndividual.IsChecked == true) { if (rbtnTimed.IsChecked == true) { if (rbtnSchool.IsChecked == true) { if (rbtnHeats.IsChecked == true) { Event = new DM.IndividualTimedFinalSchoolEvent( ); } else { Event = new DM.IndividualTimedSchoolEvent( ); } } else if (rbtnHeats.IsChecked == true) { Event = new DM.IndividualTimedFinalEvent( ); } else { Event = new DM.IndividualTimedEvent( ); } } else { Event = new DM.IndividualDistanceEvent( ); } } else if (rbtnTimed.IsChecked == true) { Event = new DM.SquadTimedEvent( ); } else { Event = new DM.SquadDistanceEvent( ); } setResultsDisplay( ); DialogResult = true; Close( ); }
public static List <CertificateData> GenerateCertificates(AEvent Event) { if (!Event.IsFinal) { return(new List <CertificateData> ( )); } List <CertificateData> temp; //List<CertificateData> temp = new List<CertificateData>(); Stopwatch sw2 = new Stopwatch(); sw2.Start( ); // generates certificate data based on individuals //foreach ( ACompetitor Competitor in Event.getEnteredCompetitors ( ) ) // temp.AddRange ( GenerateCertificates ( Competitor , Event ) ); temp = Event.getCertificateData( ); sw2.Stop( ); return(temp); }
public static List <CertificateData> GenerateCertificates(ACompetitor Competitor, AEvent Event) { // All error checking moved to hasEarnedCertificate() for efficacy. //if ( Event == null ) // throw new ArgumentNullException ( "Event can not be null when generating certificates" ); //if ( Competitor == null ) // throw new ArgumentNullException ( "Competitor can not be null when generating certificates" ); //if ( Competitor.CompetingIn != Event ) // throw new ArgumentException ( "Competitor must be competing for the Event used as a parameter" ); //if ( Event.Results.Count ( ) == 0 ) // // There are not results to process certificates for // return new List<CertificateData> ( ); //if ( Event.Results.Where ( r => r.Competitor == Competitor ).Count ( ) == 0 ) // // This competitor does not appear in this events results // return new List<CertificateData> ( ); if (Competitor?.Result?.CertificateEarned == true) { return(Event.getCertificateData( ).Where(c => c.Competitor == Competitor).ToList( )); } else { return(new List <CertificateData> ( )); } }
/// <summary> /// Compares a set of standards against a result and produces a string of the achieved standards /// </summary> /// <param name="standard">Standard to be compared against, can be null.</param> /// <param name="result">Result to be compared, can be null</param> /// <returns>Will always return false if standard is null</returns> public static string getStandardShortString(AEvent Event, ResultValue result) { if (result == null) { return(string.Empty); } if (Event == null) { return(string.Empty); } // will always return false if there is no result to compare against if (result.HasValue( ) == false) { return(string.Empty); } string temp = string.Empty; if (Event.CountyBestPerformance.HasValue( )) { if (result.isTime( )) { if (Event.CountyBestPerformance.RawValue >= result.RawValue) { temp += "CBP" + " / "; } } else if (result.isDistance( )) { if (Event.CountyBestPerformance.RawValue <= result.RawValue) { temp += "CBP" + " / "; } } else { throw new ArgumentException("Result must have a declared ValueType", "result"); } } IEnumerable <Standard> standards = Event.Standards; if (result.isTime( )) { standards = standards.OrderBy(s => s.StandardValue.RawValue); } else if (result.isDistance( )) { standards = standards.OrderByDescending(s => s.StandardValue.RawValue); } else { throw new ArgumentException("Result must have a declared ValueType", "result"); } foreach (Standard standard in standards) { if (standard == null) { continue; } // will always be false if there are no standards if (!hasStandards(standard)) { continue; } // TODO add a check for standards values to have a defined ValueType if (result.isTime( )) { // check for standard if (standard.StandardValue.HasValue( )) { if (standard.StandardValue.RawValue >= result.RawValue) { temp += standard.ShortName + " / "; break; } } } else if (result.isDistance( )) { // check for standard if (standard.StandardValue.HasValue( )) { if (standard.StandardValue.RawValue <= result.RawValue) { temp += standard.ShortName + " / "; break; } } } } if (temp.EndsWith(" / ")) { return(temp.Remove(temp.Length - 3, 3)); } else { return(temp); } }
/// <summary> /// Compares a set of standards against a result /// </summary> /// <param name="standard">Standard to be compared against, can be null.</param> /// <param name="result">Result to be compared, can be null</param> /// <returns>Will always return false if standard is null</returns> public static bool achievedStandard(AEvent Event, ResultValue result) { if (result == null) { return(false); } if (Event == null) { return(false); } if (Event.CountyBestPerformance.HasValue( )) { if (result.isTime( )) { if (Event.CountyBestPerformance.RawValue >= result.RawValue) { return(true); } } else if (result.isDistance( )) { if (Event.CountyBestPerformance.RawValue <= result.RawValue) { return(true); } } else { throw new ArgumentException("Result must have a declared ValueType", "result"); } } foreach (Standard standard in Event.Standards) { if (standard == null) { return(false); } // will always be false if there are no standards if (!hasStandards(standard)) { return(false); } // will always return false if there is no result to compare against if (!result.HasValue( )) { return(false); } // TODO add a check for standards values to have a defined ValueType if (result.isTime( )) { if (standard.StandardValue.HasValue( )) { if (standard.StandardValue.RawValue >= result.RawValue) { return(true); } } } else if (result.isDistance( )) { if (standard.StandardValue.HasValue( )) { if (standard.StandardValue.RawValue <= result.RawValue) { return(true); } } } else { throw new ArgumentException("Result must have a declared ValueType", "result"); } } // did not achieve any standards return(false); }
public ACompetitor getCompetitorIn(Championship Championship, AEvent Event) { return(_Competitors.Where(e => e.CompetingIn == Event && e.CompetingIn.Championship == Championship).FirstOrDefault()); }
public AResult AddResult(int Rank, VestNumber vest, decimal distanceResultValue) { return(addResult(Rank, AEvent.getCompetitor(this, vest), new ResultValue(this.ResultsDisplayDescription, distanceResultValue))); }
public AResult AddResult(int Rank, VestNumber vest, TimeSpan timedResultValue) { return(addResult(Rank, AEvent.getCompetitor(this, vest), new ResultValue(this.ResultsDisplayDescription, timedResultValue))); }
public StudentCompetitor(Athlete athlete, VestNumber Vest, AEvent inEvent) : base(athlete, Vest, inEvent) { }
public Competitor(Athlete athlete, VestNumber Vest, AEvent inEvent) { this.Athlete = athlete; this.Vest = Vest; this.CompetingIn = inEvent; }
//private DataAccess.Database _database; //public DataAccess.Database database //{ // get // { // return _database; // } // set // { // _database = value; // DState.IO = value; // DState.NeedsUpdating = true; // } //} public static Championship copyChampionship(string newChampionshipName, Championship origonalChampionship, DataAccess.Database Connection, Team team = null) { Championship newChamp = new Championship(newChampionshipName, origonalChampionship.AgeDateReference); newChamp.Location = origonalChampionship.Location; newChamp.Locked = origonalChampionship.Locked; newChamp.ShortName = origonalChampionship.ShortName; newChamp._FixedName = origonalChampionship.FixedName; Connection.Add <Championship>(newChamp); // Restrictions foreach (Group res in origonalChampionship.Groups) { newChamp.addGroup(Group.CopyGroup(res)); } #if (!TeamTesting) // Teams (and schools) Team[] teams; if (team == null) { teams = origonalChampionship.Teams; } else { teams = new Team[] { team } }; foreach (Team t in teams) { Team t2 = new Team(t.Name, newChamp) { ShortName = t.ShortName }; newChamp.addTeam(t2); foreach (School sch in t.HasSchools) { School s2 = new DM.School(sch.Name); s2.ShortName = sch.ShortName; Connection.Add <School>(s2); t2.AddSchool(s2, Connection); foreach (var athlete in origonalChampionship.DState.IO.GetAll <Athlete>().Where(a => a.Attends == sch)) { // copy athlete Athlete a = new Athlete( ) { FirstName = athlete.FirstName, MiddleName = athlete.MiddleName, LastName = athlete.LastName, PreferredName = athlete.PreferredName, Attends = s2, GlobalAthleteID = athlete.GlobalAthleteID, DateOfBirth = athlete.DateOfBirth, Gender = athlete.Gender, Suffix = athlete.Suffix, Title = athlete.Title }; Connection.Add <Person>(a); // copy athlete notes foreach (var note in athlete._Notes) { if (note.GetType( ) == typeof(ConfidentialNote)) { a.AddNote(new ConfidentialNote(note)); } else if (note.GetType( ) == typeof(PublicNote)) { a.AddNote(new PublicNote((PublicNote)note)); } // 2017-03-26 // Deliberately not copying availability information between championships! // this could be a mistake. //else if ( note.GetType() == typeof(DeclaredAvailibilityInformation )) // a.AddNote( new DeclaredAvailibilityInformation( (DeclaredAvailibilityInformation)note ) ); else if (note.GetType( ) == typeof(PowerOfTenResult)) { a.AddNote(new PowerOfTenResult((PowerOfTenResult)note)); } else if (note.GetType( ) == typeof(PreviousResult)) { a.AddNote(new PreviousResult((PreviousResult)note)); } } // copy athlete contacts foreach (var contact in athlete.Contacts) { AContactDetail detail = null; if (contact is EmailContactDetail) { detail = new EmailContactDetail(((EmailContactDetail)contact).EmailAddress, contact.ContactName); } if (contact is AddressContactDetail) { detail = new AddressContactDetail( contact.ContactName, ((AddressContactDetail)contact).FirstLine, ((AddressContactDetail)contact).SecondLine, ((AddressContactDetail)contact).ThirdLine, ((AddressContactDetail)contact).FourthLine, ((AddressContactDetail)contact).PostCode); } if (contact is PhoneContactDetail) { detail = new PhoneContactDetail( ) { ContactName = contact.ContactName, phoneNumber = ((PhoneContactDetail)contact).phoneNumber } } ; if (contact is MobileContactDetail) { detail = new MobileContactDetail( ) { ContactName = contact.ContactName, phoneNumber = ((MobileContactDetail)contact).phoneNumber } } ; if (detail != null) { a.AddContact(detail); } } } origonalChampionship.DState.IO.DeleteRange <Person>( origonalChampionship.DState.IO.GetAll <Athlete>( ).Where(a => a.Attends == sch).ToArray()); } } #endif // Events (not competitors or results) foreach (AEvent Event in origonalChampionship.listAllEvents( )) { AEvent.CopyEvent(Event, newChamp); } // Custom Data CustomData.CopyCustomData(origonalChampionship.CustomDataStore, newChamp); newChamp.Save( ); return(newChamp); }