通知管理的用户注册后台部分完成,同时HeaderBarModel的notification命名空间有点不一致
This commit is contained in:
parent
7b616d9e06
commit
6628a38120
|
@ -243,7 +243,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\web.config" />
|
||||
<Content Include="packages.config" />
|
||||
<Content Include="Content\fonts\fontawesome-webfont.ttf" />
|
||||
<Content Include="Content\fonts\fontawesome-webfont.woff" />
|
||||
<Content Include="Views\Shared\_Normal.cshtml" />
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Bootstrap.Admin.Models
|
|||
UserID = user.ID;
|
||||
HomeUrl = "~/";
|
||||
Menus = MenuHelper.RetrieveLinksByUserName(UserName);
|
||||
Notifications = NotificationsHelper.RetrieveNotifications();
|
||||
Notifications = NotificationHelper.RetrieveNotifications();
|
||||
}
|
||||
public string UserName { get; protected set; }
|
||||
/// <summary>
|
||||
|
@ -43,6 +43,6 @@ namespace Bootstrap.Admin.Models
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IEnumerable<Notifications> Notifications { get; set; }
|
||||
public IEnumerable<Notification> Notifications { get; set; }
|
||||
}
|
||||
}
|
|
@ -42,6 +42,7 @@
|
|||
<add key="LogHelper-RetrieveLogs" interval="600" desc="所有日志数据缓存"/>
|
||||
<add key="DictHelper-RetrieveDicts" interval="600" desc="所有字典数据缓存"/>
|
||||
<add key="DictHelper-RetrieveDictsWebSettings" interval="600" desc="网站配置数据缓存"/>
|
||||
<add key="NotificationHelper-RetrieveNotifications" interval="600" desc="通知管理数据缓存"/>
|
||||
</cacheManager>
|
||||
|
||||
<cacheManagerList>
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?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" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
|
||||
</packages>
|
|
@ -67,8 +67,8 @@
|
|||
<Compile Include="LogHelper.cs" />
|
||||
<Compile Include="Menu.cs" />
|
||||
<Compile Include="MenuHelper.cs" />
|
||||
<Compile Include="Notifications.cs" />
|
||||
<Compile Include="NotificationsHelper.cs" />
|
||||
<Compile Include="NotificationHelper.cs" />
|
||||
<Compile Include="Notification.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Role.cs" />
|
||||
<Compile Include="RoleHelper.cs" />
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="menuIds"></param>
|
||||
/// <param name="dictIds"></param>
|
||||
/// <param name="logIds"></param>
|
||||
internal static void ClearCache(string roleIds = null, string userIds = null, string groupIds = null, string menuIds = null, string dictIds = null, string logIds = null)
|
||||
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>();
|
||||
if (roleIds != null)
|
||||
|
@ -76,6 +76,12 @@ namespace Bootstrap.DataAccess
|
|||
CacheManager.Clear(key => key.Contains(LogHelper.RetrieveLogsDataKey));
|
||||
cacheKeys.Clear();
|
||||
}
|
||||
if (notifyIds != null)
|
||||
{
|
||||
// final cleanup
|
||||
CacheManager.Clear(key => key.Contains(NotificationHelper.RetrieveNotifyDataKey));
|
||||
cacheKeys.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
public class Notification
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Category { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Content { get; set; }
|
||||
public DateTime RegisterTime { get; set; }
|
||||
public DateTime ProcessTime { get; set; }
|
||||
public string ProcessBy { get; set; }
|
||||
public string ProcessResult { get; set; }
|
||||
public string Status { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
using Longbow;
|
||||
using Longbow.Caching;
|
||||
using Longbow.Caching.Configuration;
|
||||
using Longbow.ExceptionManagement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
public class NotificationHelper
|
||||
{
|
||||
internal const string RetrieveNotifyDataKey = "NotificationHelper-RetrieveNotifications";
|
||||
|
||||
/// <summary>
|
||||
/// 新用户注册的通知的面板显示
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Notification> RetrieveNotifications(string category = null)
|
||||
{
|
||||
return CacheManager.GetOrAdd(RetrieveNotifyDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNotifyDataKey), key =>
|
||||
{
|
||||
string sql = "select * from Notifications where Category=@Category";
|
||||
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))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
notifications.Add(new Notification()
|
||||
{
|
||||
ID = (int)reader[0],
|
||||
Category = (string)reader[1],
|
||||
Title = (string)reader[2],
|
||||
Content = (string)reader[3],
|
||||
RegisterTime = (DateTime)reader[4],
|
||||
ProcessTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue),
|
||||
ProcessBy = LgbConvert.ReadValue(reader[6], string.Empty),
|
||||
ProcessResult = LgbConvert.ReadValue(reader[7], string.Empty),
|
||||
Status = (string)reader[8]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { ExceptionManager.Publish(ex); }
|
||||
return notifications;
|
||||
|
||||
}, CacheSection.RetrieveDescByKey(RetrieveNotifyDataKey));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 点击某一行用户注册通知的处理成功操作
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ProcessRegisterUser(string id)
|
||||
{
|
||||
bool ret = false;
|
||||
if (string.IsNullOrEmpty(id)) return ret;
|
||||
try
|
||||
{
|
||||
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_ProcessRegisterUser"))
|
||||
{
|
||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", Convert.ToInt32(id), ParameterDirection.Input));
|
||||
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
|
||||
}
|
||||
CacheCleanUtility.ClearCache(notifyIds: id);
|
||||
ret = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExceptionManager.Publish(ex);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -61,6 +61,7 @@
|
|||
<Compile Include="GroupHelperTests.cs" />
|
||||
<Compile Include="MenuHelperTests.cs" />
|
||||
<Compile Include="LogHelperTests.cs" />
|
||||
<Compile Include="NotificationHelperTest.cs" />
|
||||
<Compile Include="UserHelperTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
using Bootstrap.DataAccess;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Linq;
|
||||
namespace Bootstrap.DataAccessTests
|
||||
{
|
||||
[TestClass]
|
||||
public class NotificationHelperTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void RetrieveNotificationsTest()
|
||||
{
|
||||
Assert.IsTrue(NotificationHelper.RetrieveNotifications("0").Count() >= 1, "带参数的NotificationHelper.RetrieveNotifications方法调用失败,请检查数据库连接或者数据库SQL语句");
|
||||
}
|
||||
[TestMethod]
|
||||
public void ProcessRegisterUserTest()
|
||||
{
|
||||
Assert.IsTrue(NotificationHelper.ProcessRegisterUser("1"), "带参数的NotificationHelper.ProcessRegisterUser方法调用失败,请检查数据库连接或者数据库SQL语句");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -208,3 +208,28 @@ BEGIN
|
|||
END
|
||||
|
||||
GO
|
||||
Drop PROCEDURE Proc_ProcessRegisterUser
|
||||
GO
|
||||
-- =============================================
|
||||
-- Author: XiaTiantian
|
||||
-- Create date: 2016-11-10
|
||||
-- Description:
|
||||
-- =============================================
|
||||
Create PROCEDURE Proc_ProcessRegisterUser
|
||||
-- Add the parameters for the stored procedure here
|
||||
@id int
|
||||
WITH ENCRYPTION
|
||||
AS
|
||||
BEGIN
|
||||
-- SET NOCOUNT ON added to prevent extra result sets from
|
||||
-- interfering with SELECT statements.
|
||||
SET NOCOUNT ON;
|
||||
SET XACT_ABORT ON;
|
||||
-- Insert statements for procedure here
|
||||
update Users set ApprovedTime=GETDATE() where UserName=(select Title from Notifications where ID=@id)
|
||||
update Notifications set Status='1',ProcessTime=GETDATE(),ProcessResult='0' where ID=@id
|
||||
END
|
||||
GO
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue