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

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

namespace CommunityServer.Components
{
	public class TagCleanupJob : IJob
	{
		public TagCleanupJob()
		{
		}

		public void Execute(XmlNode node)
		{
			XmlAttribute applications = node.Attributes["applications"];
			ArrayList applicationTypes = new ArrayList();

			if(applications != null)
			{
				foreach (string appType in applications.Value.Split(','))
				{
					try
					{
						applicationTypes.Add((ApplicationType) Enum.Parse(typeof(ApplicationType), appType, true));
					}
					catch
					{
					}
				}
			}
			else
				applicationTypes.Add(ApplicationType.Forum);


			foreach (ApplicationType at in applicationTypes)
			{
				Tags.RemoveUnusedTags(at);
			}			
		}
	}
}
