Exemplo n.º 1
0
        public async Task <IResultModel> Crawling()
        {
            var list = await _areaCrawlingHandler.Crawling();

            _uow.BeginTransaction();

            foreach (var m in list)
            {
                var entity = _mapper.Map <AreaEntity>(m);
                await CrawlingInsert(entity, m.Children);
            }

            _uow.Commit();

            return(ResultModel.Success());
        }
Exemplo n.º 2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            try
            {
                _logger.LogInformation("开始爬取区域代码数据");

                var list = await _crawlingHandler.Crawling();

                await _service.CrawlInsert(list);

                _logger.LogInformation("爬取结束");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "数据同步失败");
            }
        }
Exemplo n.º 3
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            try
            {
                _logger.LogInformation("开始爬取区域代码数据");

                var tasks = new Task[31];
                for (int i = 0; i < 31; i++)
                {
                    AreaCrawlingHandler.Index = i;
                    var list = await _crawlingHandler.Crawling();

                    await _service.CrawlInsert(list);
                }

                Task.WaitAll(tasks);

                _logger.LogInformation("爬取结束");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "数据同步失败");
            }
        }
Exemplo n.º 4
0
        public override async Task Execute(ITaskExecutionContext context)
        {
            var list = await _crawlingHandler.Crawling();

            await _service.CrawlInsert(list);
        }