2018-10-30 13:07:29 +08:00
|
|
|
|
using MongoDB.Driver;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.DataAccess.MongoDB
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class Log : DataAccess.Log
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2019-01-15 12:52:09 +08:00
|
|
|
|
public override IEnumerable<DataAccess.Log> Retrieves() => DbManager.Logs.Find(l => l.LogTime >= DateTime.Now.AddDays(-7)).ToList();
|
2018-10-30 22:11:27 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除日志信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
/// <returns></returns>
|
2019-01-15 12:52:09 +08:00
|
|
|
|
private static void DeleteLogAsync() => System.Threading.Tasks.Task.Run(() => DbManager.Logs.DeleteMany(log => log.LogTime < DateTime.Now.AddDays(-7)));
|
2018-10-30 16:30:58 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="log"></param>
|
|
|
|
|
/// <returns></returns>
|
2019-01-11 23:20:28 +08:00
|
|
|
|
public override bool Save(DataAccess.Log log)
|
2018-10-30 16:30:58 +08:00
|
|
|
|
{
|
|
|
|
|
log.LogTime = DateTime.Now;
|
2019-01-15 12:52:09 +08:00
|
|
|
|
DbManager.Logs.InsertOne(log);
|
2018-10-30 16:30:58 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-10-30 13:07:29 +08:00
|
|
|
|
}
|
|
|
|
|
}
|