public void PruebaValidarCedula() { foreach (var cedula in cedulas) { Assert.AreEqual(cedula.Value, PersonaHelper.ValidarCedula(cedula.Key)); } }
public void PruebaValidarEmail() { foreach (var email in emails) { Assert.AreEqual(email.Value, PersonaHelper.ValidarEmail(email.Key)); } }
private static ComputerPlusEntity generateVehicleOwner(string ownerName) { Ped ped = null; while (ped == null) { //Last ditch effort to make C+ happy by just providing any ped as the owner and setting them as the owner ped = FindRandomPed(); if (ped != null && !ped.IsValid()) { ped = null; } } var parts = ownerName.Split(' '); while (parts.Length < 2) { parts = PersonaHelper.GetRandomFullName().Split(' '); } int timesStopped = Globals.Random.Next(0, 4); var persona = new Persona(parts[0], parts[1], Gender.Random, RandomDay()); Functions.SetPersonaForPed(ped, persona); return(ComputerPlusEntity.CreateFrom(ped)); }
public ActionResult Create(Persona p) { try { PersonaHelper helper = new PersonaHelper(); helper.validarPersona(p.UserName, p.Password); return(RedirectToAction("Logueado", "Home")); } catch (Exception e) { return(View("Error", Json(new { success = false, message = e.Message }, JsonRequestBehavior.AllowGet))); } }
public ActionResult Registrarme(string username, string email, string password) { PersonaHelper helper = new PersonaHelper(); try { Persona per = helper.addPersona(username, email, password, 1); return(View("Success", per)); } catch (Exception e) { return(View("Error", Json(new { success = false, message = e.Message }, JsonRequestBehavior.AllowGet))); } }
public ActionResult Login(string username, string password, bool?remember) { try { PersonaHelper helper = new PersonaHelper(); Persona p = helper.validarPersona(username, password); Session["PersonaId"] = p.IdPersona; return(RedirectToAction("Logueado", "Home", p)); } catch (Exception e) { return(View("Error", Json(new { success = false, message = e.Message }, JsonRequestBehavior.AllowGet))); } }
private Persona CreatePersona(Vehicle veh, ELicenseState lic, bool wanted, out string ownerName, bool couldBeCop = false, bool driverOwnsCar = true) { if (/*veh &&*/ veh.HasDriver && veh.Driver) { Logger.LogTrivialDebug(String.Format("Creating Persona for driver of {0} (Plate# {1})", veh.Model.Name, veh.LicensePlate)); Persona oldP = Functions.GetPersonaForPed(veh.Driver); string mFullName = ""; Gender mGender; if (oldP != null) { mFullName = oldP.FullName; mGender = oldP.Gender; Logger.LogTrivialDebug(String.Format("Using name({0}) and gender ({1}) from old Persona...", mFullName, mGender.ToString())); } else { mFullName = PersonaHelper.GetRandomFullName(); if (veh.Driver.IsFemale) { mGender = Gender.Female; } else { mGender = Gender.Male; } Logger.LogTrivialDebug(String.Format("Old persona is null; using new name ({0}); ped appears to be {1}", mFullName, mGender.ToString())); } string[] nameParts = mFullName.Split(' '); Logger.LogTrivialDebug(String.Format("First name: {0}, Last name: {1}", nameParts[0], nameParts[1])); bool isCop = false; if (couldBeCop == true) { if (Globals.Random.Next(100) < 20) { isCop = true; } } Logger.LogTrivialDebug(String.Format("isCop: {0}", isCop.ToString())); if (driverOwnsCar) { ownerName = mFullName; Logger.LogTrivialDebug(String.Format("Driver owns vehicle...using {0} as registered owner", ownerName)); } else { ownerName = PersonaHelper.GetRandomFullName(); Logger.LogTrivialDebug(String.Format("Driver does NOT own vehicle...using new name ({0}) as registered owner", ownerName)); } Logger.LogTrivialDebug("Creating new Persona object"); Logger.LogTrivialDebug(String.Format("Gender: {0}, Birthday: {1}, Citations: {2}, Forename: {3}, Surname: {4}, License: {5}, Stopped: {6}, Wanted: {7}, IsCop: {8}", mGender.ToString(), oldP.Birthday.ToString(), oldP.Citations, nameParts[0], nameParts[1], lic.ToString(), oldP.TimesStopped, wanted.ToString(), isCop.ToString())); Persona p = new Persona(nameParts[0], nameParts[1], mGender, oldP.Birthday) { Citations = oldP.Citations, ELicenseState = lic, TimesStopped = oldP.TimesStopped, Wanted = wanted, }; //Persona p = new Persona(veh.Driver, mGender, oldP.BirthDay, oldP.Citations, nameParts[0], nameParts[1], lic, oldP.TimesStopped, wanted, false, isCop); Functions.SetPersonaForPed(veh.Driver, p); Functions.SetVehicleOwnerName(veh, ownerName); return(p); } else { ownerName = ""; return(null); } }
public PlateChecker(Vehicle vehicleToCheck) { if (vehicleToCheck.Exists()) { string Flags = ""; if (vehicleToCheck.IsStolen) { Flags += "STOLEN "; DriverPersona = LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(World.GetAllPeds()[0]); //determine persona to use if (vehicleToCheck.HasDriver && vehicleToCheck.Driver.Exists()) { if (LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(vehicleToCheck.Driver).FullName.ToLower() == Functions.GetVehicleOwnerName(vehicleToCheck).ToLower()) { DriverPersona = Functions.GetPersonaForPed(World.GetAllPeds()[0]); } else { foreach (Ped p in World.EnumeratePeds()) { if (Functions.GetPersonaForPed(p).FullName.ToLower() == Functions.GetVehicleOwnerName(vehicleToCheck).ToLower()) { DriverPersona = Functions.GetPersonaForPed(p); break; } } } } if (DriverPersona == null) { //create new persona Persona tempPers = Functions.GetPersonaForPed(World.GetAllPeds()[0]); //DriverPersona = new Persona(World.GetAllPeds()[0], tempPers.Gender, tempPers.BirthDay, tempPers.Citations, tempPers.Forename, tempPers.Surname, tempPers.LicenseState, tempPers.TimesStopped, tempPers.Wanted, tempPers.IsAgent, tempPers.IsCop); } AudioFlags.Add("Stolen"); } else { //determine persona to use if (vehicleToCheck.HasDriver && vehicleToCheck.Driver.Exists()) { if (LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(vehicleToCheck.Driver).FullName.ToLower() == Functions.GetVehicleOwnerName(vehicleToCheck).ToLower()) { DriverPersona = LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(vehicleToCheck.Driver); } else { foreach (Ped p in World.EnumeratePeds()) { if (Functions.GetPersonaForPed(p).FullName.ToLower() == Functions.GetVehicleOwnerName(vehicleToCheck).ToLower()) { DriverPersona = Functions.GetPersonaForPed(p); break; } } } } if (DriverPersona == null) { DriverPersona = PersonaHelper.GenerateNewPersona(); } //DriverPersona = vehicleToCheck.HasDriver && Albo1125.Common.CommonLibrary.CommonVariables.rnd.Next(100) < 80 ? LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(vehicleToCheck.Driver) : LSPD_First_Response.Mod.API.Functions.GetPersonaForPed(World.GetAllPeds()[0]); } LSPD_First_Response.Mod.API.Functions.SetVehicleOwnerName(vehicleToCheck, DriverPersona.FullName); //determine flags on the vehicle if (!PoliceSmartRadio.IsLSPDFRPluginRunning("British Policing Script", new Version("0.9.0.0"))) { if (Traffic_Policer.API.Functions.GetVehicleRegistrationStatus(vehicleToCheck) == Traffic_Policer.EVehicleDetailsStatus.Expired) { Flags += "EXPIRED REGISTRATION "; AudioFlags.Add("TrafficViolation"); } else if (Traffic_Policer.API.Functions.GetVehicleRegistrationStatus(vehicleToCheck) == Traffic_Policer.EVehicleDetailsStatus.None) { Flags += "NO REGISTRATION "; AudioFlags.Add("TrafficViolation"); } if (Traffic_Policer.API.Functions.GetVehicleInsuranceStatus(vehicleToCheck) == Traffic_Policer.EVehicleDetailsStatus.Expired) { Flags += "EXPIRED INSURANCE "; AudioFlags.Add("TrafficViolation"); } else if (Traffic_Policer.API.Functions.GetVehicleInsuranceStatus(vehicleToCheck) == Traffic_Policer.EVehicleDetailsStatus.None) { Flags += "NO INSURANCE "; AudioFlags.Add("TrafficViolation"); } if (DriverPersona.Wanted) { AudioFlags.Add("Warrant"); if (rnd.Next(100) < 75) { Flags += "FELONY WARRANT FOR REGISTERED OWNER "; } else { Flags += "BENCH WARRANT FOR REGISTERED OWNER "; } } if (DriverPersona.ELicenseState == ELicenseState.Suspended) { Flags += "OWNER'S LICENCE SUSPENDED "; AudioFlags.Add("TrafficFelony"); } else if (DriverPersona.ELicenseState == ELicenseState.Expired) { Flags += "OWNER'S LICENCE EXPIRED "; AudioFlags.Add("TrafficViolation"); } else if (DriverPersona.ELicenseState == ELicenseState.None) { Flags += "OWNER'S LICENCE INVALID "; AudioFlags.Add("TrafficViolation"); } if (DriverPersona.Birthday.Date == DateTime.Now.Date) { Flags += "~g~OWNER'S BIRTHDAY "; } if (string.IsNullOrWhiteSpace(Flags)) { AudioFlags.Add("No1099"); this.Flags += "~g~NONE"; } else { AudioFlags.Add("ProceedCaution"); this.Flags += Flags; } } //read in strings from the vehicle information LicencePlate = vehicleToCheck.LicensePlate; vehModel = vehicleToCheck.Model.Name.ToLower(); vehModel = char.ToUpper(vehModel[0]) + vehModel.Substring(1); if (vowels.Contains(vehModel.ToLower()[0])) { modelArticle = "an"; } else { modelArticle = "a"; } vehicleYear = vehYears.PickRandom(); AllVehiclesChecked.Add(vehicleToCheck, this); } }
private string GetRandomSurname() { string randomname = PersonaHelper.GetRandomFullName(); return(randomname.Substring(randomname.IndexOf(' ') + 1)); }