public static void CreateRecord(Punishment punishment)
        {
            var ERecordId = CheckForRecords(punishment.AccountId, punishment.Type);

            if (ERecordId != "-1")
            {
                DisposeRecord(ERecordId);
            }
            Server.Database.Punishments.Add(punishment);
            Storage.Database.Helper.Save();

            var Connection = Server.Connections.Find(c => c.Owner.Id == punishment.AccountId);

            if (!Connection.Owner.Online)
            {
                return;
            }
            F2CE.ClientState State;
            if (punishment.Type == F2CE.PunishmentType.Bann || punishment.Type == F2CE.PunishmentType.BannTemporarily)
            {
                State = F2CE.ClientState.Banned;
            }
            else
            {
                State = F2CE.ClientState.Muted;
            }
            Connection.SetStreamContent(string.Join("|", F2CE.Action.SetState.ToString(), State.ToString(), JsonConvert.SerializeObject(punishment)));
        }
Ejemplo n.º 2
0
 public Inmate(OutPoint utxo, Punishment punishment, DateTimeOffset started, Guid lastDisruptedRoundId)
 {
     Utxo                 = utxo;
     Punishment           = punishment;
     Started              = started;
     LastDisruptedRoundId = lastDisruptedRoundId;
 }
Ejemplo n.º 3
0
        public static void UpdateUserFromAccount(User user, Account acc)
        {
            user.Name           = acc.Name;
            user.DisplayName    = acc.SteamName;
            user.Avatar         = acc.Avatar;
            user.Level          = acc.Level;
            user.EffectiveMmElo = (int)Math.Round(acc.GetRating(RatingCategory.MatchMaking).Elo);
            user.EffectiveElo   = (int)Math.Round(acc.GetRating(RatingCategory.Casual).Elo);
            user.RawMmElo       = (int)Math.Round(acc.GetRating(RatingCategory.MatchMaking).RealElo);
            user.SteamID        = acc.SteamID?.ToString();
            user.IsAdmin        = acc.AdminLevel >= AdminLevel.Moderator;
            user.IsBot          = acc.IsBot;
            user.Country        = acc.Country;
            user.Faction        = acc.Faction != null ? acc.Faction.Shortcut : null;
            user.Clan           = acc.Clan != null ? acc.Clan.Shortcut : null;
            user.AccountID      = acc.AccountID;
            user.Badges         = acc.GetBadges().Select(x => x.ToString()).ToList();
            user.Icon           = acc.GetIconName();
            if (user.Badges.Count == 0)
            {
                user.Badges = null;                         // slight optimization for data transfer
            }
            Interlocked.Increment(ref user.SyncVersion);

            user.BanMute     = Punishment.GetActivePunishment(acc.AccountID, user.IpAddress, 0, x => x.BanMute) != null;
            user.BanSpecChat = Punishment.GetActivePunishment(acc.AccountID, user.IpAddress, 0, x => x.BanSpecChat) != null;
        }
Ejemplo n.º 4
0
        public static void MassBan(string name, int startIndex, int endIndex, string reason, int banHours, bool banSite = false, bool banLobby = true, bool banIP = false, bool banID = false)
        {
            ZkDataContext db = new ZkDataContext();

            for (int i = startIndex; i <= endIndex; i++)
            {
                Account acc = db.Accounts.FirstOrDefault(x => x.Name == name + i);
                if (acc != null)
                {
                    int?   userID = banID ? (int?)acc.AccountUserIDs.OrderByDescending(x => x.LastLogin).FirstOrDefault().UserID : null;
                    string userIP = banIP ? acc.AccountIPs.OrderByDescending(x => x.LastLogin).FirstOrDefault().IP : null;
                    System.Console.WriteLine(acc.Name, userID, userIP);
                    Punishment punishment = new Punishment
                    {
                        Time             = DateTime.UtcNow,
                        Reason           = reason,
                        BanSite          = banSite,
                        BanLobby         = banLobby,
                        BanExpires       = DateTime.UtcNow.AddHours(banHours),
                        BanIP            = userIP,
                        CreatedAccountID = 5806,
                        UserID           = userID,
                    };
                    acc.PunishmentsByAccountID.Add(punishment);
                }
            }
            db.SubmitChanges();
        }
Ejemplo n.º 5
0
        public ActionResult RemovePunishment(int punishmentID)
        {
            var db    = new ZkDataContext();
            var todel = db.Punishments.First(x => x.PunishmentID == punishmentID);

            db.Punishments.DeleteOnSubmit(todel);
            db.SubmitAndMergeChanges();

            if (todel.BanLobby)
            {
                Account acc = todel.AccountByAccountID;
                Global.Nightwatch.Tas.AdminUnban(acc.Name);
                if (todel.BanIP != null)
                {
                    Global.Nightwatch.Tas.AdminUnban(todel.BanIP);
                }
                var otherPenalty = Punishment.GetActivePunishment(acc.AccountID, null, null, x => x.BanLobby, db);
                if (otherPenalty != null)
                {
                    var    time = otherPenalty.BanExpires - DateTime.Now;
                    double days = time.Value.TotalDays;
                    Global.Nightwatch.Tas.AdminBan(acc.Name, days / 24, otherPenalty.Reason);
                    if (otherPenalty.BanIP != null)
                    {
                        Global.Nightwatch.Tas.AdminBanIP(otherPenalty.BanIP, days / 24, otherPenalty.Reason);
                    }
                }
            }

            return(RedirectToAction("Detail", "Users", new { id = todel.AccountID }));
        }
Ejemplo n.º 6
0
        /// <inheritdoc />
        public async Task <PunishmentResponse> ApplyPunishment(Punishment punishment, SocketGuildUser user)
        {
            var punishmentResponse = new PunishmentResponse();

            var botHierarchy = user.Guild.CurrentUser.Hierarchy;

            if (botHierarchy > user.Hierarchy)
            {
                await user.Guild.AddBanAsync(user);

                var expireTime = punishment.PunishDuration == 0 ? "Never" : punishment.PunishDuration.ToString();

                punishmentResponse.Successful = true;

                punishmentResponse.StatusMessage = $"Banning user <@{user.Id}>" +
                                                   $"\nReason: {punishment.WarningType}" +
                                                   $"Expires: {expireTime}";
            }
            else
            {
                punishmentResponse.Successful = false;

                punishmentResponse.StatusMessage =
                    $"Failed to ban user <@{user.Id}> as bot has insufficient permissions.";
            }

            return(punishmentResponse);
        }
Ejemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            string idCardNumber = txbx_idcard.Text;
            var    people       = DBcontext.People.GetAll();
            Person person       = people.FirstOrDefault(x => x.IdCardNumber == idCardNumber);

            if (string.IsNullOrEmpty(cmbx_points.Text))
            {
                MessageBox.Show("You have not input all info");
            }
            else if (string.IsNullOrEmpty(idCardNumber))
            {
                MessageBox.Show("Please, define a person who is suposed to be punished");
            }
            else if (person != null)
            {
                PunishmentData       punishmentData       = new PunishmentData();
                byte                 points               = punishmentData.GetPoints(cmbx_points.Text);
                PunishmentAmountType punishmentAmountType = punishmentData.GetPunishAmountType(points);
                Punishment           punishment           = new Punishment()
                {
                    Id         = Identifier <Punishment> .GenerateID(),
                    UserId     = person.Id,
                    Points     = points,
                    Amount     = punishmentAmountType,
                    PunishDate = DateTime.Now
                };
                lbl_punishDate.Text   = punishment.PunishDate.ToString();
                lbl_punishAmount.Text = punishment.Amount.ToString() + " AZN";
                person.Points        += points;
                DBcontext.Punishments.Add(punishment);
            }
        }
Ejemplo n.º 8
0
        public Punishment GetPunishment(string _punishmentID)
        {
            Punishment punishment = new Punishment();

            punishmentDA.LoadPunishment(_punishmentID, punishment);
            return(punishment);
        }
Ejemplo n.º 9
0
        public async Task SetPunishment(Contexts contexts, Punishment punishment)
        {
            if (punishment.PunishmentOption == PunishmentOption.Nothing)
            {
                return;
            }

            Log.Information("Spam recognized! User: {user} on channel: {channel} server: {server}",
                            contexts.User.Name, contexts.Channel.Name, contexts.Server.Name);

            var messagesService = this._messagesServiceFactory.Create(contexts);

            switch (punishment.PunishmentOption)
            {
            case PunishmentOption.Warn:
                await messagesService.SendResponse(x => x.SpamAlertRecognized(contexts));

                break;

            case PunishmentOption.Mute:
                await this.MuteUserForSpam(contexts, punishment.ForTime !.Value);

                break;
            }
        }
Ejemplo n.º 10
0
        /// <inheritdoc />
        public bool IsPunishmentAlreadyActive(Punishment punishment, UserWarnings userData)
        {
            var currentlyActivePunishments = userData.ActivePunishments;

            // bool indicating whether user already has punishment.
            return(currentlyActivePunishments.Any(x => x.PunishmentId == punishment.Id));
        }
Ejemplo n.º 11
0
 private void ClearPunishmentProbationPeriod(Punishment punishment)
 {
     punishment.ProbationYears  = 0;
     punishment.ProbationMonths = 0;
     punishment.ProbationWeeks  = 0;
     punishment.ProbationDays   = 0;
 }
Ejemplo n.º 12
0
 private void ClearPunishmentPeriod(Punishment punishment)
 {
     punishment.PunishmentYears  = 0;
     punishment.PunishmentMonths = 0;
     punishment.PunishmentWeeks  = 0;
     punishment.PunishmentDays   = 0;
 }
        public ActionResult Punish(int accountID,
                                   string reason,
                                   bool deleteXP,
                                   bool deleteInfluence,
                                   bool banMute,
                                   bool banCommanders,
                                   bool banSite,
                                   bool banLobby,
                                   bool banUnlocks,
                                   bool banForum,
                                   bool setRightsToZero,
                                   string banIP,
                                   long?banUserID,
                                   double banHours)
        {
            ZkDataContext db  = new ZkDataContext();
            Account       acc = db.Accounts.Single(x => x.AccountID == accountID);

            if (banHours > MaxBanHours)
            {
                banHours = MaxBanHours;                         // todo show some notification
            }
            Punishment punishment = new Punishment
            {
                Time             = DateTime.UtcNow,
                Reason           = reason,
                BanMute          = banMute,
                BanCommanders    = banCommanders,
                BanSite          = banSite,
                BanLobby         = banLobby,
                BanExpires       = DateTime.UtcNow.AddHours(banHours),
                BanUnlocks       = banUnlocks,
                BanIP            = banIP,
                BanForum         = banForum,
                SetRightsToZero  = setRightsToZero,
                DeleteXP         = deleteXP,
                DeleteInfluence  = deleteInfluence,
                CreatedAccountID = Global.AccountID,
                UserID           = banUserID
            };

            acc.PunishmentsByAccountID.Add(punishment);
            db.SubmitChanges();

            // notify lobby of changes and post log message
            try
            {
                Global.Server.KickFromServer(Global.Account.Name, acc.Name, reason);

                Global.Server.GhostChanSay(GlobalConst.ModeratorChannel, string.Format("New penalty for {0} {1}  ", acc.Name, Url.Action("Detail", "Users", new { id = acc.AccountID }, "http")));
                Global.Server.GhostChanSay(GlobalConst.ModeratorChannel, string.Format("Reason: {0} ", reason));
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                Global.Server.GhostChanSay(GlobalConst.ModeratorChannel, ex.ToString());
            }
            return(RedirectToAction("Detail", new { id = accountID }));
        }
Ejemplo n.º 14
0
        public ActionResult DeleteConfirmed(int id)
        {
            Punishment punishment = db.Punishments.Find(id);

            db.Punishments.Remove(punishment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 15
0
 public void CreatePunishment(Punishment punishment)
 {
     if (punishment == null)
     {
         throw new ArgumentNullException(nameof(punishment));
     }
     _context.Punishments.Add(punishment);
 }
Ejemplo n.º 16
0
        public bool LoadPunishments(List <Punishment> _punishments, string _classID = "")
        {
            bool success = Connect();

            if (!success)
            {
                return(false);
            }

            try
            {
                using (SqlCommand cmd = connection.CreateCommand())
                {
                    cmd.CommandType = System.Data.CommandType.Text;
                    if (string.IsNullOrEmpty(_classID))
                    {
                        cmd.CommandText = "SELECT * FROM PUNISHMENT";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM PUNISHMENT JOIN STUDENT ON PUNISHMENT.StudentID = STUDENT.StudentID WHERE ClassID = @classid";
                        cmd.Parameters.AddWithValue("@classid", _classID);
                    }
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Punishment punishment = new Punishment();
                            punishment.ID        = reader.GetString(0);
                            punishment.StudentID = reader.GetString(1);
                            if (!reader.IsDBNull(2))
                            {
                                punishment.Content = reader.GetString(2);
                            }
                            else
                            {
                                punishment.Content = string.Empty;
                            }
                            punishment.Fault    = reader.GetString(3);
                            punishment.Grade    = Int32.Parse(reader.GetString(4));
                            punishment.Semester = reader.GetInt32(5);
                            punishment.Year     = reader.GetInt32(6);
                            _punishments.Add(punishment);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                return(false);
            }
            finally
            {
                Disconnect();
            }
            return(true);
        }
Ejemplo n.º 17
0
        void MvcApplication_PostAuthenticateRequest(object sender, EventArgs e)
        {
            if (DateTime.UtcNow.Subtract(lastPollCheck).TotalMinutes > 15)
            {
                PollController.AutoClosePolls();
                lastPollCheck = DateTime.UtcNow;
            }

            Account acc = null;

            if (Request[GlobalConst.ASmallCakeCookieName] != null)
            {
                var testAcc = Account.AccountByName(new ZkDataContext(), Request[GlobalConst.ASmallCakeLoginCookieName]);
                if (testAcc != null)
                {
                    if (AuthTools.ValidateSiteAuthToken(testAcc.Name, testAcc.Password, Request[GlobalConst.ASmallCakeCookieName]))
                    {
                        acc = testAcc;
                    }
                }
            }
            if (acc == null)
            {
                if (Request[GlobalConst.LoginCookieName] != null)
                {
                    acc = AuthServiceClient.VerifyAccountHashed(Request[GlobalConst.LoginCookieName], Request[GlobalConst.PasswordHashCookieName]);
                }
            }

            if (acc != null)
            {
                var ip = GetUserIP();
                using (var db = new ZkDataContext()) {
                    var penalty = Punishment.GetActivePunishment(acc.AccountID, ip, null, x => x.BanSite, db);
                    if (penalty != null)
                    {
                        Response.Write(string.Format("You are banned! (IP match to account {0})\n", penalty.AccountByAccountID.Name));
                        Response.Write(string.Format("Ban expires: {0} UTC\n", penalty.BanExpires));
                        Response.Write(string.Format("Reason: {0}\n", penalty.Reason));
                        Response.End();
                    }
                    else
                    {
                        HttpContext.Current.User = acc;
                        // todo replace with safer permanent cookie
                        Response.SetCookie(new HttpCookie(GlobalConst.LoginCookieName, acc.Name)
                        {
                            Expires = DateTime.Now.AddMonths(12)
                        });
                        Response.SetCookie(new HttpCookie(GlobalConst.PasswordHashCookieName, acc.Password)
                        {
                            Expires = DateTime.Now.AddMonths(12)
                        });
                    }
                }
            }
        }
Ejemplo n.º 18
0
 public void Dispose()
 {
     foreach (Punishment Punishment in Punishments)
     {
         Punishment.Dispose();
     }
     Program.GameData.MatchInfo.OnMatchNewRound -= NewRound;
     Dispose(true);
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Punishment punishment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(punishment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(punishment));
 }
Ejemplo n.º 20
0
        //Punishment
        private void punishmentBindingSource_CurrentChanged(object sender, EventArgs e)
        {
            Punishment selectedPunishment = punishmentBindingSource.Current as Punishment;

            if (selectedPunishment == null)
            {
                return;
            }
            punishmentSinsBindingSource.DataSource = selectedPunishment.Sins.ToList();
        }
Ejemplo n.º 21
0
        public ActionResult MassBanSubmit(string name, int startIndex, int endIndex, string reason, int banHours, bool banSite = false, bool banLobby = true, bool banIP = false, bool banID = false)
        {
            ZkDataContext db         = new ZkDataContext();
            int?          firstAccID = null;

            if (banHours > MaxBanHours)
            {
                banHours = MaxBanHours;
            }
            for (int i = startIndex; i <= endIndex; i++)
            {
                Account acc = db.Accounts.FirstOrDefault(x => x.Name == name + i);
                if (acc != null)
                {
                    firstAccID = firstAccID ?? acc.AccountID;
                    uint?  userID = banID ? (uint?)acc.AccountUserIDS.OrderByDescending(x => x.LastLogin).FirstOrDefault().UserID : null;
                    string userIP = banIP ? acc.AccountIPS.OrderByDescending(x => x.LastLogin).FirstOrDefault().IP : null;
                    System.Console.WriteLine(acc.Name, userID, userIP);
                    Punishment punishment = new Punishment
                    {
                        Time             = DateTime.UtcNow,
                        Reason           = reason,
                        BanSite          = banSite,
                        BanLobby         = banLobby,
                        BanExpires       = DateTime.UtcNow.AddHours(banHours),
                        BanIP            = userIP,
                        CreatedAccountID = Global.AccountID,
                        UserID           = userID,
                    };
                    acc.PunishmentsByAccountID.Add(punishment);

                    try
                    {
                        Global.Nightwatch.Tas.Extensions.PublishAccountData(acc);
                        if (banLobby)
                        {
                            Global.Nightwatch.Tas.AdminBan(acc.Name, banHours / 24, reason);
                            if (banIP)
                            {
                                Global.Nightwatch.Tas.AdminBanIP(userIP, banHours / 24, reason);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError(ex.ToString());
                    }
                }
            }
            db.SubmitChanges();
            Global.Nightwatch.Tas.Say(TasClient.SayPlace.Channel, AuthService.ModeratorChannel, string.Format("Mass ban executed by {4} for user series {0} ({1} - {2}): {3}",
                                                                                                              name, startIndex, endIndex, Url.Action("Detail", "Users", new { id = firstAccID }, "http"), Global.Account.Name), true);

            return(Index(name, null, null));
        }
        /// <inheritdoc />
        public async Task <PunishmentResponse> ApplyPunishment(Punishment punishment, SocketGuildUser user)
        {
            var punishmentResponse = new PunishmentResponse();

            if (!punishment.RoleId.HasValue)
            {
                punishmentResponse.Successful    = false;
                punishmentResponse.StatusMessage = "No role provided.";
                return(punishmentResponse);
            }

            var guild = user.Guild;

            var role = guild.GetRole(punishment.RoleId.Value);

            if (guild == null)
            {
                punishmentResponse.Successful    = false;
                punishmentResponse.StatusMessage = "Guild doesn't exist.";
                return(punishmentResponse);
            }

            if (role == null)
            {
                punishmentResponse.Successful    = false;
                punishmentResponse.StatusMessage = "Role no longer exists.";
                return(punishmentResponse);
            }

            var hierarchy = user.Guild.CurrentUser.Hierarchy;

            // Trying to assign a role higher than the bots hierarchy will throw an error.
            if (role.Position < hierarchy)
            {
                await user.AddRoleAsync(role);

                var expireTime = punishment.PunishDuration == 0 ? "Never" : punishment.PunishDuration.ToString();

                punishmentResponse.Successful = true;

                punishmentResponse.StatusMessage = $"Adding role '{role.Name}' to user <@{user.Id}>" +
                                                   $"\nReason: {punishment.WarningType}\n" +
                                                   $"Expires (minutes): {expireTime}";
            }
            else
            {
                punishmentResponse.Successful = false;

                punishmentResponse.StatusMessage =
                    $"Couldn't add role '{role.Name}' to user <@{user.Id}> as bot has insufficient permissions. " +
                    "Check your role hierarchy and make sure the bot is higher than the role you wish to apply.";
            }

            return(punishmentResponse);
        }
Ejemplo n.º 23
0
        public ActionResult Create([Bind(Include = "Id,Name")] Punishment punishment)
        {
            if (ModelState.IsValid)
            {
                db.Punishments.Add(punishment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(punishment));
        }
Ejemplo n.º 24
0
        private void MvcApplication_PostAuthenticateRequest(object sender, EventArgs e)
        {
            if (DateTime.UtcNow.Subtract(lastPollCheck).TotalMinutes > 60)
            {
                PollController.AutoClosePolls(); // this is silly here, should be a seaprate timer/thread
                lastPollCheck = DateTime.UtcNow;
            }

            Account acc = null;


            if (FormsAuthentication.IsEnabled && User.Identity.IsAuthenticated)
            {
                acc = Account.AccountByName(new ZkDataContext(), User.Identity.Name);
            }
            else if (Request[GlobalConst.SessionTokenVariable] != null)
            {
                int id = 0;
                if (Global.Server?.SessionTokens.TryRemove(Request[GlobalConst.SessionTokenVariable], out id) == true)
                {
                    acc = new ZkDataContext().Accounts.Find(id);
                }
            }

            if (acc != null)
            {
                var ip        = Request.UserHostAddress;
                var lastLogin = acc.AccountUserIDs.OrderByDescending(x => x.LastLogin).FirstOrDefault();
                var userID    = lastLogin?.UserID;
                var installID = lastLogin?.InstallID;
                var penalty   = Punishment.GetActivePunishment(acc.AccountID, ip, userID, installID, x => x.BanSite);
                if (penalty != null)
                {
                    Response.Write(string.Format("You are banned! (IP match to account {0})\n", penalty.AccountByAccountID.Name));
                    Response.Write(string.Format("Ban expires: {0} UTC\n", penalty.BanExpires));
                    Response.Write(string.Format("Reason: {0}\n", penalty.Reason));
                    Response.End();
                }
                else
                {
                    HttpContext.Current.User = acc;
                    FormsAuthentication.SetAuthCookie(acc.Name, true);
                }
            }

            // remove cake from URL
            var removeCake = Regex.Replace(Request.Url.ToString(), $"([?|&])({GlobalConst.SessionTokenVariable}=[^&?]+[?|&]*)", m => m.Groups[1].Value);

            if (removeCake != Request.Url.ToString())
            {
                Response.Redirect(removeCake, true);
            }
        }
        public async Task <ActionResult> MassBanSubmit(string name, int startIndex, int endIndex, string reason, int banHours, bool banSite = false, bool banLobby = true, bool banIP = false, bool banID = false)
        {
            ZkDataContext db         = new ZkDataContext();
            int?          firstAccID = null;

            if (banHours > MaxBanHours)
            {
                banHours = MaxBanHours;
            }
            for (int i = startIndex; i <= endIndex; i++)
            {
                Account acc = db.Accounts.FirstOrDefault(x => x.Name == name + i);
                if (acc != null)
                {
                    firstAccID = firstAccID ?? acc.AccountID;
                    long?  userID    = banID ? (uint?)acc.AccountUserIDs.OrderByDescending(x => x.LastLogin).FirstOrDefault().UserID : null;
                    string installID = banID ? acc.AccountUserIDs.OrderByDescending(x => x.LastLogin).FirstOrDefault().InstallID : null;
                    string userIP    = banIP ? acc.AccountIPs.OrderByDescending(x => x.LastLogin).FirstOrDefault().IP : null;
                    System.Console.WriteLine(acc.Name, userID, userIP);
                    Punishment punishment = new Punishment
                    {
                        Time             = DateTime.UtcNow,
                        Reason           = reason,
                        BanSite          = banSite,
                        BanLobby         = banLobby,
                        BanExpires       = DateTime.UtcNow.AddHours(banHours),
                        BanIP            = userIP,
                        CreatedAccountID = Global.AccountID,
                        UserID           = userID,
                        InstallID        = installID,
                    };
                    acc.PunishmentsByAccountID.Add(punishment);

                    try
                    {
                        await Global.Server.KickFromServer(Global.Account.Name, acc.Name, reason);
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError(ex.ToString());
                    }
                }
            }
            db.SaveChanges();
            await Global.Server.GhostChanSay(GlobalConst.ModeratorChannel, string.Format("Mass ban executed by {4} for user series {0} ({1} - {2}): {3}",
                                                                                         name, startIndex, endIndex, Url.Action("Detail", "Users", new { id = firstAccID }, "http"), Global.Account.Name));

            return(Index(new UsersIndexModel()
            {
                Name = name
            }));
        }
Ejemplo n.º 26
0
        public static Punishment GetPunishmentBetweenRange(this DBset <Punishment> dBset, DateTime startDate, DateTime endDate)
        {
            Punishment _punishment = new Punishment();

            foreach (Punishment punishment in DBcontext.Punishments.GetAll())
            {
                if (punishment.PunishDate > startDate && punishment.PunishDate < endDate)
                {
                    _punishment = punishment;
                }
            }
            return(_punishment);
        }
Ejemplo n.º 27
0
        public ActionResult MassBanByUserIDSubmit(int userID, double?maxAge, string reason, int banHours, bool banSite = false, bool banLobby = true, bool banIP = false, bool banID = false)
        {
            ZkDataContext db = new ZkDataContext();

            if (banHours > MaxBanHours)
            {
                banHours = MaxBanHours;
            }
            DateTime firstLoginAfter = maxAge != null?DateTime.UtcNow.AddHours(-(double)maxAge) : DateTime.MinValue;

            foreach (Account acc in db.Accounts.Where(x => x.AccountUserIDS.Any(y => y.UserID == userID) && (maxAge == null || x.FirstLogin > firstLoginAfter)))
            {
                uint?  punishmentUserID = banID ? (uint?)acc.AccountUserIDS.OrderByDescending(x => x.LastLogin).FirstOrDefault().UserID : null;
                string userIP           = banIP ? acc.AccountIPS.OrderByDescending(x => x.LastLogin).FirstOrDefault().IP : null;
                System.Console.WriteLine(acc.Name, userID, userIP);
                Punishment punishment = new Punishment
                {
                    Time             = DateTime.UtcNow,
                    Reason           = reason,
                    BanSite          = banSite,
                    BanLobby         = banLobby,
                    BanExpires       = DateTime.UtcNow.AddHours(banHours),
                    BanIP            = userIP,
                    CreatedAccountID = Global.AccountID,
                    UserID           = punishmentUserID,
                };
                acc.PunishmentsByAccountID.Add(punishment);

                try
                {
                    Global.Nightwatch.Tas.Extensions.PublishAccountData(acc);
                    if (banLobby)
                    {
                        Global.Nightwatch.Tas.AdminBan(acc.Name, banHours / 24, reason);
                        if (banIP)
                        {
                            Global.Nightwatch.Tas.AdminBanIP(userIP, banHours / 24, reason);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.ToString());
                }
            }
            db.SubmitChanges();
            Global.Nightwatch.Tas.Say(TasClient.SayPlace.Channel, AuthService.ModeratorChannel, string.Format("Mass ban executed by {2} for userID {0} (max age {1})",
                                                                                                              userID, maxAge, Global.Account.Name), true);

            return(NewUsers(null, null, userID));
        }
Ejemplo n.º 28
0
        // GET: Punishments/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Punishment punishment = db.Punishments.Find(id);

            if (punishment == null)
            {
                return(HttpNotFound());
            }
            return(View(punishment));
        }
        public void DeletePrisoner(Prisoner prisoner)
        {
            Punishment punishment = _context.Punishments.FirstOrDefault(x => x.IdPrisoner == prisoner.Id);

            if (punishment != null)
            {
                _context.Punishments.Remove(punishment);
            }
            Cell cell = _context.Cells.FirstOrDefault(c => c.Id == prisoner.IdCell);

            cell.OccupiedBeds--;
            _context.Cells.Update(cell);

            _context.Prisoners.Remove(prisoner);
        }
Ejemplo n.º 30
0
        public HttpResponseMessage Punish([FromBody] Punishment punish)
        {
            string token = GetToken();

            using (var db = new TCTEContext())
            {
                var order = db.Orders.Where(o => o.Code.ToLower() == punish.OrderCode.ToLower() && o.Terminal.AccessToken == token).SingleOrDefault();
                if (order != null)
                {
                    order.OrderDetails.Add(new OrderDetail()
                    {
                        DecisionNumber   = punish.DecisionNumber,
                        Deduction        = punish.Dedution,
                        PeccancyAddress  = punish.PeccancyAddress,
                        PeccancyBehavior = punish.PeccancyBehavior,
                        PeccancyTime     = punish.PeccancyTime,
                        Money            = punish.Money,
                        PeccancyPersonNo = punish.PeccancyPersonNo,
                        HandlePersonNo   = punish.HandlePersonNo
                    });
                    if (punish.Images != null && punish.Images.Length > 0)
                    {
                        foreach (var image in punish.Images)
                        {
                            db.OrderImages.Add(new OrderImage()
                            {
                                DecisionNumber = punish.DecisionNumber,
                                ImageContent   = image
                            });
                        }
                    }
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, new APIResultObject()
                    {
                        StatusCode = APIResultObject.OK,
                        Description = "success",
                        Result = ""
                    }));
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK, new APIResultObject()
            {
                StatusCode = APIResultObject.NotFound,
                Description = "没有找到请求的订单编号",
                Result = ""
            }));
        }