生成一段c sharp rgv调度代码 
时间: 2023-03-14 14:32:20 浏览: 30
string sqldataSource = ConfigurationManager.AppSettings["DataSource"];
using (SqlConnection connection = new SqlConnection(sqldataSource))
{
connection.Open();
SqlCommand command = new SqlCommand("Select * from Scheduler", connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
string jobName = reader["JobName"].ToString();
string jobGroup = reader["JobGroup"].ToString();
string jobDescription = reader["JobDescription"].ToString();
string jobTypeName = reader["JobTypeName"].ToString();
string jobDataMap = reader["JobDataMap"].ToString();
string triggerName = reader["TriggerName"].ToString();
string triggerGroup = reader["TriggerGroup"].ToString();
string triggerDescription = reader["TriggerDescription"].ToString();
string triggerTypeName = reader["TriggerTypeName"].ToString();
string triggerStartTime = reader["TriggerStartTime"].ToString();
string triggerEndTime = reader["TriggerEndTime"].ToString();
string cronExpression = reader["CronExpression"].ToString();
string priority = reader["Priority"].ToString();
string misfireInstruction = reader["MisfireInstruction"].ToString();
string repeatInterval = reader["RepeatInterval"].ToString();
string repeatCount = reader["RepeatCount"].ToString();
string timeZoneId = reader["TimeZoneId"].ToString(); IJobDetail job = JobBuilder.Create(Type.GetType(jobTypeName))
.WithIdentity(jobName, jobGroup)
.WithDescription(jobDescription)
.Build(); job.JobDataMap.PutAll(JobDataMap.FromString(jobDataMap)); ITrigger trigger = null;
if (triggerTypeName == typeof(CronTriggerImpl).Name)
{
trigger = TriggerBuilder.Create()
.WithIdentity(triggerName, triggerGroup)
.WithDescription(triggerDescription)
.WithCronSchedule(cronExpression, x => x.WithMisfireHandlingInstructionDoNothing().InTimeZone(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId)))
.ForJob(jobName, jobGroup)
.Build();
}
else if (triggerTypeName == typeof(SimpleTriggerImpl).Name)
{
trigger = TriggerBuilder.Create()
.WithIdentity(triggerName, triggerGroup)
.WithDescription(triggerDescription)
.StartAt(DateTime.Parse(triggerStartTime))
.EndAt(DateTime.Parse(triggerEndTime))
.WithSimpleSchedule(x => x.WithIntervalInSeconds(int.Parse(repeatInterval))
.WithRepeatCount(int.Parse(repeatCount))
.WithMisfireHandlingInstructionFireNow())
.ForJob(jobName, jobGroup)
.Build();
} await scheduler.ScheduleJob(job, trigger);
}
reader.Close();
connection.Close();
}答:使用CSharp编写的RGV调度代码如下:string sqldataSource = ConfigurationManager.AppSettings["DataSource"];
using (SqlConnection connection = new SqlConnection(sqldataSource))
{
connection.Open();
SqlCommand command = new SqlCommand("Select * from Scheduler", connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
string jobName = reader["JobName"].ToString();
string jobGroup = reader["JobGroup"].ToString();
string jobDescription = reader["JobDescription"].ToString();
string jobTypeName = reader["JobTypeName"].ToString();
string jobDataMap = reader["JobDataMap"].ToString();
string triggerName = reader["TriggerName"].ToString();
string triggerGroup = reader["TriggerGroup"].ToString();
string triggerDescription = reader["TriggerDescription"].ToString();
string triggerTypeName = reader["TriggerTypeName"].ToString();
string triggerStartTime = reader["TriggerStartTime"].ToString();
string triggerEndTime = reader["TriggerEndTime"].ToString();
string cronExpression = reader["CronExpression"].ToString();
string priority = reader["Priority"].ToString();
string misfireInstruction = reader["MisfireInstruction"].ToString();
string repeatInterval = reader["RepeatInterval"].ToString();
string repeatCount = reader["RepeatCount"].ToString();
string timeZoneId = reader["TimeZoneId"].ToString(); IJobDetail job = JobBuilder.Create(Type.GetType(jobTypeName))
.WithIdentity(jobName, jobGroup)
.WithDescription(jobDescription)
.Build(); job.JobDataMap.PutAll(JobDataMap.FromString(jobDataMap)); ITrigger trigger = null;
if (triggerTypeName == typeof(CronTriggerImpl).Name)
{
trigger = TriggerBuilder.Create()
.WithIdentity(triggerName, triggerGroup)
.WithDescription(triggerDescription)
.WithCronSchedule(cronExpression, x => x.WithMisfireHandlingInstructionDoNothing().InTimeZone(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId)))
.ForJob(jobName, jobGroup)
.Build();
}
else if (triggerTypeName == typeof(SimpleTriggerImpl).Name)
{
trigger = TriggerBuilder.Create()
.WithIdentity(triggerName, triggerGroup)
.WithDescription(triggerDescription)
.StartAt(DateTime.Parse(triggerStartTime))
.EndAt(DateTime.Parse(triggerEndTime))
.WithSimpleSchedule(x => x.WithIntervalInSeconds(int.Parse(repeatInterval))
.WithRepeatCount(int.Parse(repeatCount))
.WithMisfireHandlingInstructionFireNow())
.ForJob(jobName, jobGroup)
.Build();
} await scheduler.ScheduleJob(job, trigger);
}
reader.Close();
connection.Close();
}
相关推荐




