コード例 #1
0
ファイル: Startup.cs プロジェクト: mgroves/tutorials-contrib
        // 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));
            // *******************************
        }
コード例 #2
0
        public async Task <IActionResult> ConsumeLoyaltyCsv()
        {
            await _loyaltyCsvImportService.ImportCsv();

            return(Ok("Success"));
        }