Пример #1
0
        public static string Prepis2HTML(IPrepis prpPrepis)
        {
            //Prepis2Xml(prpPrepis);
            MemoryStream         msmXml   = null;
            XslCompiledTransform xctXslt  = new XslCompiledTransform();
            Assembly             assembly = Assembly.GetExecutingAssembly();
            //xctXslt.Load(@"V:\Projekty\Daliboris\Texty\Evidence\Xslt\Prepisy2HTML.xsl");
            FileInfo fi = new FileInfo(assembly.Location);

            xctXslt.Load(fi.DirectoryName + "\\Xslt\\Prepisy2HTML.xsl");

            if (prpPrepis.PuvodniPodoba != null)
            {
                msmXml = PorovnatPrepisy2HTML(prpPrepis, prpPrepis.PuvodniPodoba);
            }
            else
            {
                msmXml = new MemoryStream();
                Perzistence.UlozitDoStreamu(msmXml, prpPrepis as Prepis);
                //Prepis.Serialize(msmXml, prpPrepis);
            }

            msmXml.Seek(0, SeekOrigin.Begin);
            XmlReader    xmrReader    = XmlReader.Create(msmXml);
            MemoryStream msmXmlWriter = new MemoryStream();
            XmlWriter    xmwWriter    = XmlWriter.Create(msmXmlWriter);

            xctXslt.Transform(xmrReader, xmwWriter);

            byte[] byteArray = new byte[msmXmlWriter.Length];
            byteArray = msmXmlWriter.ToArray();
            //msmXmlWriter.Seek(0, SeekOrigin.Begin);
            //msmXmlWriter.Read(byteArray, 0, byteArray.Length);

            //System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
            String s = System.Text.Encoding.UTF8.GetString(byteArray);

            msmXml.Close();
            msmXmlWriter.Close();
            return(s);
        }
Пример #2
0
        public static XmlDocument Prepis2Xml(IPrepis prp)
        {
            XmlDocument xd = new XmlDocument();

            //Stream msm = new MemoryStream();
            MemoryStream msm = new MemoryStream();

            //Prepis.Serialize(msm, prp, Prepisy.csDefaultNamespace);
            Perzistence.UlozitDoStreamu(msm, prp as Prepis);
            //Prepis.Serialize(msm, prp);
            byte[] byteArr = new byte[msm.Length];
            System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
            msm.Seek(0, SeekOrigin.Begin);
            byteArr = msm.ToArray();
            //msm.Write(byteArr, 0, byteArr.Length);
            String s2 = enc.GetString(byteArr);

            //FileStream fl = File.Create(@"V:\Temp\Text_01.xml");
            //fl.Write(byteArr, 0, byteArr.Length);
            //fl.Close();
            xd.LoadXml(s2);
            msm.Close();
            return(xd);
        }