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;
            }
        }
Пример #2
0
        public async Task Run(IJobExecutionContext context, int jobid)
        {
            //自己的业务
            var list = await _userbussiness.QueryAsync();


            if (jobid > 0)
            {
                //任务的业务,次数
                var model = await _tasksQzServices.QueryAsync(jobid);

                if (model != null)
                {
                    model.RunTimes += 1;
                    await _tasksQzServices.UpdateAsync(model);
                }
            }

            await Console.Out.WriteLineAsync("用户总数量" + list.Count.ToString());
        }