示例#1
0
        /// <summary>
        /// Helps to load the settings key value in the memory
        /// </summary>
        /// <param name="app">Application pipleline where the setting is to be initiated.</param>
        /// <param name="memoryCache">In Memory where the values needed to be store</param>
        public static async Task CbuilderInitialTasks(this IApplicationBuilder app, IMemoryCache memoryCache, IWebHostEnvironment hostingEnvironment, IHttpContextAccessor httpContextAccessor)
        {
            SettingHelper settingHelper = new SettingHelper(memoryCache);
            Dictionary <string, string> settingValues = settingHelper.GetSettingValuesByKeys(string.Format("{0},{1},{2},{3},{4},{5},{6}",
                                                                                                           SettingKeys.ClientID,
                                                                                                           SettingKeys.ClientSecretKey,
                                                                                                           SettingKeys.IdentityUrl,
                                                                                                           SettingKeys.LoggerApiGatewayUrl,
                                                                                                           SettingKeys.CampaignBaseUri,
                                                                                                           SettingKeys.ApiGatewayBaseUri,
                                                                                                           SettingKeys.PaymentGatewayBaseUri
                                                                                                           ));

            CurrentHostEnvironment.WebRootPath     = hostingEnvironment.WebRootPath;
            CurrentHostEnvironment.ContentRootPath = hostingEnvironment.ContentRootPath;
            CurrentHostEnvironment.IsDevelopment   = hostingEnvironment.IsDevelopment();
            CurrentHostEnvironment.IsProduction    = hostingEnvironment.IsProduction();
            CurrentHostEnvironment.IsStaging       = hostingEnvironment.IsStaging();
            Common.ClientID        = settingValues[SettingKeys.ClientID];
            Common.ClientSecretKey = settingValues[SettingKeys.ClientSecretKey];
            settingHelper.CacheAllSettings();
            ////Reading particular settings from caches
            APIURL.IdentityBaseUri   = settingValues[SettingKeys.IdentityUrl];
            APIURL.LoggerBaseUri     = settingValues[SettingKeys.LoggerApiGatewayUrl];
            APIURL.CampaignBaseUri   = settingValues[SettingKeys.CampaignBaseUri];
            APIURL.PaymentGatewayUri = settingValues[SettingKeys.PaymentGatewayBaseUri];
            APIURL.ApiGatewayBaseUri = settingValues[SettingKeys.ApiGatewayBaseUri];
        }
示例#2
0
        public static void ConfigureContentderAI(this IApplicationBuilder app, IMemoryCache memoryCache)
        {
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

            var settingHelper = new SettingHelper(memoryCache);

            settingHelper.CacheAllSettings();
        }
示例#3
0
        public TextAnalyticsTest()
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json")
                                .Build();

            SQLHelperConfig.ConnectionConfig = configuration.GetConnectionString("ContentderAIConnection");

            var provider = new ServiceCollection()
                           .AddMemoryCache()
                           .BuildServiceProvider();
            var memoryCache   = provider.GetService <IMemoryCache>();
            var settingHelper = new SettingHelper(memoryCache);

            settingHelper.CacheAllSettings();

            var keys = $"{SettingKeys.TextAnalyticsEndpoint},{SettingKeys.TextAnalyticsSecret}";
            Dictionary <string, string> settings = settingHelper.GetCachedSettingValuesByKeys(keys);

            _textAnalytics = new TextAnalytics(settings[SettingKeys.TextAnalyticsEndpoint], settings[SettingKeys.TextAnalyticsSecret]);
        }
        public HelperElasticSearchTest()
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json")
                                .Build();

            SQLHelperConfig.ConnectionConfig = configuration.GetConnectionString("ContentderAIConnection");

            var provider = new ServiceCollection()
                           .AddMemoryCache()
                           .BuildServiceProvider();
            var memoryCache   = provider.GetService <IMemoryCache>();
            var settingHelper = new SettingHelper(memoryCache);

            settingHelper.CacheAllSettings();

            var url = settingHelper.GetCachedSettingValue(SettingKeys.ElasticSearchEndpoint);

            index          = settingHelper.GetCachedSettingValue(SettingKeys.ElasticSearchIndex);
            _elasticSearch = new ElasticSearch(url, index);
        }