Beispiel #1
0
        private void AddPrivateMessageinCache(string fromEmail, string chatToEmail, string userName, string message)
        {
            using (SignalREntities dc = new SignalREntities())
            {
                // Save master
                var master = dc.tblChatPrivateMessageMasters.ToList().Where(a => a.EmailID.Equals(fromEmail)).ToList();
                if (master.Count == 0)
                {
                    var result = new tblChatPrivateMessageMaster
                    {
                        EmailID  = fromEmail,
                        UserName = userName
                    };
                    dc.tblChatPrivateMessageMasters.Add(result);
                    dc.SaveChanges();
                }

                // Save details
                var resultDetails = new tblChatPrivateMessageDetail
                {
                    MasterEmailID = fromEmail,
                    ChatToEmailID = chatToEmail,
                    Message       = message
                };
                dc.tblChatPrivateMessageDetails.Add(resultDetails);
                dc.SaveChanges();
            }
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "ID,CampaignName,Date,Clicks,Impressions,AffiliateName")] DevTest devTest)
        {
            if (ModelState.IsValid)
            {
                db.DevTests.Add(devTest);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(devTest));
        }
    public void AddComment(string Comment)
    {
        var     Context = new SignalREntities();
        Comment com     = new Comment();

        com.Comment1 = Comment;
        Context.Comments.Add(com);
        Context.SaveChanges();

        Clients.All.AddNewComment(Comment);
    }
Beispiel #4
0
        public void Connect(string userName, string userEmail)
        {
            //
            emailIDLoaded = userEmail;
            var id = Context.ConnectionId;

            using (SignalREntities dc = new SignalREntities())
            {
                var item = dc.tblChatUserDetails.FirstOrDefault(x => x.EmailID == userEmail);
                if (item != null)
                {
                    dc.tblChatUserDetails.Remove(item);
                    dc.SaveChanges();

                    // Disconnect
                    Clients.All.onUserDisconnectedExisting(item.ConnectionId, item.UserName);
                }

                var Users = dc.tblChatUserDetails.ToList();
                if (Users.Where(x => x.EmailID == userEmail).ToList().Count == 0)
                {
                    var userdetails = new tblChatUserDetail
                    {
                        ConnectionId = id,
                        UserName     = userName,
                        EmailID      = userEmail
                    };
                    dc.tblChatUserDetails.Add(userdetails);
                    dc.SaveChanges();

                    // send to caller
                    var connectedUsers = dc.tblChatUserDetails.ToList();
                    var CurrentMessage = dc.tblChatMessageDetails.ToList();
                    Clients.Caller.onConnected(id, userName, connectedUsers, CurrentMessage);
                }

                // send to all except caller client
                Clients.AllExcept(id).onNewUserConnected(id, userName, userEmail);
            }
        }
Beispiel #5
0
 private void AddAllMessageinCache(string userName, string message)
 {
     using (SignalREntities dc = new SignalREntities())
     {
         var messageDetail = new tblChatMessageDetail
         {
             UserName = userName,
             Message  = message,
             EmailID  = emailIDLoaded
         };
         dc.tblChatMessageDetails.Add(messageDetail);
         dc.SaveChanges();
     }
 }
Beispiel #6
0
        public override System.Threading.Tasks.Task OnDisconnected(bool stopCalled)
        {
            using (SignalREntities dc = new SignalREntities())
            {
                var item = dc.tblChatUserDetails.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId);
                if (item != null)
                {
                    dc.tblChatUserDetails.Remove(item);
                    dc.SaveChanges();

                    var id = Context.ConnectionId;
                    Clients.All.onUserDisconnected(id, item.UserName);
                }
            }
            return(base.OnDisconnected(stopCalled));
        }