public void sendNotificationMsg(string from, string to, string msg) { var touser = UserHandler.chatusers.Where(x => x.connID == to).FirstOrDefault(); // string connectionString = @"Data Source=DOTNETSERVER\SQLEXPRESS;Initial Catalog=SignalRDemo; user id=sa;password=C1tytech; "; string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SqlDependencyConfig"].ConnectionString; string sqlQueue = @"NamesQueue"; //Listener query restrictions: http://msdn.microsoft.com/en-us/library/aewzkxxh.aspx string listenerQuery = "SELECT [NotificationId],[UserId],[NotificationMessage],[CreatedDateTime],[IsSeen] FROM[dbo].[NotificationDetails] "; SqlWatcher w = new SqlWatcher(connectionString, sqlQueue, listenerQuery); w.Start(); NotificationService _ns = new NotificationService(); NotificationDetails nd = new NotificationDetails() { UserId = _ns.GetuserIdBYSignalRId(touser.connID), NotificationMessage = msg, CreatedDateTime = DateTime.Now }; _ns.SaveNotification(nd); Clients.Client(touser.connID).sendMessage(from, msg); Clients.Caller.notifyMessageDelivered(touser.name); }
public ActionResult Notification() { UnitOfWork <UserDetails> UOW = new UnitOfWork <UserDetails>(db); string connectionString = @"Data Source=DOTNETSERVER\SQLEXPRESS;Initial Catalog=SignalRDemo; user id=sa;password=C1tytech; "; string sqlQueue = @"NamesQueue"; //Listener query restrictions: http://msdn.microsoft.com/en-us/library/aewzkxxh.aspx string listenerQuery = " select Name from [dbo].[UserDetails]"; SqlWatcher w = new SqlWatcher(connectionString, sqlQueue, listenerQuery); w.Start(); return(View()); }