public BritishPersona(Ped _ped, LicenceTypes _LicenceType, LicenceStatuses _LicenceStatus, int _PenaltyPoints, bool _CarryingLicence) : this(_ped) { if (!_ped.Exists()) { AllBritishPersona.Remove(this); return; } foreach (BritishPersona pers in AllBritishPersona.ToArray()) { if (pers.ped == _ped && pers != this) { AllBritishPersona.Remove(pers); } } ped = _ped; if (ped.Exists()) { _LSPDFRPersona = Functions.GetPersonaForPed(ped); if (ped.IsInAnyVehicle(false)) { VehicleRecords.VerifyVehicleRecordsExist(ped.CurrentVehicle); } foreach (BritishPersona pers in AllBritishPersona.ToArray()) { if (pers.ped == ped && pers != this) { AllBritishPersona.Remove(pers); } } } LicenceType = _LicenceType; LicenceStatus = _LicenceStatus; PenaltyPoints = _PenaltyPoints; CarryingLicence = _CarryingLicence; }
/// <summary> /// Constructs an object of type <see cref="Product"/>. /// </summary> /// <param name="reader">Reader attached to a source data stream.</param> internal Product(BinaryReader reader) : this() { Id = reader.ReadByte(); Version = reader.ReadByte(); Quantity = reader.ReadByte(); Type = (LicenceTypes)reader.ReadByte(); }
/// <summary> /// Constructs an object of type <see cref="Product"/>. /// </summary> /// <param name="productId">Id of the product.</param> /// <param name="version">Product version.</param> /// <param name="quantity">Number of installations allowed for this product.</param> /// <param name="type">The type of Licence.</param> public Product(byte productId, byte version, byte quantity, LicenceTypes type) : this() { Id = productId; Version = version; Quantity = quantity; Type = type; }
private void SendConfirmMessage(LicenceTypes licenceTypes) { if (licenceTypes == LicenceTypes.Trial) { MessageBox.Show("E' stata ottenuta una licenza di prova della durata di 30 giorni. Per rinnovare la licenza chiamare il produttore per richiedere il codice di attivazione!", "Attivazione prodotto", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (licenceTypes == LicenceTypes.All) { MessageBox.Show("Complimenti! Il codice di attivazione è corretto e il prodotto è stato attivato correttamente", "Attivazione prodotto", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
public static ILicence CreateLicence(LicenceTypes type, DateTime activationDate, string activationCode, TemporalRange validity, int trialDays, string hardwareId) { switch (type) { case LicenceTypes.Temporary: return(CreateTemporaryLicence(activationDate, activationCode, validity, hardwareId)); case LicenceTypes.Trial: return(CreateTrialLicence(activationDate, trialDays, hardwareId)); case LicenceTypes.All: return(CreateFullLicence(activationDate, activationCode, hardwareId)); default: return(null); } }
/// <summary> /// Constructor that sets values based off the LSPDFR API /// </summary> /// <param name="_ped"></param> public BritishPersona(Ped _ped) : this(Functions.GetPersonaForPed(_ped)) { if (!_ped.Exists()) { Game.LogTrivial("PED DOESNT EXIST"); AllBritishPersona.Remove(this); return; } foreach (BritishPersona pers in AllBritishPersona.ToArray()) { if (pers.ped == _ped && pers != this) { AllBritishPersona.Remove(pers); } } ped = _ped; if (ped.Exists()) { _LSPDFRPersona = Functions.GetPersonaForPed(ped); if (ped.IsInAnyVehicle(false)) { VehicleRecords.VerifyVehicleRecordsExist(ped.CurrentVehicle); } foreach (BritishPersona pers in AllBritishPersona.ToArray()) { if (pers.ped == ped && pers != this) { AllBritishPersona.Remove(pers); } } } int roll = EntryPoint.rnd.Next(10); if (roll < 6) { LicenceType = LicenceTypes.Full; } else { //If ped is driving a vehicle with a passenger if (_ped.IsInAnyVehicle(false)) { if (_ped.CurrentVehicle.Driver == _ped) { if (!_ped.CurrentVehicle.IsSeatFree(0)) { if (EntryPoint.rnd.Next(4) < 3) { LicenceType = LicenceTypes.Provisional; } else { LicenceType = LicenceTypes.None; } } } } else { roll = EntryPoint.rnd.Next(4); if (roll < 2) { LicenceType = LicenceTypes.Provisional; } else { LicenceType = LicenceTypes.None; } } } FullyCompInsured = EntryPoint.rnd.Next(8) == 0; int Citations = LSPDFRPersona.Citations; PenaltyPoints = Citations * 3; if (LSPDFRPersona.ELicenseState == ELicenseState.Valid) { LicenceStatus = LicenceStatuses.Valid; } else if (LSPDFRPersona.ELicenseState == ELicenseState.Suspended) { if (EntryPoint.rnd.Next(6) < 4) { LicenceStatus = LicenceStatuses.Disqualified; } else { LicenceStatus = LicenceStatuses.Revoked; } } else if (LSPDFRPersona.ELicenseState == ELicenseState.Expired) { LicenceStatus = LicenceStatuses.Expired; } else { LicenceStatus = LicenceStatuses.Valid; } if (LicenceStatus == LicenceStatuses.Disqualified || LicenceStatus == LicenceStatuses.Revoked || LicenceType == LicenceTypes.None) { CarryingLicence = false; } else { CarryingLicence = EntryPoint.rnd.Next(6) < 4; } }
public ActionResult Edit(int id, Clients item, IFormCollection form) { try { //Comboboxes LicenceTypes licenceTypes = new LicenceTypes(); var licenceType = form["licenceType"]; List <SelectListItem> comboTiposLicencia = licenceTypes.GetList(licenceType); ViewBag.ComboTiposLicencia = comboTiposLicencia; ViewBag.licenceType = licenceType; Packages packages = new Packages(); int package = Convert.ToInt32(form["package"]); List <SelectListItem> comboPackages = packages.GetList(package); ViewBag.ComboPackages = comboPackages; ViewBag.package = package; //Validations if ((licenceType == "P" || licenceType == "T") && (!item.DueDate.HasValue)) { throw new Exception("Las licencias 'Paid' o 'Trial' requieren fecha de vencimiento"); } if (licenceType == "F" && item.DueDate.HasValue) { item.DueDate = null; } //Client Update sqlcmd = $@"update public.administration_client set phone = '{item.Phone}' ,address = '{item.Address}' ,valid_client = {item.ValidClient} ,add_date = {pgSQL.DateToSQL(item.AddDate)} ,due_date = {pgSQL.DateToSQL(item.DueDate)} ,renew_date = {pgSQL.DateToSQL(item.RenewalDate)} ,licence_type = '{licenceType}' ,year_payment = {item.YearPayment} ,package_id = {package} ,db_schema = '{item.DbSchema.ToLower()}' ,db_name = '{item.DbName.ToLower()}' where id = {item.Id};"; using (var cnn = pgSQL.GetConnection()) using (var cmd = new NpgsqlCommand(sqlcmd, cnn)) { cmd.CommandType = System.Data.CommandType.Text; cmd.ExecuteNonQuery(); } //Audit information sqlcmd = $@"insert into public.administration_historyclient (date, description, client_id) values({pgSQL.DateToSQL(DateTime.Now.Date)} ,'Edición manual de datos por el operador <{User.Identity.Name}>: valid_client <{item.ValidClient}>, licence_type <{licenceType}>, package_id <{package}>, due_date <{item.DueDate}>, renew_date <{item.RenewalDate}>' ,{item.Id});"; using (var cnn = pgSQL.GetConnection()) using (var cmd = new NpgsqlCommand(sqlcmd, cnn)) { cmd.CommandType = System.Data.CommandType.Text; cmd.ExecuteNonQuery(); } return(RedirectToAction(nameof(Index))); } catch (Exception ex) { string error = $"Error: {ex.Message.ToString()}"; ViewBag.Error = error; return(View(item)); } }
// GET: Clients/Edit/5 public ActionResult Edit(int id) { { Models.MTPAdminViewModels.Clients item = new Clients(); //Returns the record sqlcmd = $@"select c.*, l.name as licence_type_name, s.description as company_size_name, p.name as package_name, u.username from public.administration_client c left join public.adminview_licence_types l on c.licence_type = l.id left join public.administration_companysize s on c.company_size_id = s.id left join public.administration_package p on c.package_id = p.id left join public.auth_user u on c.user_id = u.id where c.id = {id};"; using (var cnn = pgSQL.GetConnection()) using (var cmd = new NpgsqlCommand(sqlcmd, cnn)) using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { item.Id = Convert.ToInt32(reader["Id"]); item.CompanyName = (string)reader["company_name"]; if (reader["phone"] != DBNull.Value) { item.Phone = (string)reader["phone"]; } if (reader["address"] != DBNull.Value) { item.Address = (string)reader["address"]; } item.Country = (string)reader["country"]; item.Language = (string)reader["language"]; item.AddDate = Convert.ToDateTime(reader["add_date"]).Date; if (reader["due_date"] != DBNull.Value) { item.DueDate = Convert.ToDateTime(reader["due_date"]).Date; } if (reader["renew_date"] != DBNull.Value) { item.RenewalDate = Convert.ToDateTime(reader["renew_date"]).Date; } item.YearPayment = Convert.ToBoolean(reader["year_payment"]); item.LicenceType = (string)reader["licence_type"]; if (reader["package_id"] != DBNull.Value) { item.PackageID = Convert.ToInt32(reader["package_id"]); } item.DbSchema = (string)reader["db_schema"]; item.DbName = (string)reader["db_name"]; item.ValidClient = Convert.ToBoolean(reader["valid_client"]); item.CompanySizeId = Convert.ToInt32(reader["company_size_id"]); item.CompanySizeName = (string)reader["company_size_name"]; item.UserID = Convert.ToInt32(reader["user_id"]); item.UserName = (string)reader["username"]; } } //Comboboxes LicenceTypes licenceTypes = new LicenceTypes(); List <SelectListItem> comboTiposLicencia = licenceTypes.GetList(item.LicenceType); ViewBag.ComboTiposLicencia = comboTiposLicencia; Packages packages = new Packages(); List <SelectListItem> comboPackages = packages.GetList(item.PackageID); ViewBag.ComboPackages = comboPackages; return(View(item)); } }