/// <inheritdoc /> public void StoreDecision(DecisionModel decision) { this.RemoveAllOccurences(decision); string titre = decision.EstSupprimée ? RemovedIndicator + decision.Titre : decision.Titre; var item = new RssItem { title = titre, pubDate = decision.Date.ToString("ddd, dd MMM yyyy HH:mm:ss"), description = decision.Description, link = decision.Lien?.ToString(), guid = new Guid { isPermaLink = false, Value = decision.GetHashCode().ToString() } }; foreach (Domaine decisionDomaine in decision.Domaines) { RssChannel channel = this.OpenOrCreateChannelForDomaine(decisionDomaine); channel.Add(item); var rss = new Rss { channel = new [] { channel } }; var serializer = new XmlSerializer(typeof(Rss)); IFile file = this._feedsStorageDirectory.CreateOrReturn(FileNameForDomaine(decisionDomaine)); using (StreamWriter writer = file.CreateWriter()) serializer.Serialize(writer, rss); } }
private static RssItem PrototypeItem() { DecisionModel decision = PrototypeDecision(); var item = new RssItem { title = decision.Titre, description = decision.Description, link = decision.Lien.ToString(), guid = new Normacode.RSS.Guid { isPermaLink = false, Value = decision.GetHashCode().ToString() } }; item.SetPubDate(decision.Date); return(item); }
public void RemoveAllOccurences(DecisionModel model) { string hashCodeString = model.GetHashCode().ToString(); foreach (DomaineRssFeed domaineRssFeed in this._cache.Values) { domaineRssFeed.DoSomething(feed => { if (feed.item == null) { return; } feed.item = feed.item.Where(item => item.guid.Value != hashCodeString).ToArray(); }); } }