public static StringWriter ShowListLabelNoPageIn(params string[] strString) { StringWriter output = new StringWriter(); try { string LableName = ""; XsltArgumentList argsList = new XsltArgumentList(); argsList.AddExtensionObject("WP:BaseClass", new BaseClass()); LableName = strString[0].Split('=')[1]; string XMLPath = BaseClass.GetListLabel() + LableName + ".config"; string LableSqlString = XMLExplainer.GetXMLValue("root", "LabelSqlString", XMLPath); string LabelSqlCount = XMLExplainer.GetXMLValue("root", "LabelSqlCount", XMLPath); string XsltString = XMLExplainer.GetXMLValue("root", "LabelTemplate", XMLPath); for (int i = 1; i < strString.Length; i++) { string strObject = strString[i]; string[] strObjects = strObject.Split('='); LableSqlString = LableSqlString.Replace("@" + strObjects[0], strObjects[1]); argsList.AddParam(strObjects[0], "", strObjects[1]); } DataTable DT = XMLExplainer.GetXMLValues("attributes", XMLPath); for (int i = 0; i < DT.Rows.Count; i++) { LableSqlString = LableSqlString.Replace("@" + DT.Rows[i]["name"].ToString(), DT.Rows[i]["default"].ToString()); string tempstring = (string)argsList.GetParam(DT.Rows[i]["name"].ToString(), ""); try { argsList.AddParam(DT.Rows[i]["name"].ToString(), "", DT.Rows[i]["default"].ToString()); } catch { continue; } } XDocument source = new XDocument(); XDocument newTree = new XDocument(); using (XmlWriter writer = newTree.CreateWriter()) { XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(XmlReader.Create(new StringReader(XsltString))); DataTable DTT = PersistenceLayer.Query.ProcessSql(LableSqlString, Names.DBName); DataSet DS = new DataSet(); DS.Tables.Add(DTT); string XmlStr = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"; XmlStr = XmlStr + DS.GetXml().ToString(); XmlDocument XmlDoc = new XmlDocument(); XmlDoc.LoadXml(XmlStr); XPathNavigator navgator = XmlDoc.CreateNavigator(); xslt.Transform(navgator, argsList, output); return(output); } } catch (Exception ex) { output.Write(ex.Message.ToString()); return(output); } }
/// <summary> /// 根据静态类样式展现HTML /// </summary> /// <returns></returns> public static StringWriter ShowStaticLabel(params string[] strString) { StringWriter output = new StringWriter(); try { string LableName = ""; XsltArgumentList argsList = new XsltArgumentList(); argsList.AddExtensionObject("WP:BaseClass", new BaseClass()); LableName = strString[0].Split('=')[1]; string XMLPath = BaseClass.GetStaticLabel() + LableName + ".config"; string XsltString = XMLExplainer.GetXMLValue("root", "LabelTemplate", XMLPath); for (int i = 1; i < strString.Length; i++) { string strObject = strString[i]; string[] strObjects = strObject.Split('='); argsList.AddParam(strObjects[0], "", strObjects[1]); } DataTable DT = XMLExplainer.GetXMLValues("attributes", XMLPath); for (int i = 0; i < DT.Rows.Count; i++) { string tempstring = (string)argsList.GetParam(DT.Rows[i]["name"].ToString(), ""); if ("".Equals(tempstring) || tempstring == null) { argsList.AddParam(DT.Rows[i]["name"].ToString(), "", DT.Rows[i]["default"].ToString()); } } XDocument source = new XDocument(); XDocument newTree = new XDocument(); using (XmlWriter writer = newTree.CreateWriter()) { XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(XmlReader.Create(new StringReader(XsltString))); XmlDocument XmlDoc = new XmlDocument(); XPathNavigator navgator = XmlDoc.CreateNavigator(); xslt.Transform(navgator, argsList, output); return(output); } } catch (Exception ex) { output.Write(ex.InnerException.ToString()); return(output); } }