Ejemplo n.º 1
0
		protected void DoPage()
		{
			NewsletterManager manager = new NewsletterManager(TheFederation, TheLinkMaker, null, null, null);
			AbsoluteTopicName newsletter = Newsletter;
			
			DateTime since;
			string headInsert = null;
			string description = null;
			string newsletterName = null;
			string newsletterLink = null;
			IEnumerable topics = null;
			string homeNamespace = null;

			
			if (newsletter != null)
			{
				description = manager.GetDescriptionForNewsletter(newsletter);
				since = manager.GetLastUpdateForNewsletter(newsletter);
				newsletterName = newsletter.Name;
				newsletterLink = TheLinkMaker.LinkToTopic(newsletter);
				topics = manager.AllTopicsForNewsletter(newsletter);
				homeNamespace = newsletter.Namespace;
			}
			else
			{
				since = DateTime.Now;
				since = since.Subtract(new TimeSpan(24, 0, 0));
				// Arbitrary newsletter
				ArrayList al = new ArrayList();
				al.Add(new AbsoluteTopicName("Microsoft.Projects.Wiki.HomePage"));
				al.Add(new AbsoluteTopicName("Microsoft.Projects.Wiki.SecondPage"));
				topics = al;
				homeNamespace = TheFederation.DefaultNamespace;
			}

			since = since.Subtract(new TimeSpan(24, 0, 0));
	
			headInsert	= InsertStylesheetReferences();
			
			string html = manager.BuildArbitraryNewsletter(newsletterName, newsletterLink, topics, since, headInsert, description, homeNamespace);
			
			Response.Write(html);
		}
Ejemplo n.º 2
0
		void NewsletterFeed(string newsletterName, XmlTextWriter newsletter)
		{
			NewsletterManager nm = new NewsletterManager(TheFederation, TheLinkMaker);
			TopicInfo info = TheFederation.GetTopicInfo(newsletterName);
			if (!info.Exists) 
			{
				throw new Exception("Newsletter " +  newsletterName + "  does not exist.");
			}
			if (!info.HasProperty("Topics")) 
			{
				throw new Exception("Topic " +  newsletterName + " is not a newsletter; no Topics property defined.");
			}
			string desc = info.GetProperty("Description");
			if (desc == null) 
			{
				desc = "";
			}

			newsletter.WriteStartDocument();
			newsletter.WriteStartElement("rss");
			newsletter.WriteAttributeString("version", "2.0");
			newsletter.WriteStartElement("channel");
			newsletter.WriteElementString("title", newsletterName);
			newsletter.WriteElementString("description", desc);

			Uri link = new Uri(TheLinkMaker.LinkToTopic(info.Fullname, true), false);
			newsletter.WriteElementString("link", link.AbsoluteUri);

			DateTime last = DateTime.MinValue;
			foreach (AbsoluteTopicName topic in nm.AllTopicsForNewsletter(info.Fullname))
			{
				FormatRSSItem(topic, newsletter);
				TopicInfo each = new TopicInfo(TheFederation, topic);
				DateTime lm = each.LastModified;
				if (lm > last) 
				{
					last = lm;
				}
			}

			newsletter.WriteElementString("lastBuildDate", last.ToUniversalTime().ToString("r"));

			newsletter.WriteEndElement();
			newsletter.WriteEndElement();
		}