示例#1
0
 public override void Start()
 {
     QuartzScheduleJobManager.ScheduleAsync <InsertNewsJob>(
         job =>
     {
         job.WithDescription("InsertNewsJob")
         .WithIdentity(GetServiceIdentity(), ServiceGroupName);
     }, Trigger);
 }
示例#2
0
        /// <summary>
        /// 配置循环拉取
        /// </summary>
        /// <returns></returns>
        private static void Looppull()
        {
            if (!_configoptionDto.IsUseConfigManage)
            {
                return;
            }
            QuartzScheduleJobManager JobMange = new QuartzScheduleJobManager();

            if (_configoptionDto.IsEnableLooppull)
            {
                JobMange.ScheduleAsync <LooppullBackgroundJob>(job =>
                {
                    job.WithIdentity("LooppullConfig", "LooppullJob")
                    .UsingJobData("ConPath", "App/EnvConfig/" + _configoptionDto.APPKey + "/" + _configoptionDto.ENVKey + "/")
                    .UsingJobData("ConHost", _configoptionDto.ConsulHost)
                    .UsingJobData("ConDataCenter", _configoptionDto.ConsulDataCenter)
                    .UsingJobData("ConTimeOut", _configoptionDto.ConsulTimeOut)
                    .UsingJobData("ConWaitTime", _configoptionDto.ConsulWaitTime);
                }, trigger =>
                {
                    trigger.WithIdentity("LooppullTri" + Guid.NewGuid().ToString(), "LooppullTrigger")
                    .StartNow()
                    .WithSimpleSchedule(x => x.WithIntervalInMinutes(1).RepeatForever());
                });
            }
            else
            {
                JobMange.ScheduleAsync <LooppullBackgroundJob>(job =>
                {
                    job.WithIdentity("LooppullConfig", "LooppullJob")
                    .UsingJobData("ConPath", "App/EnvConfig/" + _configoptionDto.APPKey + "/" + _configoptionDto.ENVKey + "/")
                    .UsingJobData("ConHost", _configoptionDto.ConsulHost)
                    .UsingJobData("ConDataCenter", _configoptionDto.ConsulDataCenter)
                    .UsingJobData("ConTimeOut", _configoptionDto.ConsulTimeOut)
                    .UsingJobData("ConWaitTime", _configoptionDto.ConsulWaitTime);
                }, trigger =>
                {
                    trigger.WithIdentity("LooppullTri" + Guid.NewGuid().ToString(), "LooppullTrigger")
                    .StartNow();
                });
            }
        }