2016-11-18 135 views
2

我想测试Quartz.NET 3.0 for .NET Core的SQL数据库功能。不幸的是,我无法正确配置StdSchedulerFactory,我总是打电话​​当出现以下情况例外:提供者'SqlServer-20'没有元数据信息

var configuration = new NameValueCollection 
{ 
    { "quartz.jobStore.type", "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" }, 
    { "quartz.jobStore.driverDelegateType", "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz" }, 
    { "quartz.jobStore.tablePrefix", "QRTZ_" }, 
    { "quartz.jobStore.dataSource", "default" }, 
    { "quartz.dataSource.default.connectionString", "Server=(localdb)\\mssqllocaldb;Database=QuartzTest;Trusted_Connection=True;MultipleActiveResultSets=true" }, 
    { "quartz.dataSource.default.provider", "SqlServer-20" }, 
    { "quartz.jobStore.useProperties", "true" }, 
    { "quartz.serializer.type", "json" } 
}; 

var schedulerFactory = new StdSchedulerFactory(configuration); 

,你可以:

System.ArgumentOutOfRangeException: 
There is no metadata information for provider 'SqlServer-20' 
Parameter name: providerName 
    at Quartz.Impl.AdoJobStore.Common.DbProvider.GetDbMetadata(String providerName) 
    at Quartz.Impl.AdoJobStore.Common.DbProvider..ctor(String dbProviderName, String connectionString) 
    at Quartz.Impl.StdSchedulerFactory.<Instantiate>d__66.MoveNext() 

我用下列值配置的工厂看,我目前的目标是LocalDB(v12.0.2000)。我也在SQL Server Express上检查过它 - 结果相同。

如何避免此异常?

  • 我是否错过任何应该配置的属性?
  • 我必须为数据库提供一些数据吗?我只执行了tables_sqlServer.sql脚本。
  • SqlServer-20数据库驱动程序应该作为.NET 3.5的一部分安装,还是需要单独安装?
  • Quartz.NET目前不支持.NET Core的这个功能吗?我正在使用版本3.0.0-alpha2。
  • 我应该定位其他NuGet包吗?我引用的石英和Quartz.Serialization.Json

回答

2

我的一个朋友刚刚找到了答案:根据this example on Github,你必须在.NET核心项目使用SqlServer-41而不是SqlServer-20

0
// Grab the Scheduler instance from the Factory 
      NameValueCollection properties = new NameValueCollection 
      { 
       { "quartz.serializer.type", "binary" } 
      }; 
      properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz"; 
      properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz"; 
      properties["quartz.jobStore.dataSource"] = "default"; 
      properties["quartz.dataSource.default.connectionString"] = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=quartznet;Data Source=.\\sqlInstance;"; 
      properties["quartz.dataSource.default.provider"] = "SqlServer"; 
      properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz"; 
      properties["quartz.jobStore.useProperties"] = "true"; 
      properties["quartz.jobStore.tablePrefix"] = "QRTZ_"; 

      StdSchedulerFactory factory = new StdSchedulerFactory(properties); 
      IScheduler scheduler = await factory.GetScheduler();