int smsCounter = 0; int smsCounterQuery = 0; protected void Application_Start() { // Dynamically create new timer Timer smsTimer = new Timer { Interval = 1000, Enabled = true }; // Add handler for Elapsed event smsTimer.Elapsed += CallUrls; smsTimer.Stop(); smsTimer.Start(); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); } public void CallUrls(object sender, ElapsedEventArgs e) { smsCounter++; smsCounterQuery++; if (smsCounter == 60) { //local pc url: //string url = "http://localhost:49788/Sms/sendMultiSMS"; //server url: string url = "http://localhost:105/Sms/sendMultiSMS"; var request = (HttpWebRequest)HttpWebRequest.Create(url); request.Method = "GET"; using (StreamWriter writer = new StreamWriter("C:\\In\\smsheartbeat.txt", true)) { writer.WriteLine("Run SMS Sending method at time: " + DateTime.Now.TimeOfDay); } smsCounter = 0; } if (smsCounterQuery == 600) { //testing: //string url = "http://localhost:49788/Sms/sendLogByDate"; //server url: string url = "http://localhost:105/Sms/sendLogByDate"; var request = (HttpWebRequest)HttpWebRequest.Create(url); request.Method = "GET"; var response = (HttpWebResponse)request.GetResponse(); using (StreamWriter writer = new StreamWriter("C:\\In\\smsheartbeat.txt", true)) { writer.WriteLine("Date range search url method fired at time: " + DateTime.Now.TimeOfDay); } smsCounterQuery = 0; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)