Ejemplo n.º 1
0
        // 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");
        }
Ejemplo n.º 2
0
        public void DeleteScheduleTask()
        {
            var task = ScheduleTask;

            if (task != null)
            {
                ScheduleTaskService.DeleteTask(task);
            }
        }
Ejemplo n.º 3
0
        public void UpdateScheduleTask(bool enabled, int seconds)
        {
            var task = ScheduleTask;

            if (task != null)
            {
                task.Enabled = enabled;
                task.Seconds = seconds;

                ScheduleTaskService.UpdateTask(task);
            }
        }
Ejemplo n.º 4
0
        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,
                });
            }
        }