示例#1
0
 public static Entities.ChatMessage MapMessage(ChatMessage logicMessage)
 {
     Entities.ChatMessage contextMessage = new Entities.ChatMessage()
     {
         ChatMessageId           = logicMessage.chatMessageID,
         ClientRelationXrefId    = logicMessage.clientRelationXrefID,
         MessageReceiverClientId = logicMessage.recieverClient.clientId,
         MessageSenderClientId   = logicMessage.senderClient.clientId,
         MessageContent          = logicMessage.messageContent,
         DateTimeSent            = logicMessage.dateTimeSent,
         IsMessageRead           = logicMessage.isMessageRead,
         FromAdmin = logicMessage.fromAdmin
     };
     return(contextMessage);
 }
示例#2
0
        /// <summary>
        /// Insert a chat message
        /// </summary>
        /// <param name="message">The message to insert</param>
        public void Execute(Entities.ChatMessage message)
        {
            using (DbCommand cmd = db.GetStoredProcCommand("ChatMessage_Insert"))
            {
                db.AddInParameter(cmd, "@SentByUserId", DbType.Int32, message.SentByUserId);
                db.AddInParameter(cmd, "@SentByUserName", DbType.String, message.SentBy.HTMLEncode());
                db.AddInParameter(cmd, "@Message", DbType.String, message.Message.HTMLEncode());
                db.AddInParameter(cmd, "@DateSent", DbType.DateTime, message.SentDate);
                db.AddInParameter(cmd, "@GameID", DbType.Int32, message.GameID);
                db.AddInParameter(cmd, "@Global", DbType.Boolean, message.Global);
                db.AddInParameter(cmd, "@ConnectionType", DbType.Int32, message.ConnectionType);

                db.ExecuteScalar(cmd);
            }
        }
示例#3
0
        public void SendMessage(Entities.ChatMessage message)
        {
            message.SentByUserId = Authentication.Security.CurrentUserId;
            message.SentBy       = Authentication.Security.CurrentUserName;
            message.SentDate     = DateTime.UtcNow;
            message.DateSent     = message.SentDate.ToLongTimeString();

            _insert.Execute(message);

            if (message.Global)
            {
                Clients.All.BroadcastGlobalMessage(message);
            }
            else
            {
                Clients.Group(String.Format("Game_{0}", message.GameID.Value)).BroadcastGameMessage(message);
            }
        }
示例#4
0
        public static ChatMessage MapMessage(Entities.ChatMessage contextMessage)
        {
            ChatMessage logicMessage = new ChatMessage()
            {
                chatMessageID        = contextMessage.ChatMessageId,
                clientRelationXrefID = contextMessage.ClientRelationXrefId != null ? contextMessage.ClientRelationXrefId : null,
                recieverClient       = new ClientChatMeta()
                {
                    clientId       = contextMessage.MessageReceiverClientId != null ? contextMessage.MessageReceiverClientId : null,
                    clientNickname = contextMessage.MessageReceiverClientId != null ? contextMessage.MessageReceiverClient.Nickname : String.Empty
                },
                senderClient = new ClientChatMeta()
                {
                    clientId       = contextMessage.MessageSenderClientId != null ? contextMessage.MessageSenderClientId : null,
                    clientNickname = contextMessage.MessageSenderClientId != null ? contextMessage.MessageSenderClient.Nickname : String.Empty
                },
                messageContent = contextMessage.MessageContent,
                dateTimeSent   = contextMessage.DateTimeSent,
                isMessageRead  = contextMessage.IsMessageRead,
                fromAdmin      = contextMessage.FromAdmin
            };

            return(logicMessage);
        }
示例#5
0
 /// <summary>
 /// Insert a chat message
 /// </summary>
 /// <param name="message">The message to insert</param>
 public void Execute(Entities.ChatMessage message)
 {
     _insert.Execute(message);
 }