2016-11-18 51 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(); 
相關問題