public byte[] GetMetadataDocument(Record record) { // use either the resourcehub url or the direct data links var onlineResources = GetOnlineResources(record); // generate the XML var doc = new Gemini.Encoding.XmlEncoder().Create(record.Id, record.Gemini, onlineResources); var s = new MemoryStream(); doc.Save(s); return(s.ToArray()); }
public byte[] GetMetadataDocument(Record record, string resourceUrl) { bool alternativeResources = record.Publication != null && record.Publication.OpenData != null && record.Publication.OpenData.Resources != null && record.Publication.OpenData.Resources.Any(); var doc = new Gemini.Encoding.XmlEncoder().Create(record.Id, record.Gemini); if (alternativeResources) { // mung (mutate) the metadata doc so data.gov.uk knows about the resources var onlineResources = record.Publication.OpenData.Resources .Select(r => new OnlineResource { Name = WebificationUtility.ToUrlFriendlyString(Path.GetFileName(r.Path)), Url = resourceUrl }).ToList(); Gemini.Encoding.XmlEncoder.ReplaceDigitalTransferOptions(doc, onlineResources); } var s = new MemoryStream(); doc.Save(s); return(s.ToArray()); }