コード例 #1
0
ファイル: Rss.aspx.cs プロジェクト: nuxleus/flexwiki
		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();
		}
コード例 #2
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);
		}
コード例 #3
0
ファイル: RssFace.aspx.cs プロジェクト: nuxleus/flexwiki
		void ShowNewsletters(string ns)
		{
			Response.Write(@"<h1>Newsletters</h1>");
			
			NewsletterManager nm = new NewsletterManager(TheFederation, TheLinkMaker);

			Hashtable hash = new Hashtable();
			foreach (AbsoluteTopicName newsletterName in nm.GetAllNewsletterNames(ns))
			{
				ArrayList topicsInThisNamespace = (ArrayList)hash[newsletterName.Namespace];
				if (topicsInThisNamespace == null)
				{
					topicsInThisNamespace = new ArrayList();
					hash[newsletterName.Namespace] = topicsInThisNamespace;
				}
				topicsInThisNamespace.Add(newsletterName);
			}

			ArrayList bases = new ArrayList();
			bases.AddRange(hash.Keys);
			bases.Sort();
			
			OpenTable();
			foreach (string each in bases)
			{
				ContentBase cb = TheFederation.ContentBaseForNamespace(each);
				if (ns == null)
					Response.Write(@"<tr><td colspan='2'><div class='SubscriptionNamespace'>" + EscapeHTML(cb.FriendlyTitle)  + "</div></td></tr>");
				foreach (AbsoluteTopicName abs in (ArrayList)(hash[each]))
				{
					TopicInfo info = TheFederation.GetTopicInfo(abs.ToString());
					string desc = info.GetProperty("Description");
					Response.Write(@"
<tr>
<td><a class=""standardsButton"" href='" + RootUrl(Request) + @"rss.aspx?newsletter=" + abs.ToString() + @"'>rss</a></td>
<td><a href='" + TheLinkMaker.LinkToTopic(abs) + @"'>" + abs.Name + @"</a></td>
</tr>
<tr>
<td></td>
<td><span style='font-size: x-small; color: gray'>" + (desc == null ? "" : desc) + @"</span></td>
</tr>
<tr>");
				}
			}
			CloseTable();
		}
コード例 #4
0
ファイル: NewsletterDaemon.cs プロジェクト: nuxleus/flexwiki
		void ReallyDoWork()
		{
			DaemonBasedDeliveryBoy boy;
			boy = new DaemonBasedDeliveryBoy(SMTPServer, SMTPUser, SMTPPassword, _sendAsAttachments);
			LinkMaker lm = new LinkMaker(RootURL);
			NewsletterManager manager = new NewsletterManager(TheFederation, lm , boy, _NewslettersFrom, _HeadInsert);
			StringBuilder sb = new StringBuilder();
			StringWriter sw = new StringWriter(sb);
			boy.Log = sw;
			LogEvent ev = TheFederation.LogEventFactory.CreateAndStartEvent(null, null, null, LogEvent.LogEventType.NewsletterGeneration);
			LogResult(sb);
			sw.WriteLine("Begin: " + DateTime.Now.ToString());
			sw.WriteLine("Thread: " + Thread.CurrentThread.Name);
			try
			{
				manager.Notify(sw);
			}
			finally
			{
				ev.Record();
				sw.WriteLine("End: " + DateTime.Now.ToString());
			}
			// Append to the newsletters log file:

			string logFile = TheFederation.FederationNamespaceMapFilename;
			logFile = Path.GetDirectoryName(logFile) + Path.DirectorySeparatorChar + "Newsletter.log";
			StreamWriter sw2 = File.AppendText(logFile);
			sw2.Write(sb.ToString());
			sw2.Close();
		}