parent
7ddae1a427
commit
dafd2abe4d
|
@ -231,6 +231,7 @@
|
|||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\LogsController.cs" />
|
||||
<Compile Include="Controllers\MenusController.cs" />
|
||||
<Compile Include="Controllers\MessagesController.cs" />
|
||||
<Compile Include="Controllers\NotificationsController.cs" />
|
||||
<Compile Include="Controllers\ProfilesController.cs" />
|
||||
<Compile Include="Controllers\RolesController.cs" />
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
using Bootstrap.Admin.Models;
|
||||
using Bootstrap.DataAccess;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Bootstrap.Admin.Controllers
|
||||
{
|
||||
public class MessagesController : Controller
|
||||
{
|
||||
public ActionResult Inbox()
|
||||
{
|
||||
var v = new NavigatorBarModel("~/Admin/Messages/Inbox");
|
||||
v.MessageList = MessageHelper.Inbox(User.Identity.Name);
|
||||
return View(v);
|
||||
}
|
||||
public ActionResult SendMail()
|
||||
{
|
||||
var v = new NavigatorBarModel("~/Admin/Messages/SendMail");
|
||||
v.MessageList = MessageHelper.SendMail(User.Identity.Name);
|
||||
return View(v);
|
||||
}
|
||||
public ActionResult Mark()
|
||||
{
|
||||
var v = new NavigatorBarModel("~/Admin/Messages/Mark");
|
||||
v.MessageList = MessageHelper.Mark(User.Identity.Name);
|
||||
return View(v);
|
||||
}
|
||||
public ActionResult Trash()
|
||||
{
|
||||
var v = new NavigatorBarModel("~/Admin/Messages/Trash");
|
||||
v.MessageList = MessageHelper.Trash(User.Identity.Name);
|
||||
return View(v);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -24,6 +24,8 @@ namespace Bootstrap.Admin.Models
|
|||
var msgs = MessageHelper.RetrieveMessagesHeader(UserName);
|
||||
MessageCount = msgs.Count();
|
||||
Messages = msgs.Take(6);
|
||||
MessageList = MessageHelper.RetrieveMessages(UserName);
|
||||
|
||||
}
|
||||
public string UserName { get; protected set; }
|
||||
/// <summary>
|
||||
|
@ -62,5 +64,10 @@ namespace Bootstrap.Admin.Models
|
|||
/// 获得/设置 消息数量
|
||||
/// </summary>
|
||||
public int MessageCount { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 消息列表
|
||||
/// </summary>
|
||||
public IEnumerable<Message> MessageList { get; set; }
|
||||
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
ViewBag.Title = "站内消息";
|
||||
Layout = "~/Views/Shared/_Admin.cshtml";
|
||||
}
|
||||
|
||||
@section header {
|
||||
@Html.Partial("Header", Model)
|
||||
}
|
||||
|
@ -15,7 +16,7 @@
|
|||
<a href="javascript:;" class="inbox-avatar">
|
||||
<img src="../../content/images/logo6.jpg" alt="">
|
||||
</a>
|
||||
<div class="user-name"><h5><a href="#">Argo Zhang</a></h5></div>
|
||||
<div class="user-name"><h5><a href="#">@Model.DisplayName</a></h5></div>
|
||||
</div>
|
||||
<div class="inbox-body">
|
||||
<a class="btn btn-compose" data-toggle="modal" href="#myModal">
|
||||
|
@ -24,22 +25,20 @@
|
|||
</div>
|
||||
<ul class="inbox-nav inbox-divider">
|
||||
<li class="active">
|
||||
<a href="#"><i class="fa fa-inbox"></i>收信箱<span class="label label-danger pull-right">2</span></a>
|
||||
<a href="~/Admin/Messages/Inbox"><i class="fa fa-inbox"></i>收信箱<span class="label label-danger pull-right">2</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"><i class="fa fa-envelope-o"></i>发信箱</a>
|
||||
<a href="~/Admin/Messages/SendMail"><i class="fa fa-envelope-o"></i>发信箱</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"><i class="fa fa-bookmark-o"></i>标旗消息</a>
|
||||
<a href="~/Admin/Messages/Mark"><i class="fa fa-bookmark-o"></i>标旗消息</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"><i class=" fa fa-external-link"></i>草稿箱<span class="label label-info pull-right">30</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"><i class=" fa fa-trash-o"></i>垃圾箱</a>
|
||||
<a href="~/Admin/Messages/Trash"><i class=" fa fa-trash-o"></i>垃圾箱</a>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<aside class="lg-side">
|
||||
<div class="inbox-head">
|
||||
<h3>消息列表</h3>
|
||||
|
@ -47,46 +46,20 @@
|
|||
<div class="inbox-body">
|
||||
<table class="table table-inbox table-hover">
|
||||
<tbody>
|
||||
<tr class="unread">
|
||||
<td class="inbox-small-cells">
|
||||
<input type="checkbox" class="mail-checkbox">
|
||||
</td>
|
||||
<td class="inbox-small-cells"><i class="fa fa-star"></i></td>
|
||||
<td class="view-message dont-show">消息人</td>
|
||||
<td class="view-message ">消息标题</td>
|
||||
<td class="view-message inbox-small-cells"><i class="fa fa-paperclip"></i></td>
|
||||
<td class="view-message text-right">09:27</td>
|
||||
</tr>
|
||||
<tr class="unread">
|
||||
<td class="inbox-small-cells">
|
||||
<input type="checkbox" class="mail-checkbox">
|
||||
</td>
|
||||
<td class="inbox-small-cells"><i class="fa fa-star inbox-started"></i></td>
|
||||
<td class="view-message dont-show">消息人<span class="label label-warning pull-right">紧急</span></td>
|
||||
<td class="view-message">消息内容</td>
|
||||
<td class="view-message inbox-small-cells"></td>
|
||||
<td class="view-message text-right">12:23</td>
|
||||
</tr>
|
||||
<tr class="">
|
||||
<td class="inbox-small-cells">
|
||||
<input type="checkbox" class="mail-checkbox">
|
||||
</td>
|
||||
<td class="inbox-small-cells"><i class="fa fa-star"></i></td>
|
||||
<td class="view-message dont-show">消息人<span class="label label-success pull-right">处理</span></td>
|
||||
<td class="view-message">消息内容</td>
|
||||
<td class="view-message inbox-small-cells"></td>
|
||||
<td class="view-message text-right">11:23</td>
|
||||
</tr>
|
||||
<tr class="">
|
||||
<td class="inbox-small-cells">
|
||||
<input type="checkbox" class="mail-checkbox">
|
||||
</td>
|
||||
<td class="inbox-small-cells"><i class="fa fa-star inbox-started"></i></td>
|
||||
<td class="view-message dont-show">消息人<span class="label label-danger pull-right">紧急</span></td>
|
||||
<td class="view-message">消息内容</td>
|
||||
<td class="view-message inbox-small-cells"><i class="fa fa-paperclip"></i></td>
|
||||
<td class="view-message text-right">11:23</td>
|
||||
@foreach (var mess in Model.MessageList)
|
||||
{
|
||||
<tr >
|
||||
<td class="inbox-small-cells"><input type="checkbox" class="mail-checkbox"></td>
|
||||
@if(mess.Mark==0)
|
||||
{ <td class="inbox-small-cells"><i class="fa fa-star"></i></td> }
|
||||
else
|
||||
{ <td class="inbox-small-cells"><i class="fa fa-star inbox-started"></i></td> }
|
||||
<td class="view-message dont-show">@mess.From</td>
|
||||
<td class="view-message dont-show">@mess.To</td>
|
||||
<td class="view-message ">@mess.Title</td>
|
||||
<td class="view-message text-right">@mess.SendTime</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -45,8 +45,7 @@
|
|||
<add key="NotificationHelper-RetrieveNotifications" interval="600" desc="通知管理数据缓存"/>
|
||||
<add key="UserHelper-RetrieveNewUsers" interval="300" desc="新用户数据缓存" />
|
||||
<add key="ExceptionHelper-RetrieveExceptions" interval="600" desc="程序异常数据缓存"/>
|
||||
<add key="MessageHelper-RetrieveMessagesFromOthers" interval="600" desc="接收消息数据缓存" />
|
||||
<add key="MessageHelper-RetrieveMessagesToOthers" interval="600" desc="发送消息数据缓存"/>
|
||||
<add key="MessageHelper-RetrieveMessages" interval="600" desc="消息数据缓存" />
|
||||
</cacheManager>
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client.zh-Hans" version="5.0.0" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core.zh-Hans" version="5.0.0" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost.zh-Hans" version="5.0.0" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
|
||||
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net45" />
|
||||
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net45" developmentDependency="true" />
|
||||
|
|
|
@ -37,11 +37,23 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public DateTime SendTime { get; set; }
|
||||
/// <summary>
|
||||
/// 消息状态:0-未读,1-已读,2-删除
|
||||
/// 消息状态:0-未读,1-已读
|
||||
/// 和Dict表的通知消息关联
|
||||
/// </summary>
|
||||
public string Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标旗状态:0-未标旗,1-已标旗
|
||||
/// </summary>
|
||||
public int Mark { get; set; }
|
||||
/// <summary>
|
||||
/// 删除状态:0-未删除,1-已删除
|
||||
/// </summary>
|
||||
public int IsDelete { get; set; }
|
||||
/// <summary>
|
||||
/// 消息标签:0-一般,1-紧要
|
||||
/// 和Dict表的消息标签关联
|
||||
/// </summary>
|
||||
public string Label { get; set; }
|
||||
/// <summary>
|
||||
/// 获得/设置 时间描述 2分钟内为刚刚
|
||||
/// </summary>
|
||||
|
|
|
@ -15,19 +15,19 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public class MessageHelper
|
||||
{
|
||||
internal const string RetrieveMessageFromDataKey = "MessageHelper-RetrieveMessagesFromOthers";
|
||||
internal const string RetrieveMessageToDataKey = "MessageHelper-RetrieveMessagesToOthers";
|
||||
internal const string RetrieveMessageDataKey = "MessageHelper-RetrieveMessages";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取其他人发送给自己的消息列表
|
||||
/// 所有有关userName所有消息列表
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Message> RetrieveMessagesFromOthers(string userName)
|
||||
public static IEnumerable<Message> RetrieveMessages(string userName)
|
||||
{
|
||||
var messageRet = CacheManager.GetOrAdd(RetrieveMessageFromDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageFromDataKey), key =>
|
||||
var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key =>
|
||||
{
|
||||
string sql = "select * from [Messages] where [To]=@UserName";
|
||||
string sql = "select * from [Messages] where [To]=@UserName or [From]=@UserName";
|
||||
List<Message> messages = new List<Message>();
|
||||
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
|
||||
try
|
||||
|
@ -45,7 +45,10 @@ namespace Bootstrap.DataAccess
|
|||
From = (string)reader[3],
|
||||
To = (string)reader[4],
|
||||
SendTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue),
|
||||
Status = (string)reader[6]
|
||||
Status = (string)reader[6],
|
||||
Mark=(int)reader[7],
|
||||
IsDelete=(int)reader[8],
|
||||
Label=(string)reader[9]
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -54,47 +57,48 @@ namespace Bootstrap.DataAccess
|
|||
catch (Exception ex) { ExceptionManager.Publish(ex); }
|
||||
return messages;
|
||||
|
||||
}, CacheSection.RetrieveDescByKey(RetrieveMessageFromDataKey));
|
||||
}, CacheSection.RetrieveDescByKey(RetrieveMessageDataKey));
|
||||
return messageRet.OrderByDescending(n => n.SendTime);
|
||||
}
|
||||
/// <summary>
|
||||
/// 自己获取发送给其他人的消息列表
|
||||
/// 收件箱
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
|
||||
public static IEnumerable<Message> Inbox(string userName)
|
||||
{
|
||||
var messageRet = RetrieveMessages(userName);
|
||||
return messageRet.Where(n => n.To.Equals(userName)).Select(n => n);
|
||||
}
|
||||
/// <summary>
|
||||
/// 发件箱
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Message> RetrieveMessagesToOthers(string userName)
|
||||
public static IEnumerable<Message> SendMail(string userName)
|
||||
{
|
||||
var messageRet = CacheManager.GetOrAdd(RetrieveMessageToDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageToDataKey), key =>
|
||||
{
|
||||
string sql = "select * from [Messages] where [From]=@UserName";
|
||||
List<Message> messages = new List<Message>();
|
||||
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
|
||||
try
|
||||
{
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", userName, ParameterDirection.Input));
|
||||
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
messages.Add(new Message()
|
||||
{
|
||||
ID = (int)reader[0],
|
||||
Title = (string)reader[1],
|
||||
Content = (string)reader[2],
|
||||
From = (string)reader[3],
|
||||
To = (string)reader[4],
|
||||
SendTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue),
|
||||
Status = (string)reader[6]
|
||||
|
||||
});
|
||||
var messageRet = RetrieveMessages(userName);
|
||||
return messageRet.Where(n => n.To.Equals(userName)).Select(n => n);
|
||||
}
|
||||
/// <summary>
|
||||
/// 垃圾箱
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Message> Trash(string userName)
|
||||
{
|
||||
var messageRet = RetrieveMessages(userName);
|
||||
return messageRet.Where(n => n.Trash==1).Select(n => n);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { ExceptionManager.Publish(ex); }
|
||||
return messages;
|
||||
|
||||
}, CacheSection.RetrieveDescByKey(RetrieveMessageToDataKey));
|
||||
return messageRet.OrderByDescending(n => n.SendTime);
|
||||
/// <summary>
|
||||
/// 标旗
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Message> Mark(string userName)
|
||||
{
|
||||
var messageRet = RetrieveMessages(userName);
|
||||
return messageRet.Where(n => n.Mark==1).Select(n => n);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取Header处显示的消息列表
|
||||
|
@ -103,7 +107,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public static IEnumerable<Message> RetrieveMessagesHeader(string userName)
|
||||
{
|
||||
var messageRet = RetrieveMessagesFromOthers(userName);
|
||||
var messageRet = Inbox(userName);
|
||||
messageRet.AsParallel().ForAll(n =>
|
||||
{
|
||||
var ts = DateTime.Now - n.SendTime;
|
||||
|
|
|
@ -6,7 +6,7 @@ SET IDENTITY_INSERT [dbo].[Users] ON
|
|||
insert into Users (ID, UserName, Password, PassSalt, DisplayName, RegisterTime, ApprovedTime,ApprovedBy, [Description]) values (1, 'Admin', 'Es7WVgNsJuELwWK8daCqufUBknCsSC0IYDphQZAiGOo=', 'W5vpBEOYRGHkQXatN0t+ECM/U8cHDuEgrq56+zZBk4J481xH', 'Administrator', GetDate(), GetDate(), 'system', N'系统默认创建')
|
||||
SET IDENTITY_INSERT [dbo].[Users] OFF
|
||||
|
||||
DELETE From Dicts where ID < 15
|
||||
DELETE From Dicts
|
||||
SET IDENTITY_INSERT [dbo].[Dicts] ON
|
||||
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (1, N'菜单', N'系统菜单', N'0', 0)
|
||||
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (2, N'菜单', N'外部菜单', N'1', 0)
|
||||
|
@ -21,7 +21,9 @@ INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (10, N'
|
|||
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (11, N'处理结果', N'拒绝', N'1', 0)
|
||||
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (12, N'消息状态', N'未读', N'0', 0)
|
||||
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (13, N'消息状态', N'已读', N'1', 0)
|
||||
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (14, N'消息状态', N'删除', N'2', 0)
|
||||
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (14, N'消息标签', N'一般', N'0', 0)
|
||||
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (15, N'消息标签', N'紧要', N'1', 0)
|
||||
|
||||
SET IDENTITY_INSERT [dbo].[Dicts] OFF
|
||||
|
||||
DELETE FROM Navigations
|
||||
|
|
|
@ -313,13 +313,16 @@ GO
|
|||
ALTER TABLE [dbo].[Notifications] ADD CONSTRAINT [DF_Notifications_Status] DEFAULT ((0)) FOR [Status]
|
||||
GO
|
||||
|
||||
/****** Object: Table [dbo].[Messages] Script Date: 11/12/2016 11:18:31 ******/
|
||||
/****** Object: Table [dbo].[Messages] Script Date: 11/14/2016 13:59:21 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
SET ANSI_PADDING ON
|
||||
GO
|
||||
|
||||
CREATE TABLE [dbo].[Messages](
|
||||
[ID] [int] IDENTITY(1,1) NOT NULL,
|
||||
[Title] [nvarchar](50) NOT NULL,
|
||||
|
@ -328,6 +331,9 @@ CREATE TABLE [dbo].[Messages](
|
|||
[To] [varchar](50) NOT NULL,
|
||||
[SendTime] [datetime] NOT NULL,
|
||||
[Status] [nvarchar](50) NOT NULL,
|
||||
[Mark] [nvarchar](50) NOT NULL,
|
||||
[IsDelete] [int] NOT NULL,
|
||||
[Label] [nvarchar](50) NOT NULL,
|
||||
CONSTRAINT [PK_Messages] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ID] ASC
|
||||
|
@ -335,3 +341,6 @@ CREATE TABLE [dbo].[Messages](
|
|||
) ON [PRIMARY]
|
||||
|
||||
GO
|
||||
|
||||
SET ANSI_PADDING OFF
|
||||
GO
|
Loading…
Reference in New Issue