2019-02-28 16:44:50 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Bootstrap.Admin
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class OnlineUser
|
|
|
|
|
{
|
2019-03-01 13:48:25 +08:00
|
|
|
|
private ConcurrentQueue<KeyValuePair<DateTime, string>> _requestUrls = new ConcurrentQueue<KeyValuePair<DateTime, string>>();
|
2019-02-28 16:44:50 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2019-03-01 13:48:25 +08:00
|
|
|
|
public string UserName { get; set; }
|
2019-02-28 16:44:50 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2019-03-01 13:48:25 +08:00
|
|
|
|
public DateTime FirstAccessTime { get; set; }
|
2019-02-28 16:44:50 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTime LastAccessTime { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Method { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Ip { get; set; }
|
|
|
|
|
|
2019-03-01 02:00:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string RequestUrl { get; set; }
|
|
|
|
|
|
2019-02-28 16:44:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IEnumerable<KeyValuePair<DateTime, string>> RequestUrls
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _requestUrls.ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="url"></param>
|
|
|
|
|
public void AddRequestUrl(string url)
|
|
|
|
|
{
|
|
|
|
|
_requestUrls.Enqueue(new KeyValuePair<DateTime, string>(DateTime.Now, url));
|
2019-03-01 02:00:47 +08:00
|
|
|
|
if (_requestUrls.Count > 5)
|
2019-02-28 16:44:50 +08:00
|
|
|
|
{
|
|
|
|
|
_requestUrls.TryDequeue(out _);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|