Example #1
0
 protected BaseComponent(
     ComponentType componentType, BackgroundBaseContext context)
 {
     _type            = componentType;
     _context         = context;
     _statisticsBlock = StatisticsContainer.GetNewBlock(_type.ToString());
 }
Example #2
0
        private DownloadInfo DoDownloadIfNeed(IndexShopContext context, XmlFileInfo xmlInfo)
        {
            var filePath = FilePathHelper.GetFilePath(_settings.DirectoryPath, xmlInfo);

            if (context.DownloadFresh ||
                File.Exists(filePath) == false)
            {
                var downloadContext = new BackgroundBaseContext($"Download:{xmlInfo.Name}", "download");
                downloadContext.Prepare();
                downloadContext.Start();

                context.Contexts.Add(downloadContext);

                var downloader = new FeedsDownloader(_settings.AttemptsToDownload, Db, downloadContext);
                var file       = downloader.Download(_settings.DirectoryPath, xmlInfo);

                downloadContext.Content = "Все скачали";
                downloadContext.Finish();

                return(file);
            }

            return(new DownloadInfo(xmlInfo.ShopId, xmlInfo.NameLatin, xmlInfo.Weight)
            {
                ShopName = xmlInfo.NameLatin,
                FilePath = filePath
            });
        }
Example #3
0
 public ProductsHandler(
     ElasticSearchClientSettings settings,
     BackgroundBaseContext context,
     BackgroundWorks works,
     DbHelper db)
     : base(settings, works, db)
 {
     _context = context;
 }
Example #4
0
 public FeedsDownloader(
     int numberAttempts,
     DbHelper dbHelper,
     BackgroundBaseContext context)
     : base(ComponentType.Downloader, context)
 {
     _numberAttempts = Math.Max(numberAttempts, 1);
     _db             = dbHelper;
 }
Example #5
0
 public ProductLinker(
     ElasticSearchClientSettings settings,
     DbHelper dbHelper,
     BackgroundBaseContext context)
     : base(ComponentType.ProductLinker, context)
 {
     _elasticClient = new ElasticSearchClient <Product>(settings, context);
     _dbHelper      = dbHelper;
 }
Example #6
0
        private void DownloadAll(List <XmlFileInfo> infos)
        {
            var downloadContext = new BackgroundBaseContext("Download:All", "download");

            downloadContext.Prepare();
            _context.AddContext(downloadContext);

            var downloader = new FeedsDownloader(_settings.AttemptsToDownload, Db, downloadContext);

            downloader.FileDownloaded += HandleDownloadEvent;

            downloadContext.Start();

            downloader.DownloadsAll(_settings.DirectoryPath, infos);

            downloadContext.Content = "Все скачали";
            downloadContext.Finish();
        }
Example #7
0
 public OfferConverter(ShopData shopData, DbHelper dbHelper, BackgroundBaseContext context)
     : base(ComponentType.Converter, context)
 {
     _worker = ConverterBuilder.GetConverterByShop(shopData.Name, dbHelper);
     _offers = shopData.Offers;
 }
Example #8
0
 private static IElasticClient <IIndexedEntities> CreateElasticClient(BackgroundBaseContext context, ElasticSearchClientSettings settings) =>
 new ElasticSearchClient <IIndexedEntities>(settings, context);
Example #9
0
 private ElasticSearchClient <IIndexedEntities> CreateElasticClient(BackgroundBaseContext context) =>
Example #10
0
 protected ElasticSearchClient <Product> CreateElasticClient(BackgroundBaseContext context) =>