I'm building a website using mvc,c#. In my case I use xml files to bind data.
xml file is download from the web service.it updates once a day.so I have to update the xml file (web service gets more time to load data) according to the web service. What I wrote a method that will run on scheduled time each day.but most says it will not work fine in live environment. then I searched .most says to write console application.but I do not have idea how to use it with my project, and in live environment.what should I suppose to do.hope your help with this.
I'd write a console application and use the built in Windows Scheduler to activate it. Windows Scheduler will deal with failure actions (logging, retry etc).
Related
I have created a C# console application that needs to run once every month. The company i work at uses Azure, so I wanted to use a Azure service to run the application. But I have a hard time finding the right service for the job. I have looked at Logic apps, but is unsure if that is the right solution.
Does anyone know a Azure service which is able to run a C# console application once every month?
Not sure how complex your console app is, I guess it just starts and does a simple task. This is what Function Apps are for. They consist of a single function that can be run on schedule, or triggered by a system event.
Here is MS Docu on how to run it on schedule: https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-scheduled-function
It does not answer your question directly (how to run a console app), but if you are asking about Azure, I'd say it's a good Azure way to achieve what you want, and is not very far from a pure console app. Azure will care about launching it and the environment.
Function Apps can also be tested locally run like a cosole app.
You can use Azure Automation Account for these needs.
It also allows you to run scheduled tasks directly on premisses.
Function app is definitely a better and more flexible solution.
You can use Function apps to run a console application (any exe for that matter).
Please check this code sample. It uses an HTTP trigger to kick off the execution but in your case you could use a Timer trigger.
If you want to skip the process of downloading the binary from an external location, you could even copy the exe file to your function app folder. The steps are here
I have to make a program that watches a location on a computer for files and then converts them when new files get put into a specific folder.
Now my question is what kind of Project would be most appropriate for this?
Is ASP.NET MVC Web Application a good choice or would I be better of doing a Windows Service or WCF Service or even Console App?
My app needs to run on the same server as another MVC app already runs, and I need to access some database to keep track of what files I have converted.
You could utilize Windows task scheduler to periodically run an exe file. In this case the project would be a console app.
A better solution would be to use Windows service. See comments from David & as.if.i.code (tnx btw, you learn something new every day :)
I am creating a website in asp.net but i have some issue..
I have coded a program which can crawl a give web page i.e. thenextweb.com for its links, and content and images.
Now i want to store these crawled data inside my table *Crawlr_Data*.
I want that the crawler runs after every 30 minutes and updated the table with new links if available.
{ON the Home page of my website i am showing the information stored in the database}
How can i run the crawler on back end and update the database ?
What technology like (web services, WCF) should i use or any other thing in visual studio which i can use so that i if host website online its crawler keeps on running and updating table}
Please suggest
Thanks
There are two ways to do this with the Microsoft stack.
Create a service to run on the server. Have the service itself manage when it wakes up and crawls.
Create a console app to do the crawl. Run the console app as a scheduled task using windows task scheduler as often as you like.
I guess there are other ways to do it -- so saying there are just two is not totally accurate -- there are 3rd party programs that will do it for you also... I expect most if not all of them are implemented as a service. You could also write a program that runs on the server not as a console app or as a service. But this is generally a bad idea.
I'm building a web application that will need to import data from other database servers when it starts.
I would like to have this import done automatically at regular intervals. I would also like to be able to start and stop the import process from my web application.
What would be the best implementation for the import agent - a Windows Service? Something else?
If your web application needs to have this data in memory, you can use the Cache class.
Set it to expire every X hours, as you need and when it expires, re-fetch the data..
You could create a Windows Service that uses Quartz.Net to run the scheduled tasks.
You should not run scheduled task from your web app, since you don't have any guarantee that your web app is running. You're at IIS app pool management's mercy.
You might want to look at Best way to run scheduled tasks.
Of what I heard this looks like a description for Microsoft Sync Framework. I have just few information about it for myself but will be pleased to see you pointed into that direction.
I'm not sure about your question because you are talking about hourly syncing. When talking web applications, there can't be a nice way to do such a task. You have to create a console app or best task would be a Windows Service Process (which are easier then it sounds)?
Sync Framework Intro
http://msdn.microsoft.com/en-us/sync/bb821992
Sync Framework Tutorial
http://alexduggleby.com/2007/12/16/sync-framework-tutorial-part-1-introduction/
Sync Framework Samples
http://archive.msdn.microsoft.com/sync
And, when I'm editing the answer with links
Nice guide to create a Windows Service (and setup)
http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx
(if first time, try it on a test project before the production project)
This might be an oversimplification, but can you create a class that does all of this work using a Timer, and then in the application_start of the global.asax, create a BackgroundWorker that kicks off this process?
Your web application could then control the BackgroundWorker object, starting/stopping as necessary.
I'm looking for advice on the best way to accomplish running my C# application as a web app. My app takes a file and some configuration settings as input, it runs some scripts against the file, then outputs a new file.
I want to be able to run this as a web service so that it can be accessed from any OS, by keeping the .exe and referenced DLLs on the backend.
Is there any way to accomplish this? I know I have an option to spin up a virtual server and use RDP, but I want to make it a native web experience.
Is WCF the solution?
XAML?
Does Microsoft have a solution to take an .exe and run it on an IIS web server?
Thank you!
You can do this pretty easily with just a simple web application; you don't need to do much of anything special. Simply invoke your exe with the Process class:
Process myApp = new Process();
myApp.StartInfo.FileName = ConfigurationManager.AppSettings["myAppLocation"];
myApp.StartInfo.CreateNoWindow = true;
myApp.Start();
myApp.WaitForExit();
// Open file and read it
// Additional Info at http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
However, the better choice would simply be to extract that code from your EXE (you likely have the code somewhere) and introduce that as a Class Library for your web project to consume.
Unless there is a reason you absolutely need to keep your existing app as an .exe called in the backend, the easiest solution is to integrate your C# code into a simple ASP.NET web app. You can reference existing DLLs from within the web application to use tem on the server side. Check out a tutorial on making a simple ASP/NET web app, such as:
http://www.kirupa.com/net/helloWorld.htm
Just add an html input field to allow a user to upload the file, and make a download link for the output file.
wcf is a service but not executable thing, you may have a look in Browser WPF application, or Silverlight...
Between both of them , silverlight is highly recommended while it is more heterogeneity. bwpf is easier because just do as what you do when you creating a wpf application but only able to run under IE
http://silverlight.net/ the loading thing is build with silverlight and it is running under IIS ONLY
the browser wpf is your exe and dll thing...