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

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

namespace CommunityServer.Components
{
    public class EventLogJob : IJob
    {
        public void Execute(XmlNode node)
        {
            try
            {
                int days = 2;
                XmlAttribute dayOverride = node.Attributes["days"];
                if(dayOverride != null)
                    days = Int32.Parse(dayOverride.Value);

                DateTime date = DateTime.Now.AddDays(-1 * days);
                EventLogs.Clear(date);
            }
            catch(Exception ex)
            {
                CSException csEx = new CSException(CSExceptionType.UnknownError,"EventJob",ex);
                csEx.Log(1000);
            }
        }
    }
}