In my project, i have used schedule control. It can be able to fix appointments for single/several users. I have configured of sending mails to the selected users through save /edit appointment actions.
Now i need to send mails automatically using windows service for every 30mins to the selected users during appointment time. for e.g. if appointment spans for a user 2pm to 4pm, mail need to be sent for every 30mins bet 2pm to 4pm automatically.
I have installed windows service. But i don't know how to connect my MVC web project with the windows service. I'm using MDF database in my web project. I don't know how to process those datas in window service.
Please suggest me some way. I'm totally new to MVC and Windows service.
Thanks in advance.
The issue outlined in your question sounds like a good use of the Revalee open source project.
Revalee is a service that allows you to schedule web callbacks to your ASP.NET MVC application. Revalee manages task persistence and scheduling using a Windows Service, but leverages your ASP.NET MVC application to handle the processing effort (i.e., "the work"). In your case, your would use your MVC application to send an automated email messages to a user when the MVC application was called back by Revalee.
The following shows an overview of the workflow used by an MVC application with Revalee:
(source: sageanalytic.com)
When an appointment is scheduled, your application would register a callback action with Revalee. This would include a date & time to call the MVC application back as well as the URL to call. Therefore to register a callback with Revalee you might include the following method in your MVC application.
private void ScheduleAppointmentReminderEmail(int appointmentId)
{
// The DetermineAppointmentReminderTime() method is your private method
// which returns an appointment's next reminder time as a DateTimeOffset.
DateTimeOffset callbackTime = DetermineAppointmentReminderTime(appointmentId);
// The callback should at the task's end time
Uri callbackUrl = new Uri(
string.Format(
"http://mywebapp.com/Email/SendAppointmentEmail/{0}",
appointmentId
)
);
// Register the callback request with the Revalee service
RevaleeRegistrar.ScheduleCallback(callbackTime, callbackUrl);
}
When your MVC application receives the callback, the SendAppointmentEmail action might look like:
[AllowAnonymous]
[CallbackAction]
public ActionResult SendAppointmentEmail(int appointmentId)
{
// TODO 1. Validate the appointmentId,
// 2. Lookup the appointment's information, &
// 3. Send the email message
// ...
return new EmptyResult();
}
The Revalee website has a complete API Reference as well as instructions on how to install and configure the Windows Service. The service is available for easy deployment & intallation at Chocolatey, while MVC client libraries ready for use in Visual Studio are available at NuGet. (There are non-MVC client libraries too.) Naturally, as an open source project, Revalee's complete source code is available on GitHub.
Finally, in case it was not clear above, the Revalee Service is not an external 3rd party online scheduler service, but instead a Windows Service that you install and fully control on your own network. It resides and runs on a Windows server of your own choosing where it can receive callback registration requests from your ASP.NET MVC application.
I hope this helps. Gook luck!
Disclaimer: I was one of the developers involved with the Revalee project. To be clear, however, Revalee is free, open source software. The source code is available on GitHub.
I did´t understand your question very well, however, the connection point between the web application and the windows service is the database. Your web application writes in the database the pending appointments. Then, your windows service checks every 30 minutes, for example, if there is any pending appointment for which it has to send the emails. If it finds out that it has to send some emails, it sends them and marks the entry in the Db as completed (meaning that it has sent the notifications). You can also use Quartz.net as I mentioned in another answer, but a windows service is also a good solution.
You don't have to use the windows service. Everything you described can be solved by using the application built-in HttpModule aka Global.asax .
The high level concept is to keep the HttpApplication running, and within the life time of the application, which is your MVC web application deployed to IIS. This is to prevent the Application_End firing due to inactivity default at 20 minutes.
Once you kept the application running, you can schedule the preferred time interval to talk to database and send emails. This would be the simplest way to do your task.
There is a codeproject sample: http://www.codeproject.com/KB/aspnet/ASPNETService.aspx
Related
I have a requirement wherein I need to perform certain action in my web application based on phone call receiving event that occurs in a third party application - Knowlarity SR calling app.
We are using Knowlarity Super Receptionist calling API to receive calls to a virtual number and then route those calls to call center Agents as per their availability. There is another web application we have built which call center agents uses to manage customers and orders. Agents login to this web application (web app in Azure) and places orders for customer who is calling over the phone from Knowlarity. Here the requirement is whenever Knowlarity routes the call to any agent and when the agent picks up the call, it should notify this action to web app (CRM) the web app should automatically redirect the same Agent to a specific page.
Please suggest a solution how I can listen to the call receiving event in Knowlarity and do some action(page redirection) on the web app side.
Thanks.
I tried writing an Api method in Web app which Konwlarity will call to send event notification with some information. Also tried implementing HttpHandler for this. Please suggest the correct approach for this. Remember that it is a Web app so multiple agents can login, they have their own session so how to handle this.
I know that probably this question would be asked to many times but...
The wcf services hosted on iis7 in an asp. Net Web site can do things automatically? Like post a message to a pre-configured wall on Facebook given the permission to the application in a pre scheduled time?
For this to happen a client must send a request or it can do it alone?
The lifetime of a WCF service is typically determined by requests from a client i.e. if there is no client making requests then there is no service running.
Possible solutions:
Create a custom WCF ServiceHost, override the OnStart OnStop methods and create a background task.
Create an ASP.NET background task (external to WCF), which you can do with a library such as WebBackgrounder
Use the Windows Task Scheduler to trigger a task which polls your WCF service periodically which can then post outstanding messages to Facebook.
I'm trying to consume a Java Web Service from third party, so i dont have any control over it. I have a pfx file which is password protected, and i installed it in my development box.
This is the code i'm using:
var proxy = new MyServiceReference.WsaaServerBeanService();
var result = proxy.login("test");
I'm getting System.Net.Sockets.SocketError.TimedOut exception when invoking the login web method. The first thing that come to my mind is an authentication issue. Apart from installing the pfx, do i need to send some other info to the web server to authenticate?
System.Net.Sockets.SocketError.TimedOut
Does not indicate an authentication issue, it indicates that you either are not able to contact the remote web service endpoint, or you are and the service is taking too long to respond. Make sure you can actually hit the endpoint from your machine via telnet, a web browser etc...
Authentication failures will usually return immediately.
I have a WCF service hosted at IIS7 web application. It's created by a WebServiceHostFactory. The client connects to a service calls the Collect method, and data are stored to DB. All working fine.
Now I would like to refresh page every time the new data are "collected" (i.e. the service method Collect is called).
My question is: What is the best approach ?
I was considering the CallbackContract, but this would require a singleton pattern (service is now PerCall), or is it a wrong assumption ? Is this approach possible ?
My logic is:
ASP.NET page subscribes to WCF service
the service singleton is created from now on
when method is called the services calls subscribers (clients)
there should be therefore only one service instance in order to subscription to work (or is it ?)
the client page refreshes itself
regards,
Kate
You can't refresh the page in a user's browser from the sever. Browsers use HTTP, which is a request-response protocol, so if the browser hasn't issued a request, it won't be looking for a response from your server.
If you have a Silverlight application hosted in a browser, that's a different story, but you didn't mention Silverlight anywhere. You would also be able to do what you're asking using WebSockets in HTML5, but that's not fully standardized yet.
The question,
I have a web application - .net 4.
The client is having a requirement that he want to send email to his users on a regular basis about his new courses etc.
The webapplication created will hosted on a "Shared hosting environment" with no excess to windows services - file system other than the web root folder through FTP.
The PROBLEM is that ...
Due to shared hosting i cannot create a windows service for him which will check the database - if there are any scheduled mail to send every 5 min.
So my question is - Is there anyway i can run a wcf web service or any other web based service or page or handler which can keep running and automatically checks the database for any new scheduled mails - if yes start sending it automatically in an different thread.
Any different suggestion or answers are also very much welcomed. Thanks SO Experts.
Create a webmethod in WCF that needs to be called, and that can be reached through a url, for example:
http://www.example.org/checkandsend/email/
Add a new scheduled task on your own PC, that calls that URL every five minutes. Voila.
Rick Strahl: Forcing an ASP.NET Application to 'stay alive'