Ejemplo n.º 1
0
        /// <summary>
        /// Saves prepared pages to a stream.
        /// </summary>
        /// <param name="stream">The stream to save to.</param>
        public void Save(Stream stream)
        {
            stream = Compressor.Compress(stream);

            using (XmlDocument doc = new XmlDocument())
            {
                doc.AutoIndent = true;
                doc.Root.Name  = "preparedreport";
                XmlItem pages = doc.Root.Add();
                pages.Name = "pages";

                // attach each page's xml to the doc
                foreach (PreparedPage page in FPreparedPages)
                {
                    pages.AddItem(page.Xml);
                }

                XmlItem sourcePages = doc.Root.Add();
                sourcePages.Name = "sourcepages";
                SourcePages.Save(sourcePages);

                XmlItem dictionary = doc.Root.Add();
                dictionary.Name = "dictionary";
                Dictionary.Save(dictionary);

                XmlItem bookmarks = doc.Root.Add();
                bookmarks.Name = "bookmarks";
                Bookmarks.Save(bookmarks);

                doc.Root.AddItem(Outline.Xml);

                XmlItem blobStore = doc.Root.Add();
                blobStore.Name = "blobstore";
                BlobStore.Save(blobStore);

                doc.Save(stream);

                // detach each page's xml from the doc
                foreach (PreparedPage page in FPreparedPages)
                {
                    page.Xml.Parent = null;
                }
                Outline.Xml.Parent = null;
            }

            stream.Dispose();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves prepared pages to a stream.
        /// </summary>
        /// <param name="stream">The stream to save to.</param>
        public void Save(Stream stream)
        {
            if (Config.PreparedCompressed)
            {
                stream = Compressor.Compress(stream);
            }

            using (XmlDocument doc = new XmlDocument())
            {
                doc.AutoIndent = true;
                doc.Root.Name  = "preparedreport";

                // save ReportInfo
                doc.Root.SetProp("ReportInfo.Name", Report.ReportInfo.Name);
                doc.Root.SetProp("ReportInfo.Author", Report.ReportInfo.Author);
                doc.Root.SetProp("ReportInfo.Description", Report.ReportInfo.Description);
                doc.Root.SetProp("ReportInfo.Created", SystemFake.DateTime.Now.ToString());
                doc.Root.SetProp("ReportInfo.Modified", SystemFake.DateTime.Now.ToString());
                doc.Root.SetProp("ReportInfo.CreatorVersion", Report.ReportInfo.CreatorVersion);

                XmlItem pages = doc.Root.Add();
                pages.Name = "pages";

                // attach each page's xml to the doc
                foreach (PreparedPage page in preparedPages)
                {
                    page.Load();
                    pages.AddItem(page.Xml);
                }

                XmlItem sourcePages = doc.Root.Add();
                sourcePages.Name = "sourcepages";
                SourcePages.Save(sourcePages);

                XmlItem dictionary = doc.Root.Add();
                dictionary.Name = "dictionary";
                Dictionary.Save(dictionary);

                XmlItem bookmarks = doc.Root.Add();
                bookmarks.Name = "bookmarks";
                Bookmarks.Save(bookmarks);

                doc.Root.AddItem(Outline.Xml);

                XmlItem blobStore = doc.Root.Add();
                blobStore.Name = "blobstore";
                BlobStore.Save(blobStore);

                doc.Save(stream);

                // detach each page's xml from the doc
                foreach (PreparedPage page in preparedPages)
                {
                    page.Xml.Parent = null;
                    page.ClearUploadedXml();
                }
                Outline.Xml.Parent = null;
            }

            if (Config.PreparedCompressed)
            {
                stream.Dispose();
            }
        }