Exemplo n.º 1
0
        /// <summary>
        /// Write the dataset to the stream using the specified format.
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="source"></param>
        /// <param name="format"></param>
		public static void Write(System.IO.Stream destination, System.Data.DataSet source, StreamDataSetFormat format)
		{
			switch (format)
			{
				case StreamDataSetFormat.XML:
					source.WriteXml(destination, System.Data.XmlWriteMode.WriteSchema);
					break;
				case StreamDataSetFormat.Binary:
					BinWriteDataSetToStream(destination, source);
					break;
				default:
					throw new ApplicationException("StreamDataSet Format not supported");
			}
		}
Exemplo n.º 2
0
        //construct HTML code
        static string getHTML(System.Data.DataTable dt)
        {
            string xsltFilePath = @"C:\Users\Kelly\Documents\schedule\MySchedule\MySchedule\bin\Debug\XSLTFile1.xslt";

            TextWriter txtwriter = new StringWriter();
            dt.WriteXml(txtwriter);
            XDocument xmlDoc = XDocument.Parse(txtwriter.ToString());

            XDocument htmlDoc = new XDocument();

            using (XmlWriter writer = htmlDoc.CreateWriter())
            {
                XslCompiledTransform xslt = new XslCompiledTransform();
                xslt.Load(xsltFilePath);
                xslt.Transform(xmlDoc.CreateReader(), writer);
            }

            return htmlDoc.Document.ToString();
        }
Exemplo n.º 3
0
		/// <summary>
		/// 设置表类型配置
		/// </summary>
		/// <param name="ClassName">类名</param>
		/// <param name="TableElementName">表元素名</param>
		/// <param name="dt">表配置</param>
		public void SetTableConfig(string ClassName, string TableElementName, System.Data.DataTable dt)
		{
			if (xn == null)
			{
				throw new System.Exception("请先设置 Root!");
			}

			System.Xml.XmlNode xn1 = xn.SelectSingleNode(ClassName);
			if (xn1 == null)
			{
				xn1 = xd.CreateElement(ClassName);
				xn.AppendChild(xn1);
			}

			System.Xml.XmlNode xn2 = xn1.SelectSingleNode(TableElementName);
			if (xn2 == null)
			{
				xn2 = xd.CreateElement(TableElementName);
				xn1.AppendChild(xn2);
			}

			if (xn2 != null && xn2.ChildNodes.Count > 0)
			{
				xn2.InnerXml = string.Empty;
			}

			StringWriter sw = new StringWriter();
			dt.WriteXml(sw, System.Data.XmlWriteMode.WriteSchema);
			xn2.InnerXml = sw.ToString();
		}