public void UpdateFeed(int feedId, FeedDetails detail) { var feed = connection.Find <Feed>(feedId); feed.Feedname = detail.Title; connection.Update(feed); this.UpdateCache(feedId, detail.FeedXml); }
public static async Task<SortedList<DateTime, IList<Tuple<Uri, FeedDetails>>>> GetPackages(HttpClient client, Uri uri, string keyDateProperty) { SortedList<DateTime, IList<Tuple<Uri, FeedDetails>>> result = new SortedList<DateTime, IList<Tuple<Uri, FeedDetails>>>(); XElement feed; using (Stream stream = await client.GetStreamAsync(uri)) { feed = XElement.Load(stream); } XNamespace atom = "http://www.w3.org/2005/Atom"; XNamespace dataservices = "http://schemas.microsoft.com/ado/2007/08/dataservices"; XNamespace metadata = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"; foreach (XElement entry in feed.Elements(atom + "entry")) { Uri content = new Uri(entry.Element(atom + "content").Attribute("src").Value); XElement propertiesElement = entry.Element(metadata + "properties"); XElement createdElement = propertiesElement.Element(dataservices + CreatedDateProperty); string createdValue = createdElement != null ? createdElement.Value : null; DateTime createdDate = String.IsNullOrEmpty(createdValue) ? DateTime.MinValue : DateTime.Parse(createdValue); XElement lastEditedElement = propertiesElement.Element(dataservices + LastEditedDateProperty); string lastEditedValue = propertiesElement.Element(dataservices + LastEditedDateProperty).Value; DateTime lastEditedDate = String.IsNullOrEmpty(lastEditedValue) ? DateTime.MinValue : DateTime.Parse(lastEditedValue); XElement publishedElement = propertiesElement.Element(dataservices + PublishedDateProperty); string publishedValue = propertiesElement.Element(dataservices + PublishedDateProperty).Value; DateTime publishedDate = String.IsNullOrEmpty(publishedValue) ? createdDate : DateTime.Parse(publishedValue); XElement keyElement = propertiesElement.Element(dataservices + keyDateProperty); string keyEntryValue = propertiesElement.Element(dataservices + keyDateProperty).Value; DateTime keyDate = String.IsNullOrEmpty(keyEntryValue) ? createdDate : DateTime.Parse(keyEntryValue); // License details XElement licenseNamesElement = propertiesElement.Element(dataservices + LicenseNamesProperty); string licenseNames = licenseNamesElement != null ? licenseNamesElement.Value : null; XElement licenseReportUrlElement = propertiesElement.Element(dataservices + LicenseReportUrlProperty); string licenseReportUrl = licenseReportUrlElement != null ? licenseReportUrlElement.Value : null; // NOTE that DateTime returned by the v2 feed does not have Z at the end even though it is in UTC. So, the DateTime kind is unspecified // So, forcibly convert it to UTC here createdDate = ForceUTC(createdDate); lastEditedDate = ForceUTC(lastEditedDate); publishedDate = ForceUTC(publishedDate); keyDate = ForceUTC(keyDate); IList<Tuple<Uri, FeedDetails>> contentUris; if (!result.TryGetValue(keyDate, out contentUris)) { contentUris = new List<Tuple<Uri, FeedDetails>>(); result.Add(keyDate, contentUris); } FeedDetails details = new FeedDetails { CreatedDate = createdDate, LastEditedDate = lastEditedDate, PublishedDate = publishedDate, LicenseNames = licenseNames, LicenseReportUrl = licenseReportUrl }; contentUris.Add(new Tuple<Uri, FeedDetails>(content, details)); } return result; }