Пример #1
0
 public async Task <IActionResult> DownloadResultsFromSource()
 {
     try
     {
         _logger.LogInformation("Get information from CEF server");
         //download file
         _webService.ProcessLotteryFile(Constants.LOTOGOL);
         _logger.LogInformation("Load HTML file into Objects");
         var results = (IEnumerable <LotoGol>)_lotteryService.Load(Constants.LOTOGOL);
         _logger.LogInformation("loading into database");
         _repository.CreateDatabase();
         _repository.InsertMany(results);
         return(Ok("Loaded itens on database."));
     }
     catch (Exception e)
     {
         _logger.LogError($"Error when try to call DownloadResultsFromSource {e.Message} - {e.StackTrace}");
         return(NotFound("An error was found."));
     }
 }
        public async Task <IActionResult> DownloadResultsFromSource()
        {
            try
            {
                _logger.LogInformation("api/megasena/downloadResultsFromSource - Downloading from web service.");
                _webService.ProcessLotteryFile(Constants.MEGASENA);
                _logger.LogInformation("api/megasena/downloadResultsFromSource - Load HTML file into Objects");

                var results = _lotteryService.Load(Constants.MEGASENA);
                _logger.LogInformation("loading into database");
                _repository.CreateDatabase();
                _repository.InsertMany(results as IList <MegaSena>);
                return(Ok("All items have been loaded to database."));
            }
            catch (Exception e)
            {
                _logger.LogError($"api/megasena/downloadResultsFromSource - Error when try to call DownloadResultsFromSource {e.Message} - {e.StackTrace}");
                return(NotFound("An error was found."));
            }
        }
Пример #3
0
 public async Task <IActionResult> DownloadResultsFromSource()
 {
     try
     {
         // TODO: move to background job using Hangfire
         //https://jonhilton.net/simple-background-jobs-with-hangfire-and-aspnet-core/
         //https://www.hangfire.io/
         _logger.LogInformation("Get information from CEF server");
         _webService.ProcessLotteryFile(Constants.DUPLASENA);
         _logger.LogInformation("Load HTML file into Objects");
         var results = (IEnumerable <DuplaSena>)_lotteryService.Load(Constants.DUPLASENA);
         _logger.LogInformation("loading into database");
         _repository.CreateDatabase();
         _repository.InsertMany(results);
         return(Ok("Loaded itens on database."));
     }
     catch (Exception e)
     {
         _logger.LogError($"Error when try to call DownloadResultsFromSource {e.Message} - {e.StackTrace}");
         return(NotFound("An error was found."));
     }
 }