asp.net web services [Resolved]

Posted by Karthikreddy under ASP.NET on 8/6/2013 | Points: 10 | Views : 2168 | Status : [Member] | Replies : 10
Hi
i need to send mail alert daily for that
i was created one web service to send a email . i am calling that web service from my global.asax page . after that calling service function i used a thread.sleep(1000*60*60*24) to sleep the thread for one day . in the meantime i need to run other functionality of the web site but control is not moving to other code . how i need to run other code while thread sleep is there any solution plz help me

k@rth!k
karthikreddy08a50@gmail.com



Responses

Posted by: Bhupentiwari on: 8/6/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Sorry Bro for late reply

First you need to create DLL that will send email in C# or VB.net

Register The DLL into sql server

Call that DLL into SP

Schedule that SP into sql server agents to run after 24 hours


bro do google you will get steps.

following is the link which you can refer

http://aspnetlibrary.com/articledetails.aspx?article=Using-CLR-to-access-.NET-functions-in-SQL-Server
http://www.codeproject.com/Articles/37377/SQL-Server-CLR-Functions




Thanks n Regards
Bhupendra Tiwari

Karthikreddy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhupentiwari on: 8/6/2013 [Member] Starter | Points: 25

Up
0
Down
Create DLL which will send mail
Use that DLL in SP
Use SQL Server Agent to call that SP (or windows scheduler)



Thanks n Regards
Bhupendra Tiwari

Karthikreddy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikreddy on: 8/6/2013 [Member] Starter | Points: 25

Up
0
Down
hi tiwari

i can't use windows scheduler becoz we are using private hosting

can u plz tell me more about creating dll and calling from sp
if u have any link to refer that


k@rth!k
karthikreddy08a50@gmail.com

Karthikreddy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 8/6/2013 [Member] Starter | Points: 25

Up
0
Down
Possible Solution :

Create a table with one columns:
ExecutedOn DateTime

Whenever application is runned first tym, check whether today's date is present in above table.
If No, execute your webservice for sending Emails, and insert today's date.
If Yes, ignore.

After above steps, you can execute your stuff.


http://hashtagakash.wordpress.com/

Karthikreddy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikreddy on: 8/6/2013 [Member] Starter | Points: 25

Up
0
Down
how it will execute the service next time . it has to execute daily

k@rth!k
karthikreddy08a50@gmail.com

Karthikreddy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 8/6/2013 [Member] Starter | Points: 25

Up
0
Down
Please read it twice carefully.

Step 1:
I am saying that first time whenever it'll run for the day, let's say today i.e. 08/06/2013, then it'll store today's date in table.

Before inserting today's date, you will check in table whether today's date is present or not, in this case 08/06/2013.
If its not present, run your web service.

Now, repeat above step. According to above step, since today's date 08/06/2013 is present in table, web service wont run.

If application runs anytime tomorrow, then according to above step, since tomorrow's date 08/07/2013 is not present in table, web service will run once before storing 08/07/2013 date in table!

I have proposed a solution in logical method, but it's upto u to convert it into Coding/Technical term.

http://hashtagakash.wordpress.com/

Karthikreddy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikreddy on: 8/6/2013 [Member] Starter | Points: 25

Up
0
Down
hi akash
i understood what you are saying

plz clarify one thing
if(dbdate==todaysdate)
{
email_service();
}
else
{
//insert into table
}
this is ok
but i call web service in Global.asax
 void Application_Start(object sender, EventArgs e)

{
// i call above code here

}

whenever application starts it will run. once it will enter to if or else part it will execute and enter into other functionality like registration and other things
how we call global.asax code for a regular interval time(void application_start runs only when application starts ) .the site is always running in the server or hosting server we can't stop and run daily.

thanks



k@rth!k
karthikreddy08a50@gmail.com

Karthikreddy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 8/6/2013 [Member] Starter | Points: 25

Up
0
Down
Hey Karthik! I understood your problem now!
Googled "Global.asax" and came across this interesting thing:
Application_Start() is an event which are not fired for every request.

WhereAs, there are some Events which are fired for every request like : Application_BeginRequest().
So, maybe, you can write your code for "check Date and Execute Email_Service()" code inside this event.

Also, Bhupendra , I wanna know, too, how to create a DLL in SQL OR Steps to achieve same.



http://hashtagakash.wordpress.com/

Karthikreddy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikreddy on: 8/7/2013 [Member] Starter | Points: 25

Up
0
Down
thanks

k@rth!k
karthikreddy08a50@gmail.com

Karthikreddy, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Learningtorise on: 8/7/2013 [Member] Starter | Points: 25

Up
0
Down
Nice one Bhupendra. Thanks!

http://hashtagakash.wordpress.com/

Karthikreddy, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response