/// <summary> /// Add a message to the list of pending messages that should be shown to the end user /// </summary> /// <param name="message">The message to add</param> /// <param name="type">The message type</param> static private void AddGenericMessageForAll(string message, SystemMessage.SystemMessageType type) { try { List <SystemMessage> allUsersMessages = new List <SystemMessage>(); if (SystemMessageList.AllUsersMessageList != null) { for (int i = 0; i < SystemMessageList.AllUsersMessageList.Length; i++) { allUsersMessages.Add(SystemMessageList.AllUsersMessageList[i]); } } // Create a new list with our message at the top List <SystemMessage> newList = new List <SystemMessage>(); // added to the session for the user control to display the message only once HttpContext.Current.Session["SHOW_MESSAGE"] = true; SystemMessage theNewMessageForAllUsers = new SystemMessage(message, type); theNewMessageForAllUsers.ForAllUsers = true; newList.Add(theNewMessageForAllUsers); // Add all the elements from the previous list to the end of the new list while (allUsersMessages.Count > 0) { SystemMessage theElement = allUsersMessages[0]; allUsersMessages.RemoveAt(0); newList.Add(theElement); } // Save the list back to the user's profile SystemMessageList.AllUsersSetList(newList); } catch (Exception q) { log.Error("Failed to add message of type " + type.ToString(), q); } }
/// <summary> /// Add a message to the list of pending messages that should be shown to the end user /// </summary> /// <param name="message">The message to add</param> /// <param name="type">The message type</param> static private void AddGenericMessage(string message, SystemMessage.SystemMessageType type) { try { // Get a list of existing messages... SystemMessageList theUsersList = GetMessageListForUser(false); List <SystemMessage> myList = theUsersList.GetList(); if (myList == null) { myList = new List <SystemMessage>(); } // Create a new list with our message at the top List <SystemMessage> newList = new List <SystemMessage>(); // added to the session for the user control to display the message only once HttpContext.Current.Session["SHOW_MESSAGE"] = true; newList.Add(new SystemMessage(message, type)); // Add all the elements from the previous list to the end of the new list while (myList.Count > 0) { SystemMessage theElement = myList[0]; myList.RemoveAt(0); newList.Add(theElement); } // Save the list back to the user's profile theUsersList.SetList(newList); SaveMessageListForUser(theUsersList); } catch (Exception q) { log.Error("Failed to add message of type " + type.ToString(), q); } }