示例#1
0
文件: BanDao.cs 项目: eaceaser/PRoCon
 /// <summary>
 /// saves the ban data
 /// </summary>
 /// <param name="ban"></param>
 public void Save(Ban ban)
 {
     using (var trx = this.session.BeginTransaction())
     {
         this.session.Save(ban);
         trx.Commit();
     }
 }
示例#2
0
        private void contextMenuStrip1_Click(object sender, EventArgs e)
        {
            try
            {
                Ban ban      = lsvThucdon.Tag as Ban;
                int idhoadon = app.HoaDon.LayMaHoaDonTheoMaBan(ban.Id);

                string tenmon = lsvThucdon.SelectedItems[0].Text.ToString();
                Mon    mon    = app.Mon.GetMonTheoTen(tenmon);
                app.Mon.XoaMonKhiOrder(idhoadon, mon.Id);
                LayThongTinHoaDon(ban.Id);
                if (lsvThucdon.Items.Count < 1)
                {
                    ThanhToan(ban);
                    app.HoaDon.XoaHoaDonKhiXoaAllMon(idhoadon);
                }
            }
            catch
            {
                MessageBox.Show("Chưa chọn món");
            }
        }
示例#3
0
        public bool insertBan(Ban ban)
        {
            string        sql  = "INSERT INTO ban(ten,trangthai) VALUES (@ten,@trangthai)";
            SqlConnection conn = DBConnection.Instance.getConnection();

            try
            {
                cmd = new SqlCommand(sql, conn);
                conn.Open();

                cmd.Parameters.Add("@ten", SqlDbType.NVarChar).Value  = ban.Name;
                cmd.Parameters.Add("@trangthai", SqlDbType.Int).Value = ban.Trangthai;

                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
示例#4
0
        public async Task <IActionResult> New(int postID, [Bind("Details,Reason,EndTime")] Ban ban)
        {
            ban.Post = _context.Posts
                       .Include(p => p.User)
                       .Where(p => p.ID == postID)
                       .FirstOrDefault();
            ban.Moderator = await _userManager.GetUserAsync(User);

            if (!String.IsNullOrWhiteSpace(ban.Details) || ban.Reason != null)
            {
                _context.Add(ban);

                var reports = _context.Reports.Where(r => r.Post.ID == postID);

                foreach (var report in reports)
                {
                    _context.Update(report);
                    report.Active = false;
                }

                await _context.SaveChangesAsync();

                var users = _context.Posts
                            .Where(p => p.IP == ban.Post.IP && p.User != null)
                            .Select(p => p.User)
                            .ToList();
                foreach (var user in users)
                {
                    if (!await _userManager.IsInRoleAsync(user, "Admin"))
                    {
                        await _userManager.RemoveFromRoleAsync(user, "Moderator");
                    }
                }

                return(RedirectToAction("Index", "Home"));
            }

            return(View(ban));
        }
        public void KiemTraTinhTrangBan_MaBanKhongCo()
        {
            Ban b0 = new Ban(0, 0);
            Ban b1 = new Ban(111, 10, true);
            Ban b2 = new Ban(112, 15, false);
            Ban b3 = new Ban(113, 16);

            DSBan dsB = new DSBan();

            dsB.ThemBan(b0);
            dsB.ThemBan(b1);
            dsB.ThemBan(b2);
            dsB.ThemBan(b3);

            dsB.ThemBan(4);
            dsB.SapXep();

            bool excepted = false;
            bool actual   = dsB.KiemTraTinhTrangBan(112);

            Assert.AreEqual(excepted, actual);
        }
示例#6
0
文件: Utils.cs 项目: snsk802/TShock
        public bool HasBanExpired(Ban ban, bool byName = false)
        {
            DateTime exp;
            bool     expirationExists = DateTime.TryParse(ban.Expiration, out exp);

            if (!string.IsNullOrWhiteSpace(ban.Expiration) && (expirationExists) &&
                (DateTime.UtcNow >= exp))
            {
                if (byName)
                {
                    TShock.Bans.RemoveBan(ban.Name, true, true, false);
                }
                else
                {
                    TShock.Bans.RemoveBan(ban.IP, false, false, false);
                }

                return(true);
            }

            return(false);
        }
示例#7
0
        private object BanDestroyV2(RestVerbs verbs, IParameterCollection parameters, SecureRest.TokenData tokenData)
        {
            var ret = BanFind(parameters);

            if (ret is RestObject)
            {
                return(ret);
            }

            try
            {
                Ban ban = (Ban)ret;
                switch (parameters["type"])
                {
                case "ip":
                    if (!TShock.Bans.RemoveBan(ban.IP, false, false, true))
                    {
                        return(RestResponse("Failed to delete ban (already deleted?)"));
                    }
                    break;

                case "name":
                    if (!TShock.Bans.RemoveBan(ban.Name, true, GetBool(parameters["caseinsensitive"], true)))
                    {
                        return(RestResponse("Failed to delete ban (already deleted?)"));
                    }
                    break;

                default:
                    return(RestError("Invalid Type: '" + parameters["type"] + "'"));
                }
            }
            catch (Exception e)
            {
                return(RestError(e.Message));
            }

            return(RestResponse("Ban deleted successfully"));
        }
        public void ThemBan_MaBanChenCuoi()
        {
            Ban b0 = new Ban(0, 0);
            Ban b1 = new Ban(111, 10);
            Ban b2 = new Ban(112, 15);
            Ban b3 = new Ban(113, 16);

            DSBan dsB = new DSBan();

            dsB.ThemBan(b0);
            dsB.ThemBan(b1);
            dsB.ThemBan(b2);
            dsB.ThemBan(b3);

            dsB.ThemBan(4);
            dsB.SapXep();

            Ban excepted = new Ban(114, 4);
            Ban actual   = dsB.DsBan[4];

            Assert.AreEqual(excepted.MaBan, actual.MaBan);
        }
示例#9
0
        public void Equals_SameBanDifferentID_ReturnTrue()
        {
            var source = new BanSource()
            {
                Display       = "test source",
                Name          = "test",
                RoleplayLevel = RoleplayLevel.Medium,
                Id            = 3
            };

            var banA = new Ban()
            {
                Id               = 12,
                CKey             = "test",
                BannedOn         = DateTime.MinValue,
                BannedBy         = "tester",
                BanType          = BanType.Server,
                Reason           = "what a great test",
                Source           = source.Id,
                SourceNavigation = source
            };

            var banB = new Ban()
            {
                Id               = 0,
                CKey             = "test",
                BannedOn         = DateTime.MinValue,
                BannedBy         = "tester",
                BanType          = BanType.Server,
                Reason           = "what a great test",
                Source           = source.Id,
                SourceNavigation = source
            };

            var comparer = BanEqualityComparer.Instance;

            Assert.True(comparer.Equals(banA, banB), "Two bans equal by internal values should be equal");
            Assert.True(comparer.GetHashCode(banA) == comparer.GetHashCode(banB), "Two bans equal by internal values should have equal hashcodes");
        }
示例#10
0
        public int TATBAN(Ban ban, HoaDon hd)
        {
            /*
             *   CREATE PROCEDURE TATBAN
             *      @id_ban int,
             *      @id_hoadon int
             *      as
             *      begin
             *      -- Cập nhật trạng thái cho bàn
             *      UPDATE BAN
             *      SET TRANGTHAI = 0,GIORA = getdate()
             *      where ID_BAN = @id_ban
             *      -- Tính tổng số giờ chơi của bàn có id_hoadon
             *      UPDATE HOADON
             *      SET TONGGIOCHOI = (SELECT GIORA-GIOVAO FROM BAN WHERE ID_BAN =@id_ban)
             *      where ID_HOADON = @id_hoadon
             *      end
             */
            string sql = "TATBAN " + ban.ID_Ban + "," + hd.ID_HoaDon;

            return(ldc.ExecuteNonQuery(sql));
        }
示例#11
0
        public void TestDSTrong()
        {
            DataSet dsHienThi = new DataSet();

            string l = "select * from Ban where TinhTrang = 'Trống'";

            strcon.Open();

            OleDbDataAdapter daShowData = new OleDbDataAdapter(l, strcon);

            daShowData.Fill(dsHienThi);

            daShowData.Dispose();

            strcon.Close();

            int expected = dsHienThi.Tables[0].Rows.Count;

            int actual = Ban.DSTrong().Count;

            Assert.AreEqual(expected, actual);
        }
示例#12
0
        /// <summary>
        /// Removes the ban from the ban list.
        /// </summary>
        /// <param name="ban">The ban to remove</param>
        /// <returns>True if successful</returns>
        public bool RemoveBan(Ban ban)
        {
            //Make sure its a valid ban to begin with
            if (ban.BanType == BanType.Invalid)
            {
                return(false);
            }

            //Store its success state then try to remove accounts from each state
            bool success = false;

            if (BannedIps.RemoveAll(b => b.Ticket == ban.Ticket) > 0)
            {
                success = true;
            }
            if (BannedUuids.RemoveAll(b => b.Ticket == ban.Ticket) > 0)
            {
                success = true;
            }

            return(success);
        }
示例#13
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (isAdd) // thêm thông tin bàn
            {
                Ban b = new Ban();
                //b.maBan = Convert.ToInt32(txtMaBan.Text);
                b.tenBan    = txtTenBan.Text;
                b.trangThai = cboTrangThai.Text;
                b.maKhuVuc  = Convert.ToInt32(cboKhuVuc.SelectedValue.ToString());
                if (ban.ThemBan(b) == true)
                {
                    MessageBox.Show("Thêm thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else // sai thông tin
                {
                    MessageBox.Show("Thêm thất bại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else // cập nhật thông tin bàn
            {
                Ban b = new Ban();
                b.maKhuVuc  = Convert.ToInt32(cboKhuVuc.SelectedValue);
                b.maBan     = Convert.ToInt32(txtMaBan.Text);
                b.tenBan    = txtTenBan.Text;
                b.trangThai = cboTrangThai.Text;
                if (ban.SuaBan(b) == true)
                {
                    MessageBox.Show("Cập nhật thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else // sai thông tin
                {
                    MessageBox.Show("Cập nhật thất bại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            EnableProject(false);
            HienThiDanhSachBanTheoKhuVuc(Convert.ToInt32(cboKhuVuc.SelectedValue.ToString()));
        }
示例#14
0
        public ActionResult GhiNhan()
        {
            Ban ban = db.Ban.SingleOrDefault(n => n.MaBan == ThongTin.MaBan);

            if (ban.TinhTangBan == 1)
            {
                return(RedirectToAction("Index", "Ban"));
            }
            ban.TinhTangBan = 1;
            HoaDon hoadon = new HoaDon();

            hoadon.TenKH     = ThongTin.HoTen;
            hoadon.NgayDat   = DateTime.Now;
            hoadon.TongTien  = TongHoaDon.TongTien;
            hoadon.SDT       = ThongTin.SDT;
            hoadon.TinhTrang = 0;
            db.HoaDon.Add(hoadon);
            db.SaveChanges();
            //int MaHoaDon = hoadon.MaHD;
            int id = hoadon.MaHD;
            List <HoaDonChiTiet> lstHoaDonChiTiet = LayHoaDonChiTiet();

            ban.MaHD   = hoadon.MaHD;
            ban.GhiChu = ThongTin.GhiChu;
            db.SaveChanges();
            foreach (var item in lstHoaDonChiTiet)
            {
                ChiTiet chitiet = new ChiTiet();
                chitiet.MaMon     = item.iMaMon;
                chitiet.SoLuong   = item.SoLuong;
                chitiet.ThanhTien = item.ThanhTien;
                chitiet.MaHD      = hoadon.MaHD;
                db.ChiTiet.Add(chitiet);
                db.SaveChanges();
            }
            Session.RemoveAll();
            return(RedirectToAction("Index", "Ban"));
        }
示例#15
0
        public async Task <IEnumerable <Ban> > GetBansAsync(int page = 1)
        {
            var request  = new RestRequest("bans", Method.GET, DataFormat.Json).AddQueryParameter("json", "1").AddQueryParameter("page", page.ToString());
            var response = await _client.ExecuteAsync(request);

            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                _logger.LogError($"Beestation website returned a non-200 HTTP response code: {response.StatusCode}, aborting parse.");
                throw new BanSourceUnavailableException($"Beestation website returned a non-200 HTTP response code: {response.StatusCode}, aborting parse.");
            }

            var toReturn = new List <Ban>();
            var content  = JsonSerializer.Deserialize <IEnumerable <Dictionary <string, JsonElement> > >(response.Content);

            foreach (var b in content)
            {
                var toAdd = new Ban()
                {
                    BannedOn         = DateTime.Parse(b["ban_date"].GetString()).ToUniversalTime(),
                    BannedBy         = b["banner"].GetString(),
                    BanType          = ParseBanType(b["type"].GetString()),
                    Expires          = b["unban_date"].GetString() == null ? (DateTime?)null : DateTime.Parse(b["unban_date"].GetString()).ToUniversalTime(),
                    CKey             = b["user"].GetString(),
                    Reason           = b["reason"].GetString(),
                    BanID            = b["id"].GetInt32().ToString(),
                    SourceNavigation = ParseBanSource(b["server"].GetString())
                };

                if (toAdd.BanType == BanType.Job)
                {
                    toAdd.AddJobRange(b["job"].EnumerateArray().Select(x => x.GetString()));
                }

                toReturn.Add(toAdd);
            }

            return(toReturn);
        }
示例#16
0
        public void TestCtdb()
        {
            string  maban     = "1";
            DataSet dsHienThi = new DataSet();

            string l = "select * from DatBan where MaBan = " + maban;

            strcon.Open();

            OleDbDataAdapter daShowData = new OleDbDataAdapter(l, strcon);

            daShowData.Fill(dsHienThi);

            daShowData.Dispose();

            strcon.Close();

            int expected = dsHienThi.Tables[0].Rows.Count;

            int actual = Ban.Ctdb(maban).Rows.Count;

            Assert.AreEqual(expected, actual);
        }
        public bool CapNhatBan(Ban o)
        {
            var kq = TimBan(o.IDBan);

            try
            {
                if (kq == null)
                {
                    return(false);
                }
                else
                {
                    kq.TenBan    = o.TenBan;
                    kq.TrangThai = o.TrangThai;
                    dc.SubmitChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
示例#18
0
        public void Equals_SameBanSameAttributes_ReturnTrue()
        {
            var banA = new Ban()
            {
                Id     = 0,
                Source = 15
            };

            banA.AddAttribute(BanAttribute.BeeStationGlobal);

            var banB = new Ban()
            {
                Id     = 0,
                Source = 15
            };

            banB.AddAttribute(BanAttribute.BeeStationGlobal);

            var comparer = BanEqualityComparer.Instance;

            Assert.True(comparer.Equals(banA, banB), "Bans should be equal when they are equal including attributes");
            Assert.True(comparer.GetHashCode(banA) == comparer.GetHashCode(banB), "Bans should have the same hashcode if they are equal including attributes");
        }
示例#19
0
        public bool updateBan(Ban ban)
        {
            string        sql  = "UPDATE ban SET ten = @ten, trangthai = @trangthai WHERE id = @id";
            SqlConnection conn = DBConnection.Instance.getConnection();

            try
            {
                cmd = new SqlCommand(sql, conn);
                conn.Open();

                cmd.Parameters.Add("@ten", SqlDbType.NVarChar).Value  = ban.Name;
                cmd.Parameters.Add("@trangthai", SqlDbType.Int).Value = ban.Trangthai;
                cmd.Parameters.Add("@id", SqlDbType.Int).Value        = ban.Id;

                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
示例#20
0
        public void Equals_SameBanDifferentJobOrder_ReturnTrue()
        {
            var banA = new Ban()
            {
                Id      = 12,
                BanType = BanType.Job
            };

            banA.AddJobRange(new[] { "detective", "head of security", "security officer", "warden" });

            var banB = new Ban()
            {
                Id      = 0,
                BanType = BanType.Job
            };

            banB.AddJobRange(new[] { "head of security", "warden", "detective", "security officer" });

            var comparer = BanEqualityComparer.Instance;

            Assert.True(comparer.Equals(banA, banB), "Two bans with the same jobbans in different orders should be equal");
            Assert.True(comparer.GetHashCode(banA) == comparer.GetHashCode(banB), "Two bans with the same jobbans in different orders should be equal");
        }
示例#21
0
        private void ProcessBan(IRocketPlayer caller, Ban ban, string playerIP, string punisherIP)
        {
            try
            {
                ModerationPlugin instance = ModerationPlugin.Instance;

                ban.Player   = instance.DatabaseManager.GetPlayer(ban.PlayerId);
                ban.Punisher = instance.DatabaseManager.GetPlayer(ban.PunisherId);

                if (ban.Player == null)
                {
                    ban.Player = instance.DatabaseManager.CreatePlayer(new Player(ban.PlayerId, punisherIP));
                }
                if (ban.Punisher == null)
                {
                    ban.Punisher = instance.DatabaseManager.CreatePlayer(new Player(ban.PunisherId, caller.DisplayName, punisherIP));
                }

                instance.DatabaseManager.InsertBan(ban);

                string prettyDuration = ban.BanDuration.ToPrettyTime();
                string reason         = ban.BanReason.ToReason();

                TaskDispatcher.QueueOnMainThread(() =>
                {
                    UnturnedChat.Say(instance.Translate("BanAnnouncement", ban.Player.PlayerName, ban.Punisher.PlayerName, reason, prettyDuration));

                    SDG.Unturned.Provider.kick(new CSteamID(ban.PlayerId), instance.Translate("BanMessage", reason, prettyDuration));
                });

                instance.DiscordMessager.SendMessage(new string[] { ban.Player.PlayerName, ban.PlayerId.ToString(), ban.Punisher.PlayerName,
                                                                    reason, prettyDuration }, EMessageType.Ban);
            } catch (System.Exception e)
            {
                Logger.LogException(e, "An error occurated when processing ban");
            }
        }
示例#22
0
        private void btn_Click(object sender, EventArgs e)
        {
            Ban ban = (sender as Button).Tag as Ban;

            frmSuDungDichVu.lbTenBan.Text = ban.TenBan;
            //Lấy 1 button để lưu dữ liệu của 1 bàn khi click vào bàn
            frmSuDungDichVu.btnDaiDienBan.Tag = ban;
            //bonus
            frmSuDungDichVu.textEdit1.Text     = ban.GioVao.ToString();
            frmSuDungDichVu.btnDaiDienBan.Text = ban.TenBan;
            // Khi đã click vào 1 bàn lấy được object bàn thì cũng phải lấy được object hoadon của nó luôn
            //Nếu bàn đã được bật thì mới lấy hóa đơn và show nó lên, còn không thì ko show gì cả
            if (ban.TrangThai)
            {
                float     tongtien = 0f;
                DataTable dt       = daHoaDon.LayHoaDon(ban);
                HoaDon    hoadon   = new HoaDon(dt.Rows[0]);
                frmSuDungDichVu.btnHoaDon.Tag = hoadon;
                //bonus
                frmSuDungDichVu.btnHoaDon.Text = hoadon.ID_HoaDon.ToString();

                //Show bill thực chất là show datagridview
                blHoaDon.ShowBill(hoadon, out tongtien);


                frmSuDungDichVu.txtSoHD.Text = hoadon.ID_HoaDon.ToString();
                frmSuDungDichVu.dtpNgay.Text = ban.GioVao.ToString();

                frmSuDungDichVu.txtTienNuoc.Text = tongtien.ToString();
                frmSuDungDichVu.txtTongCong.Text = tongtien.ToString();
                Enabel(true);
            }
            else
            {
                Enabel(false);
            }
        }
示例#23
0
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            //Nhớ lấy username tài khoản thanh toán
            try
            {
                double tongTien = (float)Convert.ToDouble(txtTongTien.Text);
                Ban    ban      = listViewHoaDon.Tag as Ban;

                int idHoaDon = HoaDonDAL.Instance.LayIDHoaDonTuIDBan(ban._ID);

                if (ban.TrangThai == "Trống" && idHoaDon == -1)
                {
                    MessageBox.Show("Bàn không có gì mà cũng thanh toán ! vl", "Thông báo");
                }
                else if (idHoaDon != -1)
                {
                    if (MessageBox.Show("Bạn muốn thanh toán va in hóa đơn " + ban.TenBan + " ?", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        int    idBan  = (listViewHoaDon.Tag as Ban)._ID;
                        string tenBan = (listViewHoaDon.Tag as Ban).TenBan;
                        formInHoaDon.tenBanInHD     = tenBan;
                        formInHoaDon.idBanInHD      = idBan;
                        formInHoaDon.tenThuNganInHD = thuNgan;
                        formInHoaDon fI = new formInHoaDon();
                        fI.Show();

                        HoaDonDAL.Instance.ThanhToan(idHoaDon, (float)tongTien);
                        HienThiHoaDonTheoBan(ban._ID);
                        LoadDanhSachBan();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Chưa chọn bàn cần thanh toán !", "Thông báo");
            }
        }
示例#24
0
 public static Ban GetBan(int ID)
 {
     using (DatabaseClient DatabaseClient = DatabaseManager.GetClient())
     {
         DatabaseClient.SetParameter("@ID", ID);
         DataRow UserRow = DatabaseClient.ExecuteScalarRow("SELECT BanType, BanReason, BanExpiration FROM boombang_users WHERE ID = @ID");
         if (Convert.ToInt32(UserRow["BanType"]) != 0)
         {
             Ban Ban = new Ban();
             Ban.Reason = Convert.ToString(UserRow["BanReason"]);
             Ban.Time   = Math.Round(new TimeSpan(Time.ToDateTime(Convert.ToString(UserRow["BanExpiration"])).Ticks = DateTime.Now.Ticks).TotalSeconds);
             Ban.Type   = Convert.ToInt32(UserRow["BanType"]);
             if (Ban.Type == 2)
             {
                 Ban.Time = 0;
                 return(Ban);
             }
             else if (Ban.Type == 1)
             {
                 if (Ban.Time <= 0)
                 {
                     Ban.Time = 0;
                     return(null);
                 }
                 return(Ban);
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             return(null);
         }
     }
 }
示例#25
0
            public async Task BanPlayer(CommandContext ctx,
                                        [Description("The IP address to ban.")] string ip,
                                        [Description("The reason for the ban.")] string reason)
            {
                if (string.IsNullOrWhiteSpace(ip))
                {
                    throw new ArgumentNullException("ip");
                }

                if (string.IsNullOrWhiteSpace(reason))
                {
                    throw new ArgumentNullException("reason");
                }

                //Fetch the response
                await ctx.ReplyWorkingAsync();

                var ban = new Ban()
                {
                    IP        = ip,
                    Reason    = reason,
                    Moderator = "Discord: " + ctx.Member.Username + "(" + ctx.Member.Id + ")",
                };

                //res
                var response = await Starwatch.BanAsync(ban);

                //Something else, throw an exception
                if (response.Status != RestStatus.OK)
                {
                    throw new RestResponseException(response);
                }

                //Build the response
                await ctx.ReplyAsync(embed : BuildBanEmbed(response.Payload));
            }
示例#26
0
        public void themMonAn(string maban, string mathucdon, string tenthucdon, string gia, string soluong)
        {
            if (!kiemTraMonAnTonTai(maban, mathucdon))
            {
                GoiMon newMon = new GoiMon();
                newMon.MaBan      = maban;
                newMon.MaThucDon  = mathucdon;
                newMon.TenThucDon = tenthucdon;
                newMon.Gia        = int.Parse(gia);
                newMon.SoLuong    = int.Parse(soluong);
                newMon.ThanhTien  = int.Parse(gia) * int.Parse(soluong);
                newMon.ThoiGian   = DateTime.Now;
                Ban Ban = db.Bans.Where(a => a.MaBan == maban).FirstOrDefault();
                Ban.TrangThai = "Đã có khách";
                db.GoiMons.InsertOnSubmit(newMon);
                db.SubmitChanges();

                MessageBox.Show("Thêm món '" + tenthucdon + "' cho bàn '" + maban + "' thành công.");
            }
            else
            {
                capnhatMonAn(maban, mathucdon, soluong);
            }
        }
        public override void Use(Player p, string message)
        {
            if (message.Split(' ').Length < 2)
            {
                Help(p); return;
            }
            if (message.Split(' ')[1].Length == 1)
            {
                Help(p); return;
            }
            string username     = message.Split(' ')[0];
            string creason      = message;
            string reason       = creason.Remove(0, username.Length + 1).Replace(" ", "%20");
            string errormessage = Ban.Editreason(username, reason);

            if (errormessage != "")
            {
                Player.SendMessage(p, errormessage);
            }
            else
            {
                Player.SendMessage(p, "Succesfully edited baninfo about &0" + username + Server.DefaultColor + " to: &2" + reason.Replace("%20", " "));
            }
        }
示例#28
0
        protected override void HandleClient(ServerContext context, Client target, int duration, bool ip, string reason)
        {
            if (target.Entity == null)
            {
                Console.WriteLine($@"    {Strings.Player.offline}");

                return;
            }

            // TODO: Refactor the global/console messages into ModeratorActionCommand
            var name = target.Entity.Name;

            if (string.IsNullOrEmpty(Ban.CheckBan(target.User, "")))
            {
                Ban.Add(target, duration, reason, Strings.Commands.banuser, ip ? target.GetIp() : "");
                target.Disconnect();
                PacketSender.SendGlobalMsg(Strings.Account.banned.ToString(name));
                Console.WriteLine($@"    {Strings.Account.banned.ToString(name)}");
            }
            else
            {
                Console.WriteLine($@"    {Strings.Account.alreadybanned.ToString(name)}");
            }
        }
示例#29
0
 private void btnthemmon_Click(object sender, EventArgs e)
 {
     try
     {
         Ban ban      = lsvThucdon.Tag as Ban;
         int maHoaDon = app.HoaDon.LayMaHoaDonTheoMaBan(ban.Id);
         int maMon    = int.Parse(cboMon.SelectedValue.ToString());
         int soLuong  = (int)numSoluong.Value;
         if (maHoaDon == -1)
         {
             app.HoaDon.ThemHD(ban.Id);
             app.ChiTietHoaDon.ThemChiTietHoaDon(app.HoaDon.LayMaHDLonNhat(),
                                                 maMon, soLuong);
             ThemMon(ban);
         }
         else
         {
             var check = app.ChiTietHoaDon.KiemTraMonAnTonTai(maHoaDon, maMon);
             if (check)
             {
                 app.ChiTietHoaDon.CapNhapSoLuong(maHoaDon, maMon, soLuong);
                 LayThongTinHoaDon(ban.Id);
             }
             else
             {
                 app.ChiTietHoaDon.ThemChiTietHoaDon(maHoaDon, maMon, soLuong);
             }
         }
         LayThongTinHoaDon(ban.Id);
         hienTongTien();
     }
     catch
     {
         MessageBox.Show("Chưa chọn bàn");
     }
 }
示例#30
0
 public bool Test(Ban ban)
 {
     return ban.Enforcer == type;
 }
 private void ParseArguments(List<String> args, out Ban ban)
 {
     ban = new Ban();
     for (int i = 0; i < args.Count; i++)
     {
         string key = args[i].ToLower();
         string value = args[++i];
         switch (key)
         {
             case IP_PARAM:
                 ban.IPv4Address = value;
                 break;
             case ID_PARAM:
                 int userid = -1;
                 if (!Int32.TryParse(value, out userid))
                 {
                     throw new ArgumentException("UserID Param requires a numerical value.");
                 }
                 ban.UserId = userid;
                 break;
             case UAN_PARAM:
                 ban.UserAccountName = value;
                 break;
             case CN_PARAM:
                 ban.CharacterName = value;
                 break;
             case EXPIR_PARAM:
                 Int64 expires = -1;
                 if (!ParseExpiration(value, out expires))
                 {
                     throw new ArgumentException("Expiration Param requires '1y2M3d4h5m6s' format, with at least one of the specifiers.");
                 }
                 ban.BanExpires = expires;
                 break;
             case REASON_PARAM:
                 ban.BanReason = value;
                 break;
             case BANNER_PARAM:
                 User u = new User();
                 int id = -1;
                 u.Name = value;
                 if (Int32.TryParse(value, out id))
                 {
                     u.ID = id;
                 }
                 ban.Banner = u;
                 break;
             default:
                 throw new ArgumentException("The argument {0} is undefined.", key);
         }
     }
 }
示例#32
0
        private object BanDestroyV2(RestVerbs verbs, IParameterCollection parameters)
        {
            var returnBlock = new Dictionary<string, string>();

            var type = parameters["type"];
            if (type == null)
            {
                returnBlock.Add("Error", "Invalid Type");
                return returnBlock;
            }

            var ban = new Ban();
            if (type == "ip") ban = TShock.Bans.GetBanByIp(parameters["user"]);
            else if (type == "name") ban = TShock.Bans.GetBanByName(parameters["user"]);
            else
            {
                returnBlock.Add("Error", "Invalid Type");
                return returnBlock;
            }

            if (ban == null)
            {
                return new Dictionary<string, string> {{"status", "400"}, {"error", "The specified ban does not exist."}};
            }

            try
            {
                TShock.Bans.RemoveBan(ban.IP);
            }
            catch (Exception)
            {
                returnBlock.Add("status", "400");
                returnBlock.Add("error", "The specified ban was unable to be removed.");
                return returnBlock;
            }
            returnBlock.Add("status", "200");
            returnBlock.Add("response", "Ban deleted successfully.");
            return returnBlock;
        }
 public void InsertBan(Ban ban)
 {
     if (database.Query("INSERT INTO Bans (IP, ID, UserAccountName, CharacterName, BanningUser, Issued, Expiration, Reason) VALUES (@0, @1, @2, @3, @4, @5, @6, @7)",
                        ban.IPv4Address,
                        ban.UserId,
                        ban.UserAccountName,
                        ban.CharacterName,
                        ban.Banner != null ? ban.Banner.ID : -1,
                        Utils.ConvertToUnixTime(ban.BanIssued),
                        ban.BanExpires,
                        ban.BanReason) != 1)
     {
         throw new SqlException("Failed to insert ban.");
     }
 }
示例#34
0
 /// <summary>
 /// Checks if a ban is currently enforced on the channel
 /// </summary>
 /// <param name="ban">The ban to check</param>
 /// <returns>True if the ban is enforced</returns>
 public static bool IsBanEnforced(Ban ban)
 {
     return Irc.IsBanEnforced(ban.Mask.Mask);
 }
示例#35
0
        /// <summary>
        /// Periodically evaluate a ban
        /// </summary>
        /// <param name="ban">The ban to evaluate</param>
        /// <returns>True if the ban is now useless and should be removed</returns>
        static bool EvaluateBan(Ban ban)
        {
            if (ban.Enforcer == BanEnforcement.ByMe && ban.Expires < DateTime.UtcNow)
            {
                if (IsBanEnforced(ban))
                {
                    //remove ban, but keep in list until unban completed
                    Irc.Unban(ban.Mask.Mask);
                    return false;
                }
                else
                {
                    //remove ban, it's not enforced
                    return true;
                }
            }

            //anythign else, just keep
            return false;
        }
示例#36
0
 /// <summary>
 /// Called to test if a ban should be removed
 /// </summary>
 /// <param name="ban">The ban to test</param>
 /// <returns>True if the ban should be removed</returns>
 static bool ShouldRemoveBan(Ban ban)
 {
     return (ban.Enforcer == BanEnforcement.ByQ || ban.Enforcer == BanEnforcement.ByChannel) && !keep.Contains(ban);
 }
示例#37
0
文件: QNet.cs 项目: vsrz/desbot_vsrz
        public override bool OnResponse(string response)
        {
            if (response.StartsWith("Registered bans on")) return true;
            if (response.StartsWith("ID  Hostmask")) return true;
            if (response.StartsWith("No bans on"))
            {
                //inform ban system
                BanSystem.OnQBanListReceived(results);

                //done
                Succeeded = true;
                return false;
            }
            if (response.StartsWith("End of list"))
            {
                //inform ban system
                BanSystem.OnQBanListReceived(results);

                //done
                Succeeded = true;
                return false;
            }
            try
            {
                //parse a ban list entry
                string[] args = response.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                Ban result = new Ban();
                int next = 3;
                result.Mask = new HostMask(args[1]);
                if (args[2] == "Permanent") result.Expires = DateTime.MaxValue;
                else
                {
                    //parse time
                    result.Expires = DateTime.UtcNow;
                    result.Expires = result.Expires.AddDays(int.Parse(args[2]));
                    string[] temp = args[4].Split(new char[] { ':' });
                    result.Expires = result.Expires.AddHours(int.Parse(temp[0]));
                    result.Expires = result.Expires.AddMinutes(int.Parse(temp[1]));
                    result.Expires = result.Expires.AddSeconds(int.Parse(temp[2]));
                    next = 5;
                }

                //parse set by
                result.Enforcer = BanEnforcement.ByQ;
                result.SetBy = args[next];
                if(result.SetBy == "(channel")
                {
                    result.SetBy = "<manual>";
                    result.Enforcer = BanEnforcement.ByChannel;
                    next += 2;
                }
                else
                {
                    next += 1;
                }

                //parse reason
                result.Reason = "";
                for (int i = next; i < args.Length; i++) result.Reason += args[i] + " ";
                result.Reason.Trim();

                //look up source of ban
                string[] split = result.Reason.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (split.Length >= 2 && split[split.Length - 2] == "by")
                {
                    result.SetBy = split[split.Length - 1];
                }

                //get affected names
                result.Affected = BanSystem.GetAffectedNicks(result.Mask);

                //add ban to list
                results.Add(result);

                //read more entries
                return true;
            }
            catch (Exception ex)
            {
                //error during parsing
                Program.Log("Unexpected response while updating ban list with '" + response + "': " + ex.Message);
                return false;
            }
        }
示例#38
0
		private static void AuthChallengeRequestCallback(IAuthClient client, Ban clientBan)
		{
			if (clientBan != null)
			{
				if (clientBan.IPMinimum != 0 && clientBan.IPMaximum != 0)
				{
					if (clientBan.Expires <= DateTime.Now)
					{
						// remove the ban since it's expired
					    client.Server.EnqueueTask(QueryFactory.CreateNonResultQuery(clientBan.DeleteAndFlush));
					}
					else
					{
						OnLoginError(client, AccountStatus.Failure);
						return;
					}
				}
			}

			if (client.Server.IsAccountLoggedIn(client.CurrentUser))
			{
				OnLoginError(client, AccountStatus.AccountInUse);
			}
			else
			{
				var acctQuery = QueryFactory.CreateResultQuery(
				    () => AccountMgr.GetAccount(client.CurrentUser),
												QueryAccountCallback,
												client
											);
				client.Server.EnqueueTask(acctQuery);
			}
		}
示例#39
0
 /// <summary>
 /// Performs a ban
 /// </summary>
 /// <param name="hostmask">The mask to ban</param>
 /// <param name="duration_or_null">The duration, or null</param>
 /// <param name="reason">The reason for the ban</param>
 /// <param name="by">The user who set the ban</param>
 public static void PerformBan(string hostmask, string duration_or_null, string reason, string by)
 {
     int index = hostmask.IndexOf('!');
     if (index <= 0) throw new Exception("Not a valid hostmask");
     TimeSpan actual_duration = duration_or_null == null ? TimeSpan.FromSeconds(0) : ParseDuration(duration_or_null);
     Ban ban = new Ban();
     ban.Mask = new HostMask(hostmask);
     ban.Reason = reason;
     ban.SetBy = by;
     ban.Expires = duration_or_null == null ? DateTime.MaxValue : DateTime.UtcNow + actual_duration; 
     ban.Enforcer = BanEnforcement.ByJtv;
     ban.Affected = hostmask.Substring(0, index);
     AddOperation(new PendingBan(ban.Affected, ban));
 }
示例#40
0
        /// <summary>
        /// Tests if a ban is used to quiet a user on the channel
        /// </summary>
        /// <param name="ban">The ban to test</param>
        /// <returns>True if the ban is used to quiet the user</returns>
        public static bool IsQuietBan(Ban ban, out User match)
        {
            //clear flag
            match = null;

            //if expired, the ban never quiets
            if (ban.Expires < DateTime.UtcNow && ban.Enforcer != BanEnforcement.ByJtv) return false;

            //look for users
            foreach (User user in State.UserList.GetItems())
            {
                if (user.Left == DateTime.MaxValue && ban.Mask.Matches(user.HostMask))
                {
                    match = user;
                    return true;
                }
            }

            //no user affected
            return false;
        }
示例#41
0
 /// <summary>
 /// Called when the channel ban list has been received
 /// </summary>
 public static void OnIrcEndOfBanList()
 {
     lock (State.GlobalSync)
     {
         try
         {
             foreach (PendingOperation op in pending)
             {
                 op.Execute(banlist);
             }
             pending.Clear();
             List<Ban> toremove = new List<Ban>();
             foreach (Ban ban in State.BanList.GetItems())
             {
                 if (ban.Enforcer != BanEnforcement.ByJtv) break;
                 string hostmask = ban.Mask.Mask;
                 int index = hostmask.IndexOf('!');
                 if (index <= 0) break;
                 string nick = hostmask.Substring(0, index);
                 if (banlist.Contains(nick))
                 {
                     banlist.Remove(nick);
                 }
                 else if (ban.Expires == DateTime.MaxValue || ban.Expires < DateTime.UtcNow)
                 {
                     toremove.Add(ban);
                 }
             }
             foreach (Ban ban in toremove)
             {
                 Program.Log("Removing ban on " + ban.Affected + " from internal list, it's no longer on the JTV ban list");
                 State.BanList.Remove(ban);
             }
             foreach (string nick in banlist)
             {
                 Ban ban = new Ban();
                 ban.Affected = nick;
                 ban.Enforcer = BanEnforcement.ByJtv;
                 ban.Expires = DateTime.MaxValue;
                 ban.Mask = new HostMask(nick);
                 ban.Reason = "Manual JTV ban";
                 ban.SetBy = "JTV";
                 State.BanList.Add(ban);
             }
         }
         finally
         {
             lastupdated = DateTime.UtcNow;
             refresh_pending = false;
             banlist = null;
         }
     }
 }
示例#42
0
 public bool Update(Ban ban)
 {
     return(_banDal.Update(ban));
 }
示例#43
0
 /// <summary>
 /// Tests if a ban is enforced by Q
 /// </summary>
 /// <param name="ban">The ban to test</param>
 /// <returns>True if the ban is enforced by Q</returns>
 static bool IsQBan(Ban ban)
 {
     return ban.Enforcer == BanEnforcement.ByQ;
 }
        public IEnumerable<Ban> GetBans(Ban lookup)
        {
            List<Ban> bans = new List<Ban>();

            string queryWhere = "WHERE ";
            int index = 0;
            List<object> args = new List<object>();
            if (!String.IsNullOrEmpty(lookup.IPv4Address))
            {
                queryWhere += "@" + index.ToString() + " LIKE Bans.IP";
                queryWhere += " OR Bans.IP LIKE @" + index.ToString();
                index++;
                args.Add(lookup.IPv4Address);
            }

            if (lookup.UserId >= 0)
            {
                if (queryWhere != "")
                    queryWhere += " OR ";
                queryWhere += "Bans.ID = @" + index.ToString();
                index++;
                args.Add(lookup.UserId);
            }

            if (!String.IsNullOrEmpty(lookup.UserAccountName))
            {
                if (queryWhere != "")
                    queryWhere += " OR ";
                queryWhere += "@" + index.ToString() + " LIKE Bans.UserAccountName";
                queryWhere += " OR Bans.UserAccountName LIKE @" + index.ToString();
                index++;
                args.Add(lookup.UserAccountName);
            }

            if (!String.IsNullOrEmpty(lookup.CharacterName))
            {
                if (queryWhere != "")
                    queryWhere += " OR ";
                queryWhere += "@" + index.ToString() + " LIKE Bans.CharacterName";
                queryWhere += " OR Bans.CharacterName LIKE @" + index.ToString();
                index++;
                args.Add(lookup.CharacterName);
            }

            if (!String.IsNullOrEmpty(lookup.BanReason))
            {
                if (queryWhere != "")
                    queryWhere += " OR ";
                queryWhere += "@" + index.ToString() + " LIKE Bans.Reason";
                queryWhere += " OR Bans.Reason LIKE @" + index.ToString();
                index++;
                args.Add(lookup.BanReason);
            }

            if (lookup.Banner != null)
            {
                if (queryWhere != "")
                    queryWhere += " OR ";
                queryWhere += "Bans.BanningUser = @" + index.ToString();
                index++;
                args.Add(lookup.Banner.ID);
            }

            if (queryWhere != "WHERE ")
            {
                var query = String.Format("SELECT * FROM Bans {0}", queryWhere);

                using (var reader = database.QueryReader(query, args.ToArray()))
                {
                    while (reader.Read())
                    {
                        int row = reader.Get<Int32>("RowID");
                        Ban b = new Ban(reader.Get<string>("IP"),
                            reader.Get<Int32>("ID"),
                            reader.Get<string>("UserAccountName"),
                            reader.Get<string>("CharacterName"));
                        b.Banner = TShock.Users.GetUserByID((int) reader.Get<Int32>("BanningUser"));
                        b.BanIssued = Utils.UnixTimeToDateTime(reader.Get<Int64>("Issued"));
                        b.BanExpires = reader.Get<Int64>("Expiration");
                        b.RowId = row;
                        b.BanReason = reader.Get<string>("Reason");
                        bans.Add(b);
                    }
                }
            }
            return bans;
        }
示例#45
0
        /// <summary>
        /// Performs a ban
        /// </summary>
        /// <param name="hostmask">The mask to ban</param>
        /// <param name="duration_or_null">The duration, or null</param>
        /// <param name="reason">The reason for the ban</param>
        /// <param name="by">The user who set the ban</param>
        public static void PerformBan(string hostmask, string duration_or_null, string reason, string by)
        {
            lock (State.GlobalSync)
            {
                if (state != BanSystemState.Synchronized) throw new Exception("Bad state");
                if (State.UseQEnforce.Value && CanQBan())
                {
                    //if we use Q enforcement, queue a Q command
                    if (duration_or_null == null) new PermBanCommand(hostmask, reason);
                    else new TempBanCommand(hostmask, duration_or_null, reason);
                }
                else
                {
                    //hostmask
                    HostMask mask = new HostMask(hostmask);

                    //add to list
                    Ban ban = new Ban();
                    TimeSpan actual_duration = duration_or_null == null ? TimeSpan.FromSeconds(0) : ParseDuration(duration_or_null);
                    ban.Expires = duration_or_null == null ? DateTime.MaxValue : DateTime.UtcNow + actual_duration;
                    ban.Enforcer = BanEnforcement.ByMe;
                    ban.Affected = GetAffectedNicks(mask);
                    ban.Mask = mask;
                    ban.Reason = reason;
                    ban.SetBy = by;

                    //check if a longer ban already in place
                    Ban existing = State.BanList.Lookup(ban.Mask.Mask);
                    if (existing != null && existing.Expires > ban.Expires)
                    {
                        throw new Exception("A ban with a longer duration is already in place");
                    }

                    //add to banlist
                    if (existing != null) State.BanList.Remove(existing);
                    State.BanList.Add(ban);

                    //ban from channel
                    if (!CanChannelBan() && FreeBanSlot(1) == 0)
                    {
                        foreach (User user in State.UserList.GetItems())
                        {
                            if (user.Left == DateTime.MaxValue && mask.Matches(user.HostMask))
                            {
                                //kick from channel
                                Irc.Kick(user.Nick, "Enforcing ban: " + reason);
                            }
                        }
                    }
                    else
                    {
                        Irc.Ban(hostmask);
                        if (State.UseQuietBan.Value == false || duration_or_null == null)
                        {
                            foreach (User user in State.UserList.GetItems())
                            {
                                if (user.Left == DateTime.MaxValue && mask.Matches(user.HostMask))
                                {
                                    //kick from channel
                                    Irc.Kick(user.Nick, "Enforcing ban: " + reason);
                                }
                            }
                        }
                        else
                        {
                            //put channel message
                            Irc.SendChannelMessage(GetAffectedNicks(mask) + " has been timed out from chatting for " + ((int)(actual_duration.TotalMinutes + 0.5)).ToString() + " minutes: " + reason, false);
                        }
                    }
                }
            }
        }
 private void AddBan(CommandArgs args)
 {
     if (args.Parameters.Count < 3 || args.Parameters.Count % 2 != 1)
     {
         ShowAddUsage(args.Player);
     }
     else
     {
         Ban ban = new Ban();
         try
         {
             ParseArguments(args.Parameters.GetRange(1, args.Parameters.Count - 1), out ban);
             ban.Banner = TShock.Users.GetUserByID(args.Player.UserID);
             ban.BanIssued = DateTime.Now;
             banManager.InsertBan(ban);
             args.Player.SendSuccessMessage("Successfully added ban.");
         }
         catch (ArgumentException e)
         {
             args.Player.SendErrorMessage(e.Message);
         }
     }
 }
示例#47
0
 public Candidate(Ban ban)
 {
     this.ban = ban;
     ExtendedBanInfo info;
     this.set = extended.TryGetValue(ban.Mask.Mask, out info) ? info.SetAt : DateTime.MinValue;
 }
        private void FindBan(CommandArgs args)
        {
            if (args.Parameters.Count < 3 || args.Parameters.Count%2 != 1)
            {
                ShowFindUsage(args.Player);
            }
            else
            {
                Ban ban = new Ban();
                try
                {
                    ParseArguments(args.Parameters.GetRange(1, args.Parameters.Count - 1), out ban);
                    if (ban.Banner != null)
                    {
                        try
                        {
                            User u = TShock.Users.GetUser(ban.Banner);
                            if (u != null)
                                ban.Banner = u;
                        }
                        catch (UserNotExistException e)
                        {
                            ban.Banner = null;
                        }
                    }
                    List<Ban> bans = banManager.GetBans(ban).ToList();
                    foreach (Ban b in bans)
                    {
                        string searchParams = "";
                        if (!String.IsNullOrEmpty(b.IPv4Address))
                            searchParams = b.IPv4Address;
                        if (!String.IsNullOrEmpty(b.UserAccountName))
                        {
                            if (searchParams != "")
                                searchParams += " ";
                            searchParams += "Account Name - " + b.UserAccountName;
                        }
                        if (b.UserId >= 0)
                        {
                            if (searchParams != "")
                                searchParams += " ";
                            searchParams += "User ID - " + b.UserId;
                        }
                        if (!String.IsNullOrEmpty(b.CharacterName))
                        {
                            if (searchParams != "")
                                searchParams += " ";
                            searchParams += "Character Name - " + b.CharacterName;
                        }

                        string duration = b.BanExpires > 0 ? "until " + b.BanIssued.AddSeconds(b.BanExpires).ToString() : "forever";
                        string reason = String.IsNullOrEmpty(b.BanReason) ? "for no reason specified" : b.BanReason;
                        args.Player.SendInfoMessage("[{6}] {0}{1} banned {2} on {3} {4} {5}.", b.Banner == null ? "Console" : b.Banner.Name, b.Banner == null ? "" : "(" + b.Banner.ID + ")", searchParams, b.BanIssued.ToString(), duration, reason, b.RowId);
                    }
                }
                catch (ArgumentException e)
                {
                    args.Player.SendErrorMessage(e.Message);
                }
            }
        }
示例#49
0
 public PendingBan(string nick, Ban toadd)
 {
     this.nick = nick;
     this.toadd = toadd;
 }
 //Hook Handlers
 private void HandleConnection(JoinEventArgs args)
 {
     Ban ban = new Ban(Netplay.serverSock[args.Who].tcpClient.Client.RemoteEndPoint.ToString().Split(':')[0], -1, "", Main.player[args.Who].name);
     var bans = banManager.GetBans(ban).ToList();
     if (bans.Count > 0)
     {
         TShock.Players[args.Who].Disconnect(String.Format("Banned: {0}", String.IsNullOrEmpty(ban.BanReason) ? "No reason specified." : ban.BanReason));
         args.Handled = true;
     }
 }
示例#51
0
        /// <summary>
        /// Lấy tất cả các hóa đơn của bàn sắp xếp giảm dần
        /// </summary>
        /// <param name="ban"></param>
        /// <returns></returns>
        public DataTable LayHoaDon(Ban ban)
        {
            string sql = "select * from hoadon where id_ban = " + ban.ID_Ban + " order by id_hoadon desc";

            return(ldc.getDuLieu(sql));
        }
示例#52
0
        private object BanInfoV2(RestVerbs verbs, IParameterCollection parameters)
        {
            var returnBlock = new Dictionary<string, string>();

            var type = parameters["type"];
            if (type == null)
            {
                returnBlock.Add("Error", "Invalid Type");
                return returnBlock;
            }

            var ban = new Ban();
            if (type == "ip") ban = TShock.Bans.GetBanByIp(parameters["user"]);
            else if (type == "name") ban = TShock.Bans.GetBanByName(parameters["user"]);
            else
            {
                returnBlock.Add("Error", "Invalid Type");
                return returnBlock;
            }

            if (ban == null)
            {
                return new Dictionary<string, string> { { "status", "400" }, { "error", "The specified ban does not exist." } };
            }

            returnBlock.Add("status", "200");
            returnBlock.Add("name", ban.Name);
            returnBlock.Add("ip", ban.IP);
            returnBlock.Add("reason", ban.Reason);
            return returnBlock;
        }