Esempio n. 1
0
        public string InsertMessages(Messages objMessage)
        {
            //var messages = new List<Messages>();
            string messages = string.Empty;

            using (var connection = new SqlConnection(_connString))
            {
                connection.Open();
                using (var command = new SqlCommand("sp_Insert_Messages", connection))
                {
                    command.Notification = null;

                    var dependency = new SqlDependency(command);
                    dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
                    SignleRUOW <Messages> objSigMessage = new SignleRUOW <Messages>();
                    objSigMessage.Add(objMessage);
                    objSigMessage.Committ();
                    if (objMessage.Status1 == "Success")
                    {
                        var hubContext = GlobalHost.ConnectionManager.GetHubContext <MessagesHub>();
                        hubContext.Clients.All.updateMessages();
                        messages = "Success";
                    }
                    else
                    {
                        messages = "Failed";
                    }
                }
            }
            return(messages);
        }
Esempio n. 2
0
        public string UpdateMessages(Messages objMessage)
        {
            string messages = string.Empty;

            using (var connection = new SqlConnection(_connString))
            {
                connection.Open();
                using (var command = new SqlCommand("sp_Update_Messages", connection))
                {
                    command.Notification = null;

                    var dependency = new SqlDependency(command);
                    dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
                    SignleRUOW <Messages> objSigMessage = new SignleRUOW <Messages>();
                    objSigMessage.Add(objMessage);
                    objSigMessage.Committ();
                    if (objMessage.Status1 == "Success")
                    {
                        messages = "Success";
                        MessagesHub.UpdateStatus(objMessage.ID, "Updated");
                    }
                    else
                    {
                        messages = "Failed";
                    }
                }
            }
            return(messages);
        }