how to use signalr across multiple projects - asp.net-mvc-3

We have a customer waiting system where a customer can report in and sit and wait. Our advisers have another part of the system where they can see the queue and pick a customer and call them up.
In our solution we have a project for the customer sign in screen. The touch screen project is mvc and has a controller action to raise a new ticket to the database.
We then have another project that is for our advisers screens. This looks at the same database and again is MVC. There is a controller action to get latest tickets from the DB.
What I want to do is use signalr to inspect when a ticket is created by the touch screen and then report that back to the connected client machines in the advisers project.
How do I structure that? Do I create a new project called signalr that has references to both projects or do I need to put my hubs etc in one or other of the existing projects? Also is this even possible across multiple projects?
I looked in to sql dependency to track changes, but we are using EF ORM and I couldn't wire that up.
many thanks

I suggest you to take a look at the following docs,
http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/introduction-to-signalr
https://github.com/SignalR/SignalR/wiki/SignalR-Client
I hope this helps.

#Dani: Those are excellent resources.
I believe what you are doing is a very plausible use case for SignalR.
To answer your first question: You don't create a SIgnalR project, per se. You add a reference to SignalR in an existing project. Therefore, it's possible to use SignalR across multiple projects.
Your project where tickets are created would probably have the full SignalR reference because it would be the one to fire off a 'broadcast' to the Advisors that are currently connected. However, the Advisors project would only need a reference to the SignalR.Client because all it would need is to connect to the SignalR hub and await new tickets.

Adding my own solution here because the current answers don't really answer how to approach setting up SignalR across projects.
I essentially had a console app that needed to talk to an MVC app, so I was confused about where to put the hub. The console can't be the hub because it doesn't have an http address that the MVC project's JavaScript can point to. The MVC project couldn't be the hub because then it would have to be referenced by the console app, which coupled the two too tightly for my liking.
The solution was to use a 3rd web api project as the hub. Example from Brad Wilson on how to do that here.I could point my JavaScript there as explained here, and the console app could make POST requests to the controller there that sends messages to the hub.

Related

Why isn't the Spring Statemachine project listed on the home page of the website?

I recently thought of deep-diving into the various Spring projects, after seeing first-hand the tremendous utility provided to a project in my workplace. We used the Spring Statemachine project to implement a shopping cart lifecycle. This was a suggestion made by one of my colleagues while looking up code samples to implement the State Pattern in Java. Additionally, I've independently used Spring for Android to implement my first Android App.
However, on visiting the Spring homepage, I wasn't able to see the Spring Statemachine project listed there. Additionally, it wasn't mentioned in the offline documentation, either, despite there being a copy of the same.
I have two questions from this:
Where could one find a full listing of all the various projects provided by Spring? I tried consulting their Github page, but (for example) a filter on repos by "Kafka" returned two different repos (FYI, the project page redirects to the second URL). I was hoping for a comprehensive source like the Wikipedia page on all Apache projects
Why isn't the Statemachine project listed on the homepage? Is there some criteria which results in some projects being listed there, and some not?
Thank You
It's on its way to the main projects page as not long ago it was still kept in incubation. We're just waiting for a logo.
You generally see all projects which have created their own page in docs->Reference Documentation reference docs

What is the purpose of adding services.AddMvc() in the ConfigureServices method in mvc 6?

Why is not enought to just add app.UseMvc() in the Configuration method in a mvc6 application? why it is also necessary to add the services.AddMvc() in the ConfigureServices method? and where can I find more info about this?
Thank you.
In this new ASP.NET 5 world there are two primary aspects of app development.
Dependency Injection. Aka what services are going to be required to run our application?
The application/request pipeline. Essentially the way we answer the question of "What to do when a request hits the server".
Due to these two primary concerns there then happens to be two mechanisms for tying into the system.
First, UseMVC is the way your application can say I want MVC to take a part in the request handling stage at "this" point. It's essentially a shortcut to an MVC specific middleware.
Second, AddMvc is the way your application says that you want the MVC services available to the system (needed in order for UseMvc) to work correctly. Therefore, if you were to try and do UseMvc without adding the corresponding MVC services the call would throw. Note that this adds the appropriate MVC services to the DI container.
Hopefully this answered your questions, for more information on it you can check out http://www.asp.net/vnext for more general information. For something more specific/video I did a talk a while back at Orchard conference where I go over several of the core pieces https://www.youtube.com/watch?v=kqgIByKn9Wk
Note: I gave the talk a while back, some concepts are outdated/may have changed but the core concepts are the same.

Jetbrains REST API to move projects

I am trying to use the TeamCity REST API of JetBrains as shown in http://confluence.jetbrains.com/display/TCD8/REST+API
I was specifically looking for a way to "Move" projects between project hierarchies. Obviously you can use the web user interface to Move a project however I need to automate this.
The REST API only talks about adding build steps, agents and so on. Is there a specific API to move a job? I tried using the Chrome Developer tools to see what happens when you move the project in a web UI but could not detect anything.
The application.wadl has methods to do most of these although the confluence page itself does not necessarily document every single feature.
To achieve this project move between different hierarchies, you had to do a PUT request to
http://$host/guestAuth/app/rest/projects/id:$project_to_edit/parentProject
with a JSON snippet (or an XML) of the form
{"id" : $new_parent_id}

injecting web module into ASP.NET MVC3 application

i am developing an ERP Application, and wanted to structure it in such a way that, i can inject some other MVC web modules into its AREA at later time. this is what something like ORCHARD does. i need to know any such solution available?
to further elaborate my question, consider my application Named "MyERP" has two sub modules in its area.
1. HRM.
2. FRM.
and released this application to my client. later after release i decided to include another module for (AMS)Attendance Management System. so i wanted to structure MyERP in such a way, that my client can install this AMS module through MyERP web interface.
You may take a look at the following article which illustrates how a sample plugin system could be implemented. The project uses the custom virtual path provider that was presented in the following article and which allows to embed razor views as resources into separate assemblies.
i found this article helpful for my question.

Getting own EF 4.1 Code First classes to work with .NET Membership

I am working on a simple web application that is built with EF 4.1 Code First and MVC3. My Domain Model sits in a project outside the MVC3 project.
I have gotten to the stage where my web application is more or less complete. However right now, my application doesn't have any form of authorization or authentication. So a regular user can get to Actions and Controllers that only an Admin is suppose to have access to.
My question is, how do I get my web application to work with the .NET Membership ? Because I am aware that the .NET Membership has many database tables of its own !
My knowledge is fairly limited, thus any clear, easy to follow responses would be greatly appreciated.
After the Membership is set up, I know my way around applying Authentication and Authorization to Actions and Controllers.
Thank You.
Go into your C:\Windows\Microsoft.NET\Framework\v2.xx or v4.xx\ and execute aspnet_regsql, this will launch a wizard that allows you to choose your database and it will add the stored procs and tables to allow membership to function.
Then you run the ASP.NET configuration wizard (the little toolbox icon at the top of your solution explorer) and then configure your roles and accounts. See this page and skip to the Configuring the website for membership and roles section.
ASP.Net membership is actually kinda interesting and frustrating to an extent. To you run a tool called aspnet_regsql.exe found in your Windows\Microsoft.net\Framework folder which generates all of the necessary tables to get it running. Next move onto your Web.config file. If you started with your basic ASP.NET MVC 3 template then you should have a <connectionStrings> entry under the name "ApplicationServices". Change that to your database connection string. This is what the membership provider uses to hook everything up. If you look through the rest of the config file there should be sections for <authentication>, <membership>, <profile>, and <roleManager>. These deal with the various sections and settings that the ASP.Net user management is broken into.
At this point everything should be hooked up. If you select your project in the solution explorer, a little red hammer icon should appear. This is the ASP.NET configuration manager. You can use this to set up different profiles and manage different users.
Now this stuff won't be connected to your EF4.1 code first stuff at all. Instead, you can interact with your membership provider through static classes Membership and Roles. If you take a look at the AccountController on a default ASP.Net MVC 3 Internet application template it will give you a good idea how it works.
After working with this stuff for several months, I found it much easier to basically write your own. Tying things together eventually becomes a huge pain and there is a whole lot of extras that the membership provider gives you that is unnecessary for small applications.

Resources