I have a console application which basically sends emails once per day.
The Windows server administrator disallows this technique and doesn't want to allow extra software on the computer (launched by a scheduled task or a service).
I've been asked to evaluate the possibility of redeveloping a part of the application and integrate it into the IIS application pool but I don't think IIS can do this. Is it possible ? If so, how ?
The only approach I've looked at so far is to redevelop it as a web application and launch a web page everyday with a scheduled task, but I'd like to avoid that.
Let's analyze your options:
Use task scheduler in your server to launch console app
Use task schedule**r in your server to **web service hosted in IIS
Have an IIS application running 100% of time in an infinite loop that that checks time every minute and if it happens to be the correct time send the emails
Have a windows service.
Use task scheduler in a different server to invoke
Analyzing each one of them:
KO: Your administrator does not want console apps and process is not isolated.
KO: You have process isolated but still you are installing a console app.
OK: Not very good for performance but your fulfills your admin conditions.
KO: Your admin does not want windows services.
??: Probably your admin will not want to use an extra server
Proposed solution: As you can see only options 3 and 5 might pass the filter. Ask him
Correct solution I did similar things in the past and went for option 2. You have to convince your admin that solution 3 is a bad idea and probably 5 is already out of the question. When he had to choose the lesser of the evils option 2 is the best :-)
NOTE: You don't mention it but in case you have a SQL Server or similar you can store there an scheduled task too...
I had similar questions when I was moving from Apache servers (where it's dead easy to send a nightly email) to Windows (where you have options).
Clients have sometimes pushed me towards SQL Mail. It's not terrible. If your web app has a SQL backend, and it's okay to schedule things there, it's capable of sending emails when properly configured.
I don't think this is possible. With an IIS application you'd need something to trigger loading the application (call the web page). This itself would require a scheduled task.
You need to pound some sense into your administrator. Sorry.
Related
I've scenario to create an application(Windows service , Winforms app) which runs twice every day automatically on users PC. These Users are internal employees in the same network. So at morning and evening this application has to run. But it doesn't need to show any window or information saying its running. Its good to have a simple notification in system tray that its started execution.
My experience in with web application development. So I got a little stucked with these such application on deciding which is best.What my understandings are if its a standalone exe, we could ask all users to download the exe and install.
If its a windows service we may depend up on instalutil to install the service.
So I really needs an advice on this. The application is nothing, just requesting a TFS api and the resulting JSON has to store in Table. So the JSOn will be based on each user using their windows authentication.
Please suggest a good solution to achieve its the best,secure and easiest way even for non tech savvy users.
Instead of all user communicating to TFS server twice a day i guess better way is to install a service in one centralized machine which will run a window service twice a day and that machine will host that service using WCF so that other user will communicate with machine this will help you to distribute the load of tfs api. i used the same approach in my case where one machine talk to ALM and other talk to that machine to get the files.
Creating a window service is pretty simple and straight forward.
Follow the link to make one:
https://www.c-sharpcorner.com/UploadFile/naresh.avari/develop-and-install-a-windows-service-in-C-Sharp/
You can host the service in WCF using IIS, TCP, Webservice, Console application its upto you. Follow this link
https://www.codeproject.com/Articles/550796/A-Beginners-Tutorial-on-How-to-Host-a-WCF-Service
I guess i helped you :)
I'm making an application in C# with VS 2012 that checks a database every 15 seconds and perform some actions when it finds data. Right now I've created a Console Application so I can debug it easely but during relese this application needs to run in a IIS server.
How can I do that? I've read this question but it looks like some sort of workaround because to run it I need to perform these steps. Right now I'm reading the docs about Windows Service Application, Is this the right way?
EDIT Sorry but I've never used Windows server before, so as people pointed out IIS is only a web server, the thing I need to do is run my application in a Windows Server environment
IIS is a web-server and accordingly it should be used for hosting web applications.
Develop a windows service which does the job of checking the database in intervals and invoke a web service (which you can host in IIS)
If your application is performing some data query and manipulation on the server then I would recommend the approach to host it in a windows service.
Some advantages to this are:
The service will start and run independently of a user logging into the server.
You can configure the service to recover should it experience an exception (ideally not!).
The service will start automatically (if configured) when the server restarts.
You can configure which user group (or user) the service should run under so you have a more granual approach to security.
As it's running as a seperate process, you can monitor its memory and processor utilisation.
Debugging is slightly more cumbersome but not difficult, one approach I've used is to install the service locally, start it and then attach to it via the debugger. This question describes another approach I've also used.
Environment: C#.NET VS 2012
We need to write an order delivery process. Basically it runs through the orders tables and and creates a file every night, that contains orders that are received on that day.
Traditionally we build this using Windows Console Application and a scheduled task wakes up this console application at every night (or every 6 hrs) to deliver the files
We are planning to re-write this console application. We are leaning towards both approaches i.e.
Approach 1: the scheduled task would run to deliver the order every night
Approach 2: ASP.NET web apps, that would also deliver the orders.
I am new to WCF, not yet tried it, is this a good situation to use WCF?
If so, can someone throw me some basic points how to implement this.
FYI: I have implemented another approach for some other client, where we have a ASMX web service that does this job, and the console application just calls the web service.
One disadvantages we have with this approach is, the file creation and delivery and everything is done through IIS and we prefer not to use IIS if it needs to be called from Windows Scheduler. This is for performance reasons.
Thanks
Suresh
Keep it simple. Run a console application as a scheduled task.
An IIS app (WCF service or WebApi) would only be useful if you get job requests, i.e. acting as a server.
I have an ASP.NET web app providing access to a database on the server. What I need is a way to run code in the background on a given schedule that auto-updates the server database from another source.
I know how to do this in a windows app by adding a timer, linking up a function to the timer tick event and starting the timer. I do not know how to do this in a web app.
Is there a start-up event for a web app or somewhere where I can start this background process regardless of whatever any users are doing on the site?
You should not do this in an ASP.NET website - this is a major no-no. You are correct in thinking to use a timer on a background .exe. You should look into creating either a Windows Task (a console .exe executed by the server task timer), or a Windows Service. I would suggest the Windows Service as that is standard practice.
If you have access to the computer hosting your site I would write a little app that was run from the Task Scheduler.
The web server is not meant to handle long-running background tasks. It's the wrong tool.
If you dont have access to the hosting computer then I would suggest building some kind of interface whereby another computer rebuilt the database and uploaded it. I'm using the terms "interface" and "upload" in the loosest, broadest sense - apply your own definition.
I was searching for a solution myself couple of months ago, and even though I haven't found enough time to try it so far, I guess I can share the link with you. Maybe you'll find it helpful.
If yes, please, let me know here.
http://quartznet.sourceforge.net/
How to use Quartz.net with ASP.NET
you can use Windows Service or use Timer Control (In the Ajax Category)
Or
As other answers have stated, doing this full function - updating a database and scheduling it as an ASP.NET app is using the wrong tool for the job.
ASP.NET can be used to update a database - that's perfectly valid. Where it breaks down is in the timer. ASP.NET apps aren't meant to be long-running, which is necessary for the timer to work.
If you can do it, I'd strongly suggest using the approach others have suggested - a Windows Service or a Scheduled Task.
However, if you have no access to the actual server, other than to post ASP.NET code - you can't install a service and you can't set up a Windows app to run on a scheduled basis, here's an out-of-the box idea.
Set up a web service or ASPX page that does the update, and then call that page from a scheduled task on a machine you DO control.
So if this was at http://www.someserver.net/updatedb.aspx, there's no reason you can't set a scheduled task on your own PC to call that URL.
I'd consider this a last-ditch solution to be used only if you can't do one of the other options.
The global.asax.cs file has a method that is fired when your application starts: Application_Start. You can hook up your timer method in that event. Just beware, depending on how IIS configured, your app pool may shutdown. For example, if no one hits the site in 20 minutes for example. Just make sure if you HAVE to have this run every X minutes that you have IIS configured to ALWAYS be running and start your app. This is harder than it sounds. In the end, you may want to go with a regular windows scheduled task.
I was just wondering what the the best type of C# project would be in order to allow automation. It will most likely be sat on a server and will need to be capable of being run once every two hours. The app will communicate with a database in order to refresh some tables from one server to another.
What would be your preference for this? A winforms app or a console app and for what reasons?
Update:
I should add that management has stated that they would prefer it not to be a web service as that would have been my first choice too.
I would prefer a Windows Service.
A console app or winforms app would have to be launched by a logged in user. A Windows Service will run in the background independent of the current user.
For development, I mostly start with a console app because it's easier to deploy and test and then turn in into a windows service and deploy it.
Console application for sure.
Winforms is good when there's a need for user input, but as far as I understand, there will be no user input involved here.
You can set the Windows Scheduler to run your Console application every X hours, and it will run and complete without any further interaction.
You need task scheduler that will spawn every configurable time and do the job for you. You can also have windows service which can do this as well. But Task scheduler would be much easier.
A service application is probably your best solution, since it can be run without anyone having to be logged into a session on the server. From within the Service application, just use a Timer or equivalent to run your processes every few hours.
Otherwise, you can write a script (VBScript, Powershell, CMD, etc.) that does the work, then use Windows Task Scheduler to run the process every two hours.