Activities68
Activities68

Reputation: 21

Add Job with Jobclass in quartz.net dynamic

i build a function to create a job in on quartz.net

The Classname, Jobname and Cronstring a in my application database. Now tihs function create a new job and trigger, but the class name are a string. I search with reflaction or equivalent to java with class.forname and i found no solution for my problem.

private void newJob(string JobName, string klasse, string parameter,string cronString)
{
        IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
        scheduler.Start();

        ???

        IJobDetail job = JobBuilder.Create<???> ().WithIdentity(Jobname, "group1").Build();
        ITrigger trigger = TriggerBuilder.Create()
        .
        .
        .

How can i the string "klasse" convert in a class and use it in the JobBuilder.create Statemant?

Upvotes: 0

Views: 2582

Answers (1)

Frank
Frank

Reputation: 483

There is an overload of JobBuilder.Create() that accepts a Type parameter, so you can do JobBuilder.Create(Type.GetType(klasse, true)) to create your job

Upvotes: 2

Related Questions