Skip to content

Commit 5ac0355

Browse files
committed
Add Scheduler Signal-R local hub locking events How-to
1 parent c277d83 commit 5ac0355

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+93793
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignalRLocalHub", "SignalRLocalHub\SignalRLocalHub.csproj", "{742D4958-3961-4A90-AF8C-CFF110559981}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Release|Any CPU = Release|Any CPU
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{742D4958-3961-4A90-AF8C-CFF110559981}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13+
{742D4958-3961-4A90-AF8C-CFF110559981}.Debug|Any CPU.Build.0 = Debug|Any CPU
14+
{742D4958-3961-4A90-AF8C-CFF110559981}.Release|Any CPU.ActiveCfg = Release|Any CPU
15+
{742D4958-3961-4A90-AF8C-CFF110559981}.Release|Any CPU.Build.0 = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal
Binary file not shown.
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Owin;
2+
using Microsoft.Owin;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Web;
7+
8+
[assembly: OwinStartup(typeof(SignalRLocalHub.Startup))]
9+
namespace SignalRLocalHub
10+
{
11+
public class Startup
12+
{
13+
public void Configuration(IAppBuilder app)
14+
{
15+
app.MapSignalR();
16+
}
17+
}
18+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using SignalRLocalHub.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Web;
6+
using System.Web.Mvc;
7+
8+
namespace SignalRLocalHub.Controllers
9+
{
10+
public class HomeController : Controller
11+
{
12+
public ActionResult Index()
13+
{
14+
ViewBag.Message = "Welcome to ASP.NET MVC!";
15+
16+
return View();
17+
}
18+
19+
public ActionResult About()
20+
{
21+
ViewBag.Message = "Your app description page.";
22+
23+
return View();
24+
}
25+
26+
public ActionResult Contact()
27+
{
28+
ViewBag.Message = "Your contact page.";
29+
30+
return View();
31+
}
32+
}
33+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%@ Application Codebehind="Global.asax.cs" Inherits="SignalRLocalHub.MvcApplication" Language="C#" %>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Http;
6+
using System.Web.Mvc;
7+
using System.Web.Optimization;
8+
using System.Web.Routing;
9+
10+
namespace SignalRLocalHub
11+
{
12+
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
13+
// visit http://go.microsoft.com/?LinkId=9394801
14+
15+
public class MvcApplication : System.Web.HttpApplication
16+
{
17+
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
18+
{
19+
filters.Add(new HandleErrorAttribute());
20+
}
21+
22+
public static void RegisterRoutes(RouteCollection routes)
23+
{
24+
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
25+
26+
routes.MapHttpRoute(
27+
name: "DefaultApi",
28+
routeTemplate: "api/{controller}/{id}",
29+
defaults: new { id = RouteParameter.Optional }
30+
);
31+
32+
routes.MapRoute(
33+
name: "Default",
34+
url: "{controller}/{action}/{id}",
35+
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
36+
);
37+
}
38+
39+
protected void Application_Start()
40+
{
41+
AreaRegistration.RegisterAllAreas();
42+
43+
RegisterGlobalFilters(GlobalFilters.Filters);
44+
RegisterRoutes(RouteTable.Routes);
45+
}
46+
}
47+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using Microsoft.AspNet.SignalR;
6+
using SignalRLocalHub.Models;
7+
8+
namespace SignalRLocalHub.Hubs
9+
{
10+
public class ProductHub : Hub
11+
{
12+
private SchedulerMeetingService meetingService;
13+
14+
public ProductHub()
15+
{
16+
meetingService = new SchedulerMeetingService(new SampleEntities());
17+
}
18+
19+
public IEnumerable<MeetingViewModel> Read()
20+
{
21+
return meetingService.GetAll();
22+
}
23+
24+
public void Update(MeetingViewModel product)
25+
{
26+
meetingService.Update(product);
27+
Clients.Others.update(product);
28+
}
29+
30+
public void Destroy(MeetingViewModel product)
31+
{
32+
meetingService.Delete(product);
33+
Clients.Others.destroy(product);
34+
}
35+
36+
public MeetingViewModel Create(MeetingViewModel product)
37+
{
38+
meetingService.Insert(product);
39+
Clients.Others.create(product);
40+
41+
return product;
42+
}
43+
44+
public void LockRecord(int id)
45+
{
46+
Clients.Others.lockRecord(new
47+
{
48+
id = id
49+
});
50+
}
51+
52+
public void UnlockRecord(int id)
53+
{
54+
Clients.Others.unlockRecord(new
55+
{
56+
id = id
57+
});
58+
}
59+
}
60+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated from a template.
4+
//
5+
// Manual changes to this file may cause unexpected behavior in your application.
6+
// Manual changes to this file will be overwritten if the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
namespace SignalRLocalHub.Models
11+
{
12+
using System;
13+
using System.Collections.Generic;
14+
15+
public partial class Category
16+
{
17+
public Category()
18+
{
19+
this.Products = new HashSet<Product>();
20+
}
21+
22+
public int CategoryID { get; set; }
23+
public string CategoryName { get; set; }
24+
public string Description { get; set; }
25+
public byte[] Picture { get; set; }
26+
27+
public virtual ICollection<Product> Products { get; set; }
28+
}
29+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated from a template.
4+
//
5+
// Manual changes to this file may cause unexpected behavior in your application.
6+
// Manual changes to this file will be overwritten if the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
namespace SignalRLocalHub.Models
11+
{
12+
using System;
13+
using System.Collections.Generic;
14+
15+
public partial class Customer
16+
{
17+
public Customer()
18+
{
19+
this.Orders = new HashSet<Order>();
20+
}
21+
22+
public string CustomerID { get; set; }
23+
public string CompanyName { get; set; }
24+
public string ContactName { get; set; }
25+
public string ContactTitle { get; set; }
26+
public string Address { get; set; }
27+
public string City { get; set; }
28+
public string Region { get; set; }
29+
public string PostalCode { get; set; }
30+
public string Country { get; set; }
31+
public string Phone { get; set; }
32+
public string Fax { get; set; }
33+
public Nullable<bool> Bool { get; set; }
34+
35+
public virtual ICollection<Order> Orders { get; set; }
36+
}
37+
}

0 commit comments

Comments
 (0)