Esempio n. 1
0
        /// <summary>
        /// Sends a message to a user
        /// </summary>
        /// <param name="WebMemberID">The member posting the message</param>
        /// <param name="ToMemberID">The receiver of the message</param>
        /// <param name="Message">The text content fo the message</param>
        /// <returns>Whether the message was successfully sent</returns>
        public static bool SendMessageLive(string WebMemberID, string MemberIDTo, string FromNickName, string Message, string GUID)
        {
            ChatInbox senderInbox = GetInbox(WebMemberID);
            ChatInbox MemberInbox = GetInbox(MemberIDTo);

            // check if the user is in the list (not logged in? timed out?)
            if (MemberInbox != null)
            {
                AjaxChat ajaxC = new AjaxChat();
                if (GUID == null)
                {
                    ajaxC.ChatWebID = GetGUID();
                }
                else
                {
                    ajaxC.ChatWebID = GUID;
                }
                ajaxC.DTCreated        = DateTime.Now;
                ajaxC.OtherMemberWebID = WebMemberID;
                ajaxC.OtherMemberNick  = FromNickName;
                ajaxC.Message          = Message;
                ajaxC.Delivered        = false;

                MemberInbox.ChatMessages.Add(ajaxC);

                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// gets all the new messages that are on the server and sets them to delivered satus: true
        /// </summary>
        /// <param name="MemberID"></param>
        /// <returns></returns>
        public static List <AjaxChat> GetNewMessagesDB(string WebMemberID)
        {
            ChatInbox inbox = GetInbox(WebMemberID);
            List <Next2Friends.Data.Chat> chatMessages = null;
            List <AjaxChat> retChatMessages            = new List <AjaxChat>();

            if (inbox == null)
            {
                return(retChatMessages);
            }

            chatMessages = Next2Friends.Data.Chat.GetNewChats(inbox.MemberID);
            foreach (Next2Friends.Data.Chat c in chatMessages)
            {
                AjaxChat ajaxC = new AjaxChat();
                ajaxC.ChatWebID     = c.ChatWebID;
                ajaxC.DTCreated     = c.DTCreated;
                ajaxC.OtherMemberID = c.MemberIDFrom;
                ajaxC.Message       = c.Message;

                retChatMessages.Add(ajaxC);
            }

            return(retChatMessages);
        }