Пример #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                              LoyaltyCsvExportService loyaltyCsvExportService,
                              LoyaltyCsvImportService loyaltyCsvImportService,
                              ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Customer 360 API v1");
            });

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseHangfireDashboard("/hangfire", new DashboardOptions
            {
                Authorization = new [] { new AllowAnyoneAuthorization() }
            });
            app.UseHangfireServer();

            app.UseAuthorization();

            app.UseStaticFiles();

            loggerFactory.AddLog4Net();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            // ****** recurring jobs *********
            RecurringJob.AddOrUpdate("nightlyCsvExport", () => loyaltyCsvExportService.ExportCsv(), Cron.Daily(2, 0));

            RecurringJob.AddOrUpdate("nightlyCsvImport", () => loyaltyCsvImportService.ImportCsv(), Cron.Daily(3, 0));
            // *******************************
        }
        public Customer360Controller(
            HomeDeliveryRepository homeDeliveryRepository,
            LoyaltyRepository loyaltyRepository,
            LoyaltyCsvExportService loyaltyCsvExportService,
            LoyaltyCsvImportService loyaltyCsvImportService,
            ILogger <Customer360Controller> logger,
            EnterpriseData enterpriseData,
            OnlineStoreRepository onlineStoreRepository)
        {
            _homeDeliveryRepository  = homeDeliveryRepository;
            _loyaltyRepository       = loyaltyRepository;
            _loyaltyCsvExportService = loyaltyCsvExportService;
            _loyaltyCsvImportService = loyaltyCsvImportService;
            _logger                = logger;
            _enterpriseData        = enterpriseData;
            _onlineStoreRepository = onlineStoreRepository;

            // make sure all the appropriate tables/databases exist
            _enterpriseData.EnsureSchemas();
        }