Пример #1
0
        public void RunOnce(string id)
        {
            var data      = GetData(id);
            var paramList = new Dictionary <string, object>()
            {
                { "Entity", data },
                { "User", UserIdentityUtil.GetAdmin() }
            };

            JobHelpers.RunOnceNow(data.name, data.robotidName, paramList);
            var jobState = JobHelpers.GetJobStatus(data.name, data.robotidName).ToSelectOption();

            data.job_state     = jobState.Value.ToString();
            data.job_stateName = jobState.Name;
            UpdateData(data);
        }
Пример #2
0
        /// <summary>
        /// 注册job
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <param name="group"></param>
        /// <param name="param"></param>
        /// <param name="cronExperssion"></param>
        public static void RegisterJob(DynamicJobBase job, BaseEntity entity, TriggerState state)
        {
            StartService();

            if (sched.CheckExists(job.JobKey).Result)
            {
                return;
            }

            var jobDetail = job.GetJobBuilder().Build();

            jobDetail.JobDataMap.Add("Entity", entity);
            jobDetail.JobDataMap.Add("User", UserIdentityUtil.GetAdmin());

            ITrigger trigger = job.GetTriggerBuilder()
                               .Build();

            sched.ScheduleJob(jobDetail, trigger).Wait();

            if (state == TriggerState.Paused)
            {
                sched.PauseTrigger(trigger.Key);
            }
        }