/// <summary> /// 构造函数 /// </summary> private QuartzDataHandler() { if (_scheduler == null) { string quartzServer = WebConfigHelper.GetAppSettingValue("QuartzServer"); if (string.IsNullOrEmpty(quartzServer)) { quartzServer = "tcp://127.0.0.1:7005"; } NameValueCollection properties = new NameValueCollection(); properties["quartz.scheduler.instanceName"] = "RemoteQuartzClient"; properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz"; properties["quartz.threadPool.threadCount"] = "5"; properties["quartz.threadPool.threadPriority"] = "Normal"; //远程调度配置 properties["quartz.scheduler.proxy"] = "true"; properties["quartz.scheduler.proxy.address"] = string.Format("{0}/QuartzScheduler", quartzServer); try { ISchedulerFactory schedulerFactory = new StdSchedulerFactory(properties); IScheduler scheduler = schedulerFactory.GetScheduler(); if (scheduler != null) { _scheduler = new DefaultScheduler(scheduler); _scheduler.StartScheduler(); _data = _scheduler.Data; } } catch (Exception ex) { } } }
/// <summary> /// 构造函数 /// </summary> /// <returns></returns> public static QuartzDataHandler GetInstance() { if (_instance == null) { _instance = new QuartzDataHandler(); } else if (_scheduler != null) { _data = _scheduler.Data; } return(_instance); }