/// <summary> /// 路由处理 /// </summary> /// <param name="isu">数据接口</param> /// <param name="sug">定时器,用于堵塞</param> public void routeProcess(ISrcUrl isu, SrcUrlGroupTimer sug) { if (isu.USEPARAM) { IMakeParam ip = isu as IMakeParam; List<AqiParam> paramList = ip.enumParams(); while (paramList == null || paramList.Count == 0) { bool bEvent = ThrowWaitEvent(isu.NAME + ":缺少参数,请输入以下参数", isu); if (bEvent) { //若接受事件 //由用户生成参数 //TEST等待用户输入参数 sug.Wait(); } else { //不接受事件则无法输入参数,忽略 ThrowEvent(RunMessage.RunType.TIP, isu.NAME + ":缺少参数,而且无法获取忽略此数据接口"); return; } } foreach (AqiParam ap in paramList) { getProcess(isu, ap); } } else { getProcess(isu, null); } }
//TODO 应该合并GetProcess /// <summary> /// /// 获取处理 /// </summary> /// <param name="isup"></param> /// <param name="sugt"></param> public void GetProcess(ISrcUrlParam isup, SrcUrlGroupTimer sugt) { //获取参数 List<AqiParam> list = null; ISrcUrl isu = isup as ISrcUrl; try { if (isup is ICacheParam) { ICacheParam icp = isup as ICacheParam; if (icp.IsParamsExpired()) { icp.LoadParams(); } list = icp.FilterParams(); } else { list = isup.EnumParams(); } } catch (Exception ex) { AqiManage.Remind.Log_Error("获取参数错误,错误严重无法继续", ex, this.name, sugt.Name, isu.Name); return; } //TODO //应该在检验参数 while ((list == null) || (list.Count == 0)) { if (isup.ParamIgnoreEmpty) { AqiManage.Remind.Log_Error("缺少参数,此数据接口在无参数是将被忽略", new string[] { this.name, sugt.Name, isu.Name }); return; } if (this.ThrowWaitEvent(isu.Name + ":缺少参数,请输入以下参数", isu)) { AqiManage.Remind.Log_Debug("缺少参数,进入等待", new string[] { this.name, sugt.Name, isu.Name }); sugt.Wait(); } else { AqiManage.Remind.Log_Error("缺少参数,而且无法获取忽略此数据接口", new string[] { this.name, sugt.Name, isu.Name }); return; } } foreach (AqiParam ap in list) { if (sugt.IsCancellationRequested) { break; } byte[] data = null; try { data = isup.GetData(ap); } catch (Exception ex) { AqiManage.Remind.Log_Error("数据获取失败,进入重试队列", ex, new string[] { this.name, sugt.Name, isu.Name }); this.ar.PutNew(this.name, isu, ap, ex); } this.SaveProcess(data, isu, ap); } }