public void Update(AthleteUpdate update) { Console.WriteLine(prevUpdate); if (prevUpdate != "") { if (prevUpdate != $"{update.UpdateType}") { listView1.Items.Add(new ListViewItem(update.ToString())); prevUpdate = $"{update.UpdateType}"; } } else { prevUpdate = $"{update.UpdateType}"; listView1.Items.Add(new ListViewItem(update.ToString())); } }
public void ProcessUpdate(AthleteUpdate updateMessage) { lock (_lock) { if (updateMessage.UpdateType == AthleteRaceStatus.Registered) { RegistrationUpdate temp = (RegistrationUpdate)updateMessage; handler.AddAthlete(new Athlete(temp.BibNumber, temp.FirstName, temp.LastName, temp.Gender, temp.Age)); } else { handler.updateObservers(updateMessage); } } Console.WriteLine(updateMessage.ToString()); }
//AthleteCollection athleteCollection = new AthleteCollection(); public void ProcessUpdate(AthleteUpdate updateMessage) { // TODO: Do something to process the update message, depending on the concrete type of message if (updateMessage.UpdateType.ToString() == "Registered") { // AthleteCollection.UpdateAt lock (AthleteCollection.getAthleteCollection()) { AthleteCollection.RegisterAthlete(updateMessage); } } if (updateMessage.UpdateType.ToString() == "OnCourse") { LocationUpdate temp = (LocationUpdate)updateMessage; AthleteCollection.UpdateAthlete(temp.BibNumber, temp.LocationOnCourse, temp.Timestamp, temp.UpdateType.ToString()); } // TODO: Note that the console write line does below here Console.WriteLine(updateMessage.ToString()); }
public void ProcessUpdate(AthleteUpdate updateMessage) { string[] updateList = updateMessage.ToString().Split(','); if (updateMessage.GetType().ToString() == "RaceData.Messages.RegistrationUpdate") { AppLayer.RegistrationUpdate update = new AppLayer.RegistrationUpdate(updateList[0], updateList[1], updateList[2], updateList[3], updateList[4], updateList[5], updateList[6]); myRace.Athletes.Add(new Athlete(update.Status, update.BibNumber, update.FirstName, update.LastName, update.Gender, update.Age)); foreach (Athlete thing in myRace.Athletes) { if (thing.BibNumber == update.BibNumber) { foreach (Observer item in observersToAdd) { thing.RegisterObserver(item); } thing.NotifyObservers(); break; } } } else if (updateMessage.GetType().ToString() == "RaceData.Messages.DidNotStartUpdate") { AppLayer.DidNotStartUpdate update = new AppLayer.DidNotStartUpdate(updateList[0], updateList[1], updateList[2]); foreach (Athlete thing in myRace.Athletes) { if (thing.BibNumber == update.BibNumber) { thing.Status = RaceData.AthleteRaceStatus.DidNotStart; thing.NotifyObservers(); break; } } } else if (updateMessage.GetType().ToString() == "RaceData.Messages.StartedUpdate") { AppLayer.StartedUpdate update = new AppLayer.StartedUpdate(updateList[0], updateList[1], updateList[2], updateList[3]); foreach (Athlete thing in myRace.Athletes) { if (thing.BibNumber == update.BibNumber) { thing.Status = RaceData.AthleteRaceStatus.Started; thing.startTime = update.OfficialStartTime; thing.NotifyObservers(); break; } } } else if (updateMessage.GetType().ToString() == "RaceData.Messages.LocationUpdate") { AppLayer.LocationUpdate update = new AppLayer.LocationUpdate(updateList[0], updateList[1], updateList[2], updateList[3]); foreach (Athlete thing in myRace.Athletes) { if (thing.BibNumber == update.BibNumber) { thing.Status = RaceData.AthleteRaceStatus.OnCourse; thing.Location = update.Location; thing.NotifyObservers(); break; } } } else if (updateMessage.GetType().ToString() == "RaceData.Messages.DidNotFinishUpdate") { AppLayer.DidNotFinishUpdate update = new AppLayer.DidNotFinishUpdate(updateList[0], updateList[1], updateList[2]); foreach (Athlete thing in myRace.Athletes) { if (thing.BibNumber == update.BibNumber) { thing.Status = RaceData.AthleteRaceStatus.DidNotFinish; thing.NotifyObservers(); break; } } } else if (updateMessage.GetType().ToString() == "RaceData.Messages.FinishedUpdate") { AppLayer.FinishedUpdate update = new AppLayer.FinishedUpdate(updateList[0], updateList[1], updateList[2], updateList[3]); foreach (Athlete thing in myRace.Athletes) { if (thing.BibNumber == update.BibNumber) { thing.Status = RaceData.AthleteRaceStatus.Finished; thing.finishTime = update.OfficialEndTime; thing.NotifyObservers(); break; } } } }
public void Update(AthleteUpdate update) { listView1.Items.Add(new ListViewItem(update.ToString())); this.Refresh(); }
public void ProcessUpdate(AthleteUpdate updateMessage) { UpdateAthlete(updateMessage); Console.WriteLine(updateMessage.ToString()); }