using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ion.Storage; using Holo.Source.Virtual.Staff; using System.Collections; using Holo.Source; using System.Threading; namespace Holo.Managers { /// /// Provides management for CFH and moderacy tasks for staff. /// public static class staffManager { private static Hashtable Messages = new Hashtable(); private static Thread Cleaner; public static void Initalize() { Cleaner = new Thread(new ThreadStart(deleteSolvedCFHs)); Cleaner.Start(); } /// /// Adds a staff message to the system_stafflog table, regarding one of the actions that a MOD/other staff member performed. Details in the message: type action, ID of the user (staffmember) that performed the action, the target user ID/room ID and the message + staff note. /// /// The action performed. [alert, kick, ban, ralert, rkick] /// The ID of the staffmember that performed the action. /// The ID of the target user/target room. /// The message that went with the action. /// A staff-only note for Housekeeping. [optional] public static void addStaffMessage(string Action, int userID, int targetID, string Message, string Note) { using (DatabaseClient dbClient = (Eucalypt.dbManager.GetClient())) { dbClient.AddParamWithValue("message", Message); dbClient.AddParamWithValue("note", Note); dbClient.ExecuteQuery("INSERT INTO system_stafflog (action,userid,targetid,message,note,timestamp) VALUES ('" + Action + "','" + userID + "','" + targetID + "',@message,@note,'" + DateTime.Now.ToString() + "')"); } } #region Cry for help public static cfhMessage getMessage(string Username) { lock (Messages) { foreach (cfhMessage message in Messages.Values) if (message.Username == Username && message.pickedUp == false) return message; return null; } } public static cfhMessage getMessage(int ID) { lock (Messages) { foreach (cfhMessage message in Messages.Values) if (message.ID == ID) return message; return null; } } public static void deleteMessage(int ID) { Hashtable clone = (Hashtable)Messages.Clone(); foreach (cfhMessage message in clone.Values) if (message.ID == ID) { FuseBuilder Message = new FuseBuilder(273); // "DQ": [[#hobba_handler, #handle_delete_cry]] Message.AppendWired(ID); Message.AppendChar(2); userManager.sendToRank(4, true, Message.ToString()); Messages.Remove(ID); } clone = null; } public static void addMessage(string Username, string IP, string Message, int RoomID, string RoomName) { int ID = getFreeID(); Messages.Add(ID, new cfhMessage(ID, Username, IP, Message, RoomID, RoomName)); } public static void sendReply(int messageID, string message) { cfhMessage CFH = getMessage(messageID); if (CFH != null && userManager.containsUser(CFH.Username)) { FuseBuilder Message = new FuseBuilder(274); // "DR" Message.AppendString(message); userManager.getUser(CFH.Username).sendData(Message); } } public static void pickupMessage(int messageID) { getMessage(messageID).pickedUp = true; } private static int getFreeID() { int i = 0; while (Messages.Contains(i)) i++; return i; } private static void deleteSolvedCFHs() { while (true) { Hashtable clone = (Hashtable)Messages.Clone(); foreach (cfhMessage Message in clone.Values) { if (Message.pickedUp) deleteMessage(Message.ID); } Thread.Sleep(300000); // 5 minutes } } #endregion } }