public IJobDetail BuildQuartzJob( ServiceJob job )
{
// build the type object, will depend if the class is in an assembly or the App_Code folder
Type type = null;
if ( string.IsNullOrWhiteSpace(job.Assembly) )
{
// first, if no assembly is known, look in all the dlls for it
type = Rock.Reflection.FindType( typeof( Quartz.IJob ), job.Class );
if (type == null)
{
// if it can't be found in dlls, look in App_Code using BuildManager
type = BuildManager.GetType( job.Class, false );
}
}
else
{
// if an assembly is specified, load the type from that
string thetype = string.Format( "{0}, {1}", job.Class, job.Assembly );
type = Type.GetType( thetype );
}
// load up job attributes (parameters)
job.LoadAttributes();
JobDataMap map = new JobDataMap();
foreach ( var attrib in job.AttributeValues )
{
map.Add( attrib.Key, attrib.Value.Value );
}
// create the quartz job object
IJobDetail jobDetail = JobBuilder.Create( type )
.WithDescription( job.Id.ToString() )
.WithIdentity( job.Guid.ToString(), job.Name )
.UsingJobData( map )
.Build();
return jobDetail;
}