2019-05-01 16:46:24 +08:00
|
|
|
|
using Longbow.Web.Mvc;
|
2019-05-01 12:07:00 +08:00
|
|
|
|
using MongoDB.Driver;
|
2019-05-01 16:46:24 +08:00
|
|
|
|
using PetaPoco;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2019-03-04 13:21:04 +08:00
|
|
|
|
namespace Bootstrap.DataAccess.MongoDB
|
2019-03-04 02:41:53 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class LoginUser : DataAccess.LoginUser
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="user"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public override bool Log(DataAccess.LoginUser user)
|
|
|
|
|
{
|
|
|
|
|
DbManager.LoginUsers.InsertOne(user);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-03-04 13:21:04 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2019-05-01 12:07:00 +08:00
|
|
|
|
/// <param name="po"></param>
|
2019-03-04 13:21:04 +08:00
|
|
|
|
/// <returns></returns>
|
2019-05-04 16:44:30 +08:00
|
|
|
|
public override Page<DataAccess.LoginUser> Retrieves(PaginationOption po, string ip)
|
2019-05-01 16:46:24 +08:00
|
|
|
|
{
|
2019-05-01 12:07:00 +08:00
|
|
|
|
var logs = DbManager.LoginUsers
|
2019-05-04 16:44:30 +08:00
|
|
|
|
.Find(Builders<DataAccess.LoginUser>.Filter.Eq("Ip", ip))
|
2019-05-01 12:07:00 +08:00
|
|
|
|
.Sort(Builders<DataAccess.LoginUser>.Sort.Descending(t => t.LoginTime))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
return new Page<DataAccess.LoginUser>()
|
|
|
|
|
{
|
|
|
|
|
Context = logs,
|
|
|
|
|
CurrentPage = po.PageIndex,
|
|
|
|
|
ItemsPerPage = po.Limit,
|
|
|
|
|
TotalItems = logs.Count,
|
|
|
|
|
TotalPages = (long)Math.Ceiling(logs.Count * 1.0 / po.Limit),
|
|
|
|
|
Items = logs.Skip(po.Offset).Take(po.Limit).ToList()
|
|
|
|
|
};
|
2019-05-01 16:46:24 +08:00
|
|
|
|
}
|
2019-03-04 02:41:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|