public static async Task WriteAddress( this ISyndicationFeedWriter writer, IOptions <ResponseOptions> responseOptions, AtomFormatter formatter, string category, AddressSyndicationQueryResult address) { var item = new SyndicationItem { Id = address.Position.ToString(CultureInfo.InvariantCulture), Title = $"{address.ChangeType}-{address.Position}", Published = address.RecordCreatedAt.ToBelgianDateTimeOffset(), LastUpdated = address.LastChangedOn.ToBelgianDateTimeOffset(), Description = BuildDescription(address, responseOptions.Value.Naamruimte) }; if (address.PersistentLocalId.HasValue) { // TODO: Hier moet prolly version nog ergens in item.AddLink( new SyndicationLink( new Uri($"{responseOptions.Value.Naamruimte}/{address.PersistentLocalId}"), AtomLinkTypes.Related)); item.AddLink( new SyndicationLink( new Uri(string.Format(responseOptions.Value.DetailUrl, address.PersistentLocalId)), AtomLinkTypes.Self)); item.AddLink( new SyndicationLink( new Uri(string.Format($"{responseOptions.Value.DetailUrl}.xml", address.PersistentLocalId)), AtomLinkTypes.Alternate) { MediaType = MediaTypeNames.Application.Xml }); item.AddLink( new SyndicationLink( new Uri(string.Format($"{responseOptions.Value.DetailUrl}.json", address.PersistentLocalId)), AtomLinkTypes.Alternate) { MediaType = MediaTypeNames.Application.Json }); } item.AddCategory( new SyndicationCategory(category)); item.AddContributor( new SyndicationPerson( "agentschap Informatie Vlaanderen", "*****@*****.**", AtomContributorTypes.Author)); await writer.Write(item); }
public static async Task WritePostalInfo( this ISyndicationFeedWriter writer, IOptions <ResponseOptions> responseOptions, AtomFormatter formatter, string category, PostalInformationSyndicationQueryResult postalInformation) { var item = new SyndicationItem { Id = postalInformation.Position.ToString(CultureInfo.InvariantCulture), Title = $"{postalInformation.ChangeType}-{postalInformation.Position}", Published = postalInformation.RecordCreatedAt.ToBelgianDateTimeOffset(), LastUpdated = postalInformation.LastChangedOn.ToBelgianDateTimeOffset(), Description = BuildDescription(postalInformation, responseOptions.Value.Naamruimte) }; if (!string.IsNullOrWhiteSpace(postalInformation.PostalCode)) { item.AddLink( new SyndicationLink( new Uri($"{responseOptions.Value.Naamruimte}/{postalInformation.PostalCode}"), AtomLinkTypes.Related)); item.AddLink( new SyndicationLink( new Uri(string.Format(responseOptions.Value.DetailUrl, postalInformation.PostalCode)), AtomLinkTypes.Self)); item.AddLink( new SyndicationLink( new Uri(string.Format($"{responseOptions.Value.DetailUrl}.xml", postalInformation.PostalCode)), AtomLinkTypes.Alternate) { MediaType = MediaTypeNames.Application.Xml }); item.AddLink( new SyndicationLink( new Uri(string.Format($"{responseOptions.Value.DetailUrl}.json", postalInformation.PostalCode)), AtomLinkTypes.Alternate) { MediaType = MediaTypeNames.Application.Json }); } item.AddCategory( new SyndicationCategory(category)); item.AddContributor( new SyndicationPerson( "agentschap Informatie Vlaanderen", "*****@*****.**", AtomContributorTypes.Author)); await writer.Write(item); }
public static async Task WriteMunicipality( this ISyndicationFeedWriter writer, IOptions <ResponseOptions> responseOptions, AtomFormatter formatter, string category, MunicipalitySyndicationQueryResult municipality) { var item = new SyndicationItem { Id = municipality.Position.ToString(CultureInfo.InvariantCulture), Title = $"{municipality.ChangeType}-{municipality.Position}", Published = municipality.RecordCreatedAt.ToBelgianDateTimeOffset(), LastUpdated = municipality.LastChangedOn.ToBelgianDateTimeOffset(), Description = BuildDescription(municipality, responseOptions.Value.Naamruimte) }; if (!string.IsNullOrWhiteSpace(municipality.NisCode)) { item.AddLink( new SyndicationLink( new Uri($"{responseOptions.Value.Naamruimte}/{municipality.NisCode}"), AtomLinkTypes.Related)); //item.AddLink( // new SyndicationLink( // new Uri(string.Format(responseOptions.Value.DetailUrl, municipality.NisCode)), // AtomLinkTypes.Self)); //item.AddLink( // new SyndicationLink( // new Uri(string.Format($"{responseOptions.Value.DetailUrl}.xml", municipality.NisCode)), // AtomLinkTypes.Alternate) // { MediaType = MediaTypeNames.Application.Xml }); //item.AddLink( // new SyndicationLink( // new Uri(string.Format($"{responseOptions.Value.DetailUrl}.json", municipality.NisCode)), // AtomLinkTypes.Alternate) // { MediaType = MediaTypeNames.Application.Json }); } item.AddCategory( new SyndicationCategory(category)); item.AddContributor( new SyndicationPerson( municipality.Organisation == null ? Organisation.Unknown.ToName() : municipality.Organisation.Value.ToName(), string.Empty, AtomContributorTypes.Author)); await writer.Write(item); }
public static async Task WriteAddress( this ISyndicationFeedWriter writer, IOptions <ResponseOptions> responseOptions, AtomFormatter formatter, string category, AddressSyndicationQueryResult address) { var item = new SyndicationItem { Id = address.Position.ToString(CultureInfo.InvariantCulture), Title = $"{address.ChangeType}-{address.Position}", Published = address.RecordCreatedAt.ToBelgianDateTimeOffset(), LastUpdated = address.LastChangedOn.ToBelgianDateTimeOffset(), Description = BuildDescription(address, responseOptions.Value.Naamruimte) }; if (address.PersistentLocalId.HasValue) { item.AddLink( new SyndicationLink( new Uri($"{responseOptions.Value.Naamruimte}/{address.PersistentLocalId}"), AtomLinkTypes.Related)); //item.AddLink( // new SyndicationLink( // new Uri(string.Format(responseOptions.Value.DetailUrl, address.PersistentLocalId)), // AtomLinkTypes.Self)); //item.AddLink( // new SyndicationLink( // new Uri(string.Format($"{responseOptions.Value.DetailUrl}.xml", address.PersistentLocalId)), AtomLinkTypes.Alternate) // { MediaType = MediaTypeNames.Application.Xml }); //item.AddLink( // new SyndicationLink( // new Uri(string.Format($"{responseOptions.Value.DetailUrl}.json", // address.PersistentLocalId)), // AtomLinkTypes.Alternate) // { MediaType = MediaTypeNames.Application.Json }); } item.AddCategory( new SyndicationCategory(category)); item.AddContributor( new SyndicationPerson( address.Organisation == null ? Organisation.Unknown.ToName() : address.Organisation.Value.ToName(), string.Empty, AtomContributorTypes.Author)); await writer.Write(item); }
public async Task Rss(string type) { Response.ContentType = "application/xml"; string host = Request.Scheme + "://" + Request.Host; using (XmlWriter xmlWriter = XmlWriter.Create(Response.Body, new XmlWriterSettings { Async = true, Indent = true, Encoding = new UTF8Encoding(false) })) { IEnumerable <Post> posts = await _blog.GetPosts(10); Post[] latestPosts = posts as Post[] ?? posts.ToArray(); ISyndicationFeedWriter writer = await GetWriter(type, xmlWriter, latestPosts.Max(p => p.PubDate)); foreach (Post post in latestPosts) { var item = new AtomEntry { Title = post.Title, Description = post.Content, Id = host + post.GetLink(), Published = post.PubDate, LastUpdated = post.DateModified, ContentType = "html" }; foreach (string category in post.Categories) { item.AddCategory(new SyndicationCategory(category)); } item.AddContributor(new SyndicationPerson("*****@*****.**", _settings.Value.Owner)); item.AddLink(new SyndicationLink(new Uri(item.Id))); await writer.Write(item); } } }