using Bootstrap.DataAccess;
using Longbow.Web.Mvc;
using System;
using System.Globalization;
using System.Linq;
namespace Bootstrap.Admin.Models
{
public class QueryExceptionOption : PaginationOption
{
///
///
///
public DateTime StartTime { get; set; }
///
///
///
public DateTime EndTime { get; set; }
///
///
///
///
public QueryData RetrieveData()
{
var data = ExceptionHelper.RetrieveExceptions();
if (StartTime > DateTime.MinValue)
{
data = data.Where(t => t.LogTime > StartTime);
}
if (EndTime > DateTime.MinValue)
{
data = data.Where(t => t.LogTime < EndTime);
}
var ret = new QueryData();
ret.total = data.Count();
switch (Sort)
{
case "ErrorPage":
data = Order == "asc" ? data.OrderBy(t => t.ErrorPage) : data.OrderByDescending(t => t.ErrorPage);
break;
case "UserID":
data = Order == "asc" ? data.OrderBy(t => t.UserID) : data.OrderByDescending(t => t.UserID);
break;
case "UserIp":
data = Order == "asc" ? data.OrderBy(t => t.UserIp) : data.OrderByDescending(t => t.UserIp);
break;
case "LogTime":
data = Order == "asc" ? data.OrderBy(t => t.LogTime) : data.OrderByDescending(t => t.LogTime);
break;
default:
break;
}
ret.rows = data.Skip(Offset).Take(Limit);
return ret;
}
}
}