Ejemplo n.º 1
0
 protected BaseComponent(
     ComponentType componentType, BackgroundBaseContext context)
 {
     _type            = componentType;
     _context         = context;
     _statisticsBlock = StatisticsContainer.GetNewBlock(_type.ToString());
 }
Ejemplo n.º 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
            });
        }
Ejemplo n.º 3
0
 public ProductsHandler(
     ElasticSearchClientSettings settings,
     BackgroundBaseContext context,
     BackgroundWorks works,
     DbHelper db)
     : base(settings, works, db)
 {
     _context = context;
 }
Ejemplo n.º 4
0
 public FeedsDownloader(
     int numberAttempts,
     DbHelper dbHelper,
     BackgroundBaseContext context)
     : base(ComponentType.Downloader, context)
 {
     _numberAttempts = Math.Max(numberAttempts, 1);
     _db             = dbHelper;
 }
Ejemplo n.º 5
0
 public ProductLinker(
     ElasticSearchClientSettings settings,
     DbHelper dbHelper,
     BackgroundBaseContext context)
     : base(ComponentType.ProductLinker, context)
 {
     _elasticClient = new ElasticSearchClient <Product>(settings, context);
     _dbHelper      = dbHelper;
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 7
0
 public OfferConverter(ShopData shopData, DbHelper dbHelper, BackgroundBaseContext context)
     : base(ComponentType.Converter, context)
 {
     _worker = ConverterBuilder.GetConverterByShop(shopData.Name, dbHelper);
     _offers = shopData.Offers;
 }
Ejemplo n.º 8
0
 private static IElasticClient <IIndexedEntities> CreateElasticClient(BackgroundBaseContext context, ElasticSearchClientSettings settings) =>
 new ElasticSearchClient <IIndexedEntities>(settings, context);
Ejemplo n.º 9
0
 private ElasticSearchClient <IIndexedEntities> CreateElasticClient(BackgroundBaseContext context) =>
Ejemplo n.º 10
0
 protected ElasticSearchClient <Product> CreateElasticClient(BackgroundBaseContext context) =>