Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers().AddNewtonsoftJson();
            services.AddMemoryCache();

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.RequireHttpsMetadata      = false;
                options.SaveToken                 = true;
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidIssuer              = "FamilIntegrationService",
                    ValidAudience            = "IntegrationUser",
                    IssuerSigningKey         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("gfdiog40-]kgf-043uo")),
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    ClockSkew = TimeSpan.Zero
                };
            });;

            services.AddMemoryCache();
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.ProcessingUri, Configuration.GetValue <string>("ProcessingUri"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.ProcessingSecret, Configuration.GetValue <string>("ProcessingSecret"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.PersonalAreaToken, Configuration.GetValue <string>("PersonalAreaToken"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.PersonalAreaLogin, Configuration.GetValue <string>("PersonalAreaLogin"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.CardSynchronizationPeriod, Configuration.GetValue <int>("CardSynchronizationPeriod"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.CardCleanPeriod, Configuration.GetValue <int>("CardCleanPeriod"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.PersonalAreaPasword, Configuration.GetValue <string>("PersonalAreaPasword"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.PersonalAreaUri, Configuration.GetValue <string>("PersonalAreaUri"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.ConnectionString, Configuration.GetValue <string>("ConnectionString"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.BPMLogin, Configuration.GetSection("BPMCredentials").GetValue <string>("login"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.BPMPassword, Configuration.GetSection("BPMCredentials").GetValue <string>("password"));
            GlobalCacheReader.Cache.Set(GlobalCacheReader.CacheKeys.BPMUri, Configuration.GetSection("BPMCredentials").GetValue <string>("uri"));

            ProductManager.CreateTableIfNotExists();
            Promocode.CreateTableIfNotExists();
            AnswerTemplateCollection.CreateTableIfNotExist();
            CardController.CreateTableIfNotExist();
            CouponCache.CreateTableIfNotExist();

            JobManager.Initialize(new Scheduller());
        }