Example #1
0
        public void ChangeDbUnban(
            int AdminID,
            int UserID,
            string Reason,
            int ChannelMessageID = 0
            )
        {
            Temp.bannedUsers.Remove(UserID);
            BanHistory banHistory = new BanHistory
            {
                UserID           = UserID,
                Ban              = 1,
                Level            = 1,
                ChannelMessageID = ChannelMessageID,
                ReasonMessageID  = 0,
                AdminID          = AdminID,
                BanTime          = GetTime.GetUnixTime(),
                Reason           = Reason,
                Expires          = 0
            };

            using (var db = new BlacklistDatabaseContext())
            {
                db.BanHistorys.Add(banHistory);
                var bannedUser = db.BanUsers
                                 .Single(users => users.UserID == UserID);
                db.Remove(bannedUser);
                db.SaveChanges();
            }

            new UnBanCaller().UnBanCallerThread(UserID);
        }
Example #2
0
        public void ChangeDbBan(
            int AdminID,
            int UserID,
            int Level,
            long Expires,
            string Reason,
            int ChannelMessageID = 0,
            int ReasonMessageID  = 0
            )
        {
            BanUser baninfo = new BanUser
            {
                UserID           = UserID,
                Ban              = 0,
                Level            = Level,
                Reason           = Reason,
                HistoryID        = 0,
                ChannelMessageID = ChannelMessageID,
                ReasonMessageID  = ReasonMessageID,
                Expires          = Expires
            };

            Temp.bannedUsers[UserID] = baninfo;
            BanHistory banHistory = new BanHistory
            {
                UserID           = UserID,
                Ban              = 0,
                Level            = Level,
                ChannelMessageID = ChannelMessageID,
                ReasonMessageID  = ReasonMessageID,
                AdminID          = AdminID,
                BanTime          = GetTime.GetUnixTime(),
                Reason           = Reason,
                Expires          = Expires
            };

            using (var db = new BlacklistDatabaseContext())
            {
                db.BanHistorys.Add(banHistory);
                try
                {
                    db.BanUsers.Add(baninfo);
                    db.SaveChanges();
                }
                catch (SqliteException)
                {
                    db.BanUsers.Update(baninfo);
                    db.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    db.BanUsers.Update(baninfo);
                    db.SaveChanges();
                }
            }

            new SubscribeBanListCaller().CallGroupsInThread(baninfo);
        }