public TasksController(ILogger <TasksController> logger, TokenManager tokenManager, ISysTasksQzService tasksQzService, ITaskSchedulerServer schedulerServer) { _logger = logger; _tokenManager = tokenManager; _tasksQzService = tasksQzService; _schedulerServer = schedulerServer; }
public static IApplicationBuilder UseAddTaskSchedulers(this IApplicationBuilder app) { IServiceProvider services = app.ApplicationServices; ISysTasksQzService _tasksQzService = services.GetService <ISysTasksQzService>(); ITaskSchedulerServer _schedulerServer = services.GetService <ITaskSchedulerServer>(); var tasks = _tasksQzService.GetWhere(m => m.IsStart); foreach (var task in tasks) { _schedulerServer.AddTaskScheduleAsync(task); } return(app); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISysTasksQzService tasksQzService, ITaskSchedulerServer schedulerServer) { #region 开发错误提示 if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } ; #endregion #region 务注入 // 跨域设置 app.UseCorsSetup(); // 说明文档 app.UseSwaggerSetup(); // 请求日志监控 app.UseMiddleware <RequestMiddleware>(); // 使用静态文件 app.UseForwardedHeaders(); // 使用静态文件 app.UseStaticFiles(); // 使用cookie app.UseCookiePolicy(); // 使用Routing app.UseRouting(); // 使用相应缓存中间件 app.UseResponseCaching(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); // 恢复任务 app.UseAddTaskSchedulers(tasksQzService, schedulerServer); #endregion }
public Job_SyncProductOrder(ILogger <Job_SyncProductOrder> logger, ISysTasksQzService tasksQzService) { _logger = logger; _tasksQzService = tasksQzService; }
public static IApplicationBuilder UseAddTaskSchedulers(this IApplicationBuilder app, ISysTasksQzService tasksQzService, ITaskSchedulerServer schedulerServer) { var logger = NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger(); var tasks = tasksQzService.GetWhere(m => m.IsStart); foreach (var task in tasks) { var result = schedulerServer.AddTaskScheduleAsync(task).Result; logger.Debug(result.Message); } return(app); }