更改通知管理页面菜单为Notifications
This commit is contained in:
parent
0f66ef9d6c
commit
82a2238d28
|
@ -278,7 +278,7 @@
|
|||
<Content Include="Views\Shared\SubMenuTree.cshtml" />
|
||||
<Content Include="Views\Home\Lock.cshtml" />
|
||||
<Content Include="Views\Home\Register.cshtml" />
|
||||
<Content Include="Views\Admin\News.cshtml" />
|
||||
<Content Include="Views\Admin\Notifications.cshtml" />
|
||||
<Content Include="Views\Admin\Infos.cshtml" />
|
||||
<None Include="Web.Debug.config">
|
||||
<DependentUpon>Web.config</DependentUpon>
|
||||
|
|
|
@ -94,9 +94,9 @@ namespace Bootstrap.Admin.Controllers
|
|||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ActionResult News()
|
||||
public ActionResult Notifications()
|
||||
{
|
||||
var v = new NavigatorBarModel("~/Admin/News");
|
||||
var v = new NavigatorBarModel("~/Admin/Notifications");
|
||||
return View(v);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<div class="panel-heading">用户注册<span class="pull-right"><a href="javascript:;" class="tooltips fa fa-refresh" data-placement="left" data-original-title="点击刷新"></a></span></div>
|
||||
<div class="panel-body">
|
||||
<div class="tasks-widget">
|
||||
<ul id="sortable" class="task-list ui-sortable">
|
||||
<ul id="tasks-users" class="task-list ui-sortable">
|
||||
@foreach (var nofi in Model.Notifications)
|
||||
{
|
||||
<li class="list-primary">
|
||||
|
@ -45,7 +45,7 @@
|
|||
<div class="panel-heading">程序错误<a href="javascript:;" class="pull-right tooltips fa fa-refresh" data-placement="left" data-original-title="点击刷新"></a></div>
|
||||
<div class="panel-body">
|
||||
<div class="tasks-widget">
|
||||
<ul id="sortable" class="task-list ui-sortable">
|
||||
<ul id="tasks-app" class="task-list ui-sortable">
|
||||
@foreach (var nofi in Model.Notifications)
|
||||
{
|
||||
<li class="list-warning">
|
||||
|
@ -70,7 +70,7 @@
|
|||
<div class="panel-heading">数据库报警<span class="pull-right"><a href="javascript:;" class="tooltips fa fa-refresh" data-placement="left" data-original-title="点击刷新"></a></span></div>
|
||||
<div class="panel-body">
|
||||
<div class="tasks-widget">
|
||||
<ul id="sortable" class="task-list ui-sortable">
|
||||
<ul id="tasks-db" class="task-list ui-sortable">
|
||||
@foreach (var nofi in Model.Notifications)
|
||||
{
|
||||
<li class="list-danger">
|
|
@ -1,4 +1,4 @@
|
|||
@model Bootstrap.Admin.Models.HeaderBarModel
|
||||
@model HeaderBarModel
|
||||
<!--header start-->
|
||||
<header class="header white-bg">
|
||||
<a href="#" data-toggle="dropdown" class="sidebar-toggle-box dropdown-toggle">
|
||||
|
@ -165,56 +165,43 @@
|
|||
</li>
|
||||
<!-- inbox dropdown end -->
|
||||
<!-- notification dropdown start-->
|
||||
@if (Model.Notifications.Count() > 0)
|
||||
{
|
||||
<li id="header_notification_bar" class="dropdown">
|
||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||
<i class="fa fa-bell-o"></i>
|
||||
<span class="badge bg-warning">5</span>
|
||||
<span class="badge bg-warning">@Model.Notifications.Count()</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu notification">
|
||||
<div class="notify-arrow notify-arrow-yellow"></div>
|
||||
<li>
|
||||
<p>您有 5 条新通知</p>
|
||||
<p>您有 @Model.Notifications.Count() 条新通知</p>
|
||||
</li>
|
||||
@foreach (var noti in Model.Notifications.Take(6))
|
||||
{
|
||||
<li>
|
||||
<a href="#">
|
||||
<span class="label label-danger"><i class="fa fa-bolt"></i></span>
|
||||
服务器超载
|
||||
<span class="small italic">34 分钟</span>
|
||||
@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>
|
||||
</li>
|
||||
}
|
||||
<li>
|
||||
<a href="#">
|
||||
<span class="label label-warning"><i class="fa fa-bell"></i></span>
|
||||
服务器未响应
|
||||
<span class="small italic">1 小时</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<span class="label label-danger"><i class="fa fa-bolt"></i></span>
|
||||
数据库内存过高
|
||||
<span class="small italic">4 小时</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<span class="label label-success"><i class="fa fa-plus"></i></span>
|
||||
新用户注册
|
||||
<span class="small italic">刚刚</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
<span class="label label-info"><i class="fa fa-bullhorn"></i></span>
|
||||
程序出现错误
|
||||
<span class="small italic">10 分钟</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">查看所有通知</a>
|
||||
<a href="~/Admin/Notifications">查看所有通知</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
}
|
||||
<!-- notification dropdown end -->
|
||||
</ul>
|
||||
<!-- notification end -->
|
||||
|
@ -236,7 +223,7 @@
|
|||
<div class="arrow-up"></div>
|
||||
<li><a href="~/Admin/Infos"><i class=" fa fa-suitcase"></i>个人中心</a></li>
|
||||
<li><a href="~/Admin/Index"><i class="fa fa-cog"></i>设置</a></li>
|
||||
<li><a href="~/Admin/News"><i class="fa fa-bell-o"></i>通知<span class="badge bg-success">5</span></a></li>
|
||||
<li><a href="~/Admin/Notifications"><i class="fa fa-bell-o"></i>通知<span class="badge bg-success">@Model.Notifications.Count()</span></a></li>
|
||||
<li><a href="~/Home/Logout"><i class="fa fa-key"></i>注销</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="menuIds"></param>
|
||||
/// <param name="dictIds"></param>
|
||||
/// <param name="logIds"></param>
|
||||
/// <param name="notifyIds"></param>
|
||||
internal static void ClearCache(string roleIds = null, string userIds = null, string groupIds = null, string menuIds = null, string dictIds = null, string logIds = null, string notifyIds = null)
|
||||
{
|
||||
var cacheKeys = new List<string>();
|
||||
|
|
|
@ -1,16 +1,51 @@
|
|||
using System;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class Notification
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int ID { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Category { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public DateTime RegisterTime { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public DateTime ProcessTime { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ProcessBy { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ProcessResult { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Status { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 市场描述 2分钟内为刚刚
|
||||
/// </summary>
|
||||
public string Period { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
|
@ -18,14 +19,13 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Notification> RetrieveNotifications(string category = null)
|
||||
public static IEnumerable<Notification> RetrieveNotifications()
|
||||
{
|
||||
return CacheManager.GetOrAdd(RetrieveNotifyDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNotifyDataKey), key =>
|
||||
var ret = CacheManager.GetOrAdd(RetrieveNotifyDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNotifyDataKey), key =>
|
||||
{
|
||||
string sql = "select * from Notifications where Category=@Category";
|
||||
string sql = "select * from Notifications";
|
||||
List<Notification> notifications = new List<Notification>();
|
||||
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", Convert.ToInt32(category), ParameterDirection.Input));
|
||||
try
|
||||
{
|
||||
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
|
||||
|
@ -51,6 +51,15 @@ namespace Bootstrap.DataAccess
|
|||
return notifications;
|
||||
|
||||
}, CacheSection.RetrieveDescByKey(RetrieveNotifyDataKey));
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -66,7 +75,7 @@ namespace Bootstrap.DataAccess
|
|||
{
|
||||
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_ProcessRegisterUser"))
|
||||
{
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", Convert.ToInt32(id), ParameterDirection.Input));
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", id, ParameterDirection.Input));
|
||||
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
|
||||
}
|
||||
CacheCleanUtility.ClearCache(notifyIds: id);
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Bootstrap.DataAccessTests
|
|||
[TestMethod]
|
||||
public void RetrieveNotificationsTest()
|
||||
{
|
||||
Assert.IsTrue(NotificationHelper.RetrieveNotifications("0").Count() >= 1, "带参数的NotificationHelper.RetrieveNotifications方法调用失败,请检查数据库连接或者数据库SQL语句");
|
||||
Assert.IsTrue(NotificationHelper.RetrieveNotifications().Count() >= 0, "带参数的NotificationHelper.RetrieveNotifications方法调用失败,请检查数据库连接或者数据库SQL语句");
|
||||
}
|
||||
[TestMethod]
|
||||
public void ProcessRegisterUserTest()
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace Bootstrap.DataAccess.Tests
|
|||
// 测试更新用户方法 ID != 0
|
||||
var user = users.FirstOrDefault(u => u.UserName == User.UserName);
|
||||
user.DisplayName = "测试者2号";
|
||||
user.Description = "测试";
|
||||
Assert.IsTrue(UserHelper.SaveUser(user), string.Format("更新用户ID={0}操作失败,请检查UserHelper.SaveUser方法", user.ID));
|
||||
var ret = UserHelper.RetrieveUsers(user.ID);
|
||||
Assert.IsTrue(ret.Count() == 1, "带参数的UserHelper.RetrieveUsers方法调用失败");
|
||||
|
|
|
@ -31,7 +31,7 @@ INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [C
|
|||
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (6, 0, N'字典表维护', 50, N'fa fa-book', N'~/Admin/Dicts', N'0')
|
||||
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (7, 0, N'个性化维护', 60, N'fa fa-pencil', N'~/Admin/Profiles', N'0')
|
||||
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (8, 0, N'系统日志', 70, N'fa fa-gears', N'~/Admin/Logs', N'0')
|
||||
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (9, 0, N'通知管理', 80, N'fa fa-bell-o', N'~/Admin/News', N'0')
|
||||
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (9, 0, N'通知管理', 80, N'fa fa-bell-o', N'~/Admin/Notifications', N'0')
|
||||
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (10, 0, N'个人中心', 90, N'fa fa-suitcase', N'~/Admin/Infos', N'0')
|
||||
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (11, 0, N'返回前台', 100, N'fa fa-hand-o-left', N'~/Home/Index', N'0')
|
||||
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (12, 0, N'锁定屏幕', 110, N'fa fa-lock', N'~/Home/Lock', N'0')
|
||||
|
@ -39,10 +39,10 @@ INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [C
|
|||
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (14, 13, N'锁定屏幕', 10, N'fa fa-lock', N'~/Home/Lock', N'1')
|
||||
SET IDENTITY_INSERT [dbo].[Navigations] OFF
|
||||
|
||||
DELETE FROM RoleGroup where ID in (1)
|
||||
SET IDENTITY_INSERT [dbo].[RoleGroup] ON
|
||||
INSERT [dbo].[RoleGroup] ([ID], [RoleID], [GroupID]) VALUES (1, 1, 1)
|
||||
SET IDENTITY_INSERT [dbo].[RoleGroup] OFF
|
||||
DELETE FROM GROUPS WHERE ID = 1
|
||||
SET IDENTITY_INSERT [dbo].[Groups] ON
|
||||
INSERT [dbo].[Groups] ([ID], [GroupName], [Description]) VALUES (1, 1, N'系统默认组')
|
||||
SET IDENTITY_INSERT [dbo].[Groups] OFF
|
||||
|
||||
DELETE FROM Roles where ID in (1, 2)
|
||||
SET IDENTITY_INSERT [dbo].[Roles] ON
|
||||
|
@ -50,6 +50,11 @@ INSERT [dbo].[Roles] ([ID], [RoleName], [Description]) VALUES (1, N'Administrato
|
|||
INSERT [dbo].[Roles] ([ID], [RoleName], [Description]) VALUES (2, N'Default', N'默认用户,可访问前台页面')
|
||||
SET IDENTITY_INSERT [dbo].[Roles] OFF
|
||||
|
||||
DELETE FROM RoleGroup where ID in (1)
|
||||
SET IDENTITY_INSERT [dbo].[RoleGroup] ON
|
||||
INSERT [dbo].[RoleGroup] ([ID], [RoleID], [GroupID]) VALUES (1, 1, 1)
|
||||
SET IDENTITY_INSERT [dbo].[RoleGroup] OFF
|
||||
|
||||
DELETE FROM UserGroup where ID in (1)
|
||||
SET IDENTITY_INSERT [dbo].[UserGroup] ON
|
||||
INSERT [dbo].[UserGroup] ([ID], [UserID], [GroupID]) VALUES (1, 1, 1)
|
||||
|
|
Loading…
Reference in New Issue