Exemple #1
0
        public void GetJobsForAllPages()
        {
            var vacancies    = new List <VacancyResultItem>();
            var jobIds       = new List <int>();
            var allCompanies = new List <string>();

            var jobsCollection = new List <Vacancy>();

            for (int i = 1; i <= PAGES_COUNT; i++)
            {
                //TODO - uncomment
                var jobs = _dataService.GetAllJobs(_config.SearchRequestUrl, i).Result.Documents;
                // .Where(job => DateTime.Today - job.AddDate.Date == TimeSpan.FromDays(1));
                allCompanies.AddRange(jobs.Select(job => job.CompanyName).Distinct().ToList());
                jobIds.AddRange(jobs.Select(job => job.Id));
                vacancies.AddRange(jobs);
            }

            _repository.BulkSaveInsertCompanies(allCompanies);
            var companies = _repository.GetAllCompaniesByNames(allCompanies).ToList();

            foreach (var vacancy in vacancies)
            {
                var vacancyToInsert = new Vacancy
                {
                    Name              = vacancy.Name,
                    RabotaUaId        = vacancy.Id,
                    Company           = companies.FirstOrDefault(x => x.Name == vacancy.CompanyName),
                    Salary            = vacancy.Salary,
                    Hot               = vacancy.Hot,
                    CityName          = vacancy.CityName,
                    AddDate           = vacancy.AddDate,
                    RabotaUaCompanyId = vacancy.NotebookId,
                    VacancyUrl        = $"https://rabota.ua/company{vacancy.NotebookId}3184369/vacancy{vacancy.Id}"
                };
                var languageSkills = GetLanguageSkills(vacancy.Languages);
                var description    = GetHtmlDescription(vacancy.Id);
                var mainSkills     = GetSkillsByDescription(description).Concat(languageSkills);
                vacancyToInsert.Skills = mainSkills.ToList();
                jobsCollection.Add(vacancyToInsert);
            }

            _repository.BulkInsertVacancies(jobsCollection);
            Console.WriteLine("Done");
        }
Exemple #2
0
        public void GetJobsForAllPages()
        {
            var vacancies    = new List <VacancyResultItem>();
            var jobIds       = new List <int>();
            var allCompanies = new List <string>();

            var jobsCollection = new List <Vacancy>();

            for (int i = 1; i <= PAGES_COUNT; i++)
            {
                var jobs = _dataService.GetAllJobs(_config.SearchRequestUrl, i).Result.Documents
                           .Where(job => DateTime.Today - job.AddDate.Date == TimeSpan.FromDays(1));
                allCompanies.AddRange(jobs.Select(job => job.CompanyName).Distinct().ToList());
                jobIds.AddRange(jobs.Select(job => job.Id));
                vacancies.AddRange(jobs);
            }

            _repository.BulkSaveInsertCompanies(allCompanies);
            var companies = _repository.GetAllCompaniesByNames(allCompanies).ToList();

            foreach (var vacancy in vacancies)
            {
                jobsCollection.Add(new Vacancy
                {
                    Name       = vacancy.Name,
                    RabotaUaId = vacancy.Id,
                    Company    = companies.FirstOrDefault(x => x.Name == vacancy.CompanyName),
                    Salary     = vacancy.Salary,
                    Hot        = vacancy.Hot,
                    CityName   = vacancy.CityName,
                    AddDate    = vacancy.AddDate,
                });
            }
            _repository.BulkInsertVacancies(jobsCollection);
            Console.WriteLine("Done");
            //return result;
        }