增加功能:增加MongoDB数据库对登录日志支持 link #IS7RM

This commit is contained in:
Argo Zhang 2019-03-04 02:41:53 +08:00
parent 9924d8c3c4
commit 348438896c
2 changed files with 39 additions and 0 deletions

View File

@ -116,6 +116,17 @@ namespace Bootstrap.DataAccess.MongoDB
return DBAccess.GetCollection<BootstrapMenu>("Navigations");
}
}
/// <summary>
///
/// </summary>
public static IMongoCollection<DataAccess.LoginUser> LoginUsers
{
get
{
return DBAccess.GetCollection<DataAccess.LoginUser>("LoginLogs");
}
}
#endregion
private static void InitDb()
@ -220,6 +231,15 @@ namespace Bootstrap.DataAccess.MongoDB
md.IdMemberMap.SetIgnoreIfDefault(true);
});
}
if (!BsonClassMap.IsClassMapRegistered(typeof(DataAccess.LoginUser)))
{
BsonClassMap.RegisterClassMap<DataAccess.LoginUser>(md =>
{
md.AutoMap();
md.IdMemberMap.SetSerializer(new StringSerializer(BsonType.ObjectId));
md.IdMemberMap.SetIgnoreIfDefault(true);
});
}
}
}
}

View File

@ -0,0 +1,19 @@
namespace Bootstrap.DataAccess.MongoDB
{
/// <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;
}
}
}