Ejemplo n.º 1
0
        private IStatus _getStatus(EnumScrapers enumScraper)
        {
            //IStatus model = null;// new ScraperYad2StatusModel();
            var dataPath = _configuration.GetSection("WebScraperManager:ScraperDataPath").Value;
            var filename = _getFilenameStatusfile(dataPath, enumScraper);

            var model = _getStatusfile(filename);

            return(model);
        }
Ejemplo n.º 2
0
        public FileInfo[] GetFiles(EnumScrapers scraper)
        {
            FileInfo[] list = null;

            var pathFiles = $"{_state.RootFolder}/{scraper}";

            try
            {
                list = new DirectoryInfo(pathFiles).GetFiles();
            }
            catch { }

            return(list);
        }
Ejemplo n.º 3
0
        public bool Save(string filename, EnumScrapers scraper)
        {
            var result = true;

            var filenameWoExt       = $"{Path.GetFileNameWithoutExtension(filename)}";
            var filenameExt         = $"{Path.GetExtension(filename)}";
            var storeFilename       = $"{filenameWoExt}-utc-{DateTime.UtcNow.ToString("MM-dd-yyyy-hh-mm-ss")}{filenameExt}";
            var storePathFile       = $"{_state.RootFolder}/{scraper}/{storeFilename}";
            var storeFilenameLatest = $"{filenameWoExt}-latest{filenameExt}";
            var storePathFileLatest = $"{_state.RootFolder}/{scraper}/{storeFilenameLatest}";

            File.Copy(filename, storePathFile, overwrite: true);
            File.Copy(filename, storePathFileLatest, overwrite: true);

            return(result);
        }
Ejemplo n.º 4
0
        private string _getFilenameStatusfile(string dataPath, EnumScrapers enumScraper)
        {
            var scraper = enumScraper.ToString().ToLower();

            switch (enumScraper)
            {
            case EnumScrapers.HomeLess:
                scraper = "home-less";
                break;

            case EnumScrapers.WinWin:
                scraper = "win-win";
                break;
            }

            var result = dataPath.Replace("{scraper}", scraper);

            return(result);
        }
Ejemplo n.º 5
0
        public ScraperDomainModel Get(EnumScrapers scraperId)
        {
            var scraper = Get().Where(x => x.Id == scraperId).Select(x => x).FirstOrDefault();

            return(scraper);
        }