public SqlConnection GetConnection()
        {
            var connectionString =
                _settings.GetSetting(ApplicationSettingKeys.AvmsPlusDatabaseConnectionStringKey);

            return(new SqlConnection(connectionString));
        }
Пример #2
0
        private IEnumerable <string> GetSetting(string configName)
        {
            var str = _settings.GetSetting(configName);

            return(!string.IsNullOrEmpty(str) ? str.Split('|').Select(element => element.Trim()) : new List <string> {
                string.Empty
            });
        }
        public ElasticClientRegistry(IProvideSettings _provideSettings)
        {
            var username  = _provideSettings.GetNullableSetting(ApplicationSettingKeys.ElasticUsernameKey);
            var password  = _provideSettings.GetNullableSetting(ApplicationSettingKeys.ElasticPasswordKey);
            var indexName = _provideSettings.GetSetting(ApplicationSettingKeys.ApprenticeshipIndexAliasKey);

            ElasticClientConfiguration elasticConfig;

#if DEBUG
            var hostUrl = _provideSettings.GetSetting(ApplicationSettingKeys.VacancySearchUrlKey);

            elasticConfig = string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)
                ? new ElasticClientConfiguration(new Uri(hostUrl))
                : new ElasticClientConfiguration(new Uri(hostUrl), username, password);
#else
            var cloudId = _provideSettings.GetSetting(ApplicationSettingKeys.ElasticCloudIdKey);
            elasticConfig = new ElasticClientConfiguration(cloudId, username, password);
#endif
            For <ElasticClientConfiguration>().Use(elasticConfig);
            For <IElasticClientFactory>().Use <ElasticClientFactory>();
            For <IApprenticeshipSearchClient>().Use <ApprenticeshipSearchClient>().Ctor <string>("indexName").Is(indexName);
        }
Пример #4
0
        public ApiTypes.ApprenticeshipVacancy MapToApprenticeshipVacancy(ApprenticeshipVacancy apprenticeshipVacancy)
        {
            var liveVacancyBaseUrl = _provideSettings.GetSetting(ApplicationSettingKeys.LiveApprenticeshipVacancyBaseUrlKey);

            var apprenticeship = new ApiTypes.ApprenticeshipVacancy
            {
                VacancyReference              = apprenticeshipVacancy.VacancyReferenceNumber,
                Title                         = apprenticeshipVacancy.Title,
                ShortDescription              = apprenticeshipVacancy.ShortDescription,
                Description                   = apprenticeshipVacancy.Description,
                WageUnit                      = MapWageUnit(apprenticeshipVacancy.WageUnitId),
                WorkingWeek                   = apprenticeshipVacancy.WorkingWeek,
                WageText                      = MapWage(apprenticeshipVacancy),
                WageAdditionalInformation     = null,
                HoursPerWeek                  = apprenticeshipVacancy.HoursPerWeek,
                ExpectedDuration              = apprenticeshipVacancy.ExpectedDuration,
                ExpectedStartDate             = apprenticeshipVacancy.ExpectedStartDate,
                PostedDate                    = apprenticeshipVacancy.PostedDate,
                ApplicationClosingDate        = apprenticeshipVacancy.ApplicationClosingDate,
                NumberOfPositions             = apprenticeshipVacancy.NumberOfPositions,
                EmployerName                  = apprenticeshipVacancy.IsAnonymousEmployer ? apprenticeshipVacancy.AnonymousEmployerName : apprenticeshipVacancy.EmployerName,
                EmployerDescription           = apprenticeshipVacancy.IsAnonymousEmployer ? apprenticeshipVacancy.AnonymousEmployerDescription : apprenticeshipVacancy.EmployerDescription,
                EmployerWebsite               = apprenticeshipVacancy.IsAnonymousEmployer ? null : apprenticeshipVacancy.EmployerWebsite,
                TrainingToBeProvided          = apprenticeshipVacancy.TrainingToBeProvided,
                QualificationsRequired        = apprenticeshipVacancy.QualificationsRequired,
                SkillsRequired                = apprenticeshipVacancy.SkillsRequired,
                PersonalQualities             = apprenticeshipVacancy.PersonalQualities,
                FutureProspects               = apprenticeshipVacancy.FutureProspects,
                ThingsToConsider              = apprenticeshipVacancy.ThingsToConsider,
                IsNationwide                  = apprenticeshipVacancy.VacancyLocationTypeId == Nationwide,
                SupplementaryQuestion1        = apprenticeshipVacancy.SupplementaryQuestion1,
                SupplementaryQuestion2        = apprenticeshipVacancy.SupplementaryQuestion2,
                VacancyUrl                    = $"{liveVacancyBaseUrl}/{apprenticeshipVacancy.VacancyReferenceNumber}",
                Location                      = _geoCodedAddressMapper.MapToLocation(apprenticeshipVacancy.Location, showAnonymousEmployerDetails: apprenticeshipVacancy.IsAnonymousEmployer),
                ContactName                   = apprenticeshipVacancy.ContactName,
                ContactEmail                  = apprenticeshipVacancy.ContactEmail,
                ContactNumber                 = apprenticeshipVacancy.ContactNumber,
                TrainingProviderName          = apprenticeshipVacancy.TrainingProvider,
                TrainingProviderUkprn         = apprenticeshipVacancy.TrainingProviderUkprn,
                TrainingProviderSite          = apprenticeshipVacancy.TrainingProviderSite, //This is mapped to provider's trading name
                IsEmployerDisabilityConfident = apprenticeshipVacancy.IsDisabilityConfident,
                ApprenticeshipLevel           = EducationLevelHelper.RemapFromInt(apprenticeshipVacancy.ApprenticeshipTypeId).ToString(),
                ApplicationUrl                = apprenticeshipVacancy.EmployersRecruitmentWebsite,
                ApplicationInstructions       = apprenticeshipVacancy.EmployersApplicationInstructions
            };

            MapTrainingDetails(apprenticeshipVacancy, apprenticeship);

            return(apprenticeship);
        }
        public string GetSetting(string settingKey)
        {
            var setting = CloudConfigurationManager.GetSetting(settingKey);

            if (string.IsNullOrWhiteSpace(setting))
            {
                setting = _baseSettings.GetSetting(settingKey);
            }

            if (string.IsNullOrEmpty(setting))
            {
                throw new ConfigurationErrorsException($"Setting with key {settingKey} is missing");
            }

            return(setting);
        }
Пример #6
0
        public AzureRedisCacheService(IProvideSettings settings, ILog logger)
        {
            _settings = settings;
            _logger   = logger;

            _connectionFactory = () =>
            {
                var cacheConnectionString = settings.GetSetting(ApplicationSettingKeys.CacheConnectionString);
                if (string.IsNullOrWhiteSpace(cacheConnectionString))
                {
                    _logger.Error(new InfrastructureException(),
                                  "Redis cache connection not found in settings.");
                }

                return(ConnectionMultiplexer.Connect(cacheConnectionString));
            };
        }
Пример #7
0
        public TraineeshipVacancy MapToTraineeshipVacancy(Domain.Entities.TraineeshipVacancy traineeshipVacancy)
        {
            var liveVacancyBaseUrl = _provideSettings.GetSetting(ApplicationSettingKeys.LiveTraineeshipVacancyBaseUrlKey);

            return(new TraineeshipVacancy
            {
                VacancyReference = traineeshipVacancy.VacancyReferenceNumber,
                Title = traineeshipVacancy.Title,
                ShortDescription = traineeshipVacancy.ShortDescription,
                Description = traineeshipVacancy.Description,
                WorkingWeek = traineeshipVacancy.WorkingWeek,
                ExpectedDuration = traineeshipVacancy.ExpectedDuration,
                ExpectedStartDate = traineeshipVacancy.ExpectedStartDate,
                PostedDate = traineeshipVacancy.PostedDate,
                ApplicationClosingDate = traineeshipVacancy.ApplicationClosingDate,
                NumberOfPositions = traineeshipVacancy.NumberOfPositions,
                TraineeshipSector = traineeshipVacancy.TraineeshipSector,
                EmployerName = traineeshipVacancy.IsAnonymousEmployer ? traineeshipVacancy.AnonymousEmployerName : traineeshipVacancy.EmployerName,
                EmployerDescription = traineeshipVacancy.IsAnonymousEmployer ? traineeshipVacancy.AnonymousEmployerDescription : traineeshipVacancy.EmployerDescription,
                EmployerWebsite = traineeshipVacancy.IsAnonymousEmployer ? null : traineeshipVacancy.EmployerWebsite,
                TrainingToBeProvided = traineeshipVacancy.TrainingToBeProvided,
                QualificationsRequired = traineeshipVacancy.QualificationsRequired,
                SkillsRequired = traineeshipVacancy.SkillsRequired,
                PersonalQualities = traineeshipVacancy.PersonalQualities,
                FutureProspects = traineeshipVacancy.FutureProspects,
                ThingsToConsider = traineeshipVacancy.ThingsToConsider,
                IsNationwide = traineeshipVacancy.VacancyLocationTypeId == Nationwide,
                SupplementaryQuestion1 = traineeshipVacancy.SupplementaryQuestion1,
                SupplementaryQuestion2 = traineeshipVacancy.SupplementaryQuestion2,
                VacancyUrl = $"{liveVacancyBaseUrl}/{traineeshipVacancy.VacancyReferenceNumber}",
                Location = _geoCodedAddressMapper.MapToLocation(traineeshipVacancy.Location, showAnonymousEmployerDetails: traineeshipVacancy.IsAnonymousEmployer),
                ContactName = traineeshipVacancy.ContactName,
                ContactEmail = traineeshipVacancy.ContactEmail,
                ContactNumber = traineeshipVacancy.ContactNumber,
                TrainingProviderName = traineeshipVacancy.TrainingProvider,
                TrainingProviderUkprn = traineeshipVacancy.TrainingProviderUkprn,
                TrainingProviderSite = traineeshipVacancy.TrainingProviderSite,
                IsEmployerDisabilityConfident = traineeshipVacancy.IsDisabilityConfident,
                ApplicationUrl = traineeshipVacancy.EmployersRecruitmentWebsite,
                ApplicationInstructions = traineeshipVacancy.EmployersApplicationInstructions
            });
        }
 private IEnumerable <Uri> GetElasticIPs(string appSetting)
 {
     return(_settingsProvider.GetSetting(appSetting).Split(',').Select(url => new Uri(url)));
 }
Пример #9
0
 private string TryBaseSettingsProvider(string settingKey)
 {
     return(_baseSettings.GetSetting(settingKey));
 }
        private string GetVacancyUrl(int reference)
        {
            string url = _provideSettings.GetSetting(ApplicationSettingKeys.LiveApprenticeshipVacancyBaseUrlKey);

            return(url.EndsWith("/") ? $"{url}{reference}" : $"{url}/{reference}");
        }
        public IEnumerable <Uri> GetElasticIPs(string appSetting)
        {
            var urlsString = _settingsProvider.GetSetting(appSetting).Split(',');

            return(urlsString.Select(url => new Uri(url)));
        }
        public string QueueName(Type type)
        {
            var name = $"{TypeToName(type)}.QueueName";

            return(_settings.GetSetting(name).ToLower());
        }
        public async Task <ApiTypes.ApprenticeshipVacancy> MapFromRecruitVacancy(recruitEntities.Vacancy liveVacancy)
        {
            var liveVacancyBaseUrl = _provideSettings.GetSetting(ApplicationSettingKeys.LiveApprenticeshipVacancyBaseUrlKey);

            var trainingType =
                (ApiTypes.TrainingType)Enum.Parse(typeof(ApiTypes.TrainingType), liveVacancy.ProgrammeType);

            var trainingCode = GetTrainingCode(trainingType, liveVacancy.ProgrammeId);

            var trainingTitle = await GetTrainingTitle(trainingType, trainingCode);

            var qualifications = GetVacancyQualification(liveVacancy);

            var skills = string.Join(",", liveVacancy.Skills);

            var wageText = GetWageText(liveVacancy.Wage, liveVacancy.StartDate);

            var duration = GetDurationAsText(liveVacancy.Wage);

            var wageUnit = GetWageUnit(liveVacancy.Wage.WageType);

            var apprenticeship = new ApiTypes.ApprenticeshipVacancy
            {
                VacancyReference              = liveVacancy.VacancyReference,
                Title                         = liveVacancy.Title,
                ShortDescription              = liveVacancy.ShortDescription,
                Description                   = liveVacancy.Description,
                WageUnit                      = wageUnit,
                WorkingWeek                   = liveVacancy.Wage.WorkingWeekDescription,
                WageText                      = wageText,
                WageAdditionalInformation     = liveVacancy.Wage.WageAdditionalInformation,
                HoursPerWeek                  = liveVacancy.Wage.WeeklyHours,
                ExpectedDuration              = duration,
                ExpectedStartDate             = liveVacancy.StartDate,
                PostedDate                    = liveVacancy.LiveDate,
                ApplicationClosingDate        = liveVacancy.ClosingDate,
                NumberOfPositions             = liveVacancy.NumberOfPositions,
                EmployerName                  = liveVacancy.EmployerName,
                EmployerDescription           = liveVacancy.EmployerDescription,
                EmployerWebsite               = liveVacancy.IsAnonymous ? null : liveVacancy.EmployerWebsiteUrl,
                ContactName                   = liveVacancy.EmployerContactName ?? liveVacancy.ProviderContactName,
                ContactEmail                  = liveVacancy.EmployerContactEmail ?? liveVacancy.ProviderContactEmail,
                ContactNumber                 = liveVacancy.EmployerContactPhone ?? liveVacancy.ProviderContactPhone,
                TrainingToBeProvided          = liveVacancy.TrainingDescription,
                QualificationsRequired        = qualifications,
                SkillsRequired                = skills,
                PersonalQualities             = null,
                ApplicationInstructions       = liveVacancy.ApplicationInstructions,
                ApplicationUrl                = liveVacancy.ApplicationUrl,
                FutureProspects               = liveVacancy.OutcomeDescription,
                ThingsToConsider              = liveVacancy.ThingsToConsider,
                IsNationwide                  = false,
                SupplementaryQuestion1        = null,
                SupplementaryQuestion2        = null,
                VacancyUrl                    = $"{liveVacancyBaseUrl}/{liveVacancy.VacancyReference}",
                Location                      = MapFromRecruitAddress(liveVacancy.EmployerLocation, liveVacancy.IsAnonymous),
                TrainingProviderName          = liveVacancy.TrainingProvider.Name,
                TrainingProviderUkprn         = liveVacancy.TrainingProvider.Ukprn.ToString(),
                TrainingProviderSite          = null,
                IsEmployerDisabilityConfident = false,
                ApprenticeshipLevel           = liveVacancy.ProgrammeLevel,
                TrainingType                  = trainingType,
                TrainingCode                  = trainingCode,
                TrainingTitle                 = trainingTitle
            };

            return(apprenticeship);
        }