Click here to Skip to main content
15,894,540 members
Articles / Web Development / ASP.NET

OpenCollective -- The Requirements Management Wiki

Rate me:
Please Sign up or sign in to vote.
4.41/5 (16 votes)
9 Nov 20044 min read 262.4K   1.8K   111  
An article on building a project oriented wiki for software development requirements management
/*
OpenCollective -  http://www.netbrick.net/
Copyright (c) 2004
by Tyler Jensen ( tylerj@netbrick.net ) of NetBrick Inc. ( http://www.netbrick.net )

Permission is hereby granted, free of charge, to any person obtaining a copy 
of this software and associated documentation files (the "Software"), to deal 
in the Software without restriction, including without limitation the rights 
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
of the Software, and to permit persons to whom the Software is furnished to do 
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 
OR OTHER DEALINGS IN THE SOFTWARE.
*/
using System;
using System.Collections;
using System.Data;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Mail;
using OpenCollective.Data;

namespace OpenCollective.Engine
{
	/// <summary>
	/// Summary description for WikiWatch.
	/// </summary>
	public class WikiWatch
	{
		public WikiWatch()
		{
		}

		public void SendUpdates(int WikiTopicID, string hostName, string appUrlPath, string wikiName, string topicName, string userName, 
			bool IsMinor, string Summary, string BodyText, bool isTalk)
		{
			DataSet ds = DataAccess.GetWikiWatchList(WikiTopicID);

			if(ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
			{
				//w.Author, a.WatchAddress
				WikiWatchSender sndr = new WikiWatchSender(ds, hostName, appUrlPath, wikiName, topicName, userName, IsMinor, Summary, BodyText, isTalk);
				Thread t = new Thread(new ThreadStart(sndr.SendMessages));
				t.Start();
				//sndr.SendMessages();
			}
		}
	}

	public class WikiWatchSender
	{
		private DataSet	ds				= null;
		private string		hostName		= "";
		private string		appUrlPath	= "";
		private string		wikiName		= "";
		private string		topicName	= "";
		private string		userName		= "";
		private bool		IsMinor		= false;
		private string		Summary		= "";
		private string		Body			= "";
		private bool		isTalk		= false;

		public WikiWatchSender(DataSet ds, string hostName, string appUrlPath, string wikiName, string topicName, string userName, 
			bool IsMinor, string Summary, string BodyText, bool isTalk)
		{
			this.ds				= ds;
			this.hostName		= hostName;
			this.appUrlPath	= appUrlPath;
			this.wikiName		= wikiName;
			this.topicName		= topicName;
			this.userName		= userName;
			this.IsMinor		= IsMinor;
			this.Summary		= Summary;
			this.Body			= BodyText;
			this.isTalk			= isTalk;
		}

		//w.Author, a.WatchAddress
		public void SendMessages()
		{
			string returnAddress = Config.WatchReturnAddress;
			string appName = Config.ApplicationName;
			string smtpServer = Config.SmtpServer;
			string docLink = "http://" + hostName + appUrlPath + "/wiki/" + this.wikiName + "/" + this.topicName + ".wiki";
			docLink = "<a href=\"" + docLink + "\">" + docLink + "</a>";
			string talkLink = "http://" + hostName + appUrlPath + "/wiki/" + this.wikiName + "/" + this.topicName + ".wiki?talk";
			talkLink = "<a href=\"" + talkLink + "\">" + talkLink + "</a>";
			string watchLink = "http://" + hostName + appUrlPath + "/wiki/" + this.wikiName + "/" + this.topicName + ".wiki?watch";
			watchLink = "<a href=\"" + watchLink + "\">" + watchLink + "</a>";

			string msgBody = "<html><head></head><body><div style=\"	font-weight: normal; font-size: 10pt; color: navy; font-family: Tahoma, Verdana, Arial;\">"
				+ "@@NAME@@";
			if(isTalk)
			{
				msgBody += "The discussion page for <b>" + this.topicName + "</b> in the <b>" + this.wikiName + "</b> project has been updated by " 
					+ this.userName.ToUpper() + ".<br><br>To see this discussion go to<br>" + talkLink 
					+ "<br><br>To visit the document go to<br>" + docLink 
					+ "<br><br>To remove yourself from this notification list, click the link below and then click the \"Unwatch\" button."
					+ "<br>" + watchLink 
					+ "<br><br>Thank you for your participation.<br><br>Sincerely,<br>" + appName + " Administrator";
			}
			else
			{
				msgBody += "The document <b>" + this.topicName + "</b> in the <b>" + this.wikiName + "</b> project has been updated by " 
					+ this.userName.ToUpper() + ".<br><br>To see document go to<br>" + docLink 
					+ "<br><br>To discuss this document go to<br>" + talkLink 
					+ "<br><br>To remove yourself from this notification list, click the link below and then click the \"Unwatch\" button."
					+ "<br>" + watchLink 
					+ "<br><br>Thank you for your participation.<br><br>Sincerely,<br>" + appName + " Administrator";
			}

			msgBody += "</div></body></html>";

			string subject = (this.isTalk) ? "Discussion updated for " + this.wikiName + ": " + this.topicName : "Document updated for " + this.wikiName + ": " + this.topicName;

			foreach(DataRow row in ds.Tables[0].Rows)
			{
				string emailTo = row["WatchAddress"].ToString();
				string author  = row["Author"].ToString();
				msgBody = msgBody.Replace("@@NAME@@", "Dear " + author.ToUpper() + ":<br><br>");

				MailMessage msg = new MailMessage();
				SmtpMail.SmtpServer = smtpServer;
				msg.From = "\"" + appName + " Daemon\" <" + returnAddress + ">";     //e.g.:  "App Daemon" <admin@domain.net>
				msg.To =  "\"" + author + "\" <" + emailTo + ">";
				msg.Subject = subject;
				msg.BodyFormat = MailFormat.Html;
				msg.Body = msgBody;
        
				SmtpMail.Send(msg);

				/*
				try
				{
					SmtpMail.Send(msg);
				}
				catch
				{
					//TODO - log send errors
				}
				*/
			}
		}
	}

}




By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Since 2001 I've been writing .NET applications in C# and architecting n-tier applications in the enterprise. Before that I worked as a tech writer for nine years. Don't bother doing the math. I'm old. Ever since I laid eyes on my first Commodore PET, I've been a technologist. I've worked in the software world for fifteen years. I started as a technical writer and learned to code from the best engineers as I worked with them in creating technical documentation. It was then that I learned that writing code was more fun and frankly easier than writing about code. I've been doing both ever since. You can visit my blog at http://www.tsjensen.com/blog.

Comments and Discussions