//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Xml;
using CommunityServer.Configuration;

namespace CommunityServer.Components
{
	/// <summary>
	/// Summary description for EmailJob.
	/// </summary>
	public class UserInvitationExpirationJob : IJob
	{
		private int _expirationDays = 15;

		public UserInvitationExpirationJob()
		{
		}

		public void Execute(XmlNode node)
		{
			XmlAttribute expirationDaysNode = node.Attributes["expirationDays"];

			if(expirationDaysNode != null)
			{
				try { this._expirationDays = int.Parse(expirationDaysNode.Value); }
				catch { this._expirationDays = 30; }
			}

			UserInvitations.Expire(DateTime.Now.AddDays(-_expirationDays));
		}
	}
}