Exemplo n.º 1
0
        public static void RunScraping()
        {
            SqlTopazBootstrapper.LoadConfigSqlRetry();

            Guid          searchId      = Guid.NewGuid();
            Guid          itemInfoId    = Guid.NewGuid();
            ScraperConfig scraperConfig = new ScraperConfig
            {
                CommerceId = 111,
                SearchId   = searchId,
                ItemInfoId = itemInfoId,
                Keyword    = "",
                Source     = "https://www.sams.com.mx/celulares/iphone-xr-apple-64gb-white-at-t/980010722"
            };

            try
            {
                LogicEngine logicEngine = new LogicEngine();

                logicEngine.RunScraping(scraperConfig);
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 2
0
        public static async Task Run([ServiceBusTrigger("%ServiceBusQueueName%", Connection = "ServiceBusQueueConnectionString")] string message, ILogger log)
        {
            log.LogInformation("***** Iniciando scraper-amazoncommx *****");

            var dateStart = DateTime.Now;

            SqlTopazBootstrapper.LoadConfigSqlRetry();

            var exceptions = new List <Exception>();

            try
            {
                ScraperConfig scraperConfig = JsonConvert.DeserializeObject <ScraperConfig>(message);

                LogicEngine logicEngine = new LogicEngine();
                logicEngine.RunScraping(scraperConfig);

                TimeSpan diff = DateTime.Now - dateStart;
                log.LogInformation($"Mensaje procesado: {message} Time: {diff.TotalMilliseconds} ms.");
                await Task.Yield();
            }
            catch (PlatformException e)
            {
                exceptions.Add(e);
                log.LogError(new EventId(-200), e, $"xl-error-platform: {e.Message} MessageBody: {message}");
            }
            catch (Exception e)
            {
                exceptions.Add(e);
                log.LogError(new EventId(-100), e, $"xl-error: {e.Message} MessageBody: {message}");
            }

            if (exceptions.Count > 1)
            {
                throw new AggregateException(exceptions);
            }

            if (exceptions.Count == 1)
            {
                throw exceptions.Single();
            }
        }