/// <summary> /// Reads the registered personas from a fixed-string database file. /// </summary> /// <remarks>This is NOT dynamic, this only reads from the database.</remarks> /// <returns>An initialized "List<Persona>" containing the database entries for the personas.</returns> public static ObservableCollection<Persona> GetCurrentPersonaList() { ObservableCollection<Persona> listPersona = new ObservableCollection<Persona>(); SQLiteCommand command = new SQLiteCommand("select * from personas order by Id asc", NfswSession.dbConnection); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { Persona dummyPersona = new Persona((Int64)reader[0], (Int16)reader[1], (String)reader[2], (String)reader[3], (Int16)reader[4], (Int32)reader[5], (Int32)reader[6], (Int16)reader[7], (Int32)reader[8], (Int32)reader[9]); listPersona.Add(dummyPersona); } return listPersona; }
/// <summary> /// Initializes the Persona class with the given persona. /// </summary> public Persona(Persona persona) { Id = persona.Id; AvatarIndex = persona.AvatarIndex; Name = persona.Name; Motto = persona.Motto; Level = persona.Level; Cash = persona.Cash; Boost = persona.Boost; PercentageOfLevelCompletion = persona.PercentageOfLevelCompletion; ReputationInLevel = persona.ReputationInLevel; ReputationInTotal = persona.ReputationInTotal; SQLiteCommand command = new SQLiteCommand("select * from Id" + persona.Id.ToString() + " order by ApId asc", NfswSession.dbCarsConnection); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { DateTime ValidTime = (String)reader[12] == "null" ? new DateTime(1, 1, 1) : DateTime.ParseExact((String)reader[12], "o", System.Globalization.CultureInfo.CurrentCulture); Car dummyCar = new Car((Int64)reader[0], (CarClass)reader[1], (Int64)reader[2], XElement.Parse((String)reader[3]), XElement.Parse((String)reader[4]), (Int64)reader[5], (Int32)reader[6], (Int32)reader[7], XElement.Parse((String)reader[8]), XElement.Parse((String)reader[9]), XElement.Parse((String)reader[10]), (Int16)reader[11], ValidTime, (Int16)reader[13], (Int32)reader[14]); Cars.Add(dummyCar); } SelectedCar = Cars[0]; }