This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNet.SignalR; | |
using Microsoft.AspNet.SignalR.Hubs; | |
public class ChatHub : Hub | |
{ | |
[HubMethodName("sendMessages")] | |
public static void SendMessages() | |
{ | |
IHubContext context = GlobalHost.ConnectionManager.GetHubContext<ChatHub>(); | |
context.Clients.All.updateMessages(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 += () => | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
T item = container.GetExportedValue() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Export(typeof(IRepository<>))] | |
[PartCreationPolicy(CreationPolicy.NonShared)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DatabaseChangeListener | |
{ | |
#region Constructor | |
public DatabaseChangeListener(string connectionString) | |
{ | |
this.connectionString = connectionString; | |
SqlDependency.Stop(connectionString); | |
SqlDependency.Start(connectionString); | |
connection = new SqlConnection(connectionString); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]"); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void ProvisionTenant(string tenantSchema, DbConnection connection) | |
{ | |
using(DbContext ctx = Create(tenantSchema, connection)) | |
{ | |
if (!ctx.Database.Exists()) | |
{ | |
ctx.Database.Create(); | |
} | |
else | |
{ |