Пример #1
0
        public static void UseQuartzJobMildd(this IApplicationBuilder app, ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            try
            {
                if (Appsettings.app("Middleware", "QuartzNetJob", "Enabled").ObjToBool())
                {
                    var allQzServices = tasksQzServices.Query().Result;
                    foreach (var item in allQzServices)
                    {
                        if (item.IsStart)
                        {
                            var ResuleModel = schedulerCenter.AddScheduleJobAsync(item).Result;
                            if (ResuleModel.success)
                            {
                                Console.WriteLine($"QuartzNetJob{item.Name}启动成功!");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                log.Error($"An error was reported when starting the job service.\n{e.Message}");
                throw;
            }
        }
        public TasksQzController(ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter)
        {
            _tasksQzService  = tasksQzServices;
            _schedulerCenter = schedulerCenter;

            //Log.Info("测试测试");
        }
Пример #3
0
 public Job_Billi_Quartz(ICSDNSignServices csdnsignservices, IVipPrivilegeDomainService vipService, IBiliCookieServices bilicookieservices, IBiliAccountService biliaccountservice, ITasksQzServices tasksQzServices)
 {
     _csdnsignservices   = csdnsignservices;
     _vipService         = vipService;
     _bilicookieservices = bilicookieservices;
     _biliaccountservice = biliaccountservice;
     _tasksQzServices    = tasksQzServices;
 }
Пример #4
0
        // 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, ITasksQzServices tasksQzServices, 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
                //app.UseHsts();
            }

            // 封装Swagger展示
            app.UseSwaggerMildd(() => GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Blog.Core.Api.index.html"));

            // ↓↓↓↓↓↓ 注意下边这些中间件的顺序,很重要 ↓↓↓↓↓↓

            // CORS跨域
            app.UseCors(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }));
            // 跳转https
            //app.UseHttpsRedirection();
            // 使用静态文件
            app.UseStaticFiles();
            // 使用cookie
            app.UseCookiePolicy();
            // 返回错误码
            app.UseStatusCodePages();
            // Routing
            app.UseRouting();
            // 这种自定义授权中间件,可以尝试,但不推荐
            // app.UseJwtTokenAuth();

            // 测试用户,用来通过鉴权
            if (Configuration.GetValue <bool>("AppSettings:UseLoadTest"))
            {
                app.UseMiddleware <ByPassAuthMidd>();
            }
            // 先开启认证
            app.UseAuthentication();
            // 然后是授权中间件
            app.UseAuthorization();

            // 开启异常中间件,要放到最后
            //app.UseExceptionHandlerMidd();
            // 性能分析
            app.UseMiniProfiler();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");

                endpoints.MapHub <ChatHub>("/api2/chatHub");
            });

            // 生成种子数据
            app.UseSeedDataMildd(myContext, Env.WebRootPath);
            // 开启QuartzNetJob调度服务
            app.UseQuartzJobMildd(tasksQzServices, schedulerCenter);
            //服务注册
            app.UseConsulMildd(Configuration, lifetime);
        }
Пример #5
0
 public TasksQzController(ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter)
 {
     _tasksQzServices = tasksQzServices;
     _schedulerCenter = schedulerCenter;
 }
Пример #6
0
 public Job_OperateLog_Quartz(IOperateLogServices operateLogServices, ITasksQzServices tasksQzServices, IWebHostEnvironment environment)
 {
     _operateLogServices = operateLogServices;
     _environment        = environment;
     _tasksQzServices    = tasksQzServices;
 }
Пример #7
0
 public JobBase(ITasksQzServices tasksQzServices)
 {
     _tasksQzServices = tasksQzServices;
 }
Пример #8
0
 public TestController(ITasksQzServices _tasksQzServices, IRedisBasketRepository cache)
 {
     tasksQzServices = _tasksQzServices;
     _cache          = cache;
 }
Пример #9
0
 public Job_Blogs_Quartz(IBlogArticleServices blogArticleServices, ITasksQzServices tasksQzServices)
 {
     _blogArticleServices = blogArticleServices;
     _tasksQzServices     = tasksQzServices;
 }
Пример #10
0
        // 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, ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter)
        {
            // Ip限流,尽量放管道外层
            app.UseIpRateLimiting();
            // 记录请求与返回数据
            app.UseReuestResponseLog();
            // 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
                //app.UseHsts();
            }

            // 封装Swagger展示
            app.UseSwaggerMildd(() => GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Blog.Core.index.html"));

            // ↓↓↓↓↓↓ 注意下边这些中间件的顺序,很重要 ↓↓↓↓↓↓

            // CORS跨域
            app.UseCors("LimitRequests");
            // 跳转https
            //app.UseHttpsRedirection();
            // 使用静态文件
            app.UseStaticFiles();
            // 使用cookie
            app.UseCookiePolicy();
            // 返回错误码
            app.UseStatusCodePages();
            // Routing
            app.UseRouting();
            // 这种自定义授权中间件,可以尝试,但不推荐
            // app.UseJwtTokenAuth();
            // 先开启认证
            app.UseAuthentication();
            // 然后是授权中间件
            app.UseAuthorization();

            // 开启异常中间件,要放到最后
            //app.UseExceptionHandlerMidd();

            // 性能分析
            app.UseMiniProfiler();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");

                endpoints.MapHub <ChatHub>("/api2/chatHub");
            });

            // 生成种子数据
            app.UseSeedDataMildd(myContext, Env.WebRootPath);

            // 开启QuartzNetJob调度服务
            app.UseQuartzJobMildd(tasksQzServices, schedulerCenter);
        }
Пример #11
0
 public Job_HttpApi_Quartz(ITasksQzServices tasksQzServices)
 {
     _tasksQzServices = tasksQzServices;
 }
Пример #12
0
 public Job_Synchronous(IRoleModulePermissionServices roleModulePermissionServices, ITasksQzServices tasksQzServices)
 {
     this.roleModulePermissionServices = roleModulePermissionServices;
     this.tasksQzServices = tasksQzServices;
 }
Пример #13
0
 public Job_AccessTrendLog_Quartz(IAccessTrendLogServices accessTrendLogServices, ITasksQzServices tasksQzServices, IWebHostEnvironment environment)
 {
     _accessTrendLogServices = accessTrendLogServices;
     _environment            = environment;
     _tasksQzServices        = tasksQzServices;
 }
Пример #14
0
 public TasksQzController(ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter, IUnitOfWork unitOfWork)
 {
     _unitOfWork      = unitOfWork;
     _tasksQzServices = tasksQzServices;
     _schedulerCenter = schedulerCenter;
 }
Пример #15
0
 public Job_CSDN_Quartz(ICSDNSignServices csdnsignservices, ITasksQzServices tasksQzServices)
 {
     _csdnsignservices = csdnsignservices;
     _tasksQzServices  = tasksQzServices;
 }