/*
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 System.Web;
using System.Web.Mvc;
using Everest.Library.Mvc;
using Everest.Library.Extjs;
using Everest.Library.Json;
using Everest.Library.Extjs.Tree;
using Everest.Library.ExtensionMethod;
using Everest.Library.Data.Rule;
using Everest.CmsServices.Services;
using Everest.CmsServices.Models;
namespace Everest.CmsServices.Controllers{
[PermissionFilter(Permission = FolderType.WebEvent)]
public class WebEventController : CmsExtController
{
IEverestCmsDataContext dataContext = EverestCmsEntities.GetDataContext();
/// <summary>
/// Gets the list.
/// </summary>
/// <returns></returns>
public ActionResult GetList()
{
int start, limit;
EnsurePaging(out start, out limit);
IQueryable<aspnet_WebEvent_Events> queryable = dataContext.aspnet_WebEvent_Events.AsQueryable<aspnet_WebEvent_Events>();
//string pageName = Request.Form["PageName"];
//if (!StringExtensions.IsNullOrEmptyTrim(pageName))
//{
// queryable = queryable.Where(p => p.PageName.Contains(pageName));
//}
queryable = queryable.OrderByDescending(we => we.EventTime);
queryable = OrderByRequest(queryable);
var queryResult = queryable.Select(we => new
{
we.EventId,
we.EventTime,
we.EventType,
we.EventCode,
we.RequestUrl,
we.ExceptionType
});
return Json(new ExtJsonReaderObject(queryResult.Skip(start).Take(limit).ToArray(), queryResult.Count()));
}
public ActionResult GetDetail(string eventId)
{
JsonResultData resultData = new JsonResultData();
var webEvent = dataContext.aspnet_WebEvent_Events.Where(we => we.EventId == eventId).First();
resultData.data = new
{
webEvent.EventId,
EventTime = webEvent.EventTime.ToString(),
webEvent.EventType,
webEvent.EventCode,
webEvent.RequestUrl,
webEvent.ExceptionType,
webEvent.Details
};
return Json(resultData);
}
public ActionResult Delete(string[] eventId)
{
var resultData = new JsonResultData() { success = true };
foreach (var id in eventId)
{
var webEvent = dataContext.aspnet_WebEvent_Events.Where(we => we.EventId == id).First();
dataContext.DeleteObject(webEvent);
}
dataContext.SaveChanges();
return Json(resultData);
}
}
}
|