public TasksQzController(ITasksQzService tasksQzService, IMapper mapper, ISchedulerCenter schedulerCenter, IQzRunLogService qzRunLogService)
 {
     _tasksQzService  = tasksQzService;
     _mapper          = mapper;
     _schedulerCenter = schedulerCenter;
     _qzRunLogService = qzRunLogService;
 }
        public TasksQzController(ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter)
        {
            _tasksQzService  = tasksQzServices;
            _schedulerCenter = schedulerCenter;

            //Log.Info("测试测试");
        }
Exemplo n.º 3
0
 public ResScheduleController(IUowProvider uowProvider, IDataPager <ResSchedule> dataPager,
                              ISchedulerCenter schedulerCenter)
 {
     _uowProvider     = uowProvider;
     _dataPager       = dataPager;
     _schedulerCenter = schedulerCenter;
     logger           = LogFactory.GetLogger(LogType.InfoLog);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="_jwtSettingsAccesser"></param>
 /// <param name="userServer"></param>
 /// <param name="redisCacheManager"></param>
 /// <param name="rabbitMQ">消息队列</param>
 /// <param name="permissionRequirement"></param>
 /// <param name="hostingEnvironment"></param>
 /// <param name="schedulerCenter"></param>
 public AuthorizeController(IOptions <JwtSettings> _jwtSettingsAccesser,
                            IUserServer userServer, IRedisCacheManager redisCacheManager, IRabbitMQ rabbitMQ,
                            PermissionRequirement permissionRequirement, IHostingEnvironment hostingEnvironment, ISchedulerCenter schedulerCenter)
 {
     this._jwtSettings        = _jwtSettingsAccesser.Value;
     this._userserver         = userServer;
     this._redisCacheManager  = redisCacheManager;
     this._requirement        = permissionRequirement;
     this._hostingEnvironment = hostingEnvironment;
     this._rabbitMQ           = rabbitMQ;
     this._schedulerCenter    = schedulerCenter;
 }
Exemplo n.º 5
0
 public SysTaskQzService(
     IMapper mapper,
     ICache cache,
     ISysTaskQzRepository SysTaskQzRepository,
     IAuthUser authUser,
     ISchedulerCenter schedulerCenter
     )
 {
     _mapper = mapper;
     _cache  = cache;
     _SysTaskQzRepository = SysTaskQzRepository;
     _authUser            = authUser;
     _schedulerCenter     = schedulerCenter;
 }
Exemplo n.º 6
0
        public static void UseQuartzJob(this IApplicationBuilder app,
                                        IServiceProvider serviceProvider)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (!Appsettings.app("Middleware", "Job", "Enabled").ToBool())
            {
                return;
            }

            ITaskService taskService = serviceProvider.GetService <ITaskService>();

            ISchedulerCenter schedulerCenter = serviceProvider.GetService <ISchedulerCenter>();

            try
            {
                var taskDtos = taskService.GetAll().Result;
                foreach (var task in taskDtos)
                {
                    if (task.IsEnable)
                    {
                        var success = schedulerCenter.AddAsync(task).Result;
                        if (success)
                        {
                            Console.WriteLine($"QuartzNetJob{task.Name}启动成功!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex, "定时任务UseQuartzJob启动失败" + ex.Message);
            }
        }
Exemplo n.º 7
0
 public ScheduleServer(IScheduleRepositoty scheduleRepositoty, ISchedulerCenter schedulerCenter)
 {
     this._scheduleRepositoty = scheduleRepositoty;
     this._schedulerCenter    = schedulerCenter;
 }
Exemplo n.º 8
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, 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 static void UseQuartzJobMildd(this IApplicationBuilder app, ITasksQzBussiness tasksQzServices, ISchedulerCenter schedulerCenter)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            try
            {
                if (Appsettings.app("AppSettings", "QuartzNetJob", "Enabled").ObjToBool())
                {
                    var allQzServices = tasksQzServices.QueryAsync().Result;
                    foreach (var item in allQzServices)
                    {
                        if (item.IsStart)
                        {
                            var ResuleModel = schedulerCenter.AddScheduleJobAsync(item).Result;
                            if (ResuleModel.success)
                            {
                                log.Info($"QuartzNetJob{item.Name}启动成功!");
                            }
                            else
                            {
                                log.Error($"QuartzNetJob{item.Name}启动失败!错误信息:{ResuleModel.msg}");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                log.Fatal($"An error was reported when starting the job service.\n{e.Message}");
                throw;
            }
        }
Exemplo n.º 10
0
 public TasksQzController(ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter)
 {
     _tasksQzServices = tasksQzServices;
     _schedulerCenter = schedulerCenter;
 }
Exemplo n.º 11
0
 public TasksQzController(ITasksQzSvc tasksQzSvc, ISchedulerCenter schedulerCenter)
 {
     _tasksQzSvc      = tasksQzSvc;
     _schedulerCenter = schedulerCenter;
 }
Exemplo n.º 12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ITasksQzService tasksQzService, ISchedulerCenter schedulerCenter)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebAssemblyDebugging();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }
            app.UseErrorHandling();
            app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
            app.UseBlazorFrameworkFiles();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapControllers();
                endpoints.MapFallbackToFile("index.html");
            });
        }
Exemplo n.º 13
0
 public TasksQzController(ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter, IUnitOfWork unitOfWork)
 {
     _unitOfWork      = unitOfWork;
     _tasksQzServices = tasksQzServices;
     _schedulerCenter = schedulerCenter;
 }
Exemplo n.º 14
0
        public static void UseQuartzJobMiddleware(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 result = schedulerCenter.AddScheduleJobAsync(item).Result;
                            if (result.success)
                            {
                                Console.WriteLine($"QuartzNetJob{item.Name}启动成功!");
                            }
                            else
                            {
                                Console.WriteLine($"QuartzNetJob{item.Name}启动失败!错误信息:{result.msg}");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error($"An error was reported when starting the job service.\n{e.Message}");
                throw;
            }
        }
Exemplo n.º 15
0
        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;
            }
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
 //private static readonly ILog log = LogManager.GetLogger(typeof(QuartzJobMildd));
 public static void UseQuartzJobMildd(this IApplicationBuilder app, ITasksQzService tasksQzService, ISchedulerCenter schedulerCenter)
 {
     if (app == null)
     {
         throw new ArgumentNullException(nameof(app));
     }
     try
     {
         var allQzServices = tasksQzService.GetAsync().Result;
         foreach (var item in allQzServices)
         {
             if (item.IsStart)
             {
                 var ResuleModel = schedulerCenter.AddScheduleJobAsync(item).Result;
                 if (ResuleModel.success)
                 {
                     Console.WriteLine($"QuartzNetJob{item.Name}启动成功!");
                 }
                 else
                 {
                     Console.WriteLine($"QuartzNetJob{item.Name}启动失败!错误信息:{ResuleModel.msg}");
                 }
             }
         }
     }
     catch (Exception e)
     {
         //log.Error($"An error was reported when starting the job service.\n{e.Message}");
         throw;
     }
 }
Exemplo n.º 18
0
 public TaskQzController(IMapper mapper, ISysTaskQzService SysTaskQzService, ISchedulerCenter schedulerCenter)
 {
     _mapper           = mapper;
     _SysTaskQzService = SysTaskQzService;
     _schedulerCenter  = schedulerCenter;
 }
Exemplo n.º 19
0
 public JobController(ISchedulerCenter schedulerCenter)
 {
     _schedulerCenter = schedulerCenter;
 }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 用于配置整个HTTP请求的流程
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, MyContext myContext, ITasksQzBussiness tasksQzServices, ISchedulerCenter schedulerCenter, IHostApplicationLifetime lifetime, IWebHostEnvironment env)
        {
            // 查看注入的所有服务
            app.UseAllServicesMildd(_services);
            #region 判断环境

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();//使用HTTP严格安全传输
            }
            #endregion

            // 封装Swagger
            app.UseSwaggerMildd();

            // CORS跨域
            app.UseCors(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }));

            //用户构建HTTPS通道(将HTTP请求重定向到HTTPS中间件)
            //app.UseHttpsRedirection();

            // 使用静态文件
            app.UseStaticFiles();
            // 使用cookie
            //app.UseCookiePolicy();
            // 返回错误码
            app.UseStatusCodePages();
            // Routing
            app.UseRouting();

            //开启认证
            app.UseAuthentication();
            //开启授权
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
            //种子数据
            app.UseSeedDataMildd(myContext, Env.WebRootPath);
            // 开启QuartzNetJob调度服务
            app.UseQuartzJobMildd(tasksQzServices, schedulerCenter);
            //服务注册
            //app.UseConsulMildd(Configuration, lifetime);
        }