-1

Seeking advice on how to create a scheduler to call a action method (url) at the end of every day to generate report.

I have an existing web application created using ASP.NET MVC 5 and I need an action method to be called using an automated process. Currently, I am manually calling the link at the end of the day.

Alvindra Dutt
  • 141
  • 1
  • 3
  • 12

4 Answers4

0

You can try the below approach.

  1. First, create a batch file through which you can request the URL. (You can take help from Open a URL without using a browser from a batch file )

  2. Create a Basic Windows Task scheduler and set the Action to "Start a Program" and point it to your Batch file.

  3. The Task should trigger Daily at the specified time.

Try this out.

Community
  • 1
  • 1
Pramod
  • 195
  • 1
  • 9
0

You should look into Azure Scheduler, is a micro service that does exactly what you described. If you only need to call an endpoint once an hour, the free tier will be sufficient.

Derek Li
  • 3,089
  • 2
  • 25
  • 38
0

The best solution would be to use a Azure Web Job that runs on a time trigger or is hooked to a cron trigger.

Create a console app. Install the Microsoft.Azure.Webjobs package and Microsoft.Azure.WebJobs.Extensions packages from NuGet.

Add this to your Program.cs

  public static void Main()
  {
      JobHostConfiguration config = new JobHostConfiguration();
      config.UseTimers();

      JobHost host = new JobHost(config);
      host.RunAndBlock();
  }

In a Functions.cs class: ( A TimeTrigger that runs every 24 hours )

 public class Functions
    {
        public static void UpdateCurrencyExchange([TimerTrigger("24:00:00")] TimerInfo timerInfo, TextWriter log)
        {
            //Invoke your method with a Webclient here
        }
     }

If you need it to run at a certain time, use a cron expression in the trigger:

http://blog.amitapple.com/post/2015/06/scheduling-azure-webjobs/#.WGyYEfkrIuU

Gavin Stevens
  • 673
  • 5
  • 14
-1

Are you clicking a link? Is that all you are doing?

You have to find your element first, by its ID or other filters:

HtmlElement fbLink = webBrowser.Document.GetElementByID("fbLink");

And to simulate "click":

fbLink.InvokeMember("click");

An example for finding your link by inner text:

HtmlElement FindLink(string innerText)
{
    foreach (HtmlElement link in webBrowser.Document.GetElementsByTagName("a"))
    {
        if (link.InnerText.Equals("Google Me"))
        {
            return link;
        }
    }
}

Just create an executable in C# and save it on your machine. Then, call that exe file using the Windows Scheduler.

http://www.digitalcitizen.life/how-create-task-basic-task-wizard

ASH
  • 20,759
  • 19
  • 87
  • 200