Beispiel #1
0
 public virtual void Write(ContentItem item, XmlTextWriter writer)
 {
     using (new ElementWriter("children", writer))
     {
         foreach (ContentItem child in ItemXmlWriter.GetChildren(item, options))
         {
             WriteChild(writer, child);
         }
     }
 }
        public void ExportItem(ContentItem item)
        {
            // no UrlParser and FS -> cannot export Attachments
            var itemXmlWriter = new ItemXmlWriter(_definitions, null, null);
            var exporter = new Exporter(itemXmlWriter);
            var path = _path + '/' + GetContentItemFilenameUnique(item.ID);

            using (var ms = new MemoryStream())
            {
                using (var tw = new StreamWriter(ms))
                {
                    lock (_syncLock)
                    {
                        // Nhibernate doesn't like parallel ?
                        exporter.Export(item, ExportOptions.ExcludeAttachments | ExportOptions.ExcludePages, tw);
                    }
                    // Save to FS
                    ms.Position = 0;
                    _fs.WriteFile(path, ms, item.Published);
                }
            }
        }
        public ActionResult Item(int id)
        {
            var item = _repository.Get(id);
            if (item != null)
                try
                {
                    var itemXmlWriter = new ItemXmlWriter(Context.Current.Definitions, null, null);
                    var exporter = new Exporter(itemXmlWriter);
                    var ms = new MemoryStream();
                    var tw = new StreamWriter(ms);
                    {
                        exporter.Export(item, ExportOptions.ExcludeAttachments | ExportOptions.ExcludePages, tw);
                    }
                    ms.Position = 0;
                    return new FileStreamResult(ms, "application/xml");
                }
                catch (Exception ex)
                {
                    return Content(ex.Message, "text/plain");
                }

            return new EmptyResult();
        }
Beispiel #4
0
 public GZipExporter(ItemXmlWriter writer)
     : base(writer)
 {
 }
Beispiel #5
0
 public Exporter(ItemXmlWriter itemWriter)
 {
     this.itemWriter = itemWriter;
 }
Beispiel #6
0
 public Exporter(ItemXmlWriter itemWriter)
 {
     this.itemWriter = itemWriter;
 }
Beispiel #7
0
 public GZipExporter(ItemXmlWriter writer)
     : base(writer)
 {
 }