public static void UseQuartzJobMildd(this IApplicationBuilder app, ITasksQzSvc tasksQzSvc, ISchedulerCenter schedulerCenter) { if (app == null) { throw new ArgumentNullException(nameof(app)); } try { if (Appsettings.App("Middleware", "QuartzNetJob", "Enabled").ToBoolReq()) { var allQzServices = tasksQzSvc.Query().Result; foreach (var item in allQzServices) { if (item.JobStatus == JobStatus.运行中) { var ResuleModel = schedulerCenter.AddScheduleJobAsync(item).Result; if (ResuleModel.Success) { Console.WriteLine($"QuartzNetJob{item.JobName}启动成功!"); } else { Console.WriteLine($"QuartzNetJob{item.JobName}启动失败!错误信息:{ResuleModel.Message}"); } } } } } catch (Exception e) { log.Error($"An error was reported when starting the job service.\n{e.Message}"); throw; } }
public TableData(IUserSvc userSvc, IDeptSvc deptSvc, IRoleSvc roleSvc, IMenuSvc menuSvc, ITasksQzSvc tasksQzSvc) { _userSvc = userSvc; _deptSvc = deptSvc; _roleSvc = roleSvc; _menuSvc = menuSvc; _tasksQzSvc = tasksQzSvc; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MyContext myContext, ITasksQzSvc tasksQzSvc, ISchedulerCenter schedulerCenter, IHostApplicationLifetime lifetime) { // Ip限流,尽量放管道外层 app.UseIpLimitMildd(); // 记录请求与返回数据 app.UseReuestResponseLog(); // 用户访问记录(必须放到外层,不然如果遇到异常,会报错,因为不能返回流) app.UseRecordAccessLogsMildd(); // signalr app.UseSignalRSendMildd(); // 记录ip请求 app.UseIPLogMildd(); // 查看注入的所有服务 app.UseAllServicesMildd(_services); if (env.IsDevelopment()) { // 在开发环境中,使用异常页面,这样可以暴露错误堆栈信息,所以不要放在生产环境。 app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // 在非开发环境中,使用HTTP严格安全传输(or HSTS) 对于保护web安全是非常重要的。 // 强制实施 HTTPS 在 ASP.NET Core,需要配合 app.UseHttpsRedirection()与services.AddHstsSetup() //app.UseHsts(); // HSTS 中间件(UseHsts)用于向客户端发送 HTTP 严格传输安全协议(HSTS)标头 } // 自定义Swagger权限拦截中间件,放到Swagger中间件之前 app.UseSession(); app.UseSwaggerAuthorized(); // 封装Swagger展示 app.UseSwaggerMildd(() => GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Xu.WebApi.index.html")); // ↓↓↓↓↓↓ 注意下边这些中间件的顺序,很重要 ↓↓↓↓↓↓ // CORS跨域 app.UseCors(Appsettings.App(new string[] { "Startup", "Cors", "PolicyName" })); // 重定向中间件,用于将 HTTP 请求重定向到 HTTPS //app.UseHttpsRedirection(); // 使用静态文件 DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions(); defaultFilesOptions.DefaultFileNames.Clear(); defaultFilesOptions.DefaultFileNames.Add("index.html"); app.UseDefaultFiles(defaultFilesOptions); // 默认使用wwwroot静态文件 app.UseStaticFiles(); // 使用cookie app.UseCookiePolicy(); // 返回错误码 app.UseStatusCodePages(); // Routing app.UseRouting(); // 这种自定义授权中间件,可以尝试,但不推荐 // app.UseJwtTokenAuth(); // 先开启认证--验证当前请求的用户,并设置HttpContext.User,当OAuth callbacks时,会中止执行下一个中间件。 app.UseAuthentication(); // 然后是授权中间件 app.UseAuthorization(); // 开启性能分析 app.UseMiniProfilerMildd(); // 开启异常中间件,要放到最后 app.UseExceptionHandlerMidd(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapHub <ChatHub>("/api/chatHub"); }); // 生成种子数据 app.UseSeedDataMildd(myContext, Env.WebRootPath); // 开启QuartzNetJob调度服务 app.UseQuartzJobMildd(tasksQzSvc, schedulerCenter); // 服务注册 app.UseConsulMildd(Configuration, lifetime); // 事件总线,订阅服务 app.ConfigureEventBus(); }
public JobQuartz(ITasksQzSvc tasksQzSvc, IWebHostEnvironment environment) { // _blogArticleServices = blogArticleServices; _environment = environment; _tasksQzSvc = tasksQzSvc; }
public TasksQzController(ITasksQzSvc tasksQzSvc, ISchedulerCenter schedulerCenter) { _tasksQzSvc = tasksQzSvc; _schedulerCenter = schedulerCenter; }
public SchedulerCenter(ITasksQzSvc tasksQzSvc, IJobFactory jobFactory) { _tasksQzSvc = tasksQzSvc; _iocjobFactory = jobFactory; _scheduler = GetSchedulerAsync(); }