/// <summary> /// 根据参数Xml文档列表生成指定段名的宏变量参数: /// </summary> /// <param name="xmldoc">文档参数</param> /// <param name="bandName">段名称</param> /// <returns>返回参数</returns> static public NameObjectList BuildParamMacro(XmlDocument xmldoc, string bandName) { if (string.IsNullOrEmpty(bandName)) { return(BuildParams(xmldoc)); } string strPath = "/*/PL[(@t='{0}' and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/P[@pt='M']"; string strPass = "******"; NameObjectList paramList = new NameObjectList(); for (int i = _typerange.Length - 1; i > -1; i--) { for (int j = _typeuser.Length - 1; j > -1; j--) { string strFind = string.Format(strPath, _typerange[i], _typeuser[j], bandName); XmlNodeList xnlist = xmldoc.SelectNodes(strFind); foreach (XmlNode xnP in xnlist) { if (null == xnP.Attributes["n"]) { continue; } string key = xnP.Attributes["n"].Value; bool isParam = true; for (int m = i; m > -1; m--) { for (int n = j - 1; n > -1; n--) { string strFindPass = string.Format(strPass, _typerange[m], _typeuser[n], key, bandName); XmlNode xnPtemp = xnP.SelectSingleNode(strFindPass); if (null != xnPtemp) { isParam = false; break; } } if (!isParam) { break; } } //增加到参数列表 if (isParam) { BuildParamList.setParamByParamNode(paramList, xnP); } }//foreach (XmlNode xnP in xnlist) } } return(paramList); }
/// <summary> /// 根据参数Xml文档列表生成指定段对应参数:数组List只限定于PL[@t='B']/L[@='D']/List /// </summary> /// <param name="xmldoc">文档参数</param> /// <param name="bandName">段名称</param> /// <returns>返回参数数组</returns> static public NameObjectList[] BuildParamsList(XmlDocument xmldoc, string bandName) { if (string.IsNullOrEmpty(bandName)) { return(BuildParamsList(xmldoc)); } string strPath = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/P[not(@pt) or @pt!='M']"; string strPath2 = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/List/P"; string strPass = "******"; string strPass2 = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{3}')]/L[@t='{1}']/List/P[@n='{2}']"; NameObjectList paramList = new NameObjectList(); for (int i = _typerange.Length - 1; i > -1; i--) { for (int j = _typeuser.Length - 1; j > -1; j--) { string strFind = string.Format(strPath, _typerange[i], _typeuser[j], bandName); if (null != xmldoc.SelectSingleNode(string.Format(strPath2, _typerange[i], _typeuser[j], bandName))) { continue; } XmlNodeList xnlist = xmldoc.SelectNodes(strFind); foreach (XmlNode xnP in xnlist) { if (null == xnP.Attributes["n"]) { continue; } string key = xnP.Attributes["n"].Value; bool isParam = true; for (int m = i; m > -1; m--) { for (int n = j - 1; n > -1; n--) { string strFindPass = string.Format(strPass, _typerange[m], _typeuser[n], key, bandName); XmlNode xnPtemp = xnP.SelectSingleNode(strFindPass); if (null != xnPtemp) { isParam = false; break; } string strFindPass2 = string.Format(strPass2, _typerange[m], _typeuser[n], key, bandName); xnPtemp = xnP.SelectSingleNode(strFindPass2); if (null != xnPtemp) { isParam = false; break; } } if (!isParam) { break; } } //增加到参数列表 if (isParam) { BuildParamList.setParamByParamNode(paramList, xnP); } }//foreach (XmlNode xnP in xnlist) } } strPath2 = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/List"; string strFind2 = string.Format(strPath2, "B", "D", bandName); XmlNodeList xnlistList = xmldoc.SelectNodes(strFind2); NameObjectList[] param = new NameObjectList[xnlistList.Count]; for (int i = 0; i < xnlistList.Count; i++) { param[i] = new NameObjectList(); for (int k = 0; k < paramList.Count; k++) { param[i][paramList.Keys[k]] = paramList[k]; } XmlNodeList xnlist = xnlistList[i].SelectNodes("P"); foreach (XmlNode xnP in xnlist) { BuildParamList.setParamByParamNode(param[i], xnP); } } return(param); }