/// <summary> /// 合并timer /// </summary> /// <param name="runner"></param> public void Union(AqiRunner runner) { foreach (SrcUrlGroupTimer timer in runner.sugtlist.Values) { Add(timer); } }
/// <summary> /// 初始化运行者 /// </summary> private void initRunner() { //读取配置文件,独立或合并 RunMode rm = (RunMode)Enum.Parse(typeof(RunMode), AqiManage.Setting["RunMode"]); switch (rm) { case RunMode.SELF: runnerlist = new Dictionary<string, AqiRunner>(); foreach(IAqiWeb iaw in allAqiWebs.Values) { AqiRunner ar = new AqiRunner(this, iaw.getAllSrcUrl(), iaw.TAG + "_Runner"); runnerlist.Add(ar.Name, ar); } break; case RunMode.JOINT: default: aqiRunner = new AqiRunner(this, allSrcUrls); aqiRunner.RunEvent += new AqiRunner.RunEventHandler(aqiRunner_RunEvent); break; } }
/// <summary> /// 添加 数据源 /// </summary> /// <param name="iaw">数据源</param> public void AddAqiWeb(IAqiWeb iaw) { thisLock.EnterUpgradeableReadLock(); { if (allAqiWebs.ContainsKey(iaw.TAG)) { //移出旧数据 ThrowEvent(RunMessage.RunType.TIP, "数据源已经存在,进行更新:" + iaw.TAG); allAqiWebs.Remove(iaw.TAG); } //1添加到All集合 Dictionary<string, ISrcUrl> temp = iaw.getAllSrcUrl(); thisLock.EnterWriteLock(); { //添加到列表 allAqiWebs.Add(iaw.TAG, iaw); allSrcUrls = allSrcUrls.Concat(temp).ToDictionary(x => x.Key, x => x.Value); } thisLock.ExitWriteLock(); //2应用到具体的Runner AqiRunner runner = this[iaw.TAG + "_Runner"]; if (runner == null) { //独立模式&&不存在 runner = new AqiRunner(this, temp, iaw.TAG + "_Runner"); //新添加 Add(runner); } else { //只给数据 runner.AddSrcUrl(temp); } } thisLock.ExitUpgradeableReadLock(); }
/// <summary> /// 添加runner /// </summary> /// <param name="runner"></param> public void Add(AqiRunner runner) { if (runnerlist.ContainsKey(runner.Name)) { runnerlist[runner.Name].Union(runner); } else { runnerlist.Add(runner.Name, runner); runner.RunAll(); } }