|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Quartz; |
|
|
|
using Quartz.Impl; |
|
|
|
using Quartz.Impl.AdoJobStore.Common; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
using Volo.Abp.Threading; |
|
|
|
@ -15,37 +16,35 @@ namespace Volo.Abp.Quartz |
|
|
|
{ |
|
|
|
var options = context.Services.ExecutePreConfiguredActions<AbpQuartzOptions>(); |
|
|
|
|
|
|
|
// todo: Remove this once Pomelo update MySqlConnector to >= 1.0.0 : https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/pull/1103
|
|
|
|
var mySqlAvailable = System.Type.GetType("MySql.Data.MySqlClient.MySqlConnection, MySqlConnector") != null; |
|
|
|
if (mySqlAvailable) |
|
|
|
{ |
|
|
|
// Overriding the default 'MySqlConnector' provider to use the old 'MySql.Data' namespace found in MySqlConnector < 1.0.0
|
|
|
|
DbProvider.RegisterDbMetadata("MySqlConnector", new DbMetadata() |
|
|
|
{ |
|
|
|
ProductName = "MySQL, MySqlConnector provider", |
|
|
|
AssemblyName = "MySqlConnector", |
|
|
|
ConnectionType = System.Type.GetType("MySql.Data.MySqlClient.MySqlConnection, MySqlConnector"), |
|
|
|
CommandType = System.Type.GetType("MySql.Data.MySqlClient.MySqlCommand, MySqlConnector"), |
|
|
|
ParameterType = System.Type.GetType("MySql.Data.MySqlClient.MySqlParameter, MySqlConnector"), |
|
|
|
ParameterDbType = System.Type.GetType("MySql.Data.MySqlClient.MySqlDbType, MySqlConnector"), |
|
|
|
ParameterDbTypePropertyName = "MySqlDbType", |
|
|
|
ParameterNamePrefix = "?", |
|
|
|
ExceptionType = System.Type.GetType("MySql.Data.MySqlClient.MySqlException, MySqlConnector"), |
|
|
|
BindByName = true, |
|
|
|
DbBinaryTypeName = "Blob" |
|
|
|
}); |
|
|
|
} |
|
|
|
// TODO: Remove this once Pomelo update MySqlConnector to >= 1.0.0 : https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/pull/1103
|
|
|
|
AdaptMysqlConnector(); |
|
|
|
|
|
|
|
context.Services.AddQuartz(options.Properties, build => |
|
|
|
{ |
|
|
|
build.UseMicrosoftDependencyInjectionScopedJobFactory(); |
|
|
|
// these are the defaults
|
|
|
|
build.UseSimpleTypeLoader(); |
|
|
|
build.UseInMemoryStore(); |
|
|
|
build.UseDefaultThreadPool(tp => |
|
|
|
if (options.Properties[StdSchedulerFactory.PropertySchedulerJobFactoryType] == null) |
|
|
|
{ |
|
|
|
tp.MaxConcurrency = 10; |
|
|
|
}); |
|
|
|
build.UseMicrosoftDependencyInjectionScopedJobFactory(); |
|
|
|
} |
|
|
|
|
|
|
|
if (options.Properties[StdSchedulerFactory.PropertySchedulerTypeLoadHelperType] == null) |
|
|
|
{ |
|
|
|
build.UseSimpleTypeLoader(); |
|
|
|
} |
|
|
|
|
|
|
|
if (options.Properties[StdSchedulerFactory.PropertyJobStoreType] == null) |
|
|
|
{ |
|
|
|
build.UseInMemoryStore(); |
|
|
|
} |
|
|
|
|
|
|
|
if (options.Properties[StdSchedulerFactory.PropertyThreadPoolType] == null) |
|
|
|
{ |
|
|
|
build.UseDefaultThreadPool(tp => |
|
|
|
{ |
|
|
|
tp.MaxConcurrency = 10; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
options.Configurator?.Invoke(build); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -77,5 +76,28 @@ namespace Volo.Abp.Quartz |
|
|
|
AsyncHelper.RunSync(() => _scheduler.Shutdown()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void AdaptMysqlConnector() |
|
|
|
{ |
|
|
|
var mySqlAvailable = System.Type.GetType("MySql.Data.MySqlClient.MySqlConnection, MySqlConnector") != null; |
|
|
|
if (mySqlAvailable) |
|
|
|
{ |
|
|
|
// Overriding the default 'MySqlConnector' provider to use the old 'MySql.Data' namespace found in MySqlConnector < 1.0.0
|
|
|
|
DbProvider.RegisterDbMetadata("MySqlConnector", new DbMetadata() |
|
|
|
{ |
|
|
|
ProductName = "MySQL, MySqlConnector provider", |
|
|
|
AssemblyName = "MySqlConnector", |
|
|
|
ConnectionType = System.Type.GetType("MySql.Data.MySqlClient.MySqlConnection, MySqlConnector"), |
|
|
|
CommandType = System.Type.GetType("MySql.Data.MySqlClient.MySqlCommand, MySqlConnector"), |
|
|
|
ParameterType = System.Type.GetType("MySql.Data.MySqlClient.MySqlParameter, MySqlConnector"), |
|
|
|
ParameterDbType = System.Type.GetType("MySql.Data.MySqlClient.MySqlDbType, MySqlConnector"), |
|
|
|
ParameterDbTypePropertyName = "MySqlDbType", |
|
|
|
ParameterNamePrefix = "?", |
|
|
|
ExceptionType = System.Type.GetType("MySql.Data.MySqlClient.MySqlException, MySqlConnector"), |
|
|
|
BindByName = true, |
|
|
|
DbBinaryTypeName = "Blob" |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|