Пример #1
0
        public override ChatRoomDetail Execute(IDataContext context)
        {
            ChatRoomDetail result = null;

            ContextQuery = ctx =>
            {
                if (ctx.AsQueryable <ChatRoom>().Any(cr => cr.Name == RoomName))
                {
                    throw new DomainException("Chat room '{0}' already exists", RoomName);
                }

                var creator = ctx.AsQueryable <User>().SingleOrDefault(u => u.Id == CreatorId);
                if (creator == null)
                {
                    throw new DomainException("Room creator does not exist");
                }

                var room = ChatRoom.Create(creator, RoomName);

                ctx.Add(room);
                ctx.Commit();

                result = new ChatRoomDetail(room);
            };

            ExecuteInternal(context);

            return(result);
        }
Пример #2
0
        public void Send(string message, int userAccountID)
        {
            if (string.IsNullOrWhiteSpace(message) || (userAccountID == 0)) return;

            ChatRoom cr = new ChatRoom();

            cr.ChatMessage = message;
            cr.CreatedByUserID = userAccountID;
            cr.Create();

            BootBaronLib.AppSpec.DasKlub.BOL.UserAccountDetail uad = new BootBaronLib.AppSpec.DasKlub.BOL.UserAccountDetail();
            uad.GetUserAccountDeailForUser(userAccountID);
            string userFace = string.Format(@"<div class=""user_face"">{0}</div>", uad.UserFace);

            if (!message.Contains("CONNECTION OPENED") && !message.Contains("CONNECTION CLOSED") && !message.Contains("RECONNECT"))
            {
                message = HttpUtility.HtmlEncode(message);
                message = Video.IFrameVideo(message);
            }

            // Call the addMessage method on all clients
            Clients.addMessage(string.Format(@"{2} <span style=""font-size:10px"">{0}</span> <span style=""font-size:14px;color:#FFF;font-family: ‘Lucida Sans Unicode’, ‘Lucida Grande’, sans-serif;"">{1}</span>", DateTime.UtcNow.ToString("u"), message, userFace));
        }
Пример #3
0
        public void SendMessageToAll(string userName, string message)
        {
            message = HttpUtility.HtmlEncode(message);
            message = Utilities.MakeLink(message);

            MembershipUser mu = MembershipWrapper.GetUser();

            if (mu != null)
            {
                var chatMessage = new ChatRoom
                {
                    CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey),
                    ChatMessage = message
                };
                chatMessage.Create();
            }

            AddMessageinCache(userName, message);

            // Broad cast message
            Clients.All.messageReceived(userName, message);
        }