// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //------Swagger----------- app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Contacts API V1"); }); //-----Hangfire schedule task------ app.UseHangfireServer(); app.UseHangfireDashboard(); IScheduleTaskService scheduleTaskService = new ScheduleTaskService(); RecurringJob.AddOrUpdate(() => scheduleTaskService.DailyTask(), Cron.Daily); RecurringJob.AddOrUpdate(() => scheduleTaskService.MonthlyTask(), Cron.Monthly); //------Authentication------------ //!!! Important use Auth need before use Mvc. app.UseAuthentication(); app.UseMvc(); app.UseCors("EnableCORS"); }
public void DeleteScheduleTask() { var task = ScheduleTask; if (task != null) { ScheduleTaskService.DeleteTask(task); } }
public void UpdateScheduleTask(bool enabled, int seconds) { var task = ScheduleTask; if (task != null) { task.Enabled = enabled; task.Seconds = seconds; ScheduleTaskService.UpdateTask(task); } }
public void InsertScheduleTask(int minutes = 360) { var task = ScheduleTask; if (task == null) { ScheduleTaskService.InsertTask(new ScheduleTask { Name = "{0} feed file generation".FormatWith(SystemName), Seconds = minutes * 60, Type = ScheduleTaskType, Enabled = false, StopOnError = false, }); } }