Exemplo n.º 1
0
        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}");
        }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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));
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
 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); }
 }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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;
            }
        }
Exemplo n.º 11
0
        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);
                }
            }
        }
Exemplo n.º 12
0
 public BanModel UpdateBan([FromBody] BanModel model)
 {
     _itemBusiness.Update(model);
     return(model);
 }
Exemplo n.º 13
0
 public BanModel CreateBan([FromBody] BanModel model)
 {
     model.ma_ban = Guid.NewGuid().ToString();
     _itemBusiness.Create(model);
     return(model);
 }
Exemplo n.º 14
0
 public bool Update(BanModel model)
 {
     return(_res.Update(model));
 }
Exemplo n.º 15
0
 public bool Create(BanModel model)
 {
     return(_res.Create(model));
 }
Exemplo n.º 16
0
 public TableUserControl(BanModel banItem)
 {
     InitializeComponent();
     BanItem = banItem;
 }