public static IMvcBuilder AddSchedulerNet(this IMvcBuilder builder, Action <ISchedulerOptions> setupAction)
        {
            var schedulerOptions = new SchedulerOptions();

            setupAction(schedulerOptions);

            builder.Services.AddHttpClient();
            builder.Services.AddSignalR();

            builder.AddMvcOptions(options => options.Filters.Add <HttpGlobalExceptionFilter>());

            builder.Services.AddSingleton <ISchedulerOptions>(schedulerOptions);
            builder.Services.AddTransient <IJobManager <CallbackJob>, HangFireCallbackJobManager>();
            builder.Services.AddTransient <IJobManager <Job>, HangFireJobManager>();
            builder.Services.AddHangfire(config => { });
            switch (schedulerOptions.HangfireStorageType.ToLower())
            {
            case "sqlserver":
            {
                GlobalConfiguration.Configuration.UseStorage(new SqlServerStorage(schedulerOptions.HangfireConnectionString));
                break;
            }

            case "redis":
            {
                GlobalConfiguration.Configuration.UseStorage(new RedisStorage(schedulerOptions.HangfireConnectionString));
                break;
            }

            case "mysql":
            {
                builder.Services.AddHangfire(r => { });
                GlobalConfiguration.Configuration.UseStorage(
                    new MySqlStorage(
                        schedulerOptions.HangfireConnectionString,
                        new MySqlStorageOptions
                    {
                        TransactionIsolationLevel  = IsolationLevel.ReadCommitted,
                        QueuePollInterval          = TimeSpan.FromSeconds(2),
                        JobExpirationCheckInterval = TimeSpan.FromHours(1),
                        CountersAggregateInterval  = TimeSpan.FromMinutes(5),
                        PrepareSchemaIfNecessary   = true,
                        DashboardJobListLimit      = 50000,
                        TransactionTimeout         = TimeSpan.FromMinutes(1),
                    }));
                break;
            }
            }

            InitDatabase(schedulerOptions);
            return(builder);
        }
        public static IMvcBuilder AddSchedulerNet(this IMvcBuilder builder, Action <ISchedulerOptions> configOptions)
        {
            ISchedulerOptions options = new SchedulerOptions();

            configOptions(options);

            builder.Services.AddHttpClient();
            builder.AddMvcOptions(o => o.Filters.Add <HttpGlobalExceptionFilter>());

            builder.Services.AddSingleton(options);
            builder.Services.AddTransient <IJobManager <CallbackJob>, HangFireCallbackJobManager>();
            builder.Services.AddTransient <IJobManager <Job>, HangFireJobManager>();

            var signalRbuilder = builder.Services.AddSignalR();

            switch (options.Cache.Type)
            {
            case StorageType.Redis:
            {
                builder.Services.AddSingleton <ISchedulerNetCache, RedisSchedulerNetCache>();
                signalRbuilder.AddRedis(options.Cache.ConnectionString);
                break;
            }

            case StorageType.Memory:
            {
                builder.Services.AddSingleton <ISchedulerNetCache, MemorySchedulerNetCache>();
                break;
            }

            default:
            {
                throw new NotImplementedException($"{options.Cache.Type} cache");
            }
            }

            builder.Services.AddHangfire(config => { });

            switch (options.Hangfire.StorageType)
            {
            case StorageType.Memory:
            {
                GlobalConfiguration.Configuration.UseStorage(new MemoryStorage());
                break;
            }

            case StorageType.SqlServer:
            {
                var sssOptions = new SqlServerStorageOptions()
                {
                    SchemaName = options.Hangfire.SchemaName
                };
                GlobalConfiguration.Configuration.UseStorage(new SqlServerStorage(options.Hangfire.ConnectionString, sssOptions));
                break;
            }

            case StorageType.Redis:
            {
                GlobalConfiguration.Configuration.UseStorage(new RedisStorage(options.Hangfire.ConnectionString));
                break;
            }

            case StorageType.MySql:
            {
                GlobalConfiguration.Configuration.UseStorage(new MySqlStorage(options.Hangfire.ConnectionString));
                break;
            }
            }
            //创建计划数据库
            InitSchedulerNetDatabase(options);
            return(builder);
        }