mirror of
https://github.com/anjoy8/Blog.Core.git
synced 2024-09-20 23:48:27 +08:00
welcome data
This commit is contained in:
parent
3fe4c66796
commit
8fd7ee0a5e
|
@ -120,25 +120,15 @@ namespace Blog.Core.Controllers
|
|||
};
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public MessageModel<List<UserAccessModel>> GetAccessLogs([FromServices]IWebHostEnvironment environment)
|
||||
{
|
||||
var Logs = JsonConvert.DeserializeObject<List<UserAccessModel>>("[" + LogLock.ReadLog(Path.Combine(environment.ContentRootPath, "Log"), "RecordAccessLogs_", Encoding.UTF8, ReadType.PrefixLatest) + "]");
|
||||
|
||||
Logs = Logs.Where(d => d.BeginTime.ObjToDate() >= DateTime.Today).OrderByDescending(d => d.BeginTime).Take(50).ToList();
|
||||
|
||||
return new MessageModel<List<UserAccessModel>>()
|
||||
{
|
||||
msg = "获取成功",
|
||||
success = true,
|
||||
response = Logs
|
||||
};
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public MessageModel<WelcomeInitData> GetActiveUsers([FromServices]IWebHostEnvironment environment)
|
||||
{
|
||||
var accessLogsToday = JsonConvert.DeserializeObject<List<UserAccessModel>>("[" + LogLock.ReadLog(Path.Combine(environment.ContentRootPath, "Log"), "RecordAccessLogs_", Encoding.UTF8, ReadType.PrefixLatest) + "]");
|
||||
var accessLogsToday = JsonConvert.DeserializeObject<List<UserAccessModel>>("[" + LogLock.ReadLog(
|
||||
Path.Combine(environment.ContentRootPath, "Log"), "RecordAccessLogs_", Encoding.UTF8, ReadType.PrefixLatest
|
||||
) + "]")
|
||||
.Where(d => d.BeginTime.ObjToDate() >= DateTime.Today);
|
||||
|
||||
var Logs = accessLogsToday.OrderByDescending(d => d.BeginTime).Take(50).ToList();
|
||||
|
||||
var errorCountToday = LogLock.GetLogData().Where(d => d.Import == 9).Count();
|
||||
|
||||
|
@ -163,7 +153,8 @@ namespace Blog.Core.Controllers
|
|||
{
|
||||
activeUsers = activeUsers,
|
||||
activeUserCount = activeUsersCount,
|
||||
errorCount = errorCountToday
|
||||
errorCount = errorCountToday,
|
||||
logs = Logs
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -213,9 +204,9 @@ namespace Blog.Core.Controllers
|
|||
|
||||
public class WelcomeInitData
|
||||
{
|
||||
|
||||
public List<ActiveUserVM> activeUsers { get; set; }
|
||||
public int activeUserCount { get; set; }
|
||||
public List<UserAccessModel> logs { get; set; }
|
||||
public int errorCount { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace Blog.Core.Common.LogHelper
|
|||
|
||||
try
|
||||
{
|
||||
var sqllogContent = ReadLog(Path.Combine(_contentRoot, "Log"), "SqlLog_", Encoding.UTF8, ReadType.Prefix);
|
||||
var sqllogContent = ReadLog(Path.Combine(_contentRoot, "Log"), "SqlLog_", Encoding.UTF8, ReadType.PrefixLatest);
|
||||
|
||||
if (!string.IsNullOrEmpty(sqllogContent))
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ namespace Blog.Core.Common.LogHelper
|
|||
|
||||
try
|
||||
{
|
||||
var Logs = JsonConvert.DeserializeObject<List<RequestInfo>>("[" + ReadLog(Path.Combine(_contentRoot, "Log"), "RequestIpInfoLog_", Encoding.UTF8, ReadType.Prefix) + "]");
|
||||
var Logs = JsonConvert.DeserializeObject<List<RequestInfo>>("[" + ReadLog(Path.Combine(_contentRoot, "Log"), "RequestIpInfoLog_", Encoding.UTF8, ReadType.PrefixLatest) + "]");
|
||||
|
||||
Logs = Logs.Where(d => d.Datetime.ObjToDate() >= DateTime.Today).ToList();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user