public IHttpActionResult DownloadInfo(string accessKey) { Result result = new Result(true); try { if (accessKey != KAccessKey) { result.ResultData = false; result.AddError("Invalid accessKey."); } else { ScraperFixture fixture = new ScraperFixture(); fixture.ExecuteFixture(); } } catch (Exception ex) { _logger.Error("WebApi", "SetupController: DownloadInfo", ex); result.ResultData = false; result.AddError($"Error al ejecutar el proceso de descarga: {ex.Message}"); } return(result.CreateResponse(this)); }
static void Main(string[] args) { //DateTime baseDate = new DateTime(1970, 1, 1); //TimeSpan diff1 = new DateTime(2018, 1, 1) - baseDate; //Console.WriteLine(diff1.TotalMilliseconds); //TimeSpan diff2 = new DateTime(2018, 12, 31) - baseDate; //Console.WriteLine(diff2.TotalMilliseconds); //TimeSpan now = DateTime.Now.Date - baseDate; //Console.WriteLine(now.TotalMilliseconds); //var normalizer = new ScraperNormalizer(); //normalizer.NormalizeDb(); var fixture = new ScraperFixture(); fixture.ExecuteFixture(); }
public void SchedulerService() { try { _schedular = new Timer(new TimerCallback(SchedularCallback)); //Set the Default Time. var scheduler = SchedulerFactory.GetInstance(); var scheduledTime = scheduler.GetScheduledTime(); var timeSpan = scheduledTime.Subtract(DateTime.Now); string schedule = string.Format("{0} day(s) {1} hour(s) {2} minute(s) {3} seconds(s)", timeSpan.Days, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds); _logger.Info("ServicioScheduler", string.Format("Service mode: {0}.", SchedulerCommonSettings.SchedulerMode)); _logger.Info("ServicioScheduler", string.Format("Service to run after: {0}.", schedule)); //Ejecutamos servicio que descarga la información de vialidad nacional var fixture = new ScraperFixture(); fixture.ExecuteFixture(); //Get the difference in Minutes between the Scheduled and Current Time. var dueTime = Convert.ToInt32(timeSpan.TotalMilliseconds); //Change the Timer's Due Time. _schedular.Change(dueTime, Timeout.Infinite); } catch (Exception ex) { _logger.Error("ServicioScheduler", ex.Message, ex); StopWindowsService(); } }