ASP webservice call to be automated - c#

I have an ASP web service call that imports some data.
This is usually invoked by a user on a Silverlight client, clicking a button.
Now they want to have that automated to periodically import.
I know I can set up a windows service to invoke the web service call, but are there any alternatives?

I just made application like that in 2 ways :
1- windows console which will run as batch to call the web service
2- windows service as you have mentiond in your quesion
i have noticed that webservice is more better than batch file as its more stable

Create DispatcherTimer in silverlight Application Put the webService Method in Tick event of DispatcherTimer Object.
Refer this Link for DispatcherTimeclass
http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer%28VS.95%29.aspx

Related

Have a background process running continously on an MVC4 website

I have an ASP.NET MVC4 website running and now i need some sort of background task that is continously running. But is this even possible?
The MVC4 website is a sort of notifying system. Other websites can register a Callback URL on this website and this website should trigger that callback URL for a specified interval. So, for every hour for example.
Normally the code of my website only becomes active when I visit a page. But in order to make this work I need a way to have my ASP.NET website to run in the background continously. So it can do its checks and make an HTTP call when necessary.
It's important though that other websites can register their own Callback url through an http web request, and not through a socket.
Is something like this possible in an ASP.NET MVC web application? Or do I need a different approach?
Check this out: Easy Background Tasks in ASP.NET MVC
I do not prefer to run continuous jobs in asp.net because of these reasons.
You can use Windows Azure Scheduler for scheduling http requests for a particular URL.
Alternatively you can create a Windows service (example here)
You can also try console app and schedule it using Windows task schedule
Azure Worker Role is also a good option

connect ASP.NET application to windows service application

I have one windows service application and one ASP.NET web application, both created by C#.
Both applications get data from the database(SQL server).
Once I update database from web application, how could I inform service application to reload data from database?
Right now our solution is to use service controller to restart windows service application. Is there any low cost solution, like communication between service application and web application?
By the way, my boss hate polling method...
Thanks a lot!
You could use a table like a queue between the web page and the service.
When the page modify some data will flag new record in the table, the service will review that table each X seconds, if find a new record, will change the state and run any process you want.
Hope this help.

Call client windows service from asp.net

I have an asp.net application that must call a client windows service that will start an exe previouslly installed in the client computer.
I use ServiceController class to manage the service: sc = new ServiceController("HippoTwain", Environment.MachineName);
I call the service using sc.ExecuteCommand((int)HippoTwainMethods.Select);
Then, the service does:
ApplicationLoader.PROCESS_INFORMATION procInfo;
ApplicationLoader.StartProcessAndBypassUAC(#"C:\HippoCard\HTwain\HTwain.exe", out procInfo);
The problem is: The asp.net is calling the Server service, but I need to call the service from the Client computer.
How do I do this?
If you want to access the service installed on the client computer, you obviously have to call it from the client. That means either from a Silverlight control or from javascript.
What I suggest is to make the Windows service host a web service on localhost. Inside this web service add a method that once called starts your process.
On your page add a Silverlight control that calls the above method or make a jquery.post() call to that method. Obviously you need to mind the security issues, but you get the idea: you can't access a resource on the client-side using code executed server-side.

Creating C# windows service that is called by en event in the browser

I am a java developer and very new to C# and C++. I am trying to create a windows service in c# that another web application will call to close one of the projects in c++. I've created a dll file in c++ with a method to close the application.
I created a web service as specified in http://www.cjvandyk.com/blog/Articles/How-do-I--Create-a-Windows-Service-application-using-Visual-Studio-2010.aspx. However, I am not sure how to call this service from the web application.
Can someone advise me or refer me to some place where I can learn how to do this?
Not sure why you would want to go Windows service route. Your web application should be able to do everything on the server side.
If you have to use Windows service, you will need to expose some sort of service; e.g. wcf net.tcp service to accept calls for closing your app.
I would suggest you revisit your solution of using windows service.
You can try a software utility Application as Service by Eltima company. It lainchibg any application a s a service and offers different options. So If I've understood you right - it will help you.
http://download.cnet.com/Application-As-Service/3000-2094_4-10338474.html?tag=mncol;9

How to Use ASP.NET MVC to get "content=source code" from another web page once a day?

I would like to set timer for getting page source from some page and compare it if some changes happens with a version of yesterday.
which logic should i use to call some page once a day? my program is just a webpage and it cant send requests every 24 hours. how can i achieve to send request and check if changes happens?
you don't want to use a Web Application to do this, since a Web application typically responds to requests and doesn't wake up and make requests of its own (which is what you need).
What you need is a regular .NET application. It could be a console application that makes the call out to this other website. you could use the WebClient class or similar to do the job.
Once you have it all working, you can use Windows Scheduler to schedule the task at whatever interval you need.
If you need to then communicate with you Web Application from the console app, you can do the same thing, that is make a request to a specific page or handler from you console app (just like you called a page on the other website). When you web application receives the request, you can act on this and do what you need to.
Keep in mind that if all you need to do is update some database tables, you might as well do that from the console application.
Think of your console app (that uses WebClient) as a custom browser. You can call any url you need to and the Web application on the other end sees that call as if it were made by a browser. So using you specialized "browser" you can call other web sites as well as your own.

Categories

Resources