修改BUG:MongoDB环境下程序异常页面增加排序功能 #IRWZD

This commit is contained in:
Argo-Surface 2019-02-22 16:27:39 +08:00
parent acd7669213
commit 809582b02b
1 changed files with 24 additions and 0 deletions

View File

@ -65,6 +65,30 @@ namespace Bootstrap.DataAccess.MongoDB
public override Page<DataAccess.Exceptions> RetrievePages(PaginationOption po, DateTime? startTime, DateTime? endTime)
{
var exceps = DbManager.Exceptions.Find(FilterDefinition<DataAccess.Exceptions>.Empty).ToList();
// sort
var orderProxy = po.Order == "asc" ?
new Func<Func<DataAccess.Exceptions, string>, List<DataAccess.Exceptions>>(p => exceps.OrderBy(p).ToList()) :
new Func<Func<DataAccess.Exceptions, string>, List<DataAccess.Exceptions>>(p => exceps.OrderByDescending(p).ToList());
var logTimeProxy = po.Order == "asc" ?
new Func<Func<DataAccess.Exceptions, DateTime>, List<DataAccess.Exceptions>>(p => exceps.OrderBy(p).ToList()) :
new Func<Func<DataAccess.Exceptions, DateTime>, List<DataAccess.Exceptions>>(p => exceps.OrderByDescending(p).ToList());
switch (po.Sort)
{
case "ErrorPage":
exceps = orderProxy(ex => ex.ErrorPage);
break;
case "UserId":
exceps = orderProxy(ex => ex.UserId);
break;
case "UserIp":
exceps = orderProxy(ex => ex.UserIp);
break;
case "LogTime":
exceps = logTimeProxy(ex => ex.LogTime);
break;
}
return new Page<DataAccess.Exceptions>()
{
Context = exceps,