/// <summary> /// 读取参数列表 /// 从 SrcUrl 接口 /// </summary> /// <param name="iParseSrcUrlParam">实现IParseSrcUrlParam的SrcUrl</param> /// <param name="relySrcUrl">参数来源SrcUrl</param> /// <returns></returns> public static List <AqiParam> CreateListFormSrcUrl(IParseSrcUrlParam iParseSrcUrlParam, ISrcUrl relySrcUrl) { List <AqiParam> listParam = new List <AqiParam>(); //TODO 应该将 runner的处理过程公开,交由Runner处理,公用代码,考虑将Process处理函数静态化 try { if (relySrcUrl is ISrcUrlParam) { ISrcUrlParam isup = relySrcUrl as ISrcUrlParam; List <AqiParam> list = null; if (isup is ICacheParam) { ICacheParam icp = isup as ICacheParam; if (icp.IsParamsExpired()) { icp.LoadParams(); } list = icp.FilterParams(); } else { list = isup.EnumParams(); } if ((list == null) || (list.Count == 0)) { throw new ParamException("缺少参数"); } foreach (AqiParam ap in list) { byte[] data = data = isup.GetData(ap); List <AqiParam> aps = iParseSrcUrlParam.ParseParam(data); listParam.AddRange(aps); } } else { byte[] data = relySrcUrl.GetData(); List <AqiParam> aps = iParseSrcUrlParam.ParseParam(data); listParam.AddRange(aps); } } catch (System.Exception ex) { throw new ParamException("参数创建错误", ex); } return(listParam); }
//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); } }