Skip to content

Instantly share code, notes, and snippets.

<div class="row">
<div class="col-md-12">
<div id="messagesTable">
</div>
</div>
</div>
@section scripts
{
<script src="~/Scripts/jquery.signalR-2.2.0.min.js"></script>
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
public class ChatHub : Hub
{
[HubMethodName(&quot;sendMessages&quot;)]
public static void SendMessages()
{
IHubContext context = GlobalHost.ConnectionManager.GetHubContext&lt;ChatHub&gt;();
context.Clients.All.updateMessages();
string connectionString = Settings.Default.ConnString;
string listenQuery = @ & quot;
SELECT[Name] FROM[dbo].[Insurers] & quot;;
// Create instance of the DB Listener
DatabaseChangeListener changeListener = new DatabaseChangeListener(connectionString);
// Define what to do when changes were detected
changeListener.OnChange += () =>
{
public IEnumerable GetWordPressPosts()
{
using(WebClient webClient = new WebClient())
{
string blogUrl = @ "https://public-api.wordpress.com/rest/v1.1/sites/hendrikbulens.wordpress.com/posts/";
string response = webClient.DownloadString(blogUrl);
WordPressBlog blogPosts = JsonConvert.DeserializeObject(response);
IEnumerable posts = blogPosts.posts.OrderByDescending(x => x.date).Take(3).Select(x => new BlogPost() {
Title = x.title,
AggregateCatalog catalog = new AggregateCatalog();
// Add all the parts found in all assemblies in
// the same directory as the executing program
catalog.Catalogs.Add(
new DirectoryCatalog(
Path.GetDirectoryName(
Assembly.GetExecutingAssembly().Location )
)
[Export(typeof(IRepository<>))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class DatabaseChangeListener
{
#region Constructor
public DatabaseChangeListener(string connectionString)
{
this.connectionString = connectionString;
SqlDependency.Stop(connectionString);
SqlDependency.Start(connectionString);
connection = new SqlConnection(connectionString);
class Program
{
static void Main(string[] args)
{
string connectionString = Settings.Default.ConnString;
var changeListener = new DatabaseChangeListener(connectionString);
changeListener.OnChange += () => {
Console.WriteLine("There was a change");
changeListener.Start(@ "SELECT [Name] FROM [dbo].[Cars]");
};
public static void ProvisionTenant(string tenantSchema, DbConnection connection)
{
using(DbContext ctx = Create(tenantSchema, connection))
{
if (!ctx.Database.Exists())
{
ctx.Database.Create();
}
else
{