Click here to Skip to main content
11,438,636 members (77,352 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET WCF service
Hi everyone, first of all, I am a newbie in ASP.NET, so don't hate me if I ask dumb question.

So, I have this site heartpatients.com (not right now, say hypothetically), in the site I have option to let any user who visits the site, configure a time, say 6hrs, 12hrs, 1day or whatever, so that after the time they configured, a mail be dispatched reminding them to take their heart pills. I have a method in WCF service named SendMail, so as should be clear by now, I need to call that method for particular user at a particular time as configured by user, so how can I do it? Also please take into consideration that if user number increases, how should I manage all this? I mean say User A sets time 6hr while user B sets 1Day, so what I need is that after every 6hr user A sets the time, and after every 1day user B sets the time, this method be called and should dispatch mail to respective user.

I haven't designed the method yet, so if you want me to customize something in method I could do that too.

I am really confused as to what should be done.
Any help be appreciated.

Regards.
Posted 18-Jan-12 16:44pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I had a similar criteria a few times. Every time I have kept the last sent, if it should be sent, and the interval in a database.

I have used both windows cron jobs, and a full time daemon to poll this information. If you don't have access to the machines cron jobs, or the ability to install a service on the machine, you may go with user driven actions.. i.e. when a user does something you poll the information.

I never did like the User driven calls, because I was always worried that if no one interacted with the pages then nothing would happen.

p.s.
I have no idea what the windows cron is called. I always forget >,< . sorry about that.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

This is a typical example where a distributed software architecture is required.
I would help you with the top-level design of the systems

Solution -1

There should be 3 main components
- ASP.NET website
- Database
- WCF polling service

In this design, the web user will visit the website, and set the time. This entry should go and sit in the database. There should be a WCF windows service (it can be a normal Windows service as well) that keeps looking at the Database for every configured interval (say 5 mins). The moment it sees an entry which has reached the time limit (you can configure the threshold for it to be say +/- 10 mins), it fetches the required information for that entry, and initiates to send the email.

Solution 2. The above was a simpler solution and may not be that scalable.

There will be 5 components
- ASP.NET website
- Database
- WCF polling service
- MSMQ
- WCF mail service

This is another way of doing it where the components are more loosely coupled but more complex.
In this design, the web user will visit the website, and set the time. This entry should go and sit in the database. There should be a WCF windows service (it can be a normal Windows service as well) that keeps looking at the Database for every configured interval (say 5 mins). The moment it sees an entry which has reached the time limit (you can configure the threshold for it to be say +/- 10 mins), it fetches the required information for that entry and pushes it into the MSMQ.
The WCF mail service only polls the MSMQ service. As and when there is an entry in the MSMQ, it takes the entry and initates sending the mail.

I have not put down any implementation details, but only a very high level design of how the whole architecture can look like. You still can debate the whole thing with an expert (Software Architect in your company) and make required changes.
  Permalink  
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

The easiest way you can do is, save all configuration in database and create a sql job which runs every one minute and executes the stored procedures which the logic to take members to whom mail has to be sent, and use sql mail to send mails.
  Permalink  
Comments
Richard Deeming at 16-Jan-15 13:53pm
   
This question is three years old, and already has an accepted answer. What makes you think the OP is still looking for an answer?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.150506.1 | Last Updated 16 Jan 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100