public void ReCacheBans() { if (this._bans.Count > 0) { this._bans.Clear(); } using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor()) { DataTable GetBans = null; dbClient.SetQuery("SELECT `bantype`,`value`,`reason`,`expire` FROM `bans` WHERE `bantype` = 'machine' OR `bantype` = 'user'"); GetBans = dbClient.getTable(); if (GetBans != null) { foreach (DataRow dRow in GetBans.Rows) { string value = Convert.ToString(dRow["value"]); string reason = Convert.ToString(dRow["reason"]); double expires = (double)dRow["expire"]; string type = Convert.ToString(dRow["bantype"]); ModerationBan Ban = new ModerationBan(BanTypeUtility.GetModerationBanType(type), value, reason, expires); if (Ban != null) { if (expires > QuasarEnvironment.GetUnixTimestamp()) { if (!this._bans.ContainsKey(value)) { this._bans.Add(value, Ban); } } else { dbClient.SetQuery("DELETE FROM `bans` WHERE `bantype` = '" + BanTypeUtility.FromModerationBanType(Ban.Type) + "' AND `value` = @Key LIMIT 1"); dbClient.AddParameter("Key", value); dbClient.RunQuery(); } } } } } Console.WriteLine(CurrentTime + "» Cached " + this._bans.Count + " gebruiker en machine bans."); }
public void Init() { if (this._userPresets.Count > 0) { this._userPresets.Clear(); } if (this._userActionPresetCategories.Count > 0) { this._userActionPresetCategories.Clear(); } if (this._userActionPresetMessages.Count > 0) { this._userActionPresetMessages.Clear(); } if (this._bans.Count > 0) { this._bans.Clear(); } using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor()) { DataTable PresetsTable = null; dbClient.SetQuery("SELECT * FROM `moderation_presets`;"); PresetsTable = dbClient.getTable(); if (PresetsTable != null) { foreach (DataRow Row in PresetsTable.Rows) { string Type = Convert.ToString(Row["type"]).ToLower(); switch (Type) { case "user": this._userPresets.Add(Convert.ToString(Row["message"])); break; case "room": this._roomPresets.Add(Convert.ToString(Row["message"])); break; } } } } using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor()) { DataTable PresetsActionCats = null; dbClient.SetQuery("SELECT * FROM `moderation_preset_action_categories`;"); PresetsActionCats = dbClient.getTable(); if (PresetsActionCats != null) { foreach (DataRow Row in PresetsActionCats.Rows) { this._userActionPresetCategories.Add(Convert.ToInt32(Row["id"]), Convert.ToString(Row["caption"])); } } } using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor()) { DataTable PresetsActionMessages = null; dbClient.SetQuery("SELECT * FROM `moderation_preset_action_messages`;"); PresetsActionMessages = dbClient.getTable(); if (PresetsActionMessages != null) { foreach (DataRow Row in PresetsActionMessages.Rows) { int ParentId = Convert.ToInt32(Row["parent_id"]); if (!this._userActionPresetMessages.ContainsKey(ParentId)) { this._userActionPresetMessages.Add(ParentId, new List <ModerationPresetActionMessages>()); } this._userActionPresetMessages[ParentId].Add(new ModerationPresetActionMessages(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["parent_id"]), Convert.ToString(Row["caption"]), Convert.ToString(Row["message_text"]), Convert.ToInt32(Row["mute_hours"]), Convert.ToInt32(Row["ban_hours"]), Convert.ToInt32(Row["ip_ban_hours"]), Convert.ToInt32(Row["trade_lock_days"]), Convert.ToString(Row["notice"]))); } } } using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor()) { DataTable GetBans = null; dbClient.SetQuery("SELECT `bantype`,`value`,`reason`,`expire` FROM `bans` WHERE `bantype` = 'machine' OR `bantype` = 'user'"); GetBans = dbClient.getTable(); if (GetBans != null) { foreach (DataRow dRow in GetBans.Rows) { string value = Convert.ToString(dRow["value"]); string reason = Convert.ToString(dRow["reason"]); double expires = (double)dRow["expire"]; string type = Convert.ToString(dRow["bantype"]); ModerationBan Ban = new ModerationBan(BanTypeUtility.GetModerationBanType(type), value, reason, expires); if (Ban != null) { if (expires > QuasarEnvironment.GetUnixTimestamp()) { if (!this._bans.ContainsKey(value)) { this._bans.Add(value, Ban); } } else { dbClient.SetQuery("DELETE FROM `bans` WHERE `bantype` = '" + BanTypeUtility.FromModerationBanType(Ban.Type) + "' AND `value` = @Key LIMIT 1"); dbClient.AddParameter("Key", value); dbClient.RunQuery(); } } } } } Console.WriteLine(CurrentTime + "» " + "Moderator " + (this._userPresets.Count + this._roomPresets.Count) + " templates"); Console.WriteLine(CurrentTime + "» " + "Moderator " + this._userActionPresetCategories.Count + " categorieën"); Console.WriteLine(CurrentTime + "» " + "Moderator " + this._userActionPresetMessages.Count + " acties"); Console.WriteLine(CurrentTime + "» " + "Moderator " + this._bans.Count + " verbanningen"); }