如何使用ASP.Net以人类可读的格式获取Quart Next_Fire_Time

时间:2018-12-28 10:41:33

标签: quartz.net quartz

我正在为我的ASP.Net应用程序使用 Quartz Scheduling Framework (石英计划框架)3.0.7v。这是我用来在应用程序中保存新工作的代码。

#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 作为哈希值。如何将该值转换为人类可读的格式?

hash value sample

0 个答案:

没有答案