/*
Kooboo is a content management system based on ASP.NET MVC framework. Copyright 2009 Yardi Technology Limited.
This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License version 3 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.kooboo.com/gpl3/.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Everest.CmsServices.Services;
using Everest.CmsServices.Models;
namespace Everest.CmsServices.Search{
public class IndexContentTrigger : IContentTrigger
{
#region IContentTrigger Members
public void OnAdded(Cms_Content content)
{
TriggerIndex(content.UUID, IndexType.Add);
}
public void OnUpdated(Cms_Content content)
{
TriggerIndex(content.UUID, IndexType.Update);
}
public void OnDeleted(Guid contentUUID, Cms_Folder folder)
{
TriggerIndex(contentUUID, IndexType.Delete);
}
public void OnLocalized(Cms_Content sourceContent, Cms_Content localiztionContent)
{
TriggerIndex(sourceContent.UUID, IndexType.Update);
TriggerIndex(localiztionContent.UUID, IndexType.Add);
}
public void OnIncluded(Cms_Content content, Cms_Folder folder)
{
TriggerIndex(content.UUID, IndexType.Update);
}
public void OnExcluded(Cms_Content content, Cms_Folder folder)
{
TriggerIndex(content.UUID, IndexType.Update);
}
#endregion
protected void TriggerIndex(Guid contentUUID, IndexType indexType)
{
Cms_IndexTrigger trigger = new Cms_IndexTrigger();
trigger.ContentUUID = contentUUID;
trigger.Action = (int)indexType;
trigger.ChangedDate = DateTime.Now;
var dataContext = EverestCmsEntities.GetDataContext();
dataContext.AddToCms_IndexTrigger(trigger);
dataContext.SaveChanges();
}
}
}
|