예제 #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,
            ProjectContext _context,
            IBackgroundJobClient backgroundJobClient,
            IRecurringJobManager recurringJobManager
            )
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();
            app.UseCors("CorsApi");
            app.UseAuthorization();

            app.UseSession();

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

            //_context.Database.EnsureDeleted();
            //_context.Database.EnsureCreated();
            //new Seeder(_context);
            //DBSeed.Initialize(IUnitOfWork<ProjectContext>);

            SchedulerController scheduler = new SchedulerController(null, null, null);

            app.UseHangfireDashboard();
            //backgroundJobClient.Enqueue(() => scheduler.seeder());
            //recurringJobManager.AddOrUpdate("compile reorder",() => scheduler.reorder(), "*/5 * * * *");
            recurringJobManager.AddOrUpdate("compile reorder monthly", () => scheduler.reorder(), "5 0 1 * *", TimeZoneInfo.Local);            //Cron string
            recurringJobManager.AddOrUpdate("autorevoke delegate", () => scheduler.reorder(), "0 0 * * *", TimeZoneInfo.Local);                //Cron string
            recurringJobManager.AddOrUpdate("disbursement reminder", () => scheduler.disbursementreminder(), "0 8 * * *", TimeZoneInfo.Local); //Cron string
        }