页面头部和通知管理中显示注册用户信息

This commit is contained in:
lq_avenue 2016-11-11 18:02:27 +08:00
parent b50081cfea
commit fac7e6a09d
7 changed files with 75 additions and 23 deletions

View File

@ -17,7 +17,7 @@ namespace Bootstrap.Admin.Models
UserID = user.ID;
HomeUrl = "~/";
Menus = MenuHelper.RetrieveLinksByUserName(UserName);
Notifications = NotificationHelper.RetrieveNotifications();
Notifications = NotificationHelper.RetrieveUser();
}
public string UserName { get; protected set; }
/// <summary>
@ -43,6 +43,6 @@ namespace Bootstrap.Admin.Models
/// <summary>
///
/// </summary>
public IEnumerable<Notification> Notifications { get; set; }
public IEnumerable<User> Notifications { get; set; }
}
}

View File

@ -21,14 +21,14 @@
<div class="panel-body">
<div class="tasks-widget">
<ul id="tasks-users" class="task-list ui-sortable">
@foreach (var nofi in Model.Notifications)
@foreach (var u in Model.Notifications)
{
<li class="list-primary">
<i class="fa fa-ellipsis-v"></i>
<div class="task-title">
<span class="task-title-sp">@nofi.Title</span>
<span class="task-title-sp">@u.DisplayName</span>
<div class="task-wrapper notifi">
<span class="task-value tooltips" data-placement="top" data-original-title="@nofi.Content">@nofi.Content</span>
<span class="task-value tooltips" data-placement="top" data-original-title="@u.Description">@u.Description</span>
</div>
<div class="pull-right hidden-phone">
<button class="btn btn-success btn-xs fa fa-check tooltips" data-placement="left" data-original-title="同意授权"></button>
@ -51,9 +51,9 @@
<li class="list-warning">
<i class="fa fa-ellipsis-v"></i>
<div class="task-title">
<span class="task-title-sp">@nofi.Title</span>
<span class="task-title-sp">@nofi.DisplayName</span>
<div class="task-wrapper notifi">
<span class="task-value tooltips" data-placement="top" data-original-title="@nofi.Content">@nofi.Content</span>
<span class="task-value tooltips" data-placement="top" data-original-title="@nofi.Description">@nofi.Description</span>
</div>
<div class="pull-right hidden-phone">
<button class="btn btn-success btn-xs fa fa-check tooltips" data-placement="left" data-original-title="同意授权"></button>
@ -76,9 +76,9 @@
<li class="list-danger">
<i class="fa fa-ellipsis-v"></i>
<div class="task-title">
<span class="task-title-sp">@nofi.Title</span>
<span class="task-title-sp">@nofi.DisplayName</span>
<div class="task-wrapper notifi">
<span class="task-value tooltips" data-placement="top" data-original-title="@nofi.Content">@nofi.Content</span>
<span class="task-value tooltips" data-placement="top" data-original-title="@nofi.Description">@nofi.Description</span>
</div>
<div class="pull-right hidden-phone">
<button class="btn btn-success btn-xs fa fa-check tooltips" data-placement="left" data-original-title="同意授权"></button>

View File

@ -177,22 +177,11 @@
<li>
<p>您有 @Model.Notifications.Count() 条新通知</p>
</li>
@foreach (var noti in Model.Notifications.Take(6))
@foreach (var u in Model.Notifications.Take(6))
{
<li>
<a href="#">
@if (noti.Category == "0")
{
<span class="label label-success"><i class="fa fa-plus"></i></span><div>@noti.Content</div><span class="small italic">@noti.Period</span>
}
else if (noti.Category == "1")
{
<span class="label label-warning"><i class="fa fa-bell"></i></span><div>@noti.Content</div><span class="small italic">@noti.Period</span>
}
else
{
<span class="label label-danger"><i class="fa fa-bolt"></i></span><div>@noti.Content</div><span class="small italic">@noti.Period</span>
}
<a href="~/Admin/Notifications">
<span class="label label-success"><i class="fa fa-plus"></i></span><div>@u.DisplayName</div><span class="small italic">@u.Period</span>
</a>
</li>
}

View File

@ -43,6 +43,7 @@
<add key="DictHelper-RetrieveDicts" interval="600" desc="所有字典数据缓存"/>
<add key="DictHelper-RetrieveDictsWebSettings" interval="600" desc="网站配置数据缓存"/>
<add key="NotificationHelper-RetrieveNotifications" interval="600" desc="通知管理数据缓存"/>
<add key="UserHelper-RetrieveUsersForNotify" interval="600" desc="新注册用户通知管理数据缓存" />
</cacheManager>
<cacheManagerList>

View File

@ -14,6 +14,29 @@ namespace Bootstrap.DataAccess
{
internal const string RetrieveNotifyDataKey = "NotificationHelper-RetrieveNotifications";
/// <summary>
/// 查询新注册用户
/// </summary>
/// <returns></returns>
public static IEnumerable<User> RetrieveUser()
{
var ret = UserHelper.RetrieveUsersForNotify();
if (ret != null)
{
ret.AsParallel().ForAll(n =>
{
var ts = DateTime.Now - n.RegisterTime;
if (ts.TotalMinutes < 5) n.Period = "刚刚";
else if (ts.Days > 0) n.Period = string.Format("{0}天", ts.Days);
else if (ts.Hours > 0) n.Period = string.Format("{0}小时", ts.Hours);
else if (ts.Minutes > 0) n.Period = string.Format("{0}分钟", ts.Minutes);
});
return ret;
}
List<User> users = new List<User>();
return users;
}
/// <summary>
/// 新用户注册的通知的面板显示
/// </summary>

View File

@ -43,5 +43,9 @@ namespace Bootstrap.DataAccess
/// 获得/设置 用户当前状态 0 表示管理员注册用户 1 表示用户自己注册 2 表示管理员批复
/// </summary>
public int UserStatus { get; set; }
/// <summary>
/// 获得/设置 通知描述 2分钟内为刚刚
/// </summary>
public string Period { get; set; }
}
}

View File

@ -23,6 +23,7 @@ namespace Bootstrap.DataAccess
private const string RetrieveUsersByNameDataKey = "UserHelper-RetrieveUsersByName";
internal const string RetrieveUsersByRoleIDDataKey = "UserHelper-RetrieveUsersByRoleId";
internal const string RetrieveUsersByGroupIDDataKey = "UserHelper-RetrieveUsersByGroupId";
internal const string RetrieveUsersForNotifyDataKey = "UserHelper-RetrieveUsersForNotify";
/// <summary>
/// 查询所有用户
/// </summary>
@ -95,6 +96,40 @@ namespace Bootstrap.DataAccess
return user;
}, CacheSection.RetrieveDescByKey(RetrieveUsersByNameDataKey));
}
/// <summary>
/// 查询所有的新注册用户
/// </summary>
/// <returns></returns>
public static IEnumerable<User> RetrieveUsersForNotify()
{
string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null";
var ret = CacheManager.GetOrAdd(RetrieveUsersForNotifyDataKey, CacheSection.RetrieveIntervalByKey(RetrieveUsersForNotifyDataKey), key =>
{
List<User> Users = new List<User>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try
{
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{
while (reader.Read())
{
Users.Add(new User()
{
ID = (int)reader[0],
UserName = (string)reader[1],
DisplayName = (string)reader[2],
RegisterTime = (DateTime)reader[3],
Description = (string)reader[4]
});
}
}
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return Users;
}, CacheSection.RetrieveDescByKey(RetrieveUsersForNotifyDataKey));
return ret;
}
/// <summary>
/// 删除用户
/// </summary>