Esempio n. 1
0
        public async Task Execute(IJobExecutionContext context)
        {
            DateTime dateTime = DateTime.Now;
            var      jobKey   = context.JobDetail.Key;
            var      jobId    = jobKey.Name;
            var      model    = await _tasksQzServices.GetAsync(jobId.ObjToInt());

            var executeLog = await ExecuteJob(context, async() => await Run(context, jobId.ObjToInt()));
        }
Esempio n. 2
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;
     }
 }
Esempio n. 3
0
        public async Task <string> Run(IJobExecutionContext context, int jobid)
        {
            if (jobid > 0)
            {
                var model = await _tasksQzServices.GetAsync(jobid);

                if (model != null)
                {
                    model.RunTimes += 1;
                    await _tasksQzServices.UpdateAsync(model);
                }
            }
            await Console.Out.WriteLineAsync("你好!我是测试Demo1");

            return("你好!我是测试Demo1");
        }
        public async Task <List <TasksQzDto> > Get()
        {
            var allQzServices = await _tasksQzService.GetAsync();

            return(_mapper.Map <List <TasksQzDto> >(allQzServices));
        }