using ZelWiki.Engine.Library.Interfaces;
using ZelWiki.Models;
using ZelWiki.Repository;

namespace ZelWiki.Engine.Implementation
{
    /// <summary>
    /// 
    /// </summary>
    public class CompletionHandler : ICompletionHandler
    {
        /// <summary>
        /// 完成事件
        /// </summary>
        /// <param name="state"></param>
        public void Complete(IZelEngineState state)
        {
            if (GlobalConfiguration.RecordCompilationMetrics)
            {
                StatisticsRepository.InsertCompilationStatistics(state.Page.Id,
                    state.ProcessingTime.TotalMilliseconds,
                    state.MatchCount,
                    state.ErrorCount,
                    state.OutgoingLinks.Count,
                    state.Tags.Count,
                    state.HtmlResult.Length,
                    state.Page.Body.Length);
            }
        }
    }
}