using MongoDB.Driver;
using System;
using System.Collections.Generic;
namespace Bootstrap.DataAccess.MongoDB
{
///
///
///
public class Log : DataAccess.Log
{
///
///
///
///
public override IEnumerable Retrieves() => MongoDbAccessManager.Logs.Find(l => l.LogTime >= DateTime.Now.AddDays(-7)).ToList();
///
/// 删除日志信息
///
///
///
private static void DeleteLogAsync() => System.Threading.Tasks.Task.Run(() => MongoDbAccessManager.Logs.DeleteMany(log => log.LogTime < DateTime.Now.AddDays(-7)));
///
///
///
///
///
public override bool Save(DataAccess.Log log)
{
log.LogTime = DateTime.Now;
MongoDbAccessManager.Logs.InsertOne(log);
return true;
}
}
}