Я использую Quartz Scheduling Framework 3.0.7v для моего приложения ASP.Net.Это код, который я использовал для сохранения новой работы в моем приложении.
#region SetProperties
public static NameValueCollection getProperties()
{
var properties = new NameValueCollection
{
// json serialization is the one supported under .NET Core (binary isn't)
["quartz.serializer.type"] = "json",
// the following setup of job store is just for example and it didn't change from v2
// according to your usage scenario though, you definitely need
// the ADO.NET job store and not the RAMJobStore.
["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz",
["quartz.jobStore.useProperties"] = "true",
["quartz.jobStore.dataSource"] = "sqlserver",
["quartz.jobStore.tablePrefix"] = "QRTZ_",
["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz",
//["quartz.dataSource.default.provider"] = "SqlServer-41", // SqlServer-41 is the new provider for .NET Core
["quartz.dataSource.sqlserver.provider"] = "SqlServer",
["quartz.dataSource.sqlserver.connectionString"] = @"Server=sever; Database = QUARTZ_TaskScheduling;Asynchronous Processing=true; Trusted_Connection = True;",
["quartz.threadPool.threadCount"] = "1",
};
return properties;
}
#endregion
#region SaveJob
public static int SaveJob(NewJob newJob, string companyCode)
{
var result = -1;
try
{
var properties = getProperties();
properties.Add("quartz.scheduler.instanceName", newJob.SCHED_NAME);
var schedulerFactory = new StdSchedulerFactory(properties);
_scheduler = schedulerFactory.GetScheduler().Result;
string jobType;
jobType = newJob.JOB_GROUP;
var Trigger = TriggerBuilder.Create()
.WithIdentity(newJob.JOB_NAME + " " + DateTime.Now.ToString("yyyy-MM-dd"))
.StartNow()
.WithCronSchedule(newJob.CRON_EXPRESSION)
.Build();
switch (jobType)
{
case "Job1":
var Job1 = JobBuilder.Create<Job1>()
.WithIdentity(newJob.JOB_NAME, newJob.JOB_GROUP)
.Build();
_scheduler.ScheduleJob(Job1, Trigger).Wait();
break;
case "Job2":
var Job2 = JobBuilder.Create<Job2>()
.WithIdentity(newJob.JOB_NAME, newJob.JOB_GROUP)
.Build();
_scheduler.ScheduleJob(Job2, Trigger).Wait();
break;
default:
Console.WriteLine("Error matching job type");
break;
}
}
catch (Exception ex)
{
result = -1;
Console.WriteLine("save job failed", ex.InnerException);
}
return result;
}
#endregion
Мой код работает отлично.QUARTZ_JOB_DETAILS, QUARTZ_TRIGGERS отлично вставляются в базу данных.Эти вставки сделаны библиотекой Quartz.Проблема в том, что я получаю Next_Fire_Time в качестве значения хеш-функции.Как я могу преобразовать это значение в читаемый человеком формат?
образец хеш-значения