简体   繁体   中英

Connecting C# Console Application to a Web API to Update DB

I am really new to the concept of RESTful Web APIs, please do not go hard on me but I just really cannot think a way of it.

So basically, what I cannot find a solution for that I cannot find a way to make my console application works without my manuel 'start' command so that DB can stay up to date so that in the meanwhile API would only be responsible for getting the data from DB or other CRUD operations.

I had a console application which can parse data from a website and store the necessary values to the database. Then in the same solution, I also created a Web API - MVC project and wrote CRUD operations for all entity data types. They both works without any problem, however unless I manually make the console application to run the code and update the DB, DB has old values so the get operations ended up with wrong values.

All I wanted to do is to somehow run the console application's code (might be at certain times) so that the DB can stay up to date.

Hope I did not ask in a confusing but if I do it is because I cannot figure it out and cannot understand the process.

Appreciate if someone can briefly explain me what I have to do.

Thanks !

What you're asking really isn't a programming question per se, but more of a scheduling question. You could turn your code into a service and install it, but that is really overkill for what you need. (Some people would argue that a windows service isn't appropriate for this since all it does is run at scheduled times and not wait to intercept information, but that is a whole other discussion).

What you need is a Scheduled Task in Windows: http://windows.microsoft.com/en-US/windows/schedule-task#1TC=windows-7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM