Beispiel #1
0
        /// <summary>
        /// Retrieves list of ChatMessage objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of ChatMessage objects</returns>
        private ChatMessageList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //ChatMessage list
            ChatMessageList list = new ChatMessageList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    ChatMessage chatMessageObject = new ChatMessage();
                    FillObject(chatMessageObject, reader);

                    list.Add(chatMessageObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
Beispiel #2
0
 /// <summary>
 /// 显示单个消息气泡
 /// </summary>
 /// <param name="message"></param>
 public void AddSingleChatMessage(Messageobject message)
 {
     if (ServiceLocator.Current.GetInstance <MainViewModel>().Sess.Jid == message.jid)
     {
         //Add the single to ChatMessageList
         ChatMessageList.Add(message.MessageObjectToBubbleItem());
         Messenger.Default.Send(true, ChatBubbleListControl.ScrollChatBubbleMessageToBottom);//自动滚动
         SendReadMsgAsync(new List <Messageobject> {
             message
         });                                                   //发送已读
     }
 }