internal void AddBan(List <string> identifiers, string bannedBy = "", string reason = "", DateTime?expires = null) { var expiry = expires ?? DateTime.MaxValue; var ban = new BanModel { BannedBy = string.IsNullOrEmpty(bannedBy) ? "System" : bannedBy, BanReason = string.IsNullOrEmpty(reason) ? Server.Config.DefaultBanReason : reason, Expires = expiry, Identifiers = identifiers }; if (expiry > DateTime.UtcNow) { ActiveBans.Add(ban); } AllBans.Add(ban); Log.Warn($"{ban.BannedBy} Added ban {ban.BanLength} to identifiers ({string.Join( ", ", identifiers )}). Reason: {ban.BanReason}"); SaveBanList(); var target = new PlayerList().FirstOrDefault(p => p.Identifiers.Any(identifiers.Contains)); var id = target != null ? target.Name : identifiers.FirstOrDefault(); target?.Drop($"You are banned {ban.BanLength}. Reason: {ban.BanReason}"); Server.TriggerEventForAce(Constants.AceAdmin, "UI.ShowNotification", $"~r~{id}~s~ has been banned {ban.BanLength} by ~g~{ban.BannedBy}~s~.~n~~y~Reason~s~: {ban.BanReason}"); }
internal RestBan(RestDiscordClient client, BanModel model, Snowflake guildId) : base(client) { GuildId = guildId; Guild = new RestDownloadable <RestGuild>(options => Client.GetGuildAsync(guildId, options)); User = new RestUser(client, model.User); Reason = model.Reason; }
internal RestBan(RestDiscordClient client, Snowflake guildId, BanModel model) : base(client) { GuildId = guildId; Guild = RestFetchable.Create(this, (@this, options) => @this.Client.GetGuildAsync(@this.GuildId, options)); User = new RestUser(client, model.User); Reason = model.Reason; }
// get ban public ActionResult Ban(int?page) { NhaHangEntities NhaHang_Ban = new NhaHangEntities(); BanModel banModel = new BanModel(); int pageSize = 1000; int pageNumber = page ?? 1; banModel.BanModels = (from B in NhaHang_Ban.Bans select B).OrderBy(b => b.Idban).ToPagedList(pageNumber, pageSize); return(View(banModel)); }
public BanViewModel(BanModel model) { this.model = model; DurationUnitList = model.DurationList.ToReadOnlyReactiveCollection(x => x.Name); NameText = model.ToReactivePropertyAsSynchronized(m => m.Name); Duration = model.ToReactivePropertyAsSynchronized(m => m.Duration); BanBtClicked = new DelegateCommand(BanBt_Clicked); CancelBtClicked = new DelegateCommand(model.Cancel); }
public Ban(IMainWindowTelnet telnet, string playerID = "") { InitializeComponent(); var model = new BanModel(telnet); var vm = new BanViewModel(model); DataContext = vm; model.Ended += Model_Ended; model.Name = playerID; }
private void listTableUserControl1_TableItemClick(object sender, EventArgs e) { try { var p = sender as TableUserControl; listTableUserControl1.ResetBorderStype(); p.BorderStyle = BorderStyle.Fixed3D; p.labelName.ForeColor = Color.Red; _banCurrent = p.BanItem; _presenter.LoadHoadonByBan(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
public static void CreateNewBanEntry(BanModel banClass) { try { using MySqlConnection connection = new MySqlConnection(connectionString); connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "INSERT INTO bans (UID, SCID, HardwareId, Reason) VALUES(@UID, @SCID, @HardwareId, @Reason)"; command.Parameters.AddWithValue("@UID", banClass.UID); command.Parameters.AddWithValue("@SCID", banClass.SCID); command.Parameters.AddWithValue("@HardwareId", banClass.HardwareId); command.Parameters.AddWithValue("@Reason", banClass.Reason); command.ExecuteNonQuery(); } catch (Exception ex) { Core.Debug.CatchException(ex); } }
public static List <BanModel> LoadAccountBans() { List <BanModel> AccountBans = new List <BanModel>(); using MySqlConnection connection = new MySqlConnection(connectionString); connection.Open(); MySqlCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM Bans"; using MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { BanModel accClass = new BanModel { UID = reader.GetInt32("UID"), SCID = reader.GetString("SCID"), HardwareId = reader.GetString("HardwareId"), Reason = reader.GetString("Reason"), }; AccountBans.Add(accClass); } return(AccountBans); }
public bool Update(BanModel model) { string msgError = ""; try { var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_ban_update", "@maban", model.ma_ban, "@makv", model.ma_kv, "@tenban", model.ten_ban, "@soghe", model.so_ghe, "@trangthai", model.trang_thai); if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError)) { throw new Exception(Convert.ToString(result) + msgError); } return(true); } catch (Exception ex) { throw ex; } }
public static void BanTarget(GangwarPlayer player, string Username, string Reason) { GangwarPlayer target = Functions.GetPlayerByName(Username); if (target is null || !target.Exists) { } foreach (AccountModel account in Account.Init.AccountList) { if (account.Username == Username) { BanModel newBanEntry = new BanModel { UID = account.UID, HardwareId = account.HardwareIdHash, SCID = account.SocialClubId, Reason = Reason }; Database.Database.CreateNewBanEntry(newBanEntry); Admin.Init.AccountBans.Add(newBanEntry); Functions.SendChatMessageToAll(Functions.GetHexColorcode(200, 0, 0) + Username + " got banned! Reason: " + Reason); } } }
public BanModel UpdateBan([FromBody] BanModel model) { _itemBusiness.Update(model); return(model); }
public BanModel CreateBan([FromBody] BanModel model) { model.ma_ban = Guid.NewGuid().ToString(); _itemBusiness.Create(model); return(model); }
public bool Update(BanModel model) { return(_res.Update(model)); }
public bool Create(BanModel model) { return(_res.Create(model)); }
public TableUserControl(BanModel banItem) { InitializeComponent(); BanItem = banItem; }