public void SearchSuitableProfilesCompanies(int accountId, IEnumerable <CompanyProfilesViewModel> companiesEmployees) { _debugLogService.SendDebugLog($"AccountID = { accountId }, Company ids: [ { string.Join(", ", companiesEmployees.Select(x => $"{ x.Id }")) } ]", "Start SearchSuitableProfilesCompanies"); var settings = _settingService.GetSettingsByAccountId(accountId); var rolesSearch = settings?.SettingsViewModel?.RolesSearch?.Split(',') ?? new string[] { }; foreach (var companyEmployees in companiesEmployees) { var result = new List <SuitableProfileViewModel>(); var technologiesStack = new List <string>(); var location = !string.IsNullOrEmpty(companyEmployees.HeadquartersLocation) ? companyEmployees.HeadquartersLocation.Split(',') : new string[] { }; var profileSkills = companyEmployees.ProfilesViewModel.Where(x => x.ProfileStatus == ProfileStatus.Developer).Select(z => z.AllSkills.Split(',')); foreach (var skills in profileSkills) { foreach (var skill in skills) { if (!technologiesStack.Contains(skill.Trim())) { technologiesStack.Add(skill.Trim()); } } } if (profileSkills == null || profileSkills.Count() == 0) { continue; } if (!_configuration.IsAuthorized) { _accountService.Authorization(); if (!_configuration.IsAuthorized) { break; } } if (settings.SettingsViewModel.IsSearchChiefs) { foreach (var employee in companyEmployees.ProfilesViewModel.Where(x => x.ProfileStatus == ProfileStatus.Chief)) { var emails = _emailHandler.GetValidEmails(employee.FirstName, employee.LastName, companyEmployees.Website); result.Add(GenerateResultViewModel(accountId, employee, companyEmployees, rolesSearch, technologiesStack, emails, location)); } foreach (var fullName in companyEmployees.Founders?.Split(',') ?? new string[0]) { if (string.IsNullOrEmpty(fullName.Trim())) { continue; } var founderProfile = companyEmployees.ProfilesViewModel.Where(x => x.FullName == fullName.Trim() && x.ProfileStatus == ProfileStatus.Chief).FirstOrDefault(); if (founderProfile == null) { var firstName = fullName.Trim().Split(' ')[0]; var lastName = fullName.Trim().Split(' ')[1]; var emails = _emailHandler.GetValidEmails(firstName, lastName, companyEmployees.Website); result.Add(GenerateResultViewModel(accountId, null, companyEmployees, rolesSearch, technologiesStack, emails, location, firstName, lastName, "Founder", "...")); } } } if (settings.SettingsViewModel.IsSearchDevelopers) { foreach (var employee in companyEmployees.ProfilesViewModel.Where(x => x.ProfileStatus == ProfileStatus.Developer)) { var emails = _emailHandler.GetValidEmails(employee.FirstName, employee.LastName, companyEmployees.Website); result.Add(GenerateResultViewModel(accountId, employee, companyEmployees, rolesSearch, technologiesStack, emails, location)); } } //After company scraped company data processing _suitableProfileService.InsertSuitableProfile(result); _profileService.UpdateProfilesExecutionStatusByCompanyID(accountId, ExecutionStatus.Success, companyEmployees.Id); _debugLogService.SendDebugLog($"AccountID = { accountId }, Suitable profiles ids: [ { string.Join(", ", result.Select(x => $"{ x.Id }")) } ]", "End SearchSuitableProfilesCompanies"); } }