예제 #1
0
        public async Task <Job_RPTEmailOutputDto> GetJob_RPTEmailById(long id)
        {
            var entity = await _Job_RPTEmailManager.GetJob_RPTEmailByIdAsync(id);

            return(entity.MapTo <Job_RPTEmailOutputDto>());
        }
예제 #2
0
        /// <summary>
        /// 执行一个调度
        /// </summary>
        /// <param name="quartzJobName">调度工作名称</param>
        /// <param name="quartzGroupName">调度组名称</param>
        /// <param name="quartzCronStr">调度时间</param>
        /// <param name="jobType">工作类型</param>
        /// <param name="jobId">工作ID</param>
        /// <param name="repeatCount">执行次数0为无线执行</param>
        public async void execScheduler(string quartzJobName,
                                        string quartzGroupName,
                                        string quartzCronStr,
                                        string jobType,
                                        long jobId,
                                        int repeatCount)
        {
            if (jobType == "BGJM_JOB_RPTEMAIL")
            {
                var jobEmail = await _Job_RPTEmailManager.GetJob_RPTEmailByIdAsync(jobId);

                JobDataMap jobDM = new JobDataMap();
                jobDM.Add("jobName", jobEmail.Job_RPTEmailName);
                jobDM.Add("jobType", jobType);
                jobDM.Add("jobId", jobEmail.Id);

                jobDM.Add("rptId", jobEmail.Template_Id);
                jobDM.Add("emails", jobEmail.Emails);
                jobDM.Add("paramters", jobEmail.Parameters);
                jobDM.Add("job_RPTEmailName", jobEmail.Job_RPTEmailName);

                //执行次数
                if (repeatCount == -1)
                {
                    _jobManager.RunJob <RPTEmailJob>(
                        job =>
                    {
                        job.WithIdentity(quartzJobName, quartzGroupName).SetJobData(jobDM);
                    },
                        trigger =>
                    {
                        trigger.StartNow()
                        .WithIdentity(quartzJobName, quartzGroupName)
                        .WithCronSchedule(quartzCronStr);
                    });
                }
                else
                {
                    _jobManager.RunJob <RPTEmailJob>(
                        job =>
                    {
                        job.WithIdentity(quartzJobName, quartzGroupName).SetJobData(jobDM);
                    },
                        trigger =>
                    {
                        trigger.StartNow()
                        .WithIdentity(quartzJobName, quartzGroupName)
                        .WithSimpleSchedule(schedule =>
                        {
                            schedule.WithRepeatCount(repeatCount)
                            .WithIntervalInSeconds(1)   //立即执行
                            .Build();
                        });
                    });
                }
            }
            if (jobType == "BGJM_JOB_SQL")
            {
                var jobSql = await _Job_SqlManager.GetJob_SqlByIdAsync(jobId);

                JobDataMap jobDM = new JobDataMap();
                jobDM.Add("jobName", jobSql.Job_SqlName);
                jobDM.Add("jobType", jobType);
                jobDM.Add("jobId", jobSql.Id);

                jobDM.Add("connkeyName", jobSql.ConnkeyName);
                jobDM.Add("commandType", jobSql.CommandType);
                jobDM.Add("commandText", jobSql.CommandText);
                jobDM.Add("paramters", jobSql.Paramters);

                if (repeatCount == -1)
                {
                    _jobManager.RunJob <SQLJob>(
                        job =>
                    {
                        job.WithIdentity(quartzJobName, quartzGroupName).SetJobData(jobDM);
                    },
                        trigger =>
                    {
                        trigger.StartNow()
                        .WithIdentity(quartzJobName, quartzGroupName)
                        .WithCronSchedule(quartzCronStr);
                    });
                }
                else
                {
                    _jobManager.RunJob <SQLJob>(
                        job =>
                    {
                        job.WithIdentity(quartzJobName, quartzGroupName).SetJobData(jobDM);
                    },
                        trigger =>
                    {
                        trigger.StartNow()
                        .WithIdentity(quartzJobName, quartzGroupName)
                        .WithSimpleSchedule(schedule =>
                        {
                            schedule.WithRepeatCount(repeatCount)
                            .WithIntervalInSeconds(1)       //立即执行
                            .Build();
                        });
                    });
                }
            }
        }