/// <summary> /// 初始化 /// 包括 定时器的初始化 作业的初始化 配置的初始化 /// </summary> internal void Init() { #region 清空 if (mainTimer != null) { mainTimer.Stop(); mainTimer.Elapsed -= MainTimer_Elapsed; mainTimer.Dispose(); mainTimer = null; } mainTimer = new Timer { Interval = 1000, Enabled = false, }; if (taskModelList != null) { foreach (BaseJob item in taskModelList) { item.Dispose(); } } if (taskCollection != null) { foreach (Task item in taskCollection) { item.Dispose(); } } #endregion ReadConfig readConfig = new ReadConfig(); //判断是否有异常 if (readConfig.IsException) { return; } GlobalObject.RichTextLog.AppendTextByAsync("配置加载完成!", Color.Black); BaseJob model = null; //根据配置数量进行初始化作业 foreach (SourceConfig item in readConfig._SourceConfig) { foreach (TableConfig tableConfig in item.TableConfigList) { model = JobFactory.CreateJob(tableConfig); model.InitTask(); taskModelList.Add(model); } } GlobalObject.RichTextLog.AppendTextByAsync("任务初始化完成!", Color.Black); mainTimer.Elapsed += MainTimer_Elapsed; }