/// <summary> /// Creates a new virtual event with the details given in the correct category. /// </summary> /// <param name="categoryID">The ID of the category to host the event in.</param> /// <param name="userID">The database ID of the virtual user that hosts the event.</param> /// <param name="roomID">The database ID of the virtual room where the event is hosted.</param> /// <param name="Name">The name of the new virtual event.</param> /// <param name="Description">The description of the new virtual event.</param> public static void createEvent(int categoryID, int userID, int roomID, string Name, string Description) { if (Events[categoryID - 1].Contains(roomID) == false) { virtualEvent Event = new virtualEvent(roomID, userID, Name, Description); Events[categoryID - 1].Add(roomID, Event); } }
/// <summary> /// Creates a new virtual event with the details given in the correct category. /// </summary> /// <param name="categoryID">The ID of the category to host the event in.</param> /// <param name="userID">The database ID of the virtual user that hosts the event.</param> /// <param name="roomID">The database ID of the virtual room where the event is hosted.</param> /// <param name="Name">The name of the new virtual event.</param> /// <param name="Description">The description of the new virtual event.</param> public static void createEvent(int categoryID, int userID, int roomID, string Name, string Description) { if (Events[categoryID - 1].Contains(roomID) == false) { virtualEvent Event = new virtualEvent(roomID, userID, Name, Description); DB.runQuery("INSERT INTO events (name,description,userid,roomid,category,date) VALUES ('" + DB.Stripslash(Name) + "','" + DB.Stripslash(Description) + "','" + userID + "','" + roomID + "','" + categoryID + "','" + DateTime.Now.TimeOfDay.ToString() + "')"); Events[categoryID - 1].Add(roomID, Event); } }
/// <summary> /// Edits a virtual event and re-inserts it in the category. /// </summary> /// <param name="categoryID">The ID of the category where the event is hosted.</param> /// <param name="roomID">The database ID of the virtual room where the event was hosted.</param> /// <param name="Name">The (new) name of the virtual event.</param> /// <param name="Description">The (new) description of the virtual event.</param> public static void editEvent(int categoryID, int roomID, string Name, string Description) { if (Events[categoryID - 1].Contains(roomID)) { virtualEvent Event = (virtualEvent)Events[categoryID - 1][roomID]; Event.Name = Name; Event.Description = Description; Events[categoryID - 1].Remove(roomID); Events[categoryID - 1].Add(roomID, Event); // Swap (because the object is a struct) } }
/// <summary> /// Edits a virtual event and re-inserts it in the category. /// </summary> /// <param name="categoryID">The ID of the category where the event is hosted.</param> /// <param name="roomID">The database ID of the virtual room where the event was hosted.</param> /// <param name="Name">The (new) name of the virtual event.</param> /// <param name="Description">The (new) description of the virtual event.</param> public static void editEvent(int categoryID, int roomID, string Name, string Description) { if (Events[categoryID - 1].Contains(roomID)) { virtualEvent Event = (virtualEvent)Events[categoryID - 1][roomID]; Event.Name = Name; Event.Description = Description; DB.runQuery("UPDATE events SET name = '" + Name + "',description = '" + Description + "',category = '" + categoryID + "',date = '" + DateTime.Now.TimeOfDay.ToString() + "' WHERE roomid = '" + roomID + "'"); Events[categoryID - 1].Remove(roomID); Events[categoryID - 1].Add(roomID, Event); // Swap (because the object is a struct) } }
/// <summary> /// Creates a new virtual event with the details given in the correct category. /// </summary> /// <param name="categoryID">The ID of the category to host the event in.</param> /// <param name="userID">The database ID of the virtual user that hosts the event.</param> /// <param name="roomID">The database ID of the virtual room where the event is hosted.</param> /// <param name="Name">The name of the new virtual event.</param> /// <param name="Description">The description of the new virtual event.</param> public static void createEvent(int categoryID, int userID, int roomID, string Name, string Description) { if (Events[categoryID - 1].Contains(roomID) == false) { virtualEvent Event = new virtualEvent(roomID, userID, Name, Description); using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.AddParamWithValue("ename", Name); dbClient.AddParamWithValue("edescription", Description); dbClient.runQuery("INSERT INTO events (name,description,userid,roomid,category,date) VALUES (@ename, @edescription, '" + userID + "', '" + roomID + "', '" + categoryID + "', '" + DateTime.Now.TimeOfDay.ToString() + "')"); } Events[categoryID - 1].Add(roomID, Event); } }
/// <summary> /// Returns the information string about a single virtual event. If the event isn't found in a category, or the hoster isn't online, then -1 is returned. /// </summary> /// <param name="roomID">The database ID of the virtual room.</param> public static string getEvent(int roomID) { try { for (int i = 0; i < categoryAmount; i++) { if (Events[i].ContainsKey(roomID)) { virtualEvent Event = (virtualEvent)Events[i][roomID]; return(Event.userID + Convert.ToChar(2).ToString() + userManager.getUser(Event.userID)._Username + Convert.ToChar(2).ToString() + Event.roomID + Convert.ToChar(2).ToString() + Encoding.encodeVL64(i + 1) + Event.Name + Convert.ToChar(2).ToString() + Event.Description + Convert.ToChar(2).ToString() + Event.Started + Convert.ToChar(2).ToString()); } } return("-1"); } catch { return("-1"); } }
/// <summary> /// Edits a virtual event and re-inserts it in the category. /// </summary> /// <param name="categoryID">The ID of the category where the event is hosted.</param> /// <param name="roomID">The database ID of the virtual room where the event was hosted.</param> /// <param name="Name">The (new) name of the virtual event.</param> /// <param name="Description">The (new) description of the virtual event.</param> public static void editEvent(int categoryID, int roomID, string Name, string Description) { if (Events[categoryID - 1].Contains(roomID)) { virtualEvent Event = (virtualEvent)Events[categoryID - 1][roomID]; Event.Name = Name; Event.Description = Description; using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient()) { dbClient.AddParamWithValue("name", Name); dbClient.AddParamWithValue("desc", Description); dbClient.runQuery("UPDATE events SET name = @name ,description = @desc ,category = '" + categoryID + "',date = '" + DateTime.Now.TimeOfDay.ToString() + "' WHERE roomid = '" + roomID + "'"); } Events[categoryID - 1].Remove(roomID); Events[categoryID - 1].Add(roomID, Event); // Swap (because the object is a struct) } }