Closed weedkiller closed 5 years ago
Assuming you have a VCalendar
object containing all the stuff you want to export, you just call its WriteToStream()
method to save it to an output stream.
From the web demo (writing it to the response stream effectively downloads it as a file): https://github.com/EWSoftware/PDI/blob/master/Source/CSharpDemos/PDIWebDemoCS/CalendarBrowser.aspx.cs#L210
From the desktop demo (save to file): https://github.com/EWSoftware/PDI/blob/master/Source/CSharpDemos/CalendarBrowser/CalendarBrowserForm.cs#L317
I don't know how a calendar file or its content is represented in an RSS feed so I can't answer that. Depending on the format, you could probably just enumerate the calendar items and write out the various properties in the required format.
Thanks for the response and wonderful lib, will you be porting to ASP MVC/Core anytime a sample here
On SO there is a nicer answered question
some sample for the lib here.
public class RssController : Controller
{
public virtual ActionResult Feed(string id)
{
var items = new List<SyndicationItem>();
for (int i = 0; i < 10; i++)
{
string feedTitle = "Latest EW Software Articles Claendar " + i;
var helper = new UrlHelper(this.Request.RequestContext);
var url = helper.Action("Index", "Home", new { }, Request.IsSecureConnection ? "https" : "http");
var feedPackageItem = new SyndicationItem(feedTitle, "Test Description " + i, new Uri(url));
feedPackageItem.PublishDate = DateTime.Now;
items.Add(feedPackageItem);
}
return new RssResult("EWSoftware Feed", items);
}
}
RSS helper from a file
public class RssFeed : FileResult
{
private Uri _currentUrl;
private readonly string _title;
private readonly string _description;
private readonly List<SyndicationItem> _items;
public RssFeed(string contentType, string title, string description, List<SyndicationItem> items)
: base(contentType)
{
_title = title;
_description = description;
_items = items;
}
protected override void WriteFile(HttpResponseBase response)
{
var feed = new SyndicationFeed(title: this._title, description: _description, feedAlternateLink: _currentUrl,
items: this._items);
var formatter = new Rss20FeedFormatter(feed);
using (var writer = XmlWriter.Create(response.Output))
{
formatter.WriteTo(writer);
}
}
public override void ExecuteResult(ControllerContext context)
{
_currentUrl = context.RequestContext.HttpContext.Request.Url;
base.ExecuteResult(context);
}
}
I'm not a web developer and I'm out of touch with all the current web development methodologies. It'll be a while before I do anything with the web examples.
I am wondering where to insert this into the lib, so that I can expose this as an RSS While its web facing, its not a web page per say... just allowing/exporting a formatted stream, just like someone would write to file on disk etc.
I'm not sure it belongs in the library just yet. What you put in a feed is rather arbitrary and there are way more object types and properties on those calendar objects than in the RSS items from the examples you cited above. This is perhaps better off an extension or utility method you can call that takes a collection of whatever calendar objects you want and returns them in the feed format you need.
Again, I'm not familiar with RSS feeds or what calendar items might look like in them. I'd have to see some concrete examples before merging anything into the library itself.
ok. was try to help, ical has similar.. will close out
Hello, Could you please share a snippet or sample
I have an asp app with multiple calendars, and need to export a calendar to a desktop outlook/Thunderbird client. Also, how to publish an RSS feed of the calendar/s We need to hook it up to Telerk or Syncfsion calendar
thanks