Skip to content

Instantly share code, notes, and snippets.

View stpriyanka's full-sized avatar

Safwath Priyanka stpriyanka

View GitHub Profile
@stpriyanka
stpriyanka / MandrillRenderTemplate.html
Last active February 22, 2017 11:23
Example output from Mandril API request
<!DOCTYPE html>
<html>
<body>
<h1>
{{TITLE}}
</h1>
<div>
This example is {{ADJECTIVE}}.
</div>
@stpriyanka
stpriyanka / Startup.cs
Last active February 21, 2017 15:54
SignalR Connection Mapping
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
app.MapSignalR();
}
}
//import these files on top of cshtml
http://~/Scripts/jquery.signalR-2.2.0.js
http://localhost:2120/signalr/hubs
//Main logic
$(document).ready(function () {
console.log($.connection);
$.connection.hub.url = "http://localhost:53561/signalr";
//import these files on top of cshtml
http://~/Scripts/jquery.signalR-2.2.0.js
http://localhost:2120/signalr/hubs
//Main logic
$(document).ready(function () {
console.log($.connection);
$.connection.hub.url = "http://localhost:53561/signalr";
// Create a function that the hub can call to send messages
public class ConnectionMapping
{
private readonly Dictionary _connections =
new Dictionary();
public int Count
{
get { return _connections.Count; }
}
@stpriyanka
stpriyanka / Functions.cs
Last active February 21, 2017 15:54
WebJob
public class Functions
{
[NoAutomaticTrigger]
public static void ManualTrigger(TextWriter log, int value, [Queue("queue")]
out string message)
{
var c = new Functions();
c.InvokeHub().Wait();
message = "hi.";
Console.Write(message);
@stpriyanka
stpriyanka / MyHub.cs
Last active February 21, 2017 15:53
SignalRHub
public override Task OnConnected()
{
string jobid = GetUserId();
if (jobid != null)
{
Connections.Add(jobid, Context.ConnectionId);
}
return base.OnConnected();
}
............
private string GetQueryString()
{
string x = Context.QueryString["userid"];
return x;
}
public async Task SendMessage(string message)
{
var x = message;
var receivedData = (List)JsonConvert.DeserializeObject(message,
typeof(List));
foreach (var eachItem in receivedData)
{
var onlineUserId = eachItem.UserId;
string jobid = GetQueryString();
@stpriyanka
stpriyanka / RenderTemplate
Last active February 22, 2017 10:57
Send request to mandrill APIto get the 'information/raw Html' for an existing template
namespace TryToRenderTemplate
{
public class RenderTemplate: IRenderTemplate
{
...........
/// <summary>
/// Get the information for an existing template
/// </summary>
/// <param name="templateSlug"></param>