Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 public UserJob(ITB_UserBussiness _userBussiness, ITB_JobLogBussiness jobLogBussiness, ITasksQzBussiness tasksQzServices)
 {
     _JobLogBussiness = jobLogBussiness;
     _userbussiness   = _userBussiness;
     _tasksQzServices = tasksQzServices;
 }